skopy/lib/include/state.h

58 lines
1.1 KiB
C

#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_pop(struct state* self);
SK state_push_int(struct state* self, int integer, int line);
SK state_add(struct state* self);
SK state_sub(struct state* self);
SK state_usub(struct state* self);
SK state_mul(struct state* self);
SK state_div(struct state* self);
SK state_mod(struct state* self);
SK state_pow(struct state* self);
#endif