diff options
Diffstat (limited to 'src/bytecode.c')
-rw-r--r-- | src/bytecode.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bytecode.c b/src/bytecode.c new file mode 100644 index 0000000..3e9a6e8 --- /dev/null +++ b/src/bytecode.c @@ -0,0 +1,19 @@ +#include "../include/bytecode.h" +#include <assert.h> + +void tsl_bytecode_writer_init(TslBytecodeWriter *self) { + assert(sizeof(TslInstruction) == 4); + tsl_buffer_init(&self->buffer); +} + +void tsl_bytecode_writer_deinit(TslBytecodeWriter *self) { + tsl_buffer_deinit(&self->buffer); +} + +int tsl_bytecode_writer_assign(TslBytecodeWriter *self, TslRegister reg, double value) { + TslInstruction instruction; + instruction.opcode = TSL_OPCODE_ASSIGN; + instruction.type2.dst_reg = reg; + instruction.type2.value_index = value; + return tsl_buffer_append(&self->buffer, &instruction, sizeof(instruction)); +} |