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 {
|
|
51 assert(false);
|
|
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 {
|
|
71 assert(false);
|
|
72 }
|
|
73
|
72
|
74 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
75 {
|
|
76 assert(false);
|
|
77 }
|
|
78
|
72
|
79 override Statement inlineScan(InlineScanState* iss)
|
0
|
80 {
|
|
81 assert(false);
|
|
82 }
|
|
83
|
72
|
84 override void toIR(IRState* irs)
|
0
|
85 {
|
|
86 assert(false);
|
|
87 }
|
72
|
88 }
|