Skip to content

Commit abdf378

Browse files
committed
Refactor building of match object.
1 parent 69cc5ac commit abdf378

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/PAST/NQP.pir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ entry to produce the node to be returned.
460460
maphash['iscont'] = 'is_container__IP'
461461
maphash['isnull'] = 'isnull__IP'
462462
maphash['istrue'] = 'istrue__IP'
463+
maphash['istype'] = 'type_check__IPP'
463464
maphash['null'] = 'null__P'
464465
maphash['unbox_i'] = 'repr_unbox_int__IP'
465466
maphash['unbox_n'] = 'repr_unbox_num__NP'

src/QRegex/Cursor.nqp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ role NQPCursorRole {
1313
method from() { $!from }
1414
method pos() { $!pos }
1515

16-
method MATCH() {
16+
method CAPHASH() {
1717
my $caps := nqp::hash();
1818
if $!cstack {
1919
my %caplist := $!regexsub.nqpattr('caps');
20-
for %caplist{
20+
for %caplist {
2121
$caps{$_.key} := nqp::list() if $_.value >= 2;
2222
}
2323
for $!cstack -> $subcur {
@@ -29,7 +29,7 @@ role NQPCursorRole {
2929
}
3030
}
3131
}
32-
$!match := self.MATCHBUILD($!orig, $!from, $!pos, $caps);
32+
$caps;
3333
}
3434

3535
method !cursor_init($target, :$p = 0, :$c) {
@@ -255,21 +255,22 @@ class NQPMatch is NQPCapture {
255255
}
256256

257257
class NQPCursor does NQPCursorRole {
258-
method MATCHBUILD($orig, $from, $to, %caps) {
258+
method MATCH() {
259259
my $match := NQPMatch.new();
260-
nqp::bindattr($match, NQPMatch, '$!orig', $orig);
261-
nqp::bindattr_i($match, NQPMatch, '$!from', $from);
262-
nqp::bindattr_i($match, NQPMatch, '$!to', $to);
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'));
263263
my $list := $match.list;
264264
my $hash := $match.hash;
265-
for %caps {
265+
for self.CAPHASH {
266266
my $key := $_.key;
267267
nqp::iscclass(pir::const::CCLASS_NUMERIC, $key, 0)
268268
?? nqp::bindpos($list, $key, $_.value)
269269
!! nqp::bindkey($hash, $key, $_.value);
270270
}
271271
$match;
272272
}
273+
273274
method Bool() is parrot_vtable('get_bool') {
274275
!nqp::isnull(nqp::getattr(self, $?CLASS, '$!match'))
275276
&& nqp::istrue(nqp::getattr(self, $?CLASS, '$!match'));

0 commit comments

Comments
 (0)