annotate dmd/VolatileStatement.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents af724d3510d7
children b0d41ff5e0df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.VolatileStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.BE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.backend.block;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.backend.Blockx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.backend.BC;
140
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
18 import dmd.backend.elem;
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
19 import dmd.backend.OPER;
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
20 import dmd.backend.mTY;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 //import dmd.backend.BFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 class VolatileStatement : Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 Statement statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 this(Loc loc, Statement statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
29 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 super(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 this.statement = statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
34 override Statement syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
39 override Statement semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 statement = statement.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
46 override Statements flatten(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 Statements a = statement ? statement.flatten(sc) : null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 if (a)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 {
122
c77e9f4f1793 Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
51 foreach (ref Statement s; a)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 s = new VolatileStatement(loc, s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 return a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
60 override BE blockExit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 return statement ? statement.blockExit() : BE.BEfallthru;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
65 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 {
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
67 buf.writestring("volatile");
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
68 if (statement)
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
69 {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
70 if (statement.isScopeStatement())
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
71 buf.writenl();
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
72 else
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
73 buf.writebyte(' ');
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
74 statement.toCBuffer(buf, hgs);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 140
diff changeset
75 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
78 override Statement inlineScan(InlineScanState* iss)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 statement = statement.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
140
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
85 static void el_setVolatile(elem* e)
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
86 {
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
87 while (1)
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
88 {
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
89 e.Ety |= mTYvolatile;
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
90 if (OTunary(e.Eoper))
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
91 e = e.E1;
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
92 else if (OTbinary(e.Eoper))
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
93 {
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
94 el_setVolatile(e.E2);
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
95 e = e.E1;
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
96 }
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
97 else
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
98 break;
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
99 }
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
100 }
31c086f76669 dmd.lib now only contains the backend
Trass3r
parents: 122
diff changeset
101
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
102 override void toIR(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 block* b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 if (statement)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 Blockx* blx = irs.blx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 block_goto(blx, BCgoto, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 b = blx.curblock;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 statement.toIR(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 block_goto(blx, BCgoto, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 // Mark the blocks generated as volatile
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 for (; b != blx.curblock; b = b.Bnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 b.Bflags |= BFL.BFLvolatile;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 if (b.Belem)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 el_setVolatile(b.Belem);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
126 }