Mercurial > projects > ddmd
annotate dmd/VolatileStatement.d @ 146:af7e5ebef6ad
redundant extern(C)
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Tue, 14 Sep 2010 23:34:50 +0100 |
parents | 31c086f76669 |
children | af724d3510d7 |
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 { |
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 | |
140 | 76 static void el_setVolatile(elem* e) |
77 { | |
78 while (1) | |
79 { | |
80 e.Ety |= mTYvolatile; | |
81 if (OTunary(e.Eoper)) | |
82 e = e.E1; | |
83 else if (OTbinary(e.Eoper)) | |
84 { | |
85 el_setVolatile(e.E2); | |
86 e = e.E1; | |
87 } | |
88 else | |
89 break; | |
90 } | |
91 } | |
92 | |
72 | 93 override void toIR(IRState* irs) |
0 | 94 { |
95 block* b; | |
96 | |
97 if (statement) | |
98 { | |
99 Blockx* blx = irs.blx; | |
100 | |
101 block_goto(blx, BCgoto, null); | |
102 b = blx.curblock; | |
103 | |
104 statement.toIR(irs); | |
105 | |
106 block_goto(blx, BCgoto, null); | |
107 | |
108 // Mark the blocks generated as volatile | |
109 for (; b != blx.curblock; b = b.Bnext) | |
110 { | |
111 b.Bflags |= BFL.BFLvolatile; | |
112 if (b.Belem) | |
113 el_setVolatile(b.Belem); | |
114 } | |
115 } | |
116 } | |
72 | 117 } |