From d046c7d20fd283c90495d3af4bb53d1cfb2a0812 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 8 Aug 2024 14:44:48 +0100 Subject: misc --- com.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'com.c') diff --git a/com.c b/com.c index 6d701d9..f610bd7 100644 --- a/com.c +++ b/com.c @@ -7,7 +7,6 @@ #include "mem.h" #include "chunk.h" #include "util.h" -#include "prs.h" #include "lib.h" #include "read.h" @@ -23,9 +22,9 @@ Chunk chunk_new(State *S) { return (Chunk){ 0 }; } -Compiler compiler_new(Compiler *outer, Chunk *ch) { +Compiler compiler_new(State *S, Compiler *outer, Chunk *ch) { return (Compiler){ - .S = outer->S, + .S = S, .ch = ch, .stack_cur = 0, .scope = NULL, @@ -365,6 +364,7 @@ static void for_form(Compiler *C, ObjArr *a, Op _, int flags) { cpl_op(C, OP_ADD); cpl_op(C, OP_SETLOCAL); cpl_op(C, islot); + cpl_op(C, OP_DROP); cpl_op(C, OP_REDO); size_t ph_A = placeholder(C); size_t dest_B = BYTECODE(C).len; @@ -478,7 +478,7 @@ static void fn_form(Compiler *C, ObjArr *a, Op _, int flags) { uint8_t arity = arglist->len; ObjFunc *func = objfunc_new(C->S, arity); - Compiler subcompiler = compiler_new(C, &func->ch); + Compiler subcompiler = compiler_new(C->S, C, &func->ch); Compiler *SC = &subcompiler; begin_scope(SC); @@ -514,7 +514,7 @@ static void defn_form(Compiler *C, ObjArr *a, Op _, int flags) { char *fname = AS_CSTRING(blist->d[0]); ObjFunc *func = objfunc_new(C->S, arity); - Compiler subcompiler = compiler_new(C, &func->ch); + Compiler subcompiler = compiler_new(C->S, C, &func->ch); Compiler *SC = &subcompiler; begin_scope(SC); SC->stack_cur ++; -- cgit v1.2.3