2024-03-31 21:10:56 +00:00
|
|
|
#ifndef SK_PROG_H
|
|
|
|
#define SK_PROG_H
|
|
|
|
|
|
|
|
#include "commons.h"
|
|
|
|
#include "value.h"
|
|
|
|
|
|
|
|
#define SK_NO_PARAM (-1)
|
|
|
|
#define OPCODE(G) \
|
2024-03-31 23:32:47 +00:00
|
|
|
G(OP_PUSH), \
|
|
|
|
G(OP_ADD), G(OP_SUB), G(OP_MUL), \
|
|
|
|
G(OP_DIV), G(OP_MOD), G(OP_POW), \
|
2024-04-01 12:00:06 +00:00
|
|
|
G(OP_USUB), G(OP_ASSERT_EQ), \
|
|
|
|
G(OP_NOT), G(OP_AND), G(OP_OR), \
|
2024-04-01 21:33:43 +00:00
|
|
|
G(OP_BR), G(OP_BRF), G(OP_LT), G(OP_GT), \
|
2024-04-02 15:33:31 +00:00
|
|
|
G(OP_EQUAL), G(OP_LOCAL_STORE), G(OP_LOCAL_LOAD)
|
2024-03-31 21:10:56 +00:00
|
|
|
|
|
|
|
SK_ENUM_H(Opcode, OPCODE);
|
|
|
|
|
|
|
|
struct prog
|
|
|
|
{
|
|
|
|
struct vec opcodes;
|
|
|
|
struct vec params;
|
|
|
|
struct vec constants;
|
|
|
|
};
|
|
|
|
|
|
|
|
void prog_init(struct prog* self);
|
|
|
|
void prog_free(struct prog* self);
|
|
|
|
|
|
|
|
size_t prog_add_instr(struct prog* self,
|
|
|
|
Opcode opcode,
|
|
|
|
size_t param);
|
|
|
|
|
|
|
|
size_t prog_add_constant(struct prog* self,
|
|
|
|
struct value* new_value);
|
|
|
|
#endif
|