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