Mercurial > projects > ddmd
annotate dmd/VolatileStatement.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
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; | |
140 | 18 import dmd.backend.elem; |
19 import dmd.backend.OPER; | |
20 import dmd.backend.mTY; | |
0 | 21 //import dmd.backend.BFL; |
22 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 |
0 | 25 class VolatileStatement : Statement |
26 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
27 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
28 |
0 | 29 Statement statement; |
30 | |
31 this(Loc loc, Statement statement) | |
32 { | |
178 | 33 register(); |
0 | 34 super(loc); |
35 this.statement = statement; | |
36 } | |
37 | |
72 | 38 override Statement syntaxCopy() |
0 | 39 { |
40 assert(false); | |
41 } | |
42 | |
72 | 43 override Statement semantic(Scope sc) |
0 | 44 { |
45 if (statement) | |
46 statement = statement.semantic(sc); | |
47 return this; | |
48 } | |
49 | |
72 | 50 override Statements flatten(Scope sc) |
0 | 51 { |
52 Statements a = statement ? statement.flatten(sc) : null; | |
53 if (a) | |
54 { | |
122
c77e9f4f1793
Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
55 foreach (ref Statement s; a) |
0 | 56 { |
57 s = new VolatileStatement(loc, s); | |
58 } | |
59 } | |
60 | |
61 return a; | |
62 } | |
63 | |
72 | 64 override BE blockExit() |
0 | 65 { |
66 return statement ? statement.blockExit() : BE.BEfallthru; | |
67 } | |
68 | |
72 | 69 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 70 { |
174 | 71 buf.writestring("volatile"); |
72 if (statement) | |
73 { | |
74 if (statement.isScopeStatement()) | |
75 buf.writenl(); | |
76 else | |
77 buf.writebyte(' '); | |
78 statement.toCBuffer(buf, hgs); | |
79 } | |
0 | 80 } |
81 | |
72 | 82 override Statement inlineScan(InlineScanState* iss) |
0 | 83 { |
84 if (statement) | |
85 statement = statement.inlineScan(iss); | |
86 return this; | |
87 } | |
88 | |
140 | 89 static void el_setVolatile(elem* e) |
90 { | |
91 while (1) | |
92 { | |
93 e.Ety |= mTYvolatile; | |
94 if (OTunary(e.Eoper)) | |
95 e = e.E1; | |
96 else if (OTbinary(e.Eoper)) | |
97 { | |
98 el_setVolatile(e.E2); | |
99 e = e.E1; | |
100 } | |
101 else | |
102 break; | |
103 } | |
104 } | |
105 | |
72 | 106 override void toIR(IRState* irs) |
0 | 107 { |
108 block* b; | |
109 | |
110 if (statement) | |
111 { | |
112 Blockx* blx = irs.blx; | |
113 | |
114 block_goto(blx, BCgoto, null); | |
115 b = blx.curblock; | |
116 | |
117 statement.toIR(irs); | |
118 | |
119 block_goto(blx, BCgoto, null); | |
120 | |
121 // Mark the blocks generated as volatile | |
122 for (; b != blx.curblock; b = b.Bnext) | |
123 { | |
124 b.Bflags |= BFL.BFLvolatile; | |
125 if (b.Belem) | |
126 el_setVolatile(b.Belem); | |
127 } | |
128 } | |
129 } | |
72 | 130 } |