Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement getattrref_[ins] ops.
  • Loading branch information
jnthn committed Feb 28, 2015
1 parent 11b846e commit 253b419
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -87,6 +87,7 @@
import org.perl6.nqp.sixmodel.reprs.NFA;
import org.perl6.nqp.sixmodel.reprs.NFAInstance;
import org.perl6.nqp.sixmodel.reprs.NFAStateInfo;
import org.perl6.nqp.sixmodel.reprs.NativeRefInstanceAttribute;
import org.perl6.nqp.sixmodel.reprs.NativeRefInstanceIntLex;
import org.perl6.nqp.sixmodel.reprs.NativeRefInstanceNumLex;
import org.perl6.nqp.sixmodel.reprs.NativeRefInstanceStrLex;
Expand Down Expand Up @@ -2623,6 +2624,44 @@ public static long attrhintfor(SixModelObject ch, String name, ThreadContext tc)
return ch.st.REPR.hint_for(tc, ch.st, ch, name);
}

/* Attribute reference operations. */
public static SixModelObject getattrref_i(SixModelObject obj, SixModelObject ch, String name, ThreadContext tc) {
SixModelObject refType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.intAttrRef;
if (refType == null)
throw ExceptionHandling.dieInternal(tc,
"No int attribute reference type registered for current HLL");
NativeRefInstanceAttribute ref = (NativeRefInstanceAttribute)refType.st.REPR.allocate(tc, refType.st);
ref.obj = obj;
ref.classHandle = decont(ch, tc);
ref.name = name;
ref.hint = STable.NO_HINT;
return ref;
}
public static SixModelObject getattrref_n(SixModelObject obj, SixModelObject ch, String name, ThreadContext tc) {
SixModelObject refType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.numAttrRef;
if (refType == null)
throw ExceptionHandling.dieInternal(tc,
"No num attribute reference type registered for current HLL");
NativeRefInstanceAttribute ref = (NativeRefInstanceAttribute)refType.st.REPR.allocate(tc, refType.st);
ref.obj = obj;
ref.classHandle = decont(ch, tc);
ref.name = name;
ref.hint = STable.NO_HINT;
return ref;
}
public static SixModelObject getattrref_s(SixModelObject obj, SixModelObject ch, String name, ThreadContext tc) {
SixModelObject refType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.strAttrRef;
if (refType == null)
throw ExceptionHandling.dieInternal(tc,
"No string attribute reference type registered for current HLL");
NativeRefInstanceAttribute ref = (NativeRefInstanceAttribute)refType.st.REPR.allocate(tc, refType.st);
ref.obj = obj;
ref.classHandle = decont(ch, tc);
ref.name = name;
ref.hint = STable.NO_HINT;
return ref;
}

/* Positional operations. */
public static SixModelObject atpos(SixModelObject arr, long idx, ThreadContext tc) {
return arr.at_pos_boxed(tc, idx);
Expand Down

0 comments on commit 253b419

Please sign in to comment.