Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get inlined P6int/P6num/P6str to serialize.
  • Loading branch information
jnthn committed Mar 9, 2013
1 parent f5c98f8 commit 784d31f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/org/perl6/nqp/sixmodel/REPR.java
Expand Up @@ -124,6 +124,10 @@ public Instruction[] inlineGet(ThreadContext tc, STable st, ClassGen c, Constant
public void generateBoxingMethods(ThreadContext tc, STable st, ClassGen c, ConstantPoolGen cp, String prefix) {
throw ExceptionHandling.dieInternal(tc, "This representation does not support being a box target");
}
public void serialize_inlined(ThreadContext tc, STable st, SerializationWriter writer,
String prefix, SixModelObject obj) {
throw ExceptionHandling.dieInternal(tc, "This representation cannot serialize an inlined representation of itself");
}
public void deserialize_inlined(ThreadContext tc, STable st, SerializationReader reader,
String prefix, SixModelObject obj) {
throw ExceptionHandling.dieInternal(tc, "This representation cannot deserialize an inlined representation of itself");
Expand Down
10 changes: 9 additions & 1 deletion src/org/perl6/nqp/sixmodel/reprs/P6int.java
Expand Up @@ -10,7 +10,6 @@
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
import org.apache.bcel.generic.Type;
import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.REPR;
import org.perl6.nqp.sixmodel.STable;
Expand Down Expand Up @@ -129,4 +128,13 @@ public void deserialize_inlined(ThreadContext tc, STable st, SerializationReader
throw new RuntimeException(e);
}
}

public void serialize_inlined(ThreadContext tc, STable st, SerializationWriter writer,
String prefix, SixModelObject obj) {
try {
writer.writeInt((long)obj.getClass().getField(prefix).get(obj));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
9 changes: 9 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/P6num.java
Expand Up @@ -129,4 +129,13 @@ public void deserialize_inlined(ThreadContext tc, STable st, SerializationReader
throw new RuntimeException(e);
}
}

public void serialize_inlined(ThreadContext tc, STable st, SerializationWriter writer,
String prefix, SixModelObject obj) {
try {
writer.writeNum((double)obj.getClass().getField(prefix).get(obj));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
9 changes: 9 additions & 0 deletions src/org/perl6/nqp/sixmodel/reprs/P6str.java
Expand Up @@ -128,4 +128,13 @@ public void deserialize_inlined(ThreadContext tc, STable st, SerializationReader
throw new RuntimeException(e);
}
}

public void serialize_inlined(ThreadContext tc, STable st, SerializationWriter writer,
String prefix, SixModelObject obj) {
try {
writer.writeStr((String)obj.getClass().getField(prefix).get(obj));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit 784d31f

Please sign in to comment.