-
Notifications
You must be signed in to change notification settings - Fork 0
/
value.h
57 lines (47 loc) · 997 Bytes
/
value.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef VALUE_H
#define VALUE_H
#include <stdlib.h>
#include <stdio.h>
#include "nil.h"
#include "pair.h"
#include "symbol.h"
#include "enviroment.h"
#include "boolean.h"
#include "closure.h"
#include "intrinsic.h"
#include "integer.h"
#include "character.h"
#include "evaluate.h"
#include "operator.h"
enum Type
{
NIL,
PAIR,
SYMBOL,
ENVIROMENT,
BOOLEAN,
CLOSURE,
INTRINSIC,
INTEGER,
CHARACTER,
OPERATOR
};
struct Value
{
void *value;
enum Type type;
size_t references;
};
size_t memory_used;
void *allocate(size_t size);
void deallocate(void *ptr, size_t size);
void *reallocate(void *ptr, size_t old_size, size_t new_size);
void ref_inc(struct Value *v);
void ref_dec(struct Value *v);
struct Value *make_value(enum Type type, void *value);
void free_value(struct Value *v);
void builtin_quote(struct Value *argument, struct Value *env,
struct Value **out);
void builtin_allocation(struct Value *argument, struct Value *env,
struct Value **out);
#endif