2024-03-18 17:20:40 +00:00
|
|
|
#ifndef CCM_VALUE_H
|
|
|
|
#define CCM_VALUE_H
|
|
|
|
|
|
|
|
#include "commons.h"
|
|
|
|
#include "type.h"
|
|
|
|
#include "vec.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
union {
|
|
|
|
double num;
|
|
|
|
vec_t* tuple;
|
2024-03-19 06:11:28 +00:00
|
|
|
int boolean;
|
2024-03-19 13:23:11 +00:00
|
|
|
char* str;
|
2024-03-20 15:26:59 +00:00
|
|
|
vec_t* array;
|
|
|
|
size_t ref;
|
2024-03-18 17:20:40 +00:00
|
|
|
} data;
|
|
|
|
|
|
|
|
Type type;
|
|
|
|
int line;
|
|
|
|
} value_t;
|
|
|
|
|
|
|
|
void value_init_num(value_t* self, double num, int line);
|
|
|
|
void value_init_new_tuple(value_t* self, vec_t* values, int line);
|
2024-03-19 06:11:28 +00:00
|
|
|
void value_init_boolean(value_t* self, int boolean, int line);
|
2024-03-19 13:23:11 +00:00
|
|
|
void value_init_str(value_t* self, char const* value, int line);
|
2024-03-20 15:26:59 +00:00
|
|
|
void value_init_new_array(value_t* self, vec_t* value, int line);
|
|
|
|
void value_init_ref(value_t* self, size_t value, int line);
|
|
|
|
|
2024-03-18 17:20:40 +00:00
|
|
|
value_t* value_new_clone(value_t* self);
|
|
|
|
void value_free(value_t* self);
|
|
|
|
|
|
|
|
size_t value_str(value_t* self, char* buffer, size_t size);
|
|
|
|
int value_equals(value_t* self, value_t* rhs);
|
|
|
|
|
|
|
|
#endif
|