Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement existskey in ContextRef.
  • Loading branch information
jnthn committed Feb 27, 2013
1 parent e58be0c commit be4c3da
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/ContextRefInstance.java
@@ -1,6 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import org.perl6.nqp.runtime.CallFrame;
import org.perl6.nqp.runtime.StaticCodeInfo;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;

Expand Down Expand Up @@ -33,4 +34,13 @@ public void at_key_native(ThreadContext tc, String key) {
}
throw new RuntimeException("No lexical " + key + " in this lexpad");
}

public long exists_key(ThreadContext tc, String key) {
StaticCodeInfo sci = context.codeRef.staticInfo;
return sci.oTryGetLexicalIdx(key) != null ||
sci.iTryGetLexicalIdx(key) != null ||
sci.nTryGetLexicalIdx(key) != null ||
sci.sTryGetLexicalIdx(key) != null
? 1 : 0;
}
}

0 comments on commit be4c3da

Please sign in to comment.