2025-09-15 06:31:32 +02:00
|
|
|
case OP_LOAD_GLOBAL: {
|
|
|
|
|
int idx = inst.operand;
|
|
|
|
|
if (idx < 0 || idx >= VM_MAX_GLOBALS) {
|
|
|
|
|
fprintf(stderr, "Runtime error: global index out of range\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
2025-09-15 07:52:03 +02:00
|
|
|
#ifdef FUN_DEBUG
|
|
|
|
|
fprintf(stderr, "DEBUG LOAD_GLOBAL[%d]: type=%d\n", idx, vm->globals[idx].type);
|
|
|
|
|
#endif
|
2025-09-15 06:31:32 +02:00
|
|
|
push_value(vm, copy_value(&vm->globals[idx]));
|
|
|
|
|
break;
|
|
|
|
|
}
|