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 {
|
178
|
23 register();
|
0
|
24 super(loc);
|
|
25 condition = c;
|
|
26 body_ = b;
|
|
27 }
|
|
28
|
72
|
29 override Statement syntaxCopy()
|
0
|
30 {
|
62
|
31 WhileStatement s = new WhileStatement(loc, condition.syntaxCopy(), body_ ? body_.syntaxCopy() : null);
|
|
32 return s;
|
0
|
33 }
|
|
34
|
72
|
35 override Statement semantic(Scope sc)
|
0
|
36 {
|
|
37 /* Rewrite as a for(;condition;) loop
|
|
38 */
|
|
39
|
|
40 Statement s = new ForStatement(loc, null, condition, null, body_);
|
|
41 s = s.semantic(sc);
|
|
42 return s;
|
|
43 }
|
|
44
|
72
|
45 override bool hasBreak()
|
0
|
46 {
|
56
|
47 return true;
|
0
|
48 }
|
|
49
|
72
|
50 override bool hasContinue()
|
0
|
51 {
|
123
|
52 return true;
|
0
|
53 }
|
|
54
|
72
|
55 override bool usesEH()
|
0
|
56 {
|
|
57 assert(false);
|
|
58 }
|
|
59
|
72
|
60 override BE blockExit()
|
0
|
61 {
|
|
62 assert(false);
|
|
63 }
|
|
64
|
72
|
65 override bool comeFrom()
|
0
|
66 {
|
|
67 assert(false);
|
|
68 }
|
|
69
|
72
|
70 override Expression interpret(InterState istate)
|
0
|
71 {
|
135
|
72 version(LOG) {
|
|
73 printf("WhileStatement::interpret()\n");
|
|
74 }
|
|
75 assert(false); // rewritten to ForStatement
|
|
76 return null;
|
0
|
77 }
|
|
78
|
72
|
79 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
80 {
|
|
81 assert(false);
|
|
82 }
|
|
83
|
72
|
84 override Statement inlineScan(InlineScanState* iss)
|
0
|
85 {
|
|
86 assert(false);
|
|
87 }
|
|
88
|
72
|
89 override void toIR(IRState* irs)
|
0
|
90 {
|
|
91 assert(false);
|
|
92 }
|
72
|
93 }
|