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), \
|
|
|
|
G(OP_USUB)
|
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
|