This commit is contained in:
Francesco Cozzuto
2022-04-15 19:17:42 +02:00
parent 3117e7339e
commit fdf5bdc267
2 changed files with 9 additions and 2 deletions
+7
View File
@@ -679,6 +679,13 @@ static _Bool emit_instr_for_node(ExeBuilder *exeb, Node *node, Promise *break_de
if(!emit_instr_for_node(exeb, func->body, NULL, error)) if(!emit_instr_for_node(exeb, func->body, NULL, error))
return 0; return 0;
if(func->body->kind == NODE_EXPR)
{
Operand op = (Operand) { .type = OPTP_INT, .as_int = 1 };
if(!ExeBuilder_Append(exeb, error, OPCODE_POP, &op, 1, func->body->offset + func->body->length, 0))
return 0;
}
// Write a return instruction, just // Write a return instruction, just
// in case it didn't already return. // in case it didn't already return.
Operand op = (Operand) { .type = OPTP_INT, .as_int = 0 }; Operand op = (Operand) { .type = OPTP_INT, .as_int = 0 };
+2 -2
View File
@@ -1185,7 +1185,7 @@ static _Bool step(Runtime *runtime, Error *error)
if(!Object_IsBool(top)) if(!Object_IsBool(top))
{ {
Error_Report(error, 1, "JUMPIFNOTANDPOP expected a boolean on the stack"); Error_Report(error, 0, "Not a boolean");
return 0; return 0;
} }
@@ -1217,7 +1217,7 @@ static _Bool step(Runtime *runtime, Error *error)
if(!Object_IsBool(top)) if(!Object_IsBool(top))
{ {
Error_Report(error, 1, "JUMPIFNOTANDPOP expected a boolean on the stack"); Error_Report(error, 0, "Not a boolean");
return 0; return 0;
} }