-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.h
44 lines (37 loc) · 1.1 KB
/
env.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
#ifndef ENV_H
#define ENV_H
#define HASHSIZE 101
typedef struct frame { /* a frame is an array of pointers of nlist */
struct nlist **bucket;
size_t size;
} frame_t;
typedef struct env { /* an environment is a list of frames */
frame_t *fp; /* first frame of the environment */
struct env *ep; /* enclosing environment */
} env_t;
struct nlist { /* table entry */
struct nlist *next;
const char *name; /* defined name */
exp_t *defn; /* replacement expression */
};
extern env_t* globenv;
extern frame_t *newframe(void);
extern void fdump(frame_t *);
extern struct nlist *lookup(symb_t *, env_t *);
extern struct nlist *install(symb_t *, exp_t *, env_t *);
extern env_t *newenv(void);
extern env_t *extenv(exp_t *, env_t *);
extern void undef(symb_t *, frame_t *);
/* fframe: return the first frame in the environment */
static inline frame_t *
fframe(env_t *ep)
{
return ep->fp;
}
/* eenv: return the enclosing environment */
static inline env_t *
eenv(env_t *ep)
{
return ep->ep;
}
#endif /* !ENV_H */