Skip to content

Commit a4fa7e4

Browse files
committed
Serialize and deserialize VMArray REPR data.
1 parent e408df4 commit a4fa7e4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/6model/reprs/VMArray.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,26 @@ static void deserialize(PARROT_INTERP, STable *st, void *data, SerializationRead
7878
}
7979

8080
static void serialize_repr_data(PARROT_INTERP, STable *st, SerializationWriter *writer) {
81-
/* TODO */
81+
VMArrayREPRData *repr_data = (VMArrayREPRData *) st->REPR_data;
82+
writer->write_ref(interp, writer, repr_data->elem_type);
8283
}
8384

8485
static void deserialize_repr_data(PARROT_INTERP, STable *st, SerializationReader *reader) {
85-
/* TODO */
86+
VMArrayREPRData *repr_data = mem_allocate_zeroed_typed(VMArrayREPRData);
87+
PMC *type = reader->read_ref(interp, reader);
88+
89+
repr_data->elem_type = type;
90+
if(!PMC_IS_NULL(type)) {
91+
storage_spec spec = REPR(type)->get_storage_spec(interp, STABLE(type));
92+
if(spec.inlineable == STORAGE_SPEC_INLINED &&
93+
(spec.boxed_primitive == STORAGE_SPEC_BP_INT ||
94+
spec.boxed_primitive == STORAGE_SPEC_BP_NUM)) {
95+
repr_data->elem_size = spec.bits;
96+
repr_data->elem_kind = spec.boxed_primitive;
97+
}
98+
}
99+
100+
st->REPR_data = repr_data;
86101
}
87102

88103
/* Gets the storage specification for this representation. */

0 commit comments

Comments
 (0)