comparison dmd/VolatileStatement.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 2e2a5c3f943a
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
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
29 Statement syntaxCopy()
30 {
31 assert(false);
32 }
33
34 Statement semantic(Scope sc)
35 {
36 if (statement)
37 statement = statement.semantic(sc);
38 return this;
39 }
40
41 Statements flatten(Scope sc)
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
58 BE blockExit()
59 {
60 return statement ? statement.blockExit() : BE.BEfallthru;
61 }
62
63 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
64 {
65 assert(false);
66 }
67
68 Statement inlineScan(InlineScanState* iss)
69 {
70 if (statement)
71 statement = statement.inlineScan(iss);
72 return this;
73 }
74
75 void toIR(IRState* irs)
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 }
99 }