1
package org.perl6.nqp.sixmodel.reprs;
3
import org.perl6.nqp.runtime.CallFrame;
4
import org.perl6.nqp.runtime.ExceptionHandling;
5
import org.perl6.nqp.runtime.StaticCodeInfo;
6
import org.perl6.nqp.runtime.ThreadContext;
7
import org.perl6.nqp.sixmodel.SixModelObject;
9
public class ContextRefInstance extends SixModelObject {
10
public CallFrame context;
12
public SixModelObject at_key_boxed(ThreadContext tc, String key) {
13
Integer idx = context.codeRef.staticInfo.oTryGetLexicalIdx(key);
14
return idx == null ? null : context.oLex[idx];
17
public void at_key_native(ThreadContext tc, String key) {
18
Integer idx = context.codeRef.staticInfo.iTryGetLexicalIdx(key);
20
tc.native_i = context.iLex[idx];
21
tc.native_type = ThreadContext.NATIVE_INT;
24
idx = context.codeRef.staticInfo.nTryGetLexicalIdx(key);
26
tc.native_n = context.nLex[idx];
27
tc.native_type = ThreadContext.NATIVE_NUM;
30
idx = context.codeRef.staticInfo.sTryGetLexicalIdx(key);
32
tc.native_s = context.sLex[idx];
33
tc.native_type = ThreadContext.NATIVE_STR;
36
throw ExceptionHandling.dieInternal(tc, "No lexical " + key + " in this lexpad");
39
public void bind_key_boxed(ThreadContext tc, String key, SixModelObject value) {
40
Integer idx = context.codeRef.staticInfo.oTryGetLexicalIdx(key);
42
throw ExceptionHandling.dieInternal(tc, "No lexical " + key + " in this lexpad");
43
context.oLex[idx] = value;
46
public void bind_key_native(ThreadContext tc, String key) {
47
Integer idx = context.codeRef.staticInfo.iTryGetLexicalIdx(key);
49
context.iLex[idx] = tc.native_i;
50
tc.native_type = ThreadContext.NATIVE_INT;
53
idx = context.codeRef.staticInfo.nTryGetLexicalIdx(key);
55
context.nLex[idx] = tc.native_n;
56
tc.native_type = ThreadContext.NATIVE_NUM;
59
idx = context.codeRef.staticInfo.sTryGetLexicalIdx(key);
61
context.sLex[idx] = tc.native_s;
62
tc.native_type = ThreadContext.NATIVE_STR;
65
throw ExceptionHandling.dieInternal(tc, "No lexical " + key + " in this lexpad");
68
public long exists_key(ThreadContext tc, String key) {
69
StaticCodeInfo sci = context.codeRef.staticInfo;
70
return sci.oTryGetLexicalIdx(key) != null ||
71
sci.iTryGetLexicalIdx(key) != null ||
72
sci.nTryGetLexicalIdx(key) != null ||
73
sci.sTryGetLexicalIdx(key) != null