Fixed negative variables handled incorrectly

This commit is contained in:
2026-05-26 18:01:49 +10:00
parent 69175e801a
commit 190477add8
6 changed files with 40 additions and 3 deletions
+11
View File
@@ -377,6 +377,17 @@ static unsigned int writeInstructionUnary(Toy_Bytecode** mb, Toy_AstUnary ast) {
result = 1;
}
else if (ast.flag == TOY_AST_FLAG_INVERT) {
result = writeBytecodeFromAst(mb, ast.child);
EMIT_BYTE(mb, code, TOY_OPCODE_INVERT);
//4-byte alignment
EMIT_BYTE(mb, code, 0);
EMIT_BYTE(mb, code, 0);
EMIT_BYTE(mb, code, 0);
}
else {
fprintf(stderr, TOY_CC_ERROR "ERROR: Invalid AST unary flag found\n" TOY_CC_RESET);
exit(-1);