@@ -112,10 +112,11 @@ class Ctx extends NQPObject {
112
112
113
113
exceptionsStack ( ) . push ( exception ) ;
114
114
try {
115
+ let wrapped = new Ctx ( this , this , null ) ;
115
116
if ( ctx [ handler ] ) {
116
- ctx . unwind . ret = ctx [ handler ] ( this ) ;
117
+ ctx . unwind . ret = ctx [ handler ] ( wrapped ) ;
117
118
} else {
118
- ctx . unwind . ret = ctx . $$CONTROL ( this ) ;
119
+ ctx . unwind . ret = ctx . $$CONTROL ( wrapped ) ;
119
120
}
120
121
} catch ( e ) {
121
122
if ( e instanceof ResumeException && e . exception === exception ) {
@@ -130,6 +131,9 @@ class Ctx extends NQPObject {
130
131
throw ctx . unwind ;
131
132
}
132
133
ctx = ctx . $$caller ;
134
+ if ( ctx && ctx . $$controlHandlerOuter ) {
135
+ ctx = ctx . $$controlHandlerOuter ;
136
+ }
133
137
}
134
138
135
139
throw exception ;
@@ -165,8 +169,8 @@ class Ctx extends NQPObject {
165
169
throw ctx . unwind ;
166
170
}
167
171
ctx = ctx . $$caller ;
168
- if ( ctx && ctx . $$handlerOuter ) {
169
- ctx = ctx . $$handlerOuter ;
172
+ if ( ctx && ctx . $$catchHandlerOuter ) {
173
+ ctx = ctx . $$catchHandlerOuter ;
170
174
}
171
175
}
172
176
@@ -226,16 +230,18 @@ class Ctx extends NQPObject {
226
230
let ctx = lookFrom ;
227
231
228
232
while ( ctx ) {
233
+ //TODO - think about checking the label
229
234
if ( ctx [ handler ] || ctx . $$CONTROL ) {
230
235
exception . caught = ctx ;
231
236
ctx . exception = exception ;
232
237
233
238
exceptionsStack ( ) . push ( exception ) ;
234
239
try {
240
+ let wrapped = new Ctx ( this , this , null ) ;
235
241
if ( ctx [ handler ] ) {
236
- ctx . unwind . ret = ctx [ handler ] ( this ) ;
242
+ ctx . unwind . ret = ctx [ handler ] ( wrapped ) ;
237
243
} else {
238
- ctx . unwind . ret = ctx . $$CONTROL ( this ) ;
244
+ ctx . unwind . ret = ctx . $$CONTROL ( wrapped ) ;
239
245
}
240
246
} catch ( e ) {
241
247
if ( e instanceof ResumeException && e . exception === exception ) {
@@ -249,7 +255,11 @@ class Ctx extends NQPObject {
249
255
250
256
throw ctx . unwind ;
251
257
}
258
+
252
259
ctx = ctx . $$outer ;
260
+ if ( ctx && ctx . $$controlHandlerOuter ) {
261
+ ctx = ctx . $$controlHandlerOuter ;
262
+ }
253
263
}
254
264
255
265
this . $$getHLL ( ) . get ( 'lexical_handler_not_found_error' ) . $$call ( this , null , new NQPInt ( category ) , new NQPInt ( 0 ) ) ;
0 commit comments