summaryrefslogtreecommitdiff
path: root/com.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-08-08 14:44:48 +0100
committerubq323 <ubq323@ubq323.website>2024-08-08 14:49:05 +0100
commitd046c7d20fd283c90495d3af4bb53d1cfb2a0812 (patch)
treea764b20d45135101b179a4fbdc122ca0c76bd6b6 /com.c
parenta4e8599e8d0fde881cd4e6e3031e5b52550e878e (diff)
misc
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 ++;