0
|
1 module dmd.WhileStatement;
|
|
2
|
114
|
3 import dmd.common;
|
0
|
4 import dmd.Statement;
|
|
5 import dmd.Expression;
|
|
6 import dmd.Scope;
|
|
7 import dmd.InterState;
|
|
8 import dmd.HdrGenState;
|
|
9 import dmd.OutBuffer;
|
|
10 import dmd.InlineScanState;
|
|
11 import dmd.IRState;
|
|
12 import dmd.Loc;
|
|
13 import dmd.BE;
|
|
14 import dmd.ForStatement;
|
|
15
|
|
16 class WhileStatement : Statement
|
|
17 {
|
|
18 Expression condition;
|
|
19 Statement body_;
|
|
20
|
|
21 this(Loc loc, Expression c, Statement b)
|
|
22 {
|
|
23 super(loc);
|
|
24 condition = c;
|
|
25 body_ = b;
|
|
26 }
|
|
27
|
72
|
28 override Statement syntaxCopy()
|
0
|
29 {
|
62
|
30 WhileStatement s = new WhileStatement(loc, condition.syntaxCopy(), body_ ? body_.syntaxCopy() : null);
|
|
31 return s;
|
0
|
32 }
|
|
33
|
72
|
34 override Statement semantic(Scope sc)
|
0
|
35 {
|
|
36 /* Rewrite as a for(;condition;) loop
|
|
37 */
|
|
38
|
|
39 Statement s = new ForStatement(loc, null, condition, null, body_);
|
|
40 s = s.semantic(sc);
|
|
41 return s;
|
|
42 }
|
|
43
|
72
|
44 override bool hasBreak()
|
0
|
45 {
|
56
|
46 return true;
|
0
|
47 }
|
|
48
|
72
|
49 override bool hasContinue()
|
0
|
50 {
|
123
|
51 return true;
|
0
|
52 }
|
|
53
|
72
|
54 override bool usesEH()
|
0
|
55 {
|
|
56 assert(false);
|
|
57 }
|
|
58
|
72
|
59 override BE blockExit()
|
0
|
60 {
|
|
61 assert(false);
|
|
62 }
|
|
63
|
72
|
64 override bool comeFrom()
|
0
|
65 {
|
|
66 assert(false);
|
|
67 }
|
|
68
|
72
|
69 override Expression interpret(InterState istate)
|
0
|
70 {
|
135
|
71 version(LOG) {
|
|
72 printf("WhileStatement::interpret()\n");
|
|
73 }
|
|
74 assert(false); // rewritten to ForStatement
|
|
75 return null;
|
0
|
76 }
|
|
77
|
72
|
78 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
79 {
|
|
80 assert(false);
|
|
81 }
|
|
82
|
72
|
83 override Statement inlineScan(InlineScanState* iss)
|
0
|
84 {
|
|
85 assert(false);
|
|
86 }
|
|
87
|
72
|
88 override void toIR(IRState* irs)
|
0
|
89 {
|
|
90 assert(false);
|
|
91 }
|
72
|
92 }
|