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