#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(struct state* self, TypeKind type, union val val, int line); SK state_push_int(struct state* self, int integer, int line); SK state_push_bool(struct state* self, bool boolean, int line); SK state_push_float(struct state* self, double real, int line); TypeKind state_common_num_type(struct state* self, SK lhs, SK rhs); double state_as_real(struct state* self, SK lhs); int state_line(struct state* self, SK lhs); 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); SK state_and(struct state* self); SK state_or(struct state* self); SK state_not(struct state* self); #endif