implemented nullable type notation

This commit is contained in:
cozis
2022-12-04 18:39:42 +01:00
parent d610a973f4
commit 7a07a1eb3c
12 changed files with 156 additions and 9 deletions
+26
View File
@@ -653,6 +653,32 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_NLB:
{
ASSERT(opc == 0);
if(runtime->frame->used == 0)
{
Error_Report(error, 1, "Frame doesn't have enough items on the stack to execute NLB");
return 0;
}
Object *top = Stack_Top(runtime->stack, 0);
if(!Runtime_Pop(runtime, error, 1))
return 0;
ASSERT(top != NULL);
Object *nullable = Object_NewNullable(top, runtime->heap, error);
if(nullable == NULL)
return 0;
if(!Runtime_Push(runtime, error, nullable))
return 0;
return 1;
}
case OPCODE_ADD:
case OPCODE_SUB:
case OPCODE_MUL: