@@ -91,6 +91,8 @@ grammars.
91
91
how . ' add_method' (type_obj , ' !INTERPOLATE' , $P33 )
92
92
.const ' Sub' $P34 = ' Regex_Cursor_meth_!INTERPOLATE_REGEX'
93
93
how . ' add_method' (type_obj , ' !INTERPOLATE_REGEX' , $P34 )
94
+ .const ' Sub' $P35 = ' Regex_Cursor_meth_!cursor_from'
95
+ how . ' add_method' (type_obj , ' !cursor_from' , $P35 )
94
96
.const ' Sub' $P10 = ' Regex_Cursor_meth_before'
95
97
how . ' add_method' (type_obj , ' before' , $P10 )
96
98
.const ' Sub' $P11 = ' Regex_Cursor_meth_ident'
@@ -147,13 +149,14 @@ grammars.
147
149
how . ' add_method' (type_obj , ' Bool' , $P17 )
148
150
149
151
# Add attributes.
150
- .local pmc NQPAttribute , attr
152
+ .local pmc NQPAttribute , int _type, attr
151
153
NQPAttribute = get_hll_global " NQPAttribute"
154
+ int _type = get_hll_global " int"
152
155
attr = NQPAttribute . " new" (" $!target" :named (" name" ))
153
156
how . " add_attribute" (type_obj , attr )
154
- attr = NQPAttribute . " new" (" $!from" :named (" name" ))
157
+ attr = NQPAttribute . " new" (" $!from" :named (" name" ), int _type : named ( ' type ' ) )
155
158
how . " add_attribute" (type_obj , attr )
156
- attr = NQPAttribute . " new" (" $!pos" :named (" name" ))
159
+ attr = NQPAttribute . " new" (" $!pos" :named (" name" ), int _type : named ( ' type ' ) )
157
160
how . " add_attribute" (type_obj , attr )
158
161
attr = NQPAttribute . " new" (" $!match" :named (" name" ))
159
162
how . " add_attribute" (type_obj , attr )
@@ -231,9 +234,11 @@ for the Cursor if one hasn't been created yet.
231
234
.local pmc target , from , to
232
235
target = getattribute self , cur_class , ' $!target'
233
236
setattribute match , ' $!target' , target
234
- from = getattribute self , cur_class , ' $!from'
237
+ $I0 = repr_get_attr_int self , cur_class , ' $!from'
238
+ from = box $I0
235
239
setattribute match , ' $!from' , from
236
- to = getattribute self , cur_class , ' $!pos'
240
+ $I0 = repr_get_attr_int self , cur_class , ' $!pos'
241
+ to = box $I0
237
242
setattribute match , ' $!to' , to
238
243
239
244
# Create any arrayed subcaptures.
@@ -378,8 +383,8 @@ Return the cursor's current position.
378
383
.sub ' pos ' :method :subid(' Regex_Cursor_meth_pos ' )
379
384
.local pmc cur_class
380
385
cur_class = get_global ' $?CLASS '
381
- $P0 = getattribute self, cur_class, ' $! pos '
382
- .return ($P0 )
386
+ $I0 = repr_get_attr_int self, cur_class, ' $! pos '
387
+ .return ($I0 )
383
388
.end
384
389
385
390
@@ -392,8 +397,8 @@ Return the cursor's from position.
392
397
. sub ' from' :method :subid (' Regex_Cursor_meth_from' )
393
398
.local pmc cur_class
394
399
cur_class = get_global ' $?CLASS'
395
- $P0 = getattribute self , cur_class , ' $!from'
396
- .return ($P0 )
400
+ $I0 = repr_get_attr_int self , cur_class , ' $!from'
401
+ .return ($I0 )
397
402
.end
398
403
399
404
= back
@@ -423,16 +428,12 @@ Create a new cursor for matching C<target>.
423
428
setattribute cur , cur_class , ' $!target' , $P0
424
429
425
430
if has_cont goto cursor_cont
426
- $P0 = box pos
427
- setattribute cur , cur_class , ' $!from' , $P0
428
- $P0 = box pos
429
- setattribute cur , cur_class , ' $!pos' , $P0
431
+ repr_bind_attr_int cur , cur_class , ' $!from' , pos
432
+ repr_bind_attr_int cur , cur_class , ' $!pos' , pos
430
433
goto cursor_done
431
434
cursor_cont:
432
- $P0 = box CURSOR_FAIL
433
- setattribute cur , cur_class , ' $!from' , $P0
434
- $P0 = box cont
435
- setattribute cur , cur_class , ' $!pos' , $P0
435
+ repr_bind_attr_int cur , cur_class , ' $!from' , CURSOR_FAIL
436
+ repr_bind_attr_int cur , cur_class , ' $!pos' , cont
436
437
cursor_done:
437
438
438
439
.return (cur )
@@ -461,11 +462,12 @@ provided, then the new cursor has the same type as lang.
461
462
regex = getattribute self , cur_class , ' &!regex'
462
463
unless null regex goto cursor_restart
463
464
464
- .local pmc from , target , debug
465
+ .local pmc target , debug
466
+ .local int from
465
467
466
- from = getattribute self , cur_class , ' $!pos'
467
- setattribute cur , cur_class , ' $!from' , from
468
- setattribute cur , cur_class , ' $!pos' , from
468
+ from = repr_get_attr_int self , cur_class , ' $!pos'
469
+ repr_bind_attr_int cur , cur_class , ' $!from' , from
470
+ repr_bind_attr_int cur , cur_class , ' $!pos' , from
469
471
470
472
target = getattribute self , cur_class , ' $!target'
471
473
setattribute cur , cur_class , ' $!target' , target
@@ -475,16 +477,17 @@ provided, then the new cursor has the same type as lang.
475
477
.return (cur , from , target , 0)
476
478
477
479
cursor_restart:
478
- .local pmc pos , cstack , bstack
479
- from = getattribute self , cur_class , ' $!from'
480
+ .local pmc cstack , bstack
481
+ .local int pos
482
+ from = repr_get_attr_int self , cur_class , ' $!from'
480
483
target = getattribute self , cur_class , ' $!target'
481
484
debug = getattribute self , cur_class , ' $!debug'
482
485
cstack = getattribute self , cur_class , ' @!cstack'
483
486
bstack = getattribute self , cur_class , ' @!bstack'
484
- pos = box CURSOR_FAIL
487
+ pos = CURSOR_FAIL
485
488
486
- setattribute cur , cur_class , ' $!from' , from
487
- setattribute cur , cur_class , ' $!pos' , pos
489
+ repr_bind_attr_int cur , cur_class , ' $!from' , from
490
+ repr_bind_attr_int cur , cur_class , ' $!pos' , pos
488
491
setattribute cur , cur_class , ' $!target' , target
489
492
setattribute cur , cur_class , ' $!debug' , debug
490
493
if null cstack goto cstack_done
@@ -506,10 +509,9 @@ Permanently fail this cursor.
506
509
= cut
507
510
508
511
. sub ' !cursor_fail' :method :subid (' Regex_Cursor_meth_!cursor_fail' )
509
- .local pmc cur_class , pos
512
+ .local pmc cur_class
510
513
cur_class = get_global ' $?CLASS'
511
- pos = box CURSOR_FAIL_RULE
512
- setattribute self , cur_class , ' $!pos' , pos
514
+ repr_bind_attr_int self , cur_class , ' $!pos' , CURSOR_FAIL_RULE
513
515
null $P0
514
516
setattribute self , cur_class , ' $!match' , $P0
515
517
setattribute self , cur_class , ' @!bstack' , $P0
@@ -528,13 +530,13 @@ with a "real" Match object when requested.
528
530
= cut
529
531
530
532
. sub ' !cursor_pass' :method :subid (' Regex_Cursor_meth_!cursor_pass' )
531
- .param pmc pos
533
+ .param int pos
532
534
.param string name
533
535
534
536
.local pmc cur_class
535
537
cur_class = get_global ' $?CLASS'
536
538
537
- setattribute self , cur_class , ' $!pos' , pos
539
+ repr_bind_attr_int self , cur_class , ' $!pos' , pos
538
540
.local pmc match
539
541
match = get_global ' $!TRUE'
540
542
setattribute self , cur_class , ' $!match' , match
@@ -615,10 +617,24 @@ Set the cursor's position to C<pos>.
615
617
= cut
616
618
617
619
. sub ' !cursor_pos' :method :subid (' Regex_Cursor_meth_!cursor_pos' )
618
- .param pmc pos
620
+ .param int pos
621
+ .local pmc cur_class
622
+ cur_class = get_global ' $?CLASS'
623
+ repr_bind_attr_int self , cur_class , ' $!pos' , pos
624
+ .end
625
+
626
+
627
+ = item ! cursor_from (pos )
628
+
629
+ Set the cursor ' s from to C<from>.
630
+
631
+ =cut
632
+
633
+ .sub ' ! cursor_from ' :method :subid(' Regex_Cursor_meth_ ! cursor_from ' )
634
+ .param int from
619
635
.local pmc cur_class
620
636
cur_class = get_global ' $?CLASS '
621
- setattribute self , cur_class , ' $!pos ' , pos
637
+ repr_bind_attr_int self, cur_class, ' $! from ' , from
622
638
.end
623
639
624
640
@@ -636,9 +652,10 @@ Log a debug message.
636
652
$P0 = getattribute self, cur_class, ' $! debug '
637
653
if null $P0 goto done
638
654
unless $P0 goto done
639
- .local pmc fmt , from , pos , orig , line
655
+ .local pmc fmt, orig, line
656
+ .local int from
640
657
fmt = new [' ResizablePMCArray ' ]
641
- from = getattribute self , cur_class , ' $!from'
658
+ from = repr_get_attr_int self, cur_class, ' $! from '
642
659
orig = getattribute self, cur_class, ' $! target '
643
660
$P0 = get_hll_global [' HLL ' ], ' Compiler '
644
661
line = $P0.' lineof ' (orig, from, ' cache ' =>1)
0 commit comments