blob: 3e9a6e8de5826b89d61aea57d6d3366d406696b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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));
}
|