new -> operator

This commit is contained in:
cozis
2022-12-08 03:01:04 +01:00
parent b114387728
commit f7d28556a1
8 changed files with 98 additions and 41 deletions
+9 -4
View File
@@ -978,12 +978,18 @@ static _Bool step(Runtime *runtime, Error *error)
}
case OPCODE_SELECT:
case OPCODE_SELECT2:
{
ASSERT(opc == 0);
if(runtime->frame->used < 2)
int to_be_popped = (opcode == OPCODE_SELECT) ? 2 : 1;
if(runtime->frame->used < to_be_popped)
{
Error_Report(error, 1, "Frame has not enough values on the stack to run SELECT instruction");
const char *name = "SELECT";
if (opcode == OPCODE_SELECT2)
name = "SELECT2";
Error_Report(error, 1, "Frame has not enough values on the stack to run %s instruction", name);
return 0;
}
@@ -992,7 +998,7 @@ static _Bool step(Runtime *runtime, Error *error)
ASSERT(col != NULL && key != NULL);
if(!Runtime_Pop(runtime, error, 2))
if(!Runtime_Pop(runtime, error, to_be_popped))
return 0;
ASSERT(error->occurred == 0);
@@ -1007,7 +1013,6 @@ static _Bool step(Runtime *runtime, Error *error)
Error_Free(&dummy);
val = Object_NewNone(runtime->heap, error);
if(val == NULL)
return 0;
}