@@ -156,71 +156,91 @@ ZkDaedalusInstance* ZkDaedalusVm_popInstance(ZkDaedalusVm* slf) {
156
156
ZKC_TRACE_FN ();
157
157
ZKC_CHECK_NULL (slf);
158
158
159
- auto * instance = new ZkDaedalusInstance (slf->handle .pop_instance ());
160
- ZKC_RETURN_CATCH (instance);
159
+ auto instance = slf->handle .pop_instance ();
160
+ if (instance == nullptr ) {
161
+ return nullptr ;
162
+ }
163
+
164
+ ZKC_RETURN_CATCH (new ZkDaedalusInstance (instance));
161
165
}
162
166
163
167
ZkDaedalusInstance* ZkDaedalusVm_getGlobalSelf (ZkDaedalusVm* slf) {
164
168
ZKC_TRACE_FN ();
165
169
ZKC_CHECK_NULL (slf);
166
170
167
171
auto & instance = slf->handle .global_self ()->get_instance ();
172
+ if (instance == nullptr ) {
173
+ return nullptr ;
174
+ }
168
175
ZKC_RETURN_CATCH (new ZkDaedalusInstance (instance));
169
176
}
170
177
171
178
ZkDaedalusInstance* ZkDaedalusVm_getGlobalOther (ZkDaedalusVm* slf) {
172
179
ZKC_TRACE_FN ();
173
180
ZKC_CHECK_NULL (slf);
174
181
auto & instance = slf->handle .global_other ()->get_instance ();
182
+ if (instance == nullptr ) {
183
+ return nullptr ;
184
+ }
175
185
ZKC_RETURN_CATCH (new ZkDaedalusInstance (instance));
176
186
}
177
187
178
188
ZkDaedalusInstance* ZkDaedalusVm_getGlobalVictim (ZkDaedalusVm* slf) {
179
189
ZKC_TRACE_FN ();
180
190
ZKC_CHECK_NULL (slf);
181
191
auto & instance = slf->handle .global_victim ()->get_instance ();
192
+ if (instance == nullptr ) {
193
+ return nullptr ;
194
+ }
182
195
ZKC_RETURN_CATCH (new ZkDaedalusInstance (instance));
183
196
}
184
197
185
198
ZkDaedalusInstance* ZkDaedalusVm_getGlobalHero (ZkDaedalusVm* slf) {
186
199
ZKC_TRACE_FN ();
187
200
ZKC_CHECK_NULL (slf);
188
201
auto & instance = slf->handle .global_hero ()->get_instance ();
202
+ if (instance == nullptr ) {
203
+ return nullptr ;
204
+ }
189
205
ZKC_RETURN_CATCH (new ZkDaedalusInstance (instance));
190
206
}
191
207
192
208
ZkDaedalusInstance* ZkDaedalusVm_getGlobalItem (ZkDaedalusVm* slf) {
193
209
ZKC_TRACE_FN ();
194
210
ZKC_CHECK_NULL (slf);
195
211
auto & instance = slf->handle .global_item ()->get_instance ();
212
+ if (instance == nullptr ) {
213
+ return nullptr ;
214
+ }
215
+
196
216
ZKC_RETURN_CATCH (new ZkDaedalusInstance (instance));
197
217
}
198
218
199
219
void ZkDaedalusVm_setGlobalSelf (ZkDaedalusVm* slf, ZkDaedalusInstance* value) {
200
220
ZKC_TRACE_FN ();
201
221
ZKC_CHECK_NULLV (slf);
202
222
203
- ZKC_CATCH (slf->handle .global_self ()->set_instance (*value));
223
+ ZKC_CATCH (slf->handle .global_self ()->set_instance (value ? *value : nullptr ));
204
224
}
205
225
void ZkDaedalusVm_setGlobalOther (ZkDaedalusVm* slf, ZkDaedalusInstance* value) {
206
226
ZKC_TRACE_FN ();
207
227
ZKC_CHECK_NULLV (slf);
208
- ZKC_CATCH (slf->handle .global_other ()->set_instance (*value));
228
+ ZKC_CATCH (slf->handle .global_other ()->set_instance (value ? *value : nullptr ));
209
229
}
210
230
void ZkDaedalusVm_setGlobalVictim (ZkDaedalusVm* slf, ZkDaedalusInstance* value) {
211
231
ZKC_TRACE_FN ();
212
232
ZKC_CHECK_NULLV (slf);
213
- ZKC_CATCH (slf->handle .global_victim ()->set_instance (*value));
233
+ ZKC_CATCH (slf->handle .global_victim ()->set_instance (value ? *value : nullptr ));
214
234
}
215
235
void ZkDaedalusVm_setGlobalHero (ZkDaedalusVm* slf, ZkDaedalusInstance* value) {
216
236
ZKC_TRACE_FN ();
217
237
ZKC_CHECK_NULLV (slf);
218
- ZKC_CATCH (slf->handle .global_hero ()->set_instance (*value));
238
+ ZKC_CATCH (slf->handle .global_hero ()->set_instance (value ? *value : nullptr ));
219
239
}
220
240
void ZkDaedalusVm_setGlobalItem (ZkDaedalusVm* slf, ZkDaedalusInstance* value) {
221
241
ZKC_TRACE_FN ();
222
242
ZKC_CHECK_NULLV (slf);
223
- ZKC_CATCH (slf->handle .global_item ()->set_instance (*value));
243
+ ZKC_CATCH (slf->handle .global_item ()->set_instance (value ? *value : nullptr ));
224
244
}
225
245
226
246
void ZkDaedalusVm_callFunction (ZkDaedalusVm* slf, ZkDaedalusSymbol* sym) {
0 commit comments