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
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
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 79
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.ConditionalDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.AttribDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Condition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 class StaticIfDeclaration : ConditionalDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
18 ScopeDsymbol sd;
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
19 int addisdone;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
21 this(Condition condition, Dsymbols decl, Dsymbols elsedecl)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 114
diff changeset
23 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 super(condition, decl, elsedecl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 //printf("StaticIfDeclaration::StaticIfDeclaration()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
28 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
30 StaticIfDeclaration dd;
20
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
31
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
32 assert(!s);
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
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
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
36 return dd;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
39 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 //printf("StaticIfDeclaration.addMember() '%s'\n",toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 /* This is deferred until semantic(), so that
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 * expressions in the condition can refer to declarations
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 * in the same scope, such as:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 *
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 * template Foo(int i)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 * {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
48 * const int j = i + 1;
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
49 * static if (j == 3)
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
50 * const int k;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 * }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 this.sd = sd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 bool m = false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 0
diff changeset
56 if (!memnum)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 m = AttribDeclaration.addMember(sc, sd, memnum);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 addisdone = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 return m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
64 override void importAll(Scope sc)
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
65 {
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
66 // do not evaluate condition before semantic pass
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
67 }
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
68
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
69 override void setScope(Scope sc)
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
70 {
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
71 // do not evaluate condition before semantic pass
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
72 }
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
73
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
74 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 //printf("\tStaticIfDeclaration.semantic '%s', d = %p\n",toChars(), d);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 if (d)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 if (!addisdone)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 {
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 0
diff changeset
83 AttribDeclaration.addMember(sc, sd, true);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 addisdone = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 74
diff changeset
87 foreach(Dsymbol s; d)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
92 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
20
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
96 }