diff options
-rw-r--r-- | chunk.h | 2 | ||||
-rw-r--r-- | com.c | 12 |
2 files changed, 7 insertions, 7 deletions
@@ -20,6 +20,6 @@ struct _chunk { }; Chunk chunk_new(State *S); size_t compile_opcode(Compiler *C, uint8_t byte); -size_t chunk_wconst(Compiler *C, Val v); +size_t compile_constant(Compiler *C, Val v); #endif @@ -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: { |