@@ -117,6 +117,30 @@ class HLL::Compiler::SerializationContextBuilder {
117
117
));
118
118
}
119
119
120
+ # Gets PAST for referencing an object in a serialization context,
121
+ # either the one being built or another one.
122
+ method get_object_sc_ref_past ($ obj ) {
123
+ # Get the object's serialization context; we're stuck if it
124
+ # has none.
125
+ my $ sc := pir::nqp_get_sc_for_object__PP($ obj );
126
+ if pir::isnull__IP($ sc ) {
127
+ pir::die(" Object of type '" ~ $ obj . HOW . name ($ obj ) ~
128
+ " ' cannot be referenced without having been " ~
129
+ " assigned a serialization context" );
130
+ }
131
+
132
+ # If it's this context, dead easy. Otherwise, need to build a
133
+ # cross-reference.
134
+ if $ sc =:= $ ! sc {
135
+ self . get_slot_past_for_object($ obj );
136
+ }
137
+ else {
138
+ PAST::Op. new ( : pirop(' nqp_get_sc_object Psi' ),
139
+ $ sc . handle, $ sc . slot_index_for($ obj )
140
+ )
141
+ }
142
+ }
143
+
120
144
# Loads the setting and emits code
121
145
method load_setting ($ setting_name ) {
122
146
# Do nothing for the NULL setting.
@@ -161,8 +185,9 @@ class HLL::Compiler::SerializationContextBuilder {
161
185
my $ how_name := @ how_ns . pop ();
162
186
my $ setup_call := PAST::Op. new (
163
187
: pasttype(' callmethod' ), : name(' new_type' ),
164
- # XXX Should be an SC cross-reference
165
188
PAST::Var. new ( : name($ how_name ), : namespace(@ how_ns ), : scope(' package' ) )
189
+ # XXX Not ready to do this quite yet...
190
+ # self.get_object_sc_ref_past($how)
166
191
);
167
192
if pir:: defined ($ name ) {
168
193
$ setup_call . push (PAST::Val. new ( : value($ name ), : named(' name' ) ));
0 commit comments