annotate dmd/Statement.d @ 58:ecf732dfe11e

Statement.error Dsymbol.equals SuperExp.toCBuffer DotVarExp.isLvalue FuncExp.toChars
author korDen
date Sat, 21 Aug 2010 14:52:59 +0400
parents 10317f0c89a5
children cab4c37afb89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.TryCatchStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.GotoStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.AsmStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.ScopeStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.DeclarationStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.CompoundStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.ReturnStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.IfStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.InlineCostState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.InlineDoState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.BE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 class Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 Loc loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 this(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 this.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 Statement syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 void print()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 string toChars()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 void error(T...)(string format, T t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
58
ecf732dfe11e Statement.error
korDen
parents: 0
diff changeset
52 .error(loc, format, t);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 void warning(T...)(string format, T t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 if (global.params.warnings && !global.gag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 writef("warning - ");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 .error(loc, format, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 TryCatchStatement isTryCatchStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 GotoStatement isGotoStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 AsmStatement isAsmStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 version (_DH) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 int incontract;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 ScopeStatement isScopeStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 Statement semantic(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 Statement semanticScope(Scope sc, Statement sbreak, Statement scontinue)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 Scope scd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 Statement s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 scd = sc.push();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 if (sbreak)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 scd.sbreak = sbreak;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 if (scontinue)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 scd.scontinue = scontinue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 s = semantic(scd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 scd.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 bool hasBreak()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 bool hasContinue()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 bool usesEH()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 BE blockExit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 // true if statement 'comes from' somewhere else, like a goto
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 bool comeFrom()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 //printf("Statement::comeFrom()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 // Return TRUE if statement has no code in it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 bool isEmpty()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 //printf("Statement::isEmpty()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 /****************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 * If this statement has code that needs to run in a finally clause
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 * at the end of the current scope, return that code in the form of
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 * a Statement.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 * Output:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 * *sentry code executed upon entry to the scope
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 * *sexception code executed upon exit from the scope via exception
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 * *sfinally code executed in finally block
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 void scopeCode(Scope sc, Statement* sentry, Statement* sexception, Statement* sfinally)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 //printf("Statement::scopeCode()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 //print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 *sentry = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 *sexception = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 *sfinally = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 /*********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 * Flatten out the scope by presenting the statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 * as an array of statements.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 * Returns NULL if no flattening necessary.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 Statements flatten(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 Expression interpret(InterState* istate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 int inlineCost(InlineCostState* ics)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 return COST_MAX; // default is we can't inline it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 Expression doInline(InlineDoState ids)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 Statement inlineScan(InlineScanState* iss)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 // Back end
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 void toIR(IRState* irs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 // Avoid dynamic_cast
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 DeclarationStatement isDeclarationStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 CompoundStatement isCompoundStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 ReturnStatement isReturnStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 IfStatement isIfStatement() { return null; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 }