@@ -300,7 +300,7 @@ class HLL::Compiler {
300
300
my @ a := $ res . arguments;
301
301
302
302
% adverbs . update(% opts );
303
- self . usage($ program-name ) if % adverbs <help >;
303
+ self . usage($ program-name ) if % adverbs <help > || % adverbs < h > ;
304
304
305
305
pir::load_bytecode(' dumper.pbc' );
306
306
pir::load_bytecode(' PGE/Dumper.pbc' );
@@ -310,14 +310,14 @@ class HLL::Compiler {
310
310
311
311
312
312
method command_eval (* @ a , * % adverbs ) {
313
- self . version if % adverbs <version >;
313
+ self . version if % adverbs <version > || % adverbs < v > ;
314
314
self . show-config if % adverbs <show-config >;
315
315
self . nqpevent(% adverbs <nqpevent >) if % adverbs <nqpevent >;
316
316
317
317
my $ result ;
318
318
my $ error ;
319
319
my $ has_error := 0 ;
320
- my $ target := % adverbs <target >;
320
+ my $ target := pir::downcase( % adverbs <target >) ;
321
321
try {
322
322
if pir:: defined (% adverbs <e >) {
323
323
$ ! user_progname := ' -e' ;
@@ -633,25 +633,25 @@ class HLL::Compiler {
633
633
634
634
# If we've previously cached C<linepos> for target, we use it.
635
635
unless cache goto linepos_build
636
- linepos = getprop '!linepos', target
636
+ linepos = getprop target, '!linepos'
637
637
unless null linepos goto linepos_done
638
638
639
639
# calculate a new linepos array.
640
- linepos_build :
640
+ linepos_build :
641
641
linepos = new [' ResizableIntegerArray' ]
642
642
unless cache goto linepos_build_1
643
643
setprop target, ' !linepos' , linepos
644
- linepos_build_1:
644
+ linepos_build_1:
645
645
. local string s
646
646
. local int jpos, eos
647
647
s = target
648
648
eos = length s
649
649
jpos = 0
650
650
# Search for all of the newline markers in C<target>. When we
651
651
# find one, mark the ending offset of the line in C<linepos>.
652
- linepos_loop:
652
+ linepos_loop:
653
653
jpos = find_cclass . CCLASS_NEWLINE, s , jpos , eos
654
- unless jpos < eos goto linepos_done
654
+ unless jpos < eos goto linepos_done_1
655
655
$ I0 = ord s , jpos
656
656
inc jpos
657
657
push linepos , jpos
@@ -661,23 +661,28 @@ class HLL::Compiler {
661
661
if $ I0 != 10 goto linepos_loop
662
662
inc jpos
663
663
goto linepos_loop
664
- linepos_done:
665
-
666
- # We have C<linepos>, so now we search the array for the largest
667
- # element that is not greater than C<pos>. The index of that
668
- # element is the line number to be returned.
669
- # (Potential optimization: use a binary search.)
670
- . local int line , count
671
- count = elements linepos
672
- line = 0
673
- line_loop:
674
- if line >= count goto line_done
664
+ linepos_done_1:
665
+ linepos_done:
666
+
667
+ # We have C<linepos>, so now we (binary) search the array
668
+ # for the largest element that is not greater than C<pos>.
669
+ . local int lo , hi, line
670
+ lo = 0
671
+ hi = elements linepos
672
+ binary_loop:
673
+ if lo >= hi goto binary_done
674
+ line = lo + hi
675
+ line = line / 2
675
676
$ I0 = linepos[line]
676
- if $ I0 > pos goto line_done
677
- inc line
678
- goto line_loop
679
- line_done:
680
- . return (line)
677
+ if $ I0 > pos goto binary_hi
678
+ lo = line + 1
679
+ goto binary_loop
680
+ binary_hi:
681
+ hi = line
682
+ goto binary_loop
683
+ binary_done:
684
+ inc lo
685
+ . return (lo)
681
686
};
682
687
}
683
688
0 commit comments