summaryrefslogtreecommitdiff
path: root/com.c
diff options
context:
space:
mode:
Diffstat (limited to 'com.c')
-rw-r--r--com.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/com.c b/com.c
index df4ea9c..9a90a7f 100644
--- a/com.c
+++ b/com.c
@@ -48,7 +48,7 @@ size_t compile_opcode(Compiler *C, uint8_t byte) {
ch->bc.len ++;
return ix;
}
-size_t chunk_wconst(Compiler *C, Val v) {
+size_t compile_constant(Compiler *C, Val v) {
Chunk *ch = C->ch;
for (int i = 0; i < ch->consts.len; i ++)
if (val_equal(v, ch->consts.d[i])) return i;
@@ -91,7 +91,7 @@ void set_form(Compiler *C, AstVec l, Op _) {
ObjString *o = objstring_copy_cstr(C->S, ident.as.str);
compile_node(C, l.vals[2]);
compile_opcode(C, OP_SETGLOBAL);
- compile_opcode(C, chunk_wconst(C, VAL_OBJ(o)));
+ compile_opcode(C, compile_constant(C, VAL_OBJ(o)));
}
void do_form(Compiler *C, AstVec l, Op _) {
@@ -174,7 +174,7 @@ void fn_form(Compiler *C, AstVec l, Op op) {
compile_opcode(&subcompiler, OP_RET);
compile_opcode(C, OP_LOADK);
- compile_opcode(C, chunk_wconst(C, VAL_OBJ(func)));
+ compile_opcode(C, compile_constant(C, VAL_OBJ(func)));
}
@@ -227,17 +227,17 @@ static void compile_node(Compiler *C, AstNode a) {
// read global variable
ObjString *o = objstring_copy_cstr(C->S, a.as.str);
compile_opcode(C, OP_GETGLOBAL);
- compile_opcode(C, chunk_wconst(C, VAL_OBJ(o)));
+ compile_opcode(C, compile_constant(C, VAL_OBJ(o)));
}
break;
case AST_NUM:
compile_opcode(C, OP_LOADK);
- compile_opcode(C, chunk_wconst(C, VAL_NUM(a.as.num)));
+ compile_opcode(C, compile_constant(C, VAL_NUM(a.as.num)));
break;
case AST_STRING: {
ObjString *o = objstring_copy_cstr(C->S, a.as.str);
compile_opcode(C, OP_LOADK);
- compile_opcode(C, chunk_wconst(C, VAL_OBJ(o)));
+ compile_opcode(C, compile_constant(C, VAL_OBJ(o)));
break;
}
case AST_LIST: {