aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/compiler.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-28 13:34:18 +0200
committerBad Diode <bd@badd10de.dev>2021-10-28 13:34:18 +0200
commit0ff1716f45c9494b1aa02b8ddb2541821480c5ad (patch)
treef08bbe92d279a00d451a6f1c7360a52085b23b86 /src/bytecode/compiler.h
parenta8807776e6795dccfe8d2f381ae01fdb4cfb07e6 (diff)
downloadbdl-0ff1716f45c9494b1aa02b8ddb2541821480c5ad.tar.gz
bdl-0ff1716f45c9494b1aa02b8ddb2541821480c5ad.zip
Fix difference between lambda and named func calls
Diffstat (limited to 'src/bytecode/compiler.h')
-rwxr-xr-xsrc/bytecode/compiler.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/bytecode/compiler.h b/src/bytecode/compiler.h
index 867d194..5f38216 100755
--- a/src/bytecode/compiler.h
+++ b/src/bytecode/compiler.h
@@ -520,6 +520,10 @@ compile_fun_op(Chunk *chunk, Compiler *compiler, Token start) {
520 520
521void 521void
522compile_call_op(Chunk *chunk, Compiler *compiler, Token start, Token name) { 522compile_call_op(Chunk *chunk, Compiler *compiler, Token start, Token name) {
523 if (name.type == TOKEN_SYMBOL) {
524 parse_symbol(chunk, compiler, name);
525 }
526
523 // Compile body. 527 // Compile body.
524 size_t n = 0; 528 size_t n = 0;
525 while (has_next_token(compiler)) { 529 while (has_next_token(compiler)) {
@@ -540,11 +544,6 @@ compile_call_op(Chunk *chunk, Compiler *compiler, Token start, Token name) {
540 parse_tree(chunk, compiler); 544 parse_tree(chunk, compiler);
541 n++; 545 n++;
542 } 546 }
543 if (name.type == TOKEN_SYMBOL) {
544 Object obj = make_symbol(name.value);
545 emit_constant(chunk, start, obj);
546 add_code(chunk, OP_GET, start.line, start.column);
547 }
548 emit_constant(chunk, start, FIXNUM_VAL(n)); 547 emit_constant(chunk, start, FIXNUM_VAL(n));
549 add_code(chunk, OP_CALL, start.line, start.column); 548 add_code(chunk, OP_CALL, start.line, start.column);
550} 549}
@@ -635,7 +634,10 @@ parse_list(Chunk *chunk, Compiler *compiler, Token start) {
635 case TOKEN_GREATER_EQUAL: { compile_list_binary_op(chunk, compiler, start, OP_GREATER_EQUAL); } break; 634 case TOKEN_GREATER_EQUAL: { compile_list_binary_op(chunk, compiler, start, OP_GREATER_EQUAL); } break;
636 case TOKEN_PRINT: { compile_list_unary_op(chunk, compiler, start, OP_PRINT); } break; 635 case TOKEN_PRINT: { compile_list_unary_op(chunk, compiler, start, OP_PRINT); } break;
637 case TOKEN_DISPLAY: { compile_list_unary_op(chunk, compiler, start, OP_DISPLAY); } break; 636 case TOKEN_DISPLAY: { compile_list_unary_op(chunk, compiler, start, OP_DISPLAY); } break;
638 case TOKEN_NEWLINE: { compile_list_simple_op(chunk, compiler, start, OP_NEWLINE); } break; 637 case TOKEN_NEWLINE: {
638 compile_list_simple_op(chunk, compiler, start, OP_NEWLINE);
639 emit_constant(chunk, start, NIL_VAL);
640 } break;
639 case TOKEN_DEF: { compile_declare_op(chunk, compiler, start, OP_DEF); } break; 641 case TOKEN_DEF: { compile_declare_op(chunk, compiler, start, OP_DEF); } break;
640 case TOKEN_SET: { compile_declare_op(chunk, compiler, start, OP_SET); } break; 642 case TOKEN_SET: { compile_declare_op(chunk, compiler, start, OP_SET); } break;
641 case TOKEN_FUN: { compile_fun_op(chunk, compiler, start); } break; 643 case TOKEN_FUN: { compile_fun_op(chunk, compiler, start); } break;