0
|
1 module dmd.DebugSymbol;
|
|
2
|
114
|
3 import dmd.common;
|
0
|
4 import dmd.Dsymbol;
|
|
5 import dmd.Identifier;
|
|
6 import dmd.Loc;
|
|
7 import dmd.Scope;
|
|
8 import dmd.ScopeDsymbol;
|
129
|
9 import dmd.Module;
|
0
|
10 import dmd.HdrGenState;
|
129
|
11 import dmd.Array;
|
0
|
12 import dmd.OutBuffer;
|
|
13
|
129
|
14 import dmd.condition.util.findCondition;
|
|
15
|
|
16 /* DebugSymbol's happen for statements like:
|
|
17 * debug = identifier;
|
|
18 * debug = integer;
|
|
19 */
|
0
|
20 class DebugSymbol : Dsymbol
|
|
21 {
|
|
22 uint level;
|
|
23
|
|
24 this(Loc loc, Identifier ident)
|
|
25 {
|
129
|
26 super(ident);
|
|
27 this.loc = loc;
|
0
|
28 }
|
|
29
|
|
30 this(Loc loc, uint level)
|
|
31 {
|
129
|
32 this.level = level;
|
|
33 this.loc = loc;
|
0
|
34 }
|
|
35
|
72
|
36 override Dsymbol syntaxCopy(Dsymbol s)
|
0
|
37 {
|
129
|
38 assert(!s);
|
|
39 DebugSymbol ds = new DebugSymbol(loc, ident);
|
|
40 ds.level = level;
|
|
41 return ds;
|
0
|
42 }
|
|
43
|
129
|
44 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum)
|
0
|
45 {
|
129
|
46 //printf("DebugSymbol.addMember('%s') %s\n", sd.toChars(), toChars());
|
|
47 Module m;
|
|
48
|
|
49 // Do not add the member to the symbol table,
|
|
50 // just make sure subsequent debug declarations work.
|
|
51 m = sd.isModule();
|
|
52 if (ident)
|
|
53 {
|
|
54 if (!m)
|
|
55 error("declaration must be at module level");
|
|
56 else
|
|
57 {
|
|
58 if (findCondition(m.debugidsNot, ident))
|
|
59 error("defined after use");
|
|
60 if (!m.debugids)
|
|
61 m.debugids = new Vector!string();
|
|
62 m.debugids.push(ident.toChars()); ///
|
|
63 }
|
|
64 }
|
|
65 else
|
|
66 {
|
|
67 if (!m)
|
|
68 error("level declaration must be at module level");
|
|
69 else
|
|
70 m.debuglevel = level;
|
|
71 }
|
|
72
|
|
73 return false;
|
0
|
74 }
|
|
75
|
72
|
76 override void semantic(Scope sc)
|
0
|
77 {
|
129
|
78 //printf("DebugSymbol.semantic() %s\n", toChars());
|
0
|
79 }
|
|
80
|
72
|
81 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
82 {
|
129
|
83 buf.writestring("debug = ");
|
|
84 if (ident)
|
|
85 buf.writestring(ident.toChars());
|
|
86 else
|
|
87 buf.printf("%u", level);
|
|
88 buf.writestring(";");
|
|
89 buf.writenl();
|
0
|
90 }
|
|
91
|
72
|
92 override string kind()
|
0
|
93 {
|
129
|
94 return "debug";
|
0
|
95 }
|
72
|
96 }
|