-
Notifications
You must be signed in to change notification settings - Fork 2
/
macros.h
60 lines (58 loc) · 2.52 KB
/
macros.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
57
58
59
60
/*
* module : macros.h
* version : 1.1
* date : 10/11/24
*/
#define USR_NEWNODE(VALUE) \
do { Node node; node.u.ent = VALUE; node.op = USR_; \
vec_push(env->stck, node); } while (0)
#define ANON_FUNCT_NEWNODE(VALUE) \
do { Node node; node.u.proc = VALUE; node.op = ANON_FUNCT_; \
vec_push(env->stck, node); } while (0)
#define BOOLEAN_NEWNODE(VALUE) \
do { Node node; node.u.num = VALUE; node.op = BOOLEAN_; \
vec_push(env->stck, node); } while (0)
#define CHAR_NEWNODE(VALUE) \
do { Node node; node.u.num = VALUE; node.op = CHAR_; \
vec_push(env->stck, node); } while (0)
#define INTEGER_NEWNODE(VALUE) \
do { Node node; node.u.num = VALUE; node.op = INTEGER_; \
vec_push(env->stck, node); } while (0)
#define SET_NEWNODE(VALUE) \
do { Node node; node.u.set = VALUE; node.op = SET_; \
vec_push(env->stck, node); } while (0)
#define STRING_NEWNODE(VALUE) \
do { Node node; node.u.str = VALUE; node.op = STRING_; \
vec_push(env->stck, node); } while (0)
#define LIST_NULLNODE \
do { Node node; NodeList list; vec_init(list); \
node.u.lis = list; node.op = LIST_; vec_push(env->stck, node); \
} while (0)
#define LIST_NEWNODE(VALUE) \
do { Node node; NodeList list; vec_init(list); \
list->n = sizeof(VALUE) / sizeof(*VALUE); list->c = VALUE; \
node.u.lis = list; node.op = LIST_; vec_push(env->stck, node); \
} while (0)
#define FLOAT_NEWNODE(VALUE) \
do { Node node; node.u.dbl = VALUE; node.op = FLOAT_; \
vec_push(env->stck, node); } while (0)
#define FILE_NEWNODE(VALUE) \
do { Node node; node.u.fil = VALUE; node.op = FILE_; \
vec_push(env->stck, node); } while (0)
#define BIGNUM_NEWNODE(VALUE) \
do { Node node; node.u.str = VALUE; node.op = BIGNUM_; \
vec_push(env->stck, node); } while (0)
#define NULLARY(CONSTRUCTOR, VALUE) \
do { CONSTRUCTOR(VALUE); } while (0)
#define UNARY(CONSTRUCTOR, VALUE) \
do { vec_reduce(env->stck, 1); CONSTRUCTOR(VALUE); } while (0)
#define BINARY(CONSTRUCTOR, VALUE) \
do { vec_reduce(env->stck, 2); CONSTRUCTOR(VALUE); } while (0)
#define GNULLARY(NODE) \
do { vec_push(env->stck, NODE); } while (0)
#define GUNARY(NODE) \
do { vec_reduce(env->stck, 1); vec_push(env->stck, NODE); } while (0)
#define GBINARY(NODE) \
do { vec_reduce(env->stck, 2); vec_push(env->stck, NODE); } while (0)
#define GTERNARY(NODE) \
do { vec_reduce(env->stck, 3); vec_push(env->stck, NODE); } while (0)