comparison src/dil/ast/Statements.d @ 806:bcb74c9b895c

Moved out files in the trunk folder to the root.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 09 Mar 2008 00:12:19 +0100
parents trunk/src/dil/ast/Statements.d@5fe89bb8cbdd
children
comparison
equal deleted inserted replaced
805:a3fab8b74a7d 806:bcb74c9b895c
1 /++
2 Author: Aziz Köksal
3 License: GPL3
4 +/
5 module dil.ast.Statements;
6
7 public import dil.ast.Statement;
8 import dil.ast.Node;
9 import dil.ast.Expression;
10 import dil.ast.Declaration;
11 import dil.ast.Type;
12 import dil.ast.Parameters;
13 import dil.ast.NodeCopier;
14 import dil.lexer.IdTable;
15
16 class CompoundStatement : Statement
17 {
18 this()
19 {
20 mixin(set_kind);
21 }
22
23 void opCatAssign(Statement s)
24 {
25 addChild(s);
26 }
27
28 Statement[] stmnts()
29 {
30 return cast(Statement[])this.children;
31 }
32
33 void stmnts(Statement[] stmnts)
34 {
35 this.children = stmnts;
36 }
37
38 mixin(copyMethod);
39 }
40
41 class IllegalStatement : Statement
42 {
43 this()
44 {
45 mixin(set_kind);
46 }
47 mixin(copyMethod);
48 }
49
50 class EmptyStatement : Statement
51 {
52 this()
53 {
54 mixin(set_kind);
55 }
56 mixin(copyMethod);
57 }
58
59 class FuncBodyStatement : Statement
60 {
61 Statement funcBody, inBody, outBody;
62 Identifier* outIdent;
63 this()
64 {
65 mixin(set_kind);
66 }
67
68 void finishConstruction()
69 {
70 addOptChild(funcBody);
71 addOptChild(inBody);
72 addOptChild(outBody);
73 }
74
75 bool isEmpty()
76 {
77 return funcBody is null;
78 }
79
80 mixin(copyMethod);
81 }
82
83 class ScopeStatement : Statement
84 {
85 Statement s;
86 this(Statement s)
87 {
88 mixin(set_kind);
89 addChild(s);
90 this.s = s;
91 }
92 mixin(copyMethod);
93 }
94
95 class LabeledStatement : Statement
96 {
97 Identifier* label;
98 Statement s;
99 this(Identifier* label, Statement s)
100 {
101 mixin(set_kind);
102 addChild(s);
103 this.label = label;
104 this.s = s;
105 }
106 mixin(copyMethod);
107 }
108
109 class ExpressionStatement : Statement
110 {
111 Expression e;
112 this(Expression e)
113 {
114 mixin(set_kind);
115 addChild(e);
116 this.e = e;
117 }
118 mixin(copyMethod);
119 }
120
121 class DeclarationStatement : Statement
122 {
123 Declaration decl;
124 this(Declaration decl)
125 {
126 mixin(set_kind);
127 addChild(decl);
128 this.decl = decl;
129 }
130 mixin(copyMethod);
131 }
132
133 class IfStatement : Statement
134 {
135 Statement variable; // AutoDeclaration or VariableDeclaration
136 Expression condition;
137 Statement ifBody;
138 Statement elseBody;
139 this(Statement variable, Expression condition, Statement ifBody, Statement elseBody)
140 {
141 mixin(set_kind);
142 if (variable)
143 addChild(variable);
144 else
145 addChild(condition);
146 addChild(ifBody);
147 addOptChild(elseBody);
148
149 this.variable = variable;
150 this.condition = condition;
151 this.ifBody = ifBody;
152 this.elseBody = elseBody;
153 }
154 mixin(copyMethod);
155 }
156
157 class WhileStatement : Statement
158 {
159 Expression condition;
160 Statement whileBody;
161 this(Expression condition, Statement whileBody)
162 {
163 mixin(set_kind);
164 addChild(condition);
165 addChild(whileBody);
166
167 this.condition = condition;
168 this.whileBody = whileBody;
169 }
170 mixin(copyMethod);
171 }
172
173 class DoWhileStatement : Statement
174 {
175 Statement doBody;
176 Expression condition;
177 this(Expression condition, Statement doBody)
178 {
179 mixin(set_kind);
180 addChild(doBody);
181 addChild(condition);
182
183 this.condition = condition;
184 this.doBody = doBody;
185 }
186 mixin(copyMethod);
187 }
188
189 class ForStatement : Statement
190 {
191 Statement init;
192 Expression condition, increment;
193 Statement forBody;
194
195 this(Statement init, Expression condition, Expression increment, Statement forBody)
196 {
197 mixin(set_kind);
198 addOptChild(init);
199 addOptChild(condition);
200 addOptChild(increment);
201 addChild(forBody);
202
203 this.init = init;
204 this.condition = condition;
205 this.increment = increment;
206 this.forBody = forBody;
207 }
208 mixin(copyMethod);
209 }
210
211 class ForeachStatement : Statement
212 {
213 TOK tok;
214 Parameters params;
215 Expression aggregate;
216 Statement forBody;
217
218 this(TOK tok, Parameters params, Expression aggregate, Statement forBody)
219 {
220 mixin(set_kind);
221 addChildren([cast(Node)params, aggregate, forBody]);
222
223 this.tok = tok;
224 this.params = params;
225 this.aggregate = aggregate;
226 this.forBody = forBody;
227 }
228 mixin(copyMethod);
229 }
230
231 // version(D2)
232 // {
233 class ForeachRangeStatement : Statement
234 {
235 TOK tok;
236 Parameters params;
237 Expression lower, upper;
238 Statement forBody;
239
240 this(TOK tok, Parameters params, Expression lower, Expression upper, Statement forBody)
241 {
242 mixin(set_kind);
243 addChildren([cast(Node)params, lower, upper, forBody]);
244
245 this.tok = tok;
246 this.params = params;
247 this.lower = lower;
248 this.upper = upper;
249 this.forBody = forBody;
250 }
251 mixin(copyMethod);
252 }
253 // }
254
255 class SwitchStatement : Statement
256 {
257 Expression condition;
258 Statement switchBody;
259
260 this(Expression condition, Statement switchBody)
261 {
262 mixin(set_kind);
263 addChild(condition);
264 addChild(switchBody);
265
266 this.condition = condition;
267 this.switchBody = switchBody;
268 }
269 mixin(copyMethod);
270 }
271
272 class CaseStatement : Statement
273 {
274 Expression[] values;
275 Statement caseBody;
276
277 this(Expression[] values, Statement caseBody)
278 {
279 mixin(set_kind);
280 addChildren(values);
281 addChild(caseBody);
282
283 this.values = values;
284 this.caseBody = caseBody;
285 }
286 mixin(copyMethod);
287 }
288
289 class DefaultStatement : Statement
290 {
291 Statement defaultBody;
292 this(Statement defaultBody)
293 {
294 mixin(set_kind);
295 addChild(defaultBody);
296
297 this.defaultBody = defaultBody;
298 }
299 mixin(copyMethod);
300 }
301
302 class ContinueStatement : Statement
303 {
304 Identifier* ident;
305 this(Identifier* ident)
306 {
307 mixin(set_kind);
308 this.ident = ident;
309 }
310 mixin(copyMethod);
311 }
312
313 class BreakStatement : Statement
314 {
315 Identifier* ident;
316 this(Identifier* ident)
317 {
318 mixin(set_kind);
319 this.ident = ident;
320 }
321 mixin(copyMethod);
322 }
323
324 class ReturnStatement : Statement
325 {
326 Expression e;
327 this(Expression e)
328 {
329 mixin(set_kind);
330 addOptChild(e);
331 this.e = e;
332 }
333 mixin(copyMethod);
334 }
335
336 class GotoStatement : Statement
337 {
338 Identifier* ident;
339 Expression caseExpr;
340 this(Identifier* ident, Expression caseExpr)
341 {
342 mixin(set_kind);
343 addOptChild(caseExpr);
344 this.ident = ident;
345 this.caseExpr = caseExpr;
346 }
347 mixin(copyMethod);
348 }
349
350 class WithStatement : Statement
351 {
352 Expression e;
353 Statement withBody;
354 this(Expression e, Statement withBody)
355 {
356 mixin(set_kind);
357 addChild(e);
358 addChild(withBody);
359
360 this.e = e;
361 this.withBody = withBody;
362 }
363 mixin(copyMethod);
364 }
365
366 class SynchronizedStatement : Statement
367 {
368 Expression e;
369 Statement syncBody;
370 this(Expression e, Statement syncBody)
371 {
372 mixin(set_kind);
373 addOptChild(e);
374 addChild(syncBody);
375
376 this.e = e;
377 this.syncBody = syncBody;
378 }
379 mixin(copyMethod);
380 }
381
382 class TryStatement : Statement
383 {
384 Statement tryBody;
385 CatchStatement[] catchBodies;
386 FinallyStatement finallyBody;
387 this(Statement tryBody, CatchStatement[] catchBodies, FinallyStatement finallyBody)
388 {
389 mixin(set_kind);
390 addChild(tryBody);
391 addOptChildren(catchBodies);
392 addOptChild(finallyBody);
393
394 this.tryBody = tryBody;
395 this.catchBodies = catchBodies;
396 this.finallyBody = finallyBody;
397 }
398 mixin(copyMethod);
399 }
400
401 class CatchStatement : Statement
402 {
403 Parameter param;
404 Statement catchBody;
405 this(Parameter param, Statement catchBody)
406 {
407 mixin(set_kind);
408 addOptChild(param);
409 addChild(catchBody);
410 this.param = param;
411 this.catchBody = catchBody;
412 }
413 mixin(copyMethod);
414 }
415
416 class FinallyStatement : Statement
417 {
418 Statement finallyBody;
419 this(Statement finallyBody)
420 {
421 mixin(set_kind);
422 addChild(finallyBody);
423 this.finallyBody = finallyBody;
424 }
425 mixin(copyMethod);
426 }
427
428 class ScopeGuardStatement : Statement
429 {
430 Identifier* condition;
431 Statement scopeBody;
432 this(Identifier* condition, Statement scopeBody)
433 {
434 mixin(set_kind);
435 addChild(scopeBody);
436 this.condition = condition;
437 this.scopeBody = scopeBody;
438 }
439 mixin(copyMethod);
440 }
441
442 class ThrowStatement : Statement
443 {
444 Expression e;
445 this(Expression e)
446 {
447 mixin(set_kind);
448 addChild(e);
449 this.e = e;
450 }
451 mixin(copyMethod);
452 }
453
454 class VolatileStatement : Statement
455 {
456 Statement volatileBody;
457 this(Statement volatileBody)
458 {
459 mixin(set_kind);
460 addOptChild(volatileBody);
461 this.volatileBody = volatileBody;
462 }
463 mixin(copyMethod);
464 }
465
466 class AsmBlockStatement : Statement
467 {
468 CompoundStatement statements;
469 this(CompoundStatement statements)
470 {
471 mixin(set_kind);
472 addChild(statements);
473 this.statements = statements;
474 }
475 mixin(copyMethod);
476 }
477
478 class AsmStatement : Statement
479 {
480 Identifier* ident;
481 Expression[] operands;
482 this(Identifier* ident, Expression[] operands)
483 {
484 mixin(set_kind);
485 addOptChildren(operands);
486 this.ident = ident;
487 this.operands = operands;
488 }
489 mixin(copyMethod);
490 }
491
492 class AsmAlignStatement : Statement
493 {
494 int number;
495 this(int number)
496 {
497 mixin(set_kind);
498 this.number = number;
499 }
500 mixin(copyMethod);
501 }
502
503 class IllegalAsmStatement : IllegalStatement
504 {
505 this()
506 {
507 mixin(set_kind);
508 }
509 mixin(copyMethod);
510 }
511
512 class PragmaStatement : Statement
513 {
514 Identifier* ident;
515 Expression[] args;
516 Statement pragmaBody;
517 this(Identifier* ident, Expression[] args, Statement pragmaBody)
518 {
519 mixin(set_kind);
520 addOptChildren(args);
521 addChild(pragmaBody);
522
523 this.ident = ident;
524 this.args = args;
525 this.pragmaBody = pragmaBody;
526 }
527 mixin(copyMethod);
528 }
529
530 class MixinStatement : Statement
531 {
532 Expression templateExpr;
533 Identifier* mixinIdent;
534 this(Expression templateExpr, Identifier* mixinIdent)
535 {
536 mixin(set_kind);
537 addChild(templateExpr);
538 this.templateExpr = templateExpr;
539 this.mixinIdent = mixinIdent;
540 }
541 mixin(copyMethod);
542 }
543
544 class StaticIfStatement : Statement
545 {
546 Expression condition;
547 Statement ifBody, elseBody;
548 this(Expression condition, Statement ifBody, Statement elseBody)
549 {
550 mixin(set_kind);
551 addChild(condition);
552 addChild(ifBody);
553 addOptChild(elseBody);
554 this.condition = condition;
555 this.ifBody = ifBody;
556 this.elseBody = elseBody;
557 }
558 mixin(copyMethod);
559 }
560
561 class StaticAssertStatement : Statement
562 {
563 Expression condition, message;
564 this(Expression condition, Expression message)
565 {
566 mixin(set_kind);
567 addChild(condition);
568 addOptChild(message);
569 this.condition = condition;
570 this.message = message;
571 }
572 mixin(copyMethod);
573 }
574
575 abstract class ConditionalCompilationStatement : Statement
576 {
577 Token* cond;
578 Statement mainBody, elseBody;
579 this(Token* cond, Statement mainBody, Statement elseBody)
580 {
581 addChild(mainBody);
582 addOptChild(elseBody);
583 this.cond = cond;
584 this.mainBody = mainBody;
585 this.elseBody = elseBody;
586 }
587 }
588
589 class DebugStatement : ConditionalCompilationStatement
590 {
591 this(Token* cond, Statement debugBody, Statement elseBody)
592 {
593 super(cond, debugBody, elseBody);
594 mixin(set_kind);
595 }
596 mixin(copyMethod);
597 }
598
599 class VersionStatement : ConditionalCompilationStatement
600 {
601 this(Token* cond, Statement versionBody, Statement elseBody)
602 {
603 super(cond, versionBody, elseBody);
604 mixin(set_kind);
605 }
606 mixin(copyMethod);
607 }