-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj_env_rec.h
85 lines (65 loc) · 1.89 KB
/
obj_env_rec.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef OBJ_ENV_REC_INCLUDED
#define OBJ_ENV_REC_INCLUDED
#include "mem_mixvec.h"
typedef enum env_type {
ET_IMMUTABLE = -2,
ET_CLOSED = -1,
ET_OPEN = 0,
} env_type_t;
typedef enum env_ptrs {
EP_PARENT,
EP_FORMALS,
EP_ACTUALS,
} env_ptrs_t;
extern obj_t make_env_rec (obj_t parent,
int nvar,
obj_t formals,
obj_t actuals);
static inline bool is_env_rec (obj_t obj);
static inline int env_rec_nvar (obj_t obj);
static inline int env_rec_is_open (obj_t env);
static inline int env_rec_is_mutable (obj_t env);
static inline obj_t env_rec_parent (obj_t env);
static inline obj_t env_rec_formals (obj_t env);
static inline obj_t env_rec_actuals (obj_t env);
static inline void env_rec_set_nvar (obj_t env, int nvar);
static inline void env_rec_set_formals(obj_t env, obj_t formals);
static inline void env_rec_set_actuals(obj_t env, obj_t actuals);
OBJ_TYPE_PREDICATE(env_rec);
static inline int env_rec_nvar(obj_t env)
{
return mixvec_1_3_get_int(env, 0);
}
static inline int env_rec_is_open(obj_t env)
{
return env_rec_nvar(env) >= 0;
}
static inline int env_rec_is_mutable(obj_t env)
{
return env_rec_nvar(env) != ET_IMMUTABLE;
}
static inline obj_t env_rec_parent(obj_t env)
{
return mixvec_1_3_get_ptr(env, EP_PARENT);
}
static inline obj_t env_rec_formals(obj_t env)
{
return mixvec_1_3_get_ptr(env, EP_FORMALS);
}
static inline obj_t env_rec_actuals(obj_t env)
{
return mixvec_1_3_get_ptr(env, EP_ACTUALS);
}
static inline void env_rec_set_nvar(obj_t env, int nvar)
{
mixvec_1_3_set_int(env, 0, nvar);
}
static inline void env_rec_set_formals(obj_t env, obj_t formals)
{
mixvec_1_3_set_ptr(env, EP_FORMALS, formals);
}
static inline void env_rec_set_actuals(obj_t env, obj_t actuals)
{
mixvec_1_3_set_ptr(env, EP_ACTUALS, actuals);
}
#endif /* !OBJ_ENV_REC_INCLUDED */