32 lines
540 B
C
32 lines
540 B
C
|
#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
|
||
|
|