summaryrefslogtreecommitdiff
path: root/com.c
diff options
context:
space:
mode:
Diffstat (limited to 'com.c')
-rw-r--r--com.c10
1 files changed, 5 insertions, 5 deletions
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 ++;