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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.StaticIfDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.ConditionalDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.AttribDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Condition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 class StaticIfDeclaration : ConditionalDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 ScopeDsymbol sd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 int addisdone;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 super(condition, decl, elsedecl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 //printf("StaticIfDeclaration::StaticIfDeclaration()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 23
diff changeset
22 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 23
diff changeset
33 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 //printf("StaticIfDeclaration.addMember() '%s'\n",toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 /* This is deferred until semantic(), so that
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 * expressions in the condition can refer to declarations
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 * in the same scope, such as:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 *
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 * template Foo(int i)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 * {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 * const int j = i + 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 * static if (j == 3)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 * const int k;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 * }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 this.sd = sd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 bool m = false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 0
diff changeset
50 if (!memnum)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 m = AttribDeclaration.addMember(sc, sd, memnum);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 addisdone = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 return m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 23
diff changeset
58 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 //printf("\tStaticIfDeclaration.semantic '%s', d = %p\n",toChars(), d);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 if (d)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 if (!addisdone)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 {
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 0
diff changeset
67 AttribDeclaration.addMember(sc, sd, true);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 addisdone = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 74
diff changeset
71 foreach(Dsymbol s; d)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 23
diff changeset
76 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
20
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
80 }