debbuging failure to read from builtin map

This commit is contained in:
Francesco Cozzuto
2021-11-03 15:22:59 +01:00
parent d4e9eb23d3
commit 0157d28f67
16 changed files with 266 additions and 29 deletions
+42 -2
View File
@@ -641,6 +641,30 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_INSERT:
{
assert(opc == 0);
if(runtime->frame->used < 3)
{
Error_Report(error, 1, "Frame has not enough values on the stack to run INSERT instruction");
return NULL;
}
Object *col = Stack_Top(runtime->stack, -2);
Object *key = Stack_Top(runtime->stack, -1);
Object *val = Stack_Top(runtime->stack, 0);
assert(col != NULL && key != NULL && val != NULL);
if(!Runtime_Pop(runtime, error, 2))
return 0;
if(!Object_Insert(col, key, val, runtime->heap, error))
return 0;
return 1;
}
case OPCODE_PUSHINT:
{
assert(opc == 1);
@@ -713,8 +737,9 @@ static _Bool step(Runtime *runtime, Error *error)
return 0;
}
}
else if(obj == NULL)
return 0;
else
if(obj == NULL)
return 0;
if(!Runtime_Push(runtime, error, obj))
return 0;
@@ -780,6 +805,21 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_PUSHLST:
{
assert(opc == 1);
assert(ops[0].type == OPTP_INT);
Object *obj = Object_NewList(ops[0].as_int, runtime->heap, error);
if(obj == NULL)
return 0;
if(!Runtime_Push(runtime, error, obj))
return 0;
return 1;
}
case OPCODE_RETURN:
return 0;