From 634272f023a3123bc296690bc2dadd874b601ca9 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 24 Oct 2021 12:24:29 +0200 Subject: Add OP_GET_GLOBAL and symbol resolution for globals --- src/bytecode/compiler.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/bytecode/compiler.h') diff --git a/src/bytecode/compiler.h b/src/bytecode/compiler.h index 8f3fa81..47e7859 100755 --- a/src/bytecode/compiler.h +++ b/src/bytecode/compiler.h @@ -90,6 +90,9 @@ compile_list_binary_op(Chunk *chunk, Visitor *vs, Token start, Ops op) { break; } parse_tree(chunk, vs); + if (tok.type == TOKEN_SYMBOL) { + add_code(chunk, OP_GET_GLOBAL, tok.line, tok.column); + } n++; } emit_constant(chunk, start, FIXNUM_VAL(n)); @@ -123,6 +126,9 @@ compile_list_unary_op(Chunk *chunk, Visitor *vs, Token start, Ops op) { return; } parse_tree(chunk, vs); + if (tok.type == TOKEN_SYMBOL) { + add_code(chunk, OP_GET_GLOBAL, tok.line, tok.column); + } add_code(chunk, op, start.line, start.column); n++; if (n > 1) { -- cgit v1.2.1