Mercurial > projects > ddmd
annotate dmd/StaticIfDeclaration.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | 43073c7c7769 |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.StaticIfDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.ConditionalDeclaration; |
5 import dmd.ScopeDsymbol; | |
6 import dmd.AttribDeclaration; | |
7 import dmd.Scope; | |
8 import dmd.Condition; | |
9 import dmd.Array; | |
10 import dmd.Dsymbol; | |
11 | |
12 class StaticIfDeclaration : ConditionalDeclaration | |
13 { | |
79 | 14 ScopeDsymbol sd; |
15 int addisdone; | |
0 | 16 |
79 | 17 this(Condition condition, Dsymbols decl, Dsymbols elsedecl) |
0 | 18 { |
19 super(condition, decl, elsedecl); | |
20 //printf("StaticIfDeclaration::StaticIfDeclaration()\n"); | |
21 } | |
22 | |
79 | 23 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 24 { |
79 | 25 StaticIfDeclaration dd; |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
26 |
79 | 27 assert(!s); |
28 dd = new StaticIfDeclaration(condition.syntaxCopy(), | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
29 Dsymbol.arraySyntaxCopy(decl), |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
30 Dsymbol.arraySyntaxCopy(elsedecl)); |
79 | 31 return dd; |
0 | 32 } |
33 | |
79 | 34 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum) |
0 | 35 { |
36 //printf("StaticIfDeclaration.addMember() '%s'\n",toChars()); | |
37 /* This is deferred until semantic(), so that | |
38 * expressions in the condition can refer to declarations | |
39 * in the same scope, such as: | |
40 * | |
41 * template Foo(int i) | |
42 * { | |
79 | 43 * const int j = i + 1; |
44 * static if (j == 3) | |
45 * const int k; | |
0 | 46 * } |
47 */ | |
48 this.sd = sd; | |
49 bool m = false; | |
50 | |
13 | 51 if (!memnum) |
0 | 52 { |
53 m = AttribDeclaration.addMember(sc, sd, memnum); | |
54 addisdone = 1; | |
55 } | |
56 return m; | |
57 } | |
58 | |
79 | 59 override void importAll(Scope sc) |
60 { | |
61 // do not evaluate condition before semantic pass | |
62 } | |
63 | |
64 override void setScope(Scope sc) | |
65 { | |
66 // do not evaluate condition before semantic pass | |
67 } | |
68 | |
69 override void semantic(Scope sc) | |
0 | 70 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
71 auto d = include(sc, sd); |
0 | 72 |
73 //printf("\tStaticIfDeclaration.semantic '%s', d = %p\n",toChars(), d); | |
74 if (d) | |
75 { | |
76 if (!addisdone) | |
77 { | |
13 | 78 AttribDeclaration.addMember(sc, sd, true); |
0 | 79 addisdone = 1; |
80 } | |
81 | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
82 foreach(Dsymbol s; d) |
0 | 83 s.semantic(sc); |
84 } | |
85 } | |
86 | |
79 | 87 override string kind() |
0 | 88 { |
89 assert(false); | |
90 } | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
91 } |