-
Notifications
You must be signed in to change notification settings - Fork 0
/
value.h
33 lines (28 loc) · 835 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
#ifndef _VALUE
#define _VALUE
typedef enum {INT_TYPE,DOUBLE_TYPE,STR_TYPE,CONS_TYPE,NULL_TYPE,PTR_TYPE,
OPEN_TYPE,CLOSE_TYPE,BOOL_TYPE,SYMBOL_TYPE,VOID_TYPE,
CLOSURE_TYPE, PRIMITIVE_TYPE} valueType;
struct Value {
valueType type;
union {
int i;
double d;
char *s;
void *p;
struct ConsCell {
struct Value *car;
struct Value *cdr;
} c;
struct Closure {
struct Value *paramNames;
struct Value *functionCode;
struct Frame *frame;
} cl;
// A primitive style function; just a pointer to it, with the right
// signature (pf = my chosen variable for a primitive function)
struct Value *(*pf)(struct Value *);
};
};
typedef struct Value Value;
#endif