Skip to content

Commit 7ce3641

Browse files
committed
P6bigint serialization/deserialization.
1 parent 1cd19ce commit 7ce3641

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6bigint.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.perl6.nqp.sixmodel.REPR;
1111
import org.perl6.nqp.sixmodel.STable;
1212
import org.perl6.nqp.sixmodel.SerializationReader;
13+
import org.perl6.nqp.sixmodel.SerializationWriter;
1314
import org.perl6.nqp.sixmodel.SixModelObject;
1415
import org.perl6.nqp.sixmodel.StorageSpec;
1516
import org.perl6.nqp.sixmodel.TypeObject;
@@ -102,4 +103,22 @@ public void deserialize_finish(ThreadContext tc, STable st,
102103
SerializationReader reader, SixModelObject obj) {
103104
throw new RuntimeException("Deserialization NYI for P6bigint");
104105
}
106+
107+
public void deserialize_inlined(ThreadContext tc, STable st, SerializationReader reader,
108+
String prefix, SixModelObject obj) {
109+
try {
110+
obj.getClass().getField(prefix).set(obj, new BigInteger(reader.readStr()));
111+
} catch (Exception e) {
112+
throw new RuntimeException(e);
113+
}
114+
}
115+
116+
public void serialize_inlined(ThreadContext tc, STable st, SerializationWriter writer,
117+
String prefix, SixModelObject obj) {
118+
try {
119+
writer.writeStr(obj.getClass().getField(prefix).get(obj).toString());
120+
} catch (Exception e) {
121+
throw new RuntimeException(e);
122+
}
123+
}
105124
}

0 commit comments

Comments
 (0)