2024-03-18 17:20:40 +00:00
|
|
|
#ifndef CCM_CCM_H
|
|
|
|
#define CCM_CCM_H
|
|
|
|
|
|
|
|
#include "commons.h"
|
|
|
|
#include "vec.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "err.h"
|
2024-03-21 11:00:20 +00:00
|
|
|
#include "sym.h"
|
2024-03-18 17:20:40 +00:00
|
|
|
|
2024-03-20 15:26:59 +00:00
|
|
|
typedef size_t CCM;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int id;
|
|
|
|
value_t* value;
|
|
|
|
} ccm_entry_t;
|
2024-03-18 17:20:40 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2024-03-21 11:00:20 +00:00
|
|
|
sym_t sym;
|
2024-03-18 17:20:40 +00:00
|
|
|
err_t err;
|
|
|
|
vec_t values;
|
|
|
|
vec_t stack;
|
2024-03-20 15:26:59 +00:00
|
|
|
vec_t globals;
|
|
|
|
int id_counter;
|
2024-03-18 17:20:40 +00:00
|
|
|
} ccm_t;
|
|
|
|
|
|
|
|
void ccm_init(ccm_t* self);
|
2024-03-20 15:26:59 +00:00
|
|
|
void ccm_entry_free(ccm_entry_t* self);
|
2024-03-18 17:20:40 +00:00
|
|
|
void ccm_free(ccm_t* self);
|
|
|
|
|
|
|
|
size_t ccm_str(ccm_t* self, char* buffer, size_t size);
|
2024-03-20 15:26:59 +00:00
|
|
|
value_t* ccm_find_value(ccm_t* self, size_t addr);
|
|
|
|
size_t ccm_add_value(ccm_t* self, value_t* value);
|
|
|
|
|
|
|
|
size_t ccm_store_global(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_load_global(ccm_t* self, size_t addr);
|
2024-03-18 17:20:40 +00:00
|
|
|
|
2024-03-19 07:56:41 +00:00
|
|
|
CCM ccm_from_value(ccm_t* self, value_t* value);
|
2024-03-19 15:25:02 +00:00
|
|
|
value_t* ccm_to_value(ccm_t* self, CCM value);
|
2024-03-19 07:56:41 +00:00
|
|
|
|
2024-03-18 17:20:40 +00:00
|
|
|
int ccm_is_num(ccm_t* self, CCM value);
|
|
|
|
double ccm_from_num(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_to_num(ccm_t* self, double value, int line);
|
|
|
|
|
|
|
|
int ccm_is_tuple(ccm_t* self, CCM value);
|
|
|
|
vec_t* ccm_from_tuple(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_to_tuple(ccm_t* self, vec_t* values, int line);
|
|
|
|
|
2024-03-19 06:11:28 +00:00
|
|
|
int ccm_is_boolean(ccm_t* self, CCM value);
|
|
|
|
int ccm_from_boolean(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_to_boolean(ccm_t* self, int value, int line);
|
|
|
|
|
2024-03-19 13:23:11 +00:00
|
|
|
int ccm_is_str(ccm_t* self, CCM value);
|
|
|
|
char* ccm_from_str(ccm_t* self, CCM value);
|
2024-03-22 23:48:16 +00:00
|
|
|
CCM ccm_to_str(ccm_t* self, char const* value, int line);
|
2024-03-19 13:23:11 +00:00
|
|
|
|
2024-03-20 15:26:59 +00:00
|
|
|
int ccm_is_array(ccm_t* self, CCM value);
|
|
|
|
vec_t* ccm_from_array(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_to_array(ccm_t* self, vec_t* value, int line);
|
|
|
|
|
|
|
|
int ccm_is_ref(ccm_t* self, CCM value);
|
|
|
|
size_t ccm_from_ref(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_to_ref(ccm_t* self, size_t value, int line);
|
|
|
|
|
2024-03-18 17:20:40 +00:00
|
|
|
void ccm_push(ccm_t* self, CCM value);
|
|
|
|
CCM ccm_pop(ccm_t* self);
|
|
|
|
CCM ccm_top(ccm_t* self, int depth);
|
2024-03-21 11:00:20 +00:00
|
|
|
void ccm_set(ccm_t* self, CCM value, int addr);
|
|
|
|
CCM ccm_get(ccm_t* self, int addr);
|
2024-03-18 17:20:40 +00:00
|
|
|
|
2024-03-19 07:56:41 +00:00
|
|
|
void ccm_in(ccm_t* self);
|
2024-03-18 17:20:40 +00:00
|
|
|
void ccm_add(ccm_t* self);
|
|
|
|
void ccm_sub(ccm_t* self);
|
|
|
|
void ccm_usub(ccm_t* self);
|
|
|
|
void ccm_mul(ccm_t* self);
|
|
|
|
void ccm_div(ccm_t* self);
|
|
|
|
void ccm_mod(ccm_t* self);
|
|
|
|
void ccm_pow(ccm_t* self);
|
2024-03-19 06:11:28 +00:00
|
|
|
void ccm_not(ccm_t* self);
|
2024-03-18 17:20:40 +00:00
|
|
|
|
2024-03-19 15:25:02 +00:00
|
|
|
void ccm_eq(ccm_t* self);
|
|
|
|
void ccm_ne(ccm_t* self);
|
|
|
|
void ccm_lt(ccm_t* self);
|
|
|
|
void ccm_le(ccm_t* self);
|
|
|
|
void ccm_gt(ccm_t* self);
|
|
|
|
void ccm_ge(ccm_t* self);
|
|
|
|
|
2024-03-21 11:00:20 +00:00
|
|
|
#endif
|