diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-01-22 06:14:42 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-01-22 06:14:42 +0100 |
commit | 840a3c6c5aa2400ce80d8ec7bb8b1a8d6e25770b (patch) | |
tree | 3b58d296814b54ee20f050e21a9cd8f2c1f2bf5a /include | |
parent | a724ddbe1c8c53acd8b2836e437237cf17c57043 (diff) |
Simplify bytecode
Diffstat (limited to 'include')
-rw-r--r-- | include/bytecode.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/include/bytecode.h b/include/bytecode.h index 4a9d49c..6ce1dc9 100644 --- a/include/bytecode.h +++ b/include/bytecode.h @@ -2,42 +2,42 @@ #define TSL_BYTECODE_H #include "std/buffer.h" +#include "std/string_view.h" +#include "value.h" #include <stdint.h> typedef uint8_t TslOpcodeType; -/* Registers are positive if they refer to local variables and negative when they refer to parameters */ -typedef int16_t TslRegister; -typedef uint16_t TslValueIndex; typedef enum { TSL_OPCODE_LOAD_NUMBER, - TSL_OPCODE_MOV_REG + TSL_OPCODE_LOAD_BOOL, + TSL_OPCODE_SETV } TslOpcode; typedef struct { TslBuffer buffer; - TslRegister register_counter; } TslBytecodeWriter; typedef struct { - TslRegister dst_reg; double number; TslOpcodeType opcode; } TslInstructionType1; typedef struct { - TslRegister dst_reg; - TslRegister src_reg; + TslBool value; TslOpcodeType opcode; } TslInstructionType2; +typedef struct { + TslStringView key; + TslOpcodeType opcode; +} TslInstructionType3; + void tsl_bytecode_writer_init(TslBytecodeWriter *self); void tsl_bytecode_writer_deinit(TslBytecodeWriter *self); -void tsl_bytecode_writer_reset_register_counter(TslBytecodeWriter *self); -/* Returns -1 on error (too many registers used (more than 2^15)) */ -TslRegister tsl_bytecode_writer_get_unique_register(TslBytecodeWriter *self); -int tsl_bytecode_writer_load_number(TslBytecodeWriter *self, TslRegister dst, double number); -int tsl_bytecode_writer_mov_reg(TslBytecodeWriter *self, TslRegister dst, TslRegister src); +int tsl_bytecode_writer_loadn(TslBytecodeWriter *self, double number); +int tsl_bytecode_writer_loadb(TslBytecodeWriter *self, TslBool value); +int tsl_bytecode_writer_setv(TslBytecodeWriter *self, TslStringView *key); #endif /* TSL_BYTECODE_H */ |