Something went wrong. Try again.
the hito embeddable programming language
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172#ifndef value_h#define value_h
#include "intern.h"#include "env.h"#include "syntax.h"#include "builtins.h"#include <stdbool.h>typedef struct env env_t;typedef struct value value_t;typedef struct gc gc_t;
struct value { enum { VALUE_INT = 0, VALUE_FLOAT, VALUE_STRING, VALUE_CONSTRUCTOR, VALUE_CLOSURE, VALUE_BUILTIN, VALUE_ENV, } tag; union { long integer; double floating; builtin_func_t *builtin; struct { char *string; bool shared; } string; struct { intern_t name; value_t **args; size_t num_args; } constructor; struct { value_t *env; expr_t *body; size_t arity; value_t *next; // should be another closure of the same arity } closure; env_t *env; } as; value_t *gc_next;};
/* allocate a gc arena */gc_t *gc_alloc(void);
/* free a gc arena -- ensure all values are collected first */void gc_free(gc_t *);
/* Allocation */value_t *value_alloc(gc_t *gc);
value_t *value_alloc_bool(gc_t *gc, bool);value_t *value_alloc_int(gc_t *gc, long);value_t *value_alloc_float(gc_t *gc, double);value_t *value_alloc_string(gc_t *gc, char *, bool shared);
/* Mark as live for gc */void value_mark_gc(value_t *);
/* GC collection */void gc(gc_t *gc);
void value_debug_dump(value_t *it);
#endif