From fcf015508c98d16dd34d87e5df0538b44178143d Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 26 Oct 2021 15:19:25 +0200 Subject: Checking n_args at runtime for OP_CALL --- src/bytecode/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bytecode/compiler.h') diff --git a/src/bytecode/compiler.h b/src/bytecode/compiler.h index 44f03fc..995a5c1 100755 --- a/src/bytecode/compiler.h +++ b/src/bytecode/compiler.h @@ -350,8 +350,6 @@ compile_fun_op(Chunk *chunk, Compiler *compiler, Token start) { void compile_call_op(Chunk *chunk, Compiler *compiler, Token start, Token name) { - // FIXME: skipping arguments for now. Assuming nil. - // Compile body. size_t n = 0; while (has_next_token(compiler)) { @@ -370,12 +368,14 @@ compile_call_op(Chunk *chunk, Compiler *compiler, Token start, Token name) { break; } parse_tree(chunk, compiler); + n++; } if (name.type == TOKEN_SYMBOL) { Object obj = make_symbol(name.value); emit_constant(chunk, start, obj); add_code(chunk, OP_GET, start.line, start.column); } + emit_constant(chunk, start, FIXNUM_VAL(n)); add_code(chunk, OP_CALL, start.line, start.column); } -- cgit v1.2.1