ccm/lib/prog.h

32 lines
540 B
C
Raw Permalink Normal View History

2024-03-18 17:20:40 +00:00
#ifndef CCM_PROG_H
#define CCM_PROG_H
#include "commons.h"
#include "vec.h"
#include "bytecode.h"
#include "value.h"
#include "ccm.h"
#define CCM_NO_PARAM (-1)
typedef struct {
Opcode opcode;
int param;
} instr_t;
typedef struct {
vec_t instrs;
vec_t constants;
} prog_t;
void prog_init(prog_t* self);
void prog_free(prog_t* self);
size_t prog_add_instr(prog_t* self, Opcode opcode, int param);
size_t prog_add_new_constant(prog_t* self, CCM value);
size_t prog_str(prog_t* self, char* buffer, size_t size);
#endif