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