Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start to stub in P6opaque deserialization.
Funnily enough, since we serialize method caches, we actually survive
a surprising amount without actually deserializing the meta-objects
attributes.
  • Loading branch information
jnthn committed Jan 28, 2013
1 parent 67fa8fd commit ed07f89
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 4 deletions.
21 changes: 18 additions & 3 deletions src/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
Expand Up @@ -428,11 +428,26 @@ else if (nameToHintObject instanceof VMHashInstance) {
}

public SixModelObject deserialize_stub(ThreadContext tc, STable st) {
throw new RuntimeException("P6opaque deserialization NYI");
P6OpaqueDelegateInstance stub = new P6OpaqueDelegateInstance();
stub.st = st;
return stub;
}

public void deserialize_finish(ThreadContext tc, STable st,
SerializationReader reader, SixModelObject obj) {
throw new RuntimeException("P6opaque deserialization NYI");
SerializationReader reader, SixModelObject stub) {
try {
// Create instance that we'll deserialize into.
P6OpaqueBaseInstance obj = (P6OpaqueBaseInstance)((P6OpaqueREPRData)st.REPRData).jvmClass.newInstance();
obj.st = st;

// Install it as the stub's delegate.
((P6OpaqueDelegateInstance)stub).delegate = obj;


}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
6 changes: 5 additions & 1 deletion src/org/perl6/nqp/sixmodel/reprs/P6OpaqueBaseInstance.java
Expand Up @@ -2,7 +2,11 @@
import org.perl6.nqp.sixmodel.SixModelObject;

public class P6OpaqueBaseInstance extends SixModelObject {
public final int resolveAttribute(SixModelObject classHandle, String name) {
// If this is not null, all operations are delegate to it. Used when we
// load the object from an SC or when we mix in and it causes a resize.
public SixModelObject delegate;

public final int resolveAttribute(SixModelObject classHandle, String name) {
P6OpaqueREPRData rd = (P6OpaqueREPRData)this.st.REPRData;
for (int i = 0; i < rd.classHandles.length; i++) {
if (rd.classHandles[i] == classHandle) {
Expand Down
88 changes: 88 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/P6OpaqueDelegateInstance.java
@@ -0,0 +1,88 @@
package org.perl6.nqp.sixmodel.reprs;

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

public class P6OpaqueDelegateInstance extends P6OpaqueBaseInstance {
public void initialize(ThreadContext tc) {
delegate.initialize(tc);
}
public SixModelObject get_attribute_boxed(ThreadContext tc, SixModelObject class_handle,
String name, long hint) {
return delegate.get_attribute_boxed(tc, class_handle, name, hint);
}
public void get_attribute_native(ThreadContext tc, SixModelObject class_handle, String name, long hint) {
delegate.get_attribute_native(tc, class_handle, name, hint);
}
public void bind_attribute_boxed(ThreadContext tc,SixModelObject class_handle,
String name, long hint, SixModelObject value) {
delegate.bind_attribute_boxed(tc, class_handle, name, hint, value);
}
public void bind_attribute_native(ThreadContext tc,SixModelObject class_handle, String name, long hint) {
delegate.bind_attribute_native(tc, class_handle, name, hint);
}
public long is_attribute_initialized(ThreadContext tc, SixModelObject class_handle,
String name, long hint) {
return delegate.is_attribute_initialized(tc, class_handle, name, hint);
}
public void set_int(ThreadContext tc, long value) {
delegate.set_int(tc, value);
}
public long get_int(ThreadContext tc) {
return delegate.get_int(tc);
}
public void set_num(ThreadContext tc, double value) {
delegate.set_num(tc, value);
}
public double get_num(ThreadContext tc) {
return delegate.get_num(tc);
}
public void set_str(ThreadContext tc, String value) {
delegate.set_str(tc, value);
}
public String get_str(ThreadContext tc) {
return delegate.get_str(tc);
}
public SixModelObject at_pos_boxed(ThreadContext tc, long index) {
return delegate.at_pos_boxed(tc, index);
}
public void bind_pos_boxed(ThreadContext tc, long index, SixModelObject value) {
delegate.bind_pos_boxed(tc, index, value);
}
public void set_elems(ThreadContext tc, long count) {
delegate.set_elems(tc, count);
}
public void push_boxed(ThreadContext tc, SixModelObject value) {
delegate.push_boxed(tc, value);
}
public SixModelObject pop_boxed(ThreadContext tc) {
return delegate.pop_boxed(tc);
}
public void unshift_boxed(ThreadContext tc, SixModelObject value) {
delegate.unshift_boxed(tc, value);
}
public SixModelObject shift_boxed(ThreadContext tc) {
return delegate.shift_boxed(tc);
}
public void splice(ThreadContext tc, SixModelObject from, long offset, long count) {
delegate.splice(tc, from, offset, count);
}
public SixModelObject at_key_boxed(ThreadContext tc, String key) {
return delegate.at_key_boxed(tc, key);
}
public void bind_key_boxed(ThreadContext tc, String key, SixModelObject value) {
delegate.bind_key_boxed(tc, key, value);
}
public long exists_key(ThreadContext tc, String key) {
return delegate.exists_key(tc, key);
}
public void delete_key(ThreadContext tc, String key) {
delegate.delete_key(tc, key);
}
public long elems(ThreadContext tc) {
return delegate.elems(tc);
}
public SixModelObject clone(ThreadContext tc) {
return delegate.clone(tc);
}
}

0 comments on commit ed07f89

Please sign in to comment.