aboutsummaryrefslogtreecommitdiff
path: root/include/bytecode.h
blob: 4a14b8da15ad88b4187cab292a088bf827d0b49a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef TSL_BYTECODE_H
#define TSL_BYTECODE_H

#include "std/buffer.h"
#include <stdint.h>

/*
    All instructions are 4 bytes in size.
*/

typedef uint8_t TslOpcodeType;
typedef uint8_t TslRegister;
typedef uint16_t TslValueIndex;

typedef enum {
    TSL_OPCODE_ASSIGN
} TslOpcode;

typedef struct {
    TslBuffer buffer;
} TslBytecodeWriter;

typedef struct {
    TslOpcodeType opcode;
    union {
        TslRegister dst_reg;
        TslRegister src_reg;
    } type1;
    union {
        TslRegister dst_reg;
        TslValueIndex value_index;
    } type2;
} TslInstruction;

void tsl_bytecode_writer_init(TslBytecodeWriter *self);
void tsl_bytecode_writer_deinit(TslBytecodeWriter *self);

int tsl_bytecode_writer_assign(TslBytecodeWriter *self, TslRegister reg, double value);

#endif /* TSL_BYTECODE_H */