diff options
author | ubq323 <ubq323@ubq323.website> | 2024-06-24 16:52:31 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-06-24 16:52:31 +0100 |
commit | bea93dc98b602472bb36635dfdf425d14d826673 (patch) | |
tree | edd93b1a61cc1aeeb6849de88b25fe737c249b2d /com.c | |
parent | b2c8538a45aeb154d7cb8ced6ea6a8e0eafb0814 (diff) |
chunk_wconst -> compile_constant
Diffstat (limited to 'com.c')
-rw-r--r-- | com.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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: { |