0
|
1 module dmd.VolatileStatement;
|
|
2
|
|
3 import dmd.Statement;
|
|
4 import dmd.ArrayTypes;
|
|
5 import dmd.Scope;
|
|
6 import dmd.Loc;
|
|
7 import dmd.OutBuffer;
|
|
8 import dmd.HdrGenState;
|
|
9 import dmd.InlineScanState;
|
|
10 import dmd.IRState;
|
|
11 import dmd.BE;
|
|
12
|
|
13 import dmd.backend.block;
|
|
14 import dmd.backend.Blockx;
|
|
15 import dmd.backend.Util;
|
|
16 import dmd.backend.BC;
|
|
17 //import dmd.backend.BFL;
|
|
18
|
|
19 class VolatileStatement : Statement
|
|
20 {
|
|
21 Statement statement;
|
|
22
|
|
23 this(Loc loc, Statement statement)
|
|
24 {
|
|
25 super(loc);
|
|
26 this.statement = statement;
|
|
27 }
|
|
28
|
72
|
29 override Statement syntaxCopy()
|
0
|
30 {
|
|
31 assert(false);
|
|
32 }
|
|
33
|
72
|
34 override Statement semantic(Scope sc)
|
0
|
35 {
|
|
36 if (statement)
|
|
37 statement = statement.semantic(sc);
|
|
38 return this;
|
|
39 }
|
|
40
|
72
|
41 override Statements flatten(Scope sc)
|
0
|
42 {
|
|
43 Statements a = statement ? statement.flatten(sc) : null;
|
|
44 if (a)
|
|
45 {
|
|
46 for (int i = 0; i < a.dim; i++)
|
|
47 {
|
|
48 Statement s = cast(Statement)a.data[i];
|
|
49
|
|
50 s = new VolatileStatement(loc, s);
|
|
51 a.data[i] = cast(void*)s;
|
|
52 }
|
|
53 }
|
|
54
|
|
55 return a;
|
|
56 }
|
|
57
|
72
|
58 override BE blockExit()
|
0
|
59 {
|
|
60 return statement ? statement.blockExit() : BE.BEfallthru;
|
|
61 }
|
|
62
|
72
|
63 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
64 {
|
|
65 assert(false);
|
|
66 }
|
|
67
|
72
|
68 override Statement inlineScan(InlineScanState* iss)
|
0
|
69 {
|
|
70 if (statement)
|
|
71 statement = statement.inlineScan(iss);
|
|
72 return this;
|
|
73 }
|
|
74
|
72
|
75 override void toIR(IRState* irs)
|
0
|
76 {
|
|
77 block* b;
|
|
78
|
|
79 if (statement)
|
|
80 {
|
|
81 Blockx* blx = irs.blx;
|
|
82
|
|
83 block_goto(blx, BCgoto, null);
|
|
84 b = blx.curblock;
|
|
85
|
|
86 statement.toIR(irs);
|
|
87
|
|
88 block_goto(blx, BCgoto, null);
|
|
89
|
|
90 // Mark the blocks generated as volatile
|
|
91 for (; b != blx.curblock; b = b.Bnext)
|
|
92 {
|
|
93 b.Bflags |= BFL.BFLvolatile;
|
|
94 if (b.Belem)
|
|
95 el_setVolatile(b.Belem);
|
|
96 }
|
|
97 }
|
|
98 }
|
72
|
99 }
|