0
|
1 module dmd.DsymbolTable;
|
|
2
|
114
|
3 import dmd.common;
|
0
|
4 import dmd.StringTable;
|
|
5 import dmd.Dsymbol;
|
|
6 import dmd.Identifier;
|
|
7 import dmd.StringValue;
|
|
8
|
|
9 import std.stdio;
|
|
10
|
178
|
11 import dmd.TObject;
|
|
12
|
|
13 class DsymbolTable : TObject
|
0
|
14 {
|
|
15 StringTable tab;
|
|
16
|
|
17 this()
|
|
18 {
|
178
|
19 register();
|
0
|
20 }
|
|
21
|
|
22 // Look up Identifier. Return Dsymbol if found, NULL if not.
|
|
23 Dsymbol lookup(Identifier ident)
|
|
24 {
|
|
25 debug {
|
|
26 assert(ident);
|
|
27 }
|
178
|
28 Object* sv = tab.lookup(ident.string_);
|
|
29 return (sv ? cast(Dsymbol)*sv : null);
|
0
|
30 }
|
|
31
|
|
32 // Insert Dsymbol in table. Return NULL if already there.
|
|
33 Dsymbol insert(Dsymbol s)
|
|
34 {
|
|
35 Identifier ident = s.ident;
|
|
36 debug {
|
|
37 assert(ident);
|
|
38 }
|
|
39
|
|
40 return insert(ident, s);
|
|
41 }
|
|
42
|
|
43 // Look for Dsymbol in table. If there, return it. If not, insert s and return that.
|
|
44 Dsymbol update(Dsymbol s)
|
|
45 {
|
|
46 assert(false);
|
|
47 }
|
178
|
48
|
0
|
49 Dsymbol insert(Identifier ident, Dsymbol s) // when ident and s are not the same
|
|
50 {
|
178
|
51 Object* sv = tab.insert(ident.toChars());
|
0
|
52 if (sv is null) {
|
|
53 return null; // already in table
|
|
54 }
|
|
55
|
178
|
56 *sv = s;
|
0
|
57 return s;
|
|
58 }
|
178
|
59 }
|