Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a REPR for context references.
We don't make contexts have to be GCable, 6model objects. But if we
want to talk about them first class, they need objectifying. This will
provide that wrapping.
  • Loading branch information
jnthn committed Jan 23, 2013
1 parent 9e4a767 commit 39a9db0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/org/perl6/nqp/runtime/GlobalContext.java
Expand Up @@ -52,6 +52,11 @@ public class GlobalContext {
*/
public SixModelObject SCRef;

/**
* ContextRef type; a basic, method-less type with the ContextRef REPR.
*/
public SixModelObject ContextRef;

/**
* The main, startup thread's ThreadContext.
*/
Expand Down
1 change: 1 addition & 0 deletions src/org/perl6/nqp/sixmodel/KnowHOWBootstrapper.java
Expand Up @@ -17,6 +17,7 @@ public static void bootstrap(ThreadContext tc)
tc.gc.BOOTNum = bootType(tc, "BOOTNum", "P6num");
tc.gc.BOOTStr = bootType(tc, "BOOTStr", "P6str");
tc.gc.SCRef = bootType(tc, "SCRef", "SCRef");
tc.gc.ContextRef = bootType(tc, "ContextRef", "ContextRef");
Ops.setboolspec(tc.gc.BOOTIter, BoolificationSpec.MODE_ITER, null, tc);
}

Expand Down
1 change: 1 addition & 0 deletions src/org/perl6/nqp/sixmodel/REPRRegistry.java
Expand Up @@ -40,5 +40,6 @@ public static void setup() {
addREPR("P6num", new P6num());
addREPR("Uninstantiable", new Uninstantiable());
addREPR("SCRef", new SCRef());
addREPR("ContextRef", new ContextRef());
}
}
34 changes: 34 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/ContextRef.java
@@ -0,0 +1,34 @@
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.SerializationReader;
import org.perl6.nqp.sixmodel.SixModelObject;
import org.perl6.nqp.sixmodel.TypeObject;

public class ContextRef 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) {
ContextRefInstance obj = new ContextRefInstance();
obj.st = st;
return obj;
}

public SixModelObject deserialize_stub(ThreadContext tc, STable st) {
throw new RuntimeException("ContextRef does not participate in serialization");
}

public void deserialize_finish(ThreadContext tc, STable st,
SerializationReader reader, SixModelObject obj) {
throw new RuntimeException("ContextRef does not participate in serialization");
}

}
8 changes: 8 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/ContextRefInstance.java
@@ -0,0 +1,8 @@
package org.perl6.nqp.sixmodel.reprs;

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

public class ContextRefInstance extends SixModelObject {
public CallFrame context;
}

0 comments on commit 39a9db0

Please sign in to comment.