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