skopy/lib/include/state.h

48 lines
869 B
C
Raw Normal View History

2024-03-31 21:10:56 +00:00
#ifndef SK_STATE_H
#define SK_STATE_H
#include "commons.h"
#include "value.h"
#define SK size_t
struct local
{
size_t addr;
struct value* value;
};
struct frame
{
struct vec locals;
struct vec stack;
};
struct state
{
struct vec frames;
size_t addr;
};
void local_init(struct local* self,
size_t addr,
struct value* new_value);
void local_free(struct local* self);
void frame_init(struct frame* self);
void frame_free(struct frame* self);
void state_init(struct state* self);
void state_free(struct state* self);
struct frame* state_frame(struct state* self);
void state_push_frame(struct state* self);
bool state_has_top(struct state* self);
SK state_top(struct state* self);
struct value* state_try_get_value(struct state* self, SK value);
SK state_push_int(struct state* self, int integer);
#endif