Mercurial > projects > ddmd
annotate dmd/VolatileStatement.d @ 174:af724d3510d7
lot os toCBuffer methods implemented
moved shared Type.* stuff into Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 03:47:23 +0400 |
parents | 31c086f76669 |
children | e3afd1303184 |
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 | |
23 class VolatileStatement : Statement | |
24 { | |
25 Statement statement; | |
26 | |
27 this(Loc loc, Statement statement) | |
28 { | |
29 super(loc); | |
30 this.statement = statement; | |
31 } | |
32 | |
72 | 33 override Statement syntaxCopy() |
0 | 34 { |
35 assert(false); | |
36 } | |
37 | |
72 | 38 override Statement semantic(Scope sc) |
0 | 39 { |
40 if (statement) | |
41 statement = statement.semantic(sc); | |
42 return this; | |
43 } | |
44 | |
72 | 45 override Statements flatten(Scope sc) |
0 | 46 { |
47 Statements a = statement ? statement.flatten(sc) : null; | |
48 if (a) | |
49 { | |
122
c77e9f4f1793
Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
50 foreach (ref Statement s; a) |
0 | 51 { |
52 s = new VolatileStatement(loc, 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 { |
174 | 66 buf.writestring("volatile"); |
67 if (statement) | |
68 { | |
69 if (statement.isScopeStatement()) | |
70 buf.writenl(); | |
71 else | |
72 buf.writebyte(' '); | |
73 statement.toCBuffer(buf, hgs); | |
74 } | |
0 | 75 } |
76 | |
72 | 77 override Statement inlineScan(InlineScanState* iss) |
0 | 78 { |
79 if (statement) | |
80 statement = statement.inlineScan(iss); | |
81 return this; | |
82 } | |
83 | |
140 | 84 static void el_setVolatile(elem* e) |
85 { | |
86 while (1) | |
87 { | |
88 e.Ety |= mTYvolatile; | |
89 if (OTunary(e.Eoper)) | |
90 e = e.E1; | |
91 else if (OTbinary(e.Eoper)) | |
92 { | |
93 el_setVolatile(e.E2); | |
94 e = e.E1; | |
95 } | |
96 else | |
97 break; | |
98 } | |
99 } | |
100 | |
72 | 101 override void toIR(IRState* irs) |
0 | 102 { |
103 block* b; | |
104 | |
105 if (statement) | |
106 { | |
107 Blockx* blx = irs.blx; | |
108 | |
109 block_goto(blx, BCgoto, null); | |
110 b = blx.curblock; | |
111 | |
112 statement.toIR(irs); | |
113 | |
114 block_goto(blx, BCgoto, null); | |
115 | |
116 // Mark the blocks generated as volatile | |
117 for (; b != blx.curblock; b = b.Bnext) | |
118 { | |
119 b.Bflags |= BFL.BFLvolatile; | |
120 if (b.Belem) | |
121 el_setVolatile(b.Belem); | |
122 } | |
123 } | |
124 } | |
72 | 125 } |