@@ -256,19 +256,22 @@ class NQPMatch is NQPCapture {
256
256
257
257
class NQPCursor does NQPCursorRole {
258
258
method MATCH () {
259
- my $ match := NQPMatch. new ();
260
- nqp ::bindattr($ match , NQPMatch, ' $!orig' , nqp ::getattr(self , NQPCursor, ' $!orig' ));
261
- nqp ::bindattr_i($ match , NQPMatch, ' $!from' , nqp ::getattr_i(self , NQPCursor, ' $!from' ));
262
- nqp ::bindattr_i($ match , NQPMatch, ' $!to' , nqp ::getattr_i(self , NQPCursor, ' $!pos' ));
263
- my $ list := $ match . list;
264
- my $ hash := $ match . hash;
265
- for self . CAPHASH {
266
- my $ key := $ _ . key ;
267
- nqp ::iscclass(pir::const::CCLASS_NUMERIC, $ key , 0 )
268
- ?? nqp ::bindpos($ list , $ key , $ _ . value )
269
- !! nqp ::bindkey($ hash , $ key , $ _ . value );
259
+ unless nqp ::istype(nqp ::getattr(self , NQPCursor, ' $!match' ), NQPMatch) {
260
+ my $ match := NQPMatch. new ();
261
+ nqp ::bindattr(self , NQPCursor, ' $!match' , $ match );
262
+ nqp ::bindattr($ match , NQPMatch, ' $!orig' , nqp ::getattr(self , NQPCursor, ' $!orig' ));
263
+ nqp ::bindattr_i($ match , NQPMatch, ' $!from' , nqp ::getattr_i(self , NQPCursor, ' $!from' ));
264
+ nqp ::bindattr_i($ match , NQPMatch, ' $!to' , nqp ::getattr_i(self , NQPCursor, ' $!pos' ));
265
+ my $ list := $ match . list;
266
+ my $ hash := $ match . hash;
267
+ for self . CAPHASH {
268
+ my $ key := $ _ . key ;
269
+ nqp ::iscclass(pir::const::CCLASS_NUMERIC, $ key , 0 )
270
+ ?? nqp ::bindpos($ list , $ key , $ _ . value )
271
+ !! nqp ::bindkey($ hash , $ key , $ _ . value );
272
+ }
270
273
}
271
- $ match ;
274
+ nqp ::getattr( self , NQPCursor, ' $! match' ) ;
272
275
}
273
276
274
277
method Bool () is parrot_vtable(' get_bool' ) {
0 commit comments