diff options
Diffstat (limited to 'src/bytecode.c')
-rw-r--r-- | src/bytecode.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index acdb2d9..b8342b4 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -2,7 +2,7 @@ #include <assert.h> #include <stdio.h> -static const char* opcode_to_string(TslOpcode opcode) { +const char* tsl_opcode_to_string(TslOpcode opcode) { switch(opcode) { case TSL_OPCODE_LOADN: return "loadn"; case TSL_OPCODE_LOADB: return "loadb"; @@ -25,49 +25,49 @@ static const char* opcode_to_string(TslOpcode opcode) { return ""; } -void tsl_bytecode_writer_init(TslBytecodeWriter *self) { +void tsl_bytecode_init(TslBytecode *self) { tsl_buffer_init(&self->buffer); } -void tsl_bytecode_writer_deinit(TslBytecodeWriter *self) { +void tsl_bytecode_deinit(TslBytecode *self) { tsl_buffer_deinit(&self->buffer); } -int tsl_bytecode_writer_add_ins1(TslBytecodeWriter *self, TslOpcode opcode, int value) { +int tsl_bytecode_add_ins1(TslBytecode *self, TslOpcode opcode, int value) { TslInstructionType1 instruction; instruction.opcode = opcode; instruction.value = value; - fprintf(stderr, "%s %d\n", opcode_to_string(opcode), value); + fprintf(stderr, "%s %d\n", tsl_opcode_to_string(opcode), value); return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction)); } -int tsl_bytecode_writer_add_ins2(TslBytecodeWriter *self, TslOpcode opcode, double value) { +int tsl_bytecode_add_ins2(TslBytecode *self, TslOpcode opcode, double value) { TslInstructionType2 instruction; instruction.opcode = opcode; instruction.value = value; - fprintf(stderr, "%s %f\n", opcode_to_string(opcode), value); + fprintf(stderr, "%s %f\n", tsl_opcode_to_string(opcode), value); return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction)); } -int tsl_bytecode_writer_add_ins3(TslBytecodeWriter *self, TslOpcode opcode, TslBool value) { +int tsl_bytecode_add_ins3(TslBytecode *self, TslOpcode opcode, TslBool value) { TslInstructionType3 instruction; instruction.opcode = opcode; instruction.value = value; - fprintf(stderr, "%s %s\n", opcode_to_string(opcode), value ? "true" : "false"); + fprintf(stderr, "%s %s\n", tsl_opcode_to_string(opcode), value ? "true" : "false"); return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction)); } -int tsl_bytecode_writer_add_ins4(TslBytecodeWriter *self, TslOpcode opcode, TslStringView *value) { +int tsl_bytecode_add_ins4(TslBytecode *self, TslOpcode opcode, TslStringView *value) { TslInstructionType4 instruction; instruction.opcode = opcode; instruction.value = *value; - fprintf(stderr, "%s \"%.*s\"\n", opcode_to_string(opcode), (int)value->size, value->data); + fprintf(stderr, "%s \"%.*s\"\n", tsl_opcode_to_string(opcode), (int)value->size, value->data); return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction)); } -int tsl_bytecode_writer_add_ins5(TslBytecodeWriter *self, TslOpcode opcode) { +int tsl_bytecode_add_ins5(TslBytecode *self, TslOpcode opcode) { TslInstructionType5 instruction; instruction.opcode = opcode; - fprintf(stderr, "%s\n", opcode_to_string(opcode)); + fprintf(stderr, "%s\n", tsl_opcode_to_string(opcode)); return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction)); } |