Mercurial > projects > ddmd
annotate dmd/DebugSymbol.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
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 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
16 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
17 |
129 | 18 /* DebugSymbol's happen for statements like: |
19 * debug = identifier; | |
20 * debug = integer; | |
21 */ | |
0 | 22 class DebugSymbol : Dsymbol |
23 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
25 |
0 | 26 uint level; |
27 | |
28 this(Loc loc, Identifier ident) | |
29 { | |
178 | 30 register(); |
129 | 31 super(ident); |
32 this.loc = loc; | |
0 | 33 } |
34 | |
35 this(Loc loc, uint level) | |
36 { | |
178 | 37 register(); |
129 | 38 this.level = level; |
39 this.loc = loc; | |
0 | 40 } |
41 | |
72 | 42 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 43 { |
129 | 44 assert(!s); |
45 DebugSymbol ds = new DebugSymbol(loc, ident); | |
46 ds.level = level; | |
47 return ds; | |
0 | 48 } |
49 | |
129 | 50 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum) |
0 | 51 { |
129 | 52 //printf("DebugSymbol.addMember('%s') %s\n", sd.toChars(), toChars()); |
53 Module m; | |
54 | |
55 // Do not add the member to the symbol table, | |
56 // just make sure subsequent debug declarations work. | |
57 m = sd.isModule(); | |
58 if (ident) | |
59 { | |
60 if (!m) | |
61 error("declaration must be at module level"); | |
62 else | |
63 { | |
64 if (findCondition(m.debugidsNot, ident)) | |
65 error("defined after use"); | |
66 if (!m.debugids) | |
67 m.debugids = new Vector!string(); | |
68 m.debugids.push(ident.toChars()); /// | |
69 } | |
70 } | |
71 else | |
72 { | |
73 if (!m) | |
74 error("level declaration must be at module level"); | |
75 else | |
76 m.debuglevel = level; | |
77 } | |
78 | |
79 return false; | |
0 | 80 } |
81 | |
72 | 82 override void semantic(Scope sc) |
0 | 83 { |
129 | 84 //printf("DebugSymbol.semantic() %s\n", toChars()); |
0 | 85 } |
86 | |
72 | 87 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 88 { |
129 | 89 buf.writestring("debug = "); |
90 if (ident) | |
91 buf.writestring(ident.toChars()); | |
92 else | |
93 buf.printf("%u", level); | |
94 buf.writestring(";"); | |
95 buf.writenl(); | |
0 | 96 } |
97 | |
72 | 98 override string kind() |
0 | 99 { |
129 | 100 return "debug"; |
0 | 101 } |
72 | 102 } |