annotate dmd/TryFinallyStatement.d @ 72:2e2a5c3f943a

reduced warnings by adding override to the methods think this also normalizes different line endings used all over the place
author Trass3r
date Sat, 28 Aug 2010 16:19:48 +0200
parents 10317f0c89a5
children e28b18c23469
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TryFinallyStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.CompoundStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.BE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.backend.block;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.backend.Blockx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.backend.BC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 class TryFinallyStatement : Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 Statement body_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 Statement finalbody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 this(Loc loc, Statement body_, Statement finalbody)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 super(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 this.body_ = body_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this.finalbody = finalbody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
32 override Statement syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
37 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
42 override Statement semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 //printf("TryFinallyStatement::semantic()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 body_ = body_.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 sc = sc.push();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 sc.tf = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 sc.sbreak = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 sc.scontinue = null; // no break or continue out of finally block
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 finalbody = finalbody.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 if (!body_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 return finalbody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 if (!finalbody)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 return body_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 if (body_.blockExit() == BE.BEfallthru)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 Statement s = new CompoundStatement(loc, body_, finalbody);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
64 override bool hasBreak()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
69 override bool hasContinue()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
74 override bool usesEH()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
79 override BE blockExit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 if (body_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 return body_.blockExit();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 return BE.BEfallthru;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
86 override Statement inlineScan(InlineScanState* iss)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 if (body_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 body_ = body_.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 if (finalbody)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 finalbody = finalbody.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 /****************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 * A try-finally statement.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 * Builds the following:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 * _try
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 * block
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 * _finally
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 * finalbody
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 * _ret
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 */
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
104 override void toIR(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 //printf("TryFinallyStatement.toIR()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 Blockx* blx = irs.blx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 version (SEH) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 nteh_declarvars(blx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 block* tryblock = block_goto(blx, BCgoto, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 int previndex = blx.scope_index;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 tryblock.Blast_index = previndex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 tryblock.Bscope_index = blx.next_index++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 blx.scope_index = tryblock.Bscope_index;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 // Current scope index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 setScopeIndex(blx,tryblock,tryblock.Bscope_index);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 blx.tryblock = tryblock;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 block_goto(blx,BC_try,null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 IRState bodyirs = IRState(irs, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 block* breakblock = block_calloc(blx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 block* contblock = block_calloc(blx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 if (body_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 body_.toIR(&bodyirs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 blx.tryblock = tryblock.Btry; // back to previous tryblock
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 setScopeIndex(blx,blx.curblock,previndex);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 blx.scope_index = previndex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 block_goto(blx,BCgoto, breakblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 block* finallyblock = block_goto(blx,BCgoto,contblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 list_append(&tryblock.Bsucc,finallyblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 block_goto(blx,BC_finally,null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 IRState finallyState = IRState(irs, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 breakblock = block_calloc(blx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 contblock = block_calloc(blx);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 setScopeIndex(blx, blx.curblock, previndex);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 if (finalbody)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 finalbody.toIR(&finallyState);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 block_goto(blx, BCgoto, contblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 block_goto(blx, BCgoto, breakblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 block* retblock = blx.curblock;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 block_next(blx,BC_ret,null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 list_append(&finallyblock.Bsucc, blx.curblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 list_append(&retblock.Bsucc, blx.curblock);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
160 }