summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-24 16:52:31 +0100
committerubq323 <ubq323@ubq323.website>2024-06-24 16:52:31 +0100
commitbea93dc98b602472bb36635dfdf425d14d826673 (patch)
treeedd93b1a61cc1aeeb6849de88b25fe737c249b2d
parentb2c8538a45aeb154d7cb8ced6ea6a8e0eafb0814 (diff)
chunk_wconst -> compile_constant
-rw-r--r--chunk.h2
-rw-r--r--com.c12
2 files changed, 7 insertions, 7 deletions
diff --git a/chunk.h b/chunk.h
index 36452fb..ba01614 100644
--- a/chunk.h
+++ b/chunk.h
@@ -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
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: {