Skip to content

Commit 1c3a513

Browse files
committed
[js] Basic nqp::getlexrel working only on nqp::curlexpad().
Might need to make it work for outer variables, etc. latter on.
1 parent 23b4314 commit 1c3a513

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/vm/js/QAST/Compiler.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@ class QAST::OperationsJS {
14551455
}
14561456

14571457
add_simple_op('getlexdyn', $T_OBJ, [$T_STR], sub ($name) {"{$*CTX}.lookup_dynamic_from_caller($name)"});
1458+
add_simple_op('getlexrel', $T_OBJ, [$T_OBJ, $T_STR]);
14581459

14591460
add_simple_op('captureexistsnamed', $T_INT, [$T_OBJ, $T_STR]);
14601461
add_simple_op('capturehasnameds', $T_INT, [$T_OBJ]);

src/vm/js/nqp-runtime/core.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,3 +800,7 @@ op.srand = function(seed) {
800800
generator = new XorShift([seed, 0, 0, 0]);
801801
return seed;
802802
};
803+
804+
op.getlexrel = function(pad, name) {
805+
return pad.lookup(name);
806+
};

src/vm/js/nqp-runtime/curlexpad.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ CurLexpad.prototype.$$existskey = function(key) {
1616
return this.set.hasOwnProperty(key);
1717
};
1818

19+
CurLexpad.prototype.lookup = function(key) {
20+
return this.get.hasOwnProperty(key) ? this.get[key]() : null;
21+
};
22+
1923
module.exports = CurLexpad;

0 commit comments

Comments
 (0)