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 {
|
|
47 for (int i = 0; i < a.dim; i++)
|
|
48 {
|
|
49 Statement s = cast(Statement)a.data[i];
|
|
50
|
|
51 s = new VolatileStatement(loc, s);
|
|
52 a.data[i] = cast(void*)s;
|
|
53 }
|
|
54 }
|
|
55
|
|
56 return a;
|
|
57 }
|
|
58
|
72
|
59 override BE blockExit()
|
0
|
60 {
|
|
61 return statement ? statement.blockExit() : BE.BEfallthru;
|
|
62 }
|
|
63
|
72
|
64 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
65 {
|
|
66 assert(false);
|
|
67 }
|
|
68
|
72
|
69 override Statement inlineScan(InlineScanState* iss)
|
0
|
70 {
|
|
71 if (statement)
|
|
72 statement = statement.inlineScan(iss);
|
|
73 return this;
|
|
74 }
|
|
75
|
72
|
76 override void toIR(IRState* irs)
|
0
|
77 {
|
|
78 block* b;
|
|
79
|
|
80 if (statement)
|
|
81 {
|
|
82 Blockx* blx = irs.blx;
|
|
83
|
|
84 block_goto(blx, BCgoto, null);
|
|
85 b = blx.curblock;
|
|
86
|
|
87 statement.toIR(irs);
|
|
88
|
|
89 block_goto(blx, BCgoto, null);
|
|
90
|
|
91 // Mark the blocks generated as volatile
|
|
92 for (; b != blx.curblock; b = b.Bnext)
|
|
93 {
|
|
94 b.Bflags |= BFL.BFLvolatile;
|
|
95 if (b.Belem)
|
|
96 el_setVolatile(b.Belem);
|
|
97 }
|
|
98 }
|
|
99 }
|
72
|
100 }
|