From bea93dc98b602472bb36635dfdf425d14d826673 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Mon, 24 Jun 2024 16:52:31 +0100 Subject: chunk_wconst -> compile_constant --- com.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'com.c') 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: { -- cgit v1.2.3