skopy/lib/include/state.h

73 lines
1.6 KiB
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);
2024-03-31 23:32:47 +00:00
SK state_pop(struct state* self);
2024-04-01 12:00:06 +00:00
SK state_push(struct state* self,
TypeKind type,
union val val,
int line);
SK state_push_int(struct state* self, int integer, int line);
2024-04-01 12:00:06 +00:00
SK state_push_bool(struct state* self, bool boolean, int line);
2024-04-01 19:08:42 +00:00
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);
2024-03-31 21:10:56 +00:00
2024-03-31 23:32:47 +00:00
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);
2024-04-01 12:00:06 +00:00
SK state_and(struct state* self);
SK state_or(struct state* self);
SK state_not(struct state* self);
2024-03-31 21:10:56 +00:00
#endif