diff options
Diffstat (limited to 'src/bytecode/compiler.h')
-rwxr-xr-x | src/bytecode/compiler.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/bytecode/compiler.h b/src/bytecode/compiler.h index e2d5819..b1cdfb9 100755 --- a/src/bytecode/compiler.h +++ b/src/bytecode/compiler.h | |||
@@ -91,7 +91,7 @@ compile_list_binary_op(Chunk *chunk, Visitor *vs, Token start, Ops op) { | |||
91 | } | 91 | } |
92 | parse_tree(chunk, vs); | 92 | parse_tree(chunk, vs); |
93 | if (tok.type == TOKEN_SYMBOL) { | 93 | if (tok.type == TOKEN_SYMBOL) { |
94 | add_code(chunk, OP_GET_GLOBAL, tok.line, tok.column); | 94 | add_code(chunk, OP_GET, tok.line, tok.column); |
95 | } | 95 | } |
96 | n++; | 96 | n++; |
97 | } | 97 | } |
@@ -127,7 +127,7 @@ compile_list_unary_op(Chunk *chunk, Visitor *vs, Token start, Ops op) { | |||
127 | } | 127 | } |
128 | parse_tree(chunk, vs); | 128 | parse_tree(chunk, vs); |
129 | if (tok.type == TOKEN_SYMBOL) { | 129 | if (tok.type == TOKEN_SYMBOL) { |
130 | add_code(chunk, OP_GET_GLOBAL, tok.line, tok.column); | 130 | add_code(chunk, OP_GET, tok.line, tok.column); |
131 | } | 131 | } |
132 | add_code(chunk, op, start.line, start.column); | 132 | add_code(chunk, op, start.line, start.column); |
133 | n++; | 133 | n++; |
@@ -183,7 +183,7 @@ compile_list_simple_op(Chunk *chunk, Visitor *vs, Token start, Ops op) { | |||
183 | } | 183 | } |
184 | 184 | ||
185 | void | 185 | void |
186 | compile_define_op(Chunk *chunk, Visitor *vs, Token start) { | 186 | compile_declare_op(Chunk *chunk, Visitor *vs, Token start, Ops op) { |
187 | Token name = peek_token(vs); | 187 | Token name = peek_token(vs); |
188 | if (name.type != TOKEN_SYMBOL) { | 188 | if (name.type != TOKEN_SYMBOL) { |
189 | error_push((Error){ | 189 | error_push((Error){ |
@@ -216,7 +216,7 @@ compile_define_op(Chunk *chunk, Visitor *vs, Token start) { | |||
216 | } | 216 | } |
217 | parse_tree(chunk, vs); | 217 | parse_tree(chunk, vs); |
218 | if (expr.type == TOKEN_SYMBOL) { | 218 | if (expr.type == TOKEN_SYMBOL) { |
219 | add_code(chunk, OP_GET_GLOBAL, expr.line, expr.column); | 219 | add_code(chunk, OP_GET, expr.line, expr.column); |
220 | } | 220 | } |
221 | if (peek_token(vs).type != TOKEN_RPAREN) { | 221 | if (peek_token(vs).type != TOKEN_RPAREN) { |
222 | error_push((Error){ | 222 | error_push((Error){ |
@@ -228,7 +228,7 @@ compile_define_op(Chunk *chunk, Visitor *vs, Token start) { | |||
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | next_token(vs); | 230 | next_token(vs); |
231 | add_code(chunk, OP_DEF, start.line, start.column); | 231 | add_code(chunk, op, start.line, start.column); |
232 | } | 232 | } |
233 | 233 | ||
234 | void | 234 | void |
@@ -260,7 +260,8 @@ parse_list(Chunk *chunk, Visitor *vs, Token start) { | |||
260 | case TOKEN_PRINT: { compile_list_unary_op(chunk, vs, start, OP_PRINT); } break; | 260 | case TOKEN_PRINT: { compile_list_unary_op(chunk, vs, start, OP_PRINT); } break; |
261 | case TOKEN_DISPLAY: { compile_list_unary_op(chunk, vs, start, OP_DISPLAY); } break; | 261 | case TOKEN_DISPLAY: { compile_list_unary_op(chunk, vs, start, OP_DISPLAY); } break; |
262 | case TOKEN_NEWLINE: { compile_list_simple_op(chunk, vs, start, OP_NEWLINE); } break; | 262 | case TOKEN_NEWLINE: { compile_list_simple_op(chunk, vs, start, OP_NEWLINE); } break; |
263 | case TOKEN_DEF: { compile_define_op(chunk, vs, start); } break; | 263 | case TOKEN_DEF: { compile_declare_op(chunk, vs, start, OP_DEF); } break; |
264 | case TOKEN_SET: { compile_declare_op(chunk, vs, start, OP_SET); } break; | ||
264 | default: { | 265 | default: { |
265 | error_push((Error){ | 266 | error_push((Error){ |
266 | .type = ERR_TYPE_COMPILER, | 267 | .type = ERR_TYPE_COMPILER, |