-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscope.h
45 lines (35 loc) · 1003 Bytes
/
scope.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
/* -*-Mode: c++;-*-
Copyright (c) 2003-2008 John Plevyak, All Rights Reserved
*/
#ifndef _scope_h_
#define _scope_h_
class Sym;
// must match the corresponding D_SCOPE_XXX if the DParser is used
enum Scope_kind { Scope_INHERIT, Scope_RECURSIVE, Scope_PARALLEL, Scope_SEQUENTIAL };
class Scope : public gc {
public:
unsigned int kind : 2;
Map<cchar *, Sym *> hash;
Scope *up;
Scope *next;
Sym *in;
Sym *get(cchar *name, Sym **container = 0);
Sym *get_local(cchar *name, Sym **container = 0);
void put(cchar *name, Sym *s);
void add_dynamic(Scope *s, Sym *sy = 0);
Scope *global();
Scope *module();
Scope *function();
Scope() : kind(Scope_RECURSIVE), up(0), next(0), in(NULL) {}
Scope(Scope *s, unsigned int k, Sym *an_in) : up(s), next(0), in(an_in) {
if (k == Scope_INHERIT)
kind = up->kind;
else
kind = k;
}
// private
Vec<Scope *> dynamic;
Vec<Sym *> dynamic_container;
};
#define forv_Scope(_x, _v) forv_Vec(Scope, _x, _v)
#endif