aboutsummaryrefslogtreecommitdiff
path: root/include/bytecode.h
blob: 6ce1dc906268305bdcb10cd07426fd0ec42e7764 (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
41
42
43
#ifndef TSL_BYTECODE_H
#define TSL_BYTECODE_H

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

typedef uint8_t TslOpcodeType;

typedef enum {
    TSL_OPCODE_LOAD_NUMBER,
    TSL_OPCODE_LOAD_BOOL,
    TSL_OPCODE_SETV
} TslOpcode;

typedef struct {
    TslBuffer buffer;
} TslBytecodeWriter;

typedef struct {
    double number;
    TslOpcodeType opcode;
} TslInstructionType1;

typedef struct {
    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);

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 */