Mercurial > projects > ddmd
annotate dmd/VolatileStatement.d @ 137:09c858522d55
merge
author | Trass3r |
---|---|
date | Mon, 13 Sep 2010 23:29:00 +0200 |
parents | c77e9f4f1793 |
children | 31c086f76669 |
rev | line source |
---|---|
0 | 1 module dmd.VolatileStatement; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Statement; |
5 import dmd.ArrayTypes; | |
6 import dmd.Scope; | |
7 import dmd.Loc; | |
8 import dmd.OutBuffer; | |
9 import dmd.HdrGenState; | |
10 import dmd.InlineScanState; | |
11 import dmd.IRState; | |
12 import dmd.BE; | |
13 | |
14 import dmd.backend.block; | |
15 import dmd.backend.Blockx; | |
16 import dmd.backend.Util; | |
17 import dmd.backend.BC; | |
18 //import dmd.backend.BFL; | |
19 | |
20 class VolatileStatement : Statement | |
21 { | |
22 Statement statement; | |
23 | |
24 this(Loc loc, Statement statement) | |
25 { | |
26 super(loc); | |
27 this.statement = statement; | |
28 } | |
29 | |
72 | 30 override Statement syntaxCopy() |
0 | 31 { |
32 assert(false); | |
33 } | |
34 | |
72 | 35 override Statement semantic(Scope sc) |
0 | 36 { |
37 if (statement) | |
38 statement = statement.semantic(sc); | |
39 return this; | |
40 } | |
41 | |
72 | 42 override Statements flatten(Scope sc) |
0 | 43 { |
44 Statements a = statement ? statement.flatten(sc) : null; | |
45 if (a) | |
46 { | |
122
c77e9f4f1793
Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
47 foreach (ref Statement s; a) |
0 | 48 { |
49 s = new VolatileStatement(loc, s); | |
50 } | |
51 } | |
52 | |
53 return a; | |
54 } | |
55 | |
72 | 56 override BE blockExit() |
0 | 57 { |
58 return statement ? statement.blockExit() : BE.BEfallthru; | |
59 } | |
60 | |
72 | 61 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 62 { |
63 assert(false); | |
64 } | |
65 | |
72 | 66 override Statement inlineScan(InlineScanState* iss) |
0 | 67 { |
68 if (statement) | |
69 statement = statement.inlineScan(iss); | |
70 return this; | |
71 } | |
72 | |
72 | 73 override void toIR(IRState* irs) |
0 | 74 { |
75 block* b; | |
76 | |
77 if (statement) | |
78 { | |
79 Blockx* blx = irs.blx; | |
80 | |
81 block_goto(blx, BCgoto, null); | |
82 b = blx.curblock; | |
83 | |
84 statement.toIR(irs); | |
85 | |
86 block_goto(blx, BCgoto, null); | |
87 | |
88 // Mark the blocks generated as volatile | |
89 for (; b != blx.curblock; b = b.Bnext) | |
90 { | |
91 b.Bflags |= BFL.BFLvolatile; | |
92 if (b.Belem) | |
93 el_setVolatile(b.Belem); | |
94 } | |
95 } | |
96 } | |
72 | 97 } |