aboutsummaryrefslogtreecommitdiff
path: root/src/bytecode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 9406852..d15df9e 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -4,36 +4,32 @@
void tsl_bytecode_writer_init(TslBytecodeWriter *self) {
tsl_buffer_init(&self->buffer);
- self->register_counter = 0;
}
void tsl_bytecode_writer_deinit(TslBytecodeWriter *self) {
tsl_buffer_deinit(&self->buffer);
}
-void tsl_bytecode_writer_reset_register_counter(TslBytecodeWriter *self) {
- self->register_counter = 0;
-}
-
-TslRegister tsl_bytecode_writer_get_unique_register(TslBytecodeWriter *self) {
- if(self->register_counter < INT16_MAX)
- return self->register_counter++;
- fprintf(stderr, "Error: Too many variables in the same scope\n");
- return -1;
-}
-
-int tsl_bytecode_writer_load_number(TslBytecodeWriter *self, TslRegister dst, double number) {
+int tsl_bytecode_writer_loadn(TslBytecodeWriter *self, double number) {
TslInstructionType1 instruction;
instruction.opcode = TSL_OPCODE_LOAD_NUMBER;
- instruction.dst_reg = dst;
instruction.number = number;
+ fprintf(stderr, "loadn %f\n", number);
return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction));
}
-int tsl_bytecode_writer_mov_reg(TslBytecodeWriter *self, TslRegister dst, TslRegister src) {
+int tsl_bytecode_writer_loadb(TslBytecodeWriter *self, TslBool value) {
TslInstructionType2 instruction;
- instruction.opcode = TSL_OPCODE_MOV_REG;
- instruction.dst_reg = dst;
- instruction.src_reg = src;
+ instruction.opcode = TSL_OPCODE_LOAD_BOOL;
+ instruction.value = value;
+ fprintf(stderr, "loadb %s\n", value ? "true" : "false");
+ return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction));
+}
+
+int tsl_bytecode_writer_setv(TslBytecodeWriter *self, TslStringView *key) {
+ TslInstructionType3 instruction;
+ instruction.opcode = TSL_OPCODE_SETV;
+ instruction.key = *key;
+ fprintf(stderr, "setv \"%.*s\"\n", (int)key->size, key->data);
return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction));
}