skopy/lib/include/prog.h

39 lines
847 B
C
Raw Normal View History

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), \
G(OP_EQUAL), G(OP_LOCAL_STORE), G(OP_LOCAL_LOAD), \
G(OP_CALL), G(OP_RET)
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);
struct prog* prog_new_clone(struct prog* self);
2024-03-31 21:10:56 +00:00
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