skopy/lib/include/value.h

49 lines
852 B
C

#ifndef SK_VALUE_H
#define SK_VALUE_H
#include "commons.h"
#include "node.h"
#include "fun.h"
#define TYPE_KIND(G) \
G(TYPE_INT), G(TYPE_BOOL), G(TYPE_FLOAT), \
G(TYPE_STRING), G(TYPE_FUN), G(TYPE_REF), \
G(TYPE_NATIVE_FUN), G(TYPE_MODULE)
SK_ENUM_H(TypeKind, TYPE_KIND);
union val
{
int integer;
double real;
bool boolean;
char* str;
struct fun* fun;
struct nfun* nfun;
size_t ref;
struct module* mod;
};
struct value
{
TypeKind type;
union val val;
int line;
};
void value_init(struct value* self,
TypeKind type,
union val val,
int line);
void value_free(struct value* self);
struct value* value_new_clone(struct value* self);
bool value_equals(struct value* self, struct value* rhs);
void value_str(struct value* self, struct str* dest);
#endif