@@ -71,7 +71,7 @@ class HLL::Compiler::SerializationContextBuilder {
71
71
method slot_for_object ($ obj ) {
72
72
my $ slot := % ! addr_to_slot {addr($ obj )};
73
73
unless pir:: defined ($ slot ) {
74
- pir::die(' slot_for called on object no in context' );
74
+ pir::die(' slot_for_object called on object not in context' );
75
75
}
76
76
$ slot
77
77
}
@@ -87,11 +87,23 @@ class HLL::Compiler::SerializationContextBuilder {
87
87
88
88
# Utility sub to wrap PAST with slot setting.
89
89
method set_slot_past ($ slot , $ past_to_set ) {
90
- return PAST::Op. new ( : pirop(' nqp_set_sc_object vsiP' ), $ ! handle , $ slot , $ past_to_set );
90
+ return PAST::Op. new ( : pirop(' nqp_set_sc_object vsiP' ),
91
+ $ ! handle , $ slot , $ past_to_set );
92
+ }
93
+
94
+ # Used when deserializing. Makes sure the object being
95
+ # deserialized has the current SC set.
96
+ method set_cur_sc ($ to_wrap ) {
97
+ PAST::Op. new (
98
+ : pirop(' nqp_set_sc_for_object__0PP' ),
99
+ $ to_wrap ,
100
+ PAST::Var. new ( : name(' cur_sc' ), : scope(' register' ) )
101
+ )
91
102
}
92
103
93
104
# Adds an object to the root set, along with a mapping.
94
105
method add_object ($ obj ) {
106
+ pir::nqp_set_sc_for_object__vPP($ obj , $ ! sc );
95
107
my $ idx := $ ! sc . elems ();
96
108
$ ! sc [$ idx ] := $ obj ;
97
109
% ! addr_to_slot {addr($ obj )} := $ idx ;
@@ -158,8 +170,8 @@ class HLL::Compiler::SerializationContextBuilder {
158
170
if pir:: defined ($ repr ) {
159
171
$ setup_call . push (PAST::Val. new ( : value($ repr ), : named(' repr' ) ));
160
172
}
161
- # XXX Not quite ready to really do this yet...
162
- # self.add_event(:deserialize_past(self. set_slot_past($slot, $setup_call)));
173
+ self . add_event( : deserialize_past(
174
+ self . set_slot_past($ slot , self . set_cur_sc( $ setup_call ) )));
163
175
164
176
# Result is just the object.
165
177
return $ mo ;
@@ -211,7 +223,11 @@ class HLL::Compiler::SerializationContextBuilder {
211
223
PAST::Stmts. new (
212
224
PAST::Op. new ( : pirop(' nqp_dynop_setup v' ) ),
213
225
PAST::Op. new ( : pirop(' load_bytecode vs' ), ' nqpmo.pbc' ),
214
- PAST::Op. new ( : pirop(' nqp_create_sc Ps' ), $ ! handle ),
226
+ PAST::Op. new (
227
+ : pasttype(' bind' ),
228
+ PAST::Var. new ( : name(' cur_sc' ), : scope(' register' ), : isdecl(1 ) ),
229
+ PAST::Op. new ( : pirop(' nqp_create_sc Ps' ), $ ! handle )
230
+ ),
215
231
$ des
216
232
),
217
233
$ fix
0 commit comments