Some variable refactoring in vm.h and cleanups.
This commit is contained in:
parent
6b14c2776e
commit
c641599366
9 changed files with 32 additions and 43 deletions
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
case OP_LOAD_GLOBAL: {
|
||||
int idx = inst.operand;
|
||||
if (idx < 0 || idx >= VM_MAX_GLOBALS) {
|
||||
if (idx < 0 || idx >= MAX_GLOBALS) {
|
||||
fprintf(stderr, "Runtime error: global index out of range\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
case OP_LOAD_LOCAL: {
|
||||
int slot = inst.operand;
|
||||
if (slot < 0 || slot >= FRAME_MAX_LOCALS) {
|
||||
if (slot < 0 || slot >= MAX_FRAME_LOCALS) {
|
||||
fprintf(stderr, "Runtime error: local slot out of range\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
case OP_STORE_GLOBAL: {
|
||||
int idx = inst.operand;
|
||||
if (idx < 0 || idx >= VM_MAX_GLOBALS) {
|
||||
if (idx < 0 || idx >= MAX_GLOBALS) {
|
||||
fprintf(stderr, "Runtime error: global index out of range\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
case OP_STORE_LOCAL: {
|
||||
int slot = inst.operand;
|
||||
if (slot < 0 || slot >= FRAME_MAX_LOCALS) {
|
||||
if (slot < 0 || slot >= MAX_FRAME_LOCALS) {
|
||||
fprintf(stderr, "Runtime error: local slot out of range\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ case OP_PRINT: {
|
|||
Value v = pop_value(vm);
|
||||
Value snap = deep_copy_value(&v);
|
||||
free_value(v);
|
||||
if (vm->output_count < VM_OUTPUT_SIZE) {
|
||||
if (vm->output_count < OUTPUT_SIZE) {
|
||||
vm->output[vm->output_count++] = snap;
|
||||
} else {
|
||||
free_value(snap);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue