Skip to content

Commit 0440860

Browse files
committed
Implement nqp::getlexcaller.
1 parent b677b4c commit 0440860

File tree

1 file changed

+14
-0
lines changed
  • src/vm/jvm/runtime/org/perl6/nqp/runtime

1 file changed

+14
-0
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,20 @@ public static SixModelObject getlexdyn(String name, ThreadContext tc) {
796796
}
797797
return null;
798798
}
799+
public static SixModelObject getlexcaller(String name, ThreadContext tc) {
800+
CallFrame curCallerFrame = tc.curFrame.caller;
801+
while (curCallerFrame != null) {
802+
CallFrame curFrame = curCallerFrame;
803+
while (curFrame != null) {
804+
Integer found = curFrame.codeRef.staticInfo.oTryGetLexicalIdx(name);
805+
if (found != null)
806+
return curFrame.oLex[found];
807+
curFrame = curFrame.outer;
808+
}
809+
curCallerFrame = curCallerFrame.caller;
810+
}
811+
return null;
812+
}
799813

800814
/* Context introspection. */
801815
public static SixModelObject ctx(ThreadContext tc) {

0 commit comments

Comments
 (0)