annotate dmd/ScopeStatement.d @ 154:14feb7ae01a6

* changed the build system to build a release version if the debug one compiles and enabled warnings + reduced warnings by adding appriopriate overrides + IfStatement.interpret() + ScopeStatement.interpret() + TypeSArray.constConv() + TypedefDeclaration.syntaxCopy() * fixed a bug in StringExp
author trass3r
date Wed, 15 Sep 2010 15:32:31 +0200
parents e28b18c23469
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.ScopeStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.CompoundStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.BE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.backend.Blockx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.backend.BC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 class ScopeStatement : Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 Statement statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 this(Loc loc, Statement s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 super(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this.statement = s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
32 override Statement syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 Statement s = statement ? statement.syntaxCopy() : null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 s = new ScopeStatement(loc, s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
39 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 buf.writeByte('{');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 buf.writenl();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 statement.toCBuffer(buf, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 buf.writeByte('}');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 buf.writenl();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
51 override ScopeStatement isScopeStatement() { return this; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
53 override Statement semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 ScopeDsymbol sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 //printf("ScopeStatement.semantic(sc = %p)\n", sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 Statements a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 sym = new ScopeDsymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 sym.parent = sc.scopesym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 sc = sc.push(sym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 a = statement.flatten(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 if (a)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 statement = new CompoundStatement(loc, a);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 statement = statement.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 Statement sentry;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 Statement sexception;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 Statement sfinally;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 statement.scopeCode(sc, &sentry, &sexception, &sfinally);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 if (sfinally)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 //printf("adding sfinally\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 statement = new CompoundStatement(loc, statement, sfinally);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
92 override bool hasBreak()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 //printf("ScopeStatement.hasBreak() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 return statement ? statement.hasBreak() : false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
98 override bool hasContinue()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 return statement ? statement.hasContinue() : false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
103 override bool usesEH()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 return statement ? statement.usesEH() : false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
108 override BE blockExit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 //printf("ScopeStatement::blockExit(%p)\n", statement);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 return statement ? statement.blockExit() : BE.BEfallthru;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
114 override bool comeFrom()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 //printf("ScopeStatement.comeFrom()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 return statement ? statement.comeFrom() : false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
120 override bool isEmpty()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 //printf("ScopeStatement::isEmpty() %d\n", statement ? statement->isEmpty() : TRUE);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 return statement ? statement.isEmpty() : true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
126 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 {
154
14feb7ae01a6 * changed the build system to build a release version if the debug one compiles
trass3r
parents: 114
diff changeset
128 version(LOG)
14feb7ae01a6 * changed the build system to build a release version if the debug one compiles
trass3r
parents: 114
diff changeset
129 writef("ScopeStatement::interpret()\n");
14feb7ae01a6 * changed the build system to build a release version if the debug one compiles
trass3r
parents: 114
diff changeset
130
14feb7ae01a6 * changed the build system to build a release version if the debug one compiles
trass3r
parents: 114
diff changeset
131 if (istate.start is this)
14feb7ae01a6 * changed the build system to build a release version if the debug one compiles
trass3r
parents: 114
diff changeset
132 istate.start = null;
14feb7ae01a6 * changed the build system to build a release version if the debug one compiles
trass3r
parents: 114
diff changeset
133 return statement ? statement.interpret(istate) : null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
136 override Statement inlineScan(InlineScanState* iss)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 statement = statement.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
143 override void toIR(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 Blockx* blx = irs.blx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 IRState mystate = IRState(irs,this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 if (mystate.prev.ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 mystate.ident = mystate.prev.ident;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 statement.toIR(&mystate);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 if (mystate.breakBlock)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 block_goto(blx, BC.BCgoto, mystate.breakBlock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
159 }