Mercurial > projects > ddmd
annotate dmd/StaticIfDeclaration.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.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 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
12 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
|
13 |
0 | 14 class StaticIfDeclaration : ConditionalDeclaration |
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 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
|
17 |
79 | 18 ScopeDsymbol sd; |
19 int addisdone; | |
0 | 20 |
79 | 21 this(Condition condition, Dsymbols decl, Dsymbols elsedecl) |
0 | 22 { |
178 | 23 register(); |
0 | 24 super(condition, decl, elsedecl); |
25 //printf("StaticIfDeclaration::StaticIfDeclaration()\n"); | |
26 } | |
27 | |
79 | 28 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 29 { |
79 | 30 StaticIfDeclaration dd; |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
31 |
79 | 32 assert(!s); |
33 dd = new StaticIfDeclaration(condition.syntaxCopy(), | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
34 Dsymbol.arraySyntaxCopy(decl), |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
35 Dsymbol.arraySyntaxCopy(elsedecl)); |
79 | 36 return dd; |
0 | 37 } |
38 | |
79 | 39 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum) |
0 | 40 { |
41 //printf("StaticIfDeclaration.addMember() '%s'\n",toChars()); | |
42 /* This is deferred until semantic(), so that | |
43 * expressions in the condition can refer to declarations | |
44 * in the same scope, such as: | |
45 * | |
46 * template Foo(int i) | |
47 * { | |
79 | 48 * const int j = i + 1; |
49 * static if (j == 3) | |
50 * const int k; | |
0 | 51 * } |
52 */ | |
53 this.sd = sd; | |
54 bool m = false; | |
55 | |
13 | 56 if (!memnum) |
0 | 57 { |
58 m = AttribDeclaration.addMember(sc, sd, memnum); | |
59 addisdone = 1; | |
60 } | |
61 return m; | |
62 } | |
63 | |
79 | 64 override void importAll(Scope sc) |
65 { | |
66 // do not evaluate condition before semantic pass | |
67 } | |
68 | |
69 override void setScope(Scope sc) | |
70 { | |
71 // do not evaluate condition before semantic pass | |
72 } | |
73 | |
74 override void semantic(Scope sc) | |
0 | 75 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
76 auto d = include(sc, sd); |
0 | 77 |
78 //printf("\tStaticIfDeclaration.semantic '%s', d = %p\n",toChars(), d); | |
79 if (d) | |
80 { | |
81 if (!addisdone) | |
82 { | |
13 | 83 AttribDeclaration.addMember(sc, sd, true); |
0 | 84 addisdone = 1; |
85 } | |
86 | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
87 foreach(Dsymbol s; d) |
0 | 88 s.semantic(sc); |
89 } | |
90 } | |
91 | |
79 | 92 override string kind() |
0 | 93 { |
94 assert(false); | |
95 } | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
96 } |