Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Wrap subs in a CodeRef object.
- Loading branch information
Showing
6 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| function CodeRef() { | ||
| } | ||
|
|
||
| CodeRef.prototype.block = function(func) { | ||
| this.$call = func; | ||
| }; | ||
|
|
||
| CodeRef.prototype.apply = function(thisArg, argsArray) { | ||
| return this.$call.apply(thisArg, argsArray); | ||
| }; | ||
|
|
||
| CodeRef.prototype.takeclosure = function() { | ||
| var closure = new CodeRef; | ||
| closure.$call = this.$call; | ||
| return closure; | ||
| }; | ||
|
|
||
| module.exports = CodeRef; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| plan(1); | ||
| my $comp := nqp::getcomp('JavaScript'); | ||
| my $helloworld := $comp('"Hello " + "World"'); | ||
| my $helloworld := $comp.eval('"Hello " + "World"'); | ||
| ok($helloworld eq 'Hello World',"getting a simple string from JavaScript"); |