Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add an SCRef REPR.
This allows an SC to be referenced in an objecty way.
  • Loading branch information
jnthn committed Jan 18, 2013
1 parent d380c6b commit 555cc21
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/org/perl6/nqp/sixmodel/REPRRegistry.java
Expand Up @@ -39,5 +39,6 @@ public static void setup() {
addREPR("P6int", new P6int());
addREPR("P6num", new P6num());
addREPR("Uninstantiable", new Uninstantiable());
addREPR("SCRef", new SCRef());
}
}
23 changes: 23 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/SCRef.java
@@ -0,0 +1,23 @@
package org.perl6.nqp.sixmodel.reprs;

import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.REPR;
import org.perl6.nqp.sixmodel.STable;
import org.perl6.nqp.sixmodel.SixModelObject;
import org.perl6.nqp.sixmodel.TypeObject;

public class SCRef extends REPR {
public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
STable st = new STable(this, HOW);
SixModelObject obj = new TypeObject();
obj.st = st;
st.WHAT = obj;
return st.WHAT;
}

public SixModelObject allocate(ThreadContext tc, STable st) {
SCRefInstance obj = new SCRefInstance();
obj.st = st;
return obj;
}
}
8 changes: 8 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/SCRefInstance.java
@@ -0,0 +1,8 @@
package org.perl6.nqp.sixmodel.reprs;

import org.perl6.nqp.sixmodel.SerializationContext;
import org.perl6.nqp.sixmodel.SixModelObject;

public class SCRefInstance extends SixModelObject {
public SerializationContext sc;
}

0 comments on commit 555cc21

Please sign in to comment.