Skip to content

Commit 2cd24d0

Browse files
committed
another attempt to get HLL::Compiler to the latest state
1 parent 62c44da commit 2cd24d0

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/HLL/Compiler.pm

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class HLL::Compiler {
300300
my @a := $res.arguments;
301301

302302
%adverbs.update(%opts);
303-
self.usage($program-name) if %adverbs<help>;
303+
self.usage($program-name) if %adverbs<help> || %adverbs<h>;
304304

305305
pir::load_bytecode('dumper.pbc');
306306
pir::load_bytecode('PGE/Dumper.pbc');
@@ -310,14 +310,14 @@ class HLL::Compiler {
310310

311311

312312
method command_eval(*@a, *%adverbs) {
313-
self.version if %adverbs<version>;
313+
self.version if %adverbs<version> || %adverbs<v>;
314314
self.show-config if %adverbs<show-config>;
315315
self.nqpevent(%adverbs<nqpevent>) if %adverbs<nqpevent>;
316316

317317
my $result;
318318
my $error;
319319
my $has_error := 0;
320-
my $target := %adverbs<target>;
320+
my $target := pir::downcase(%adverbs<target>);
321321
try {
322322
if pir::defined(%adverbs<e>) {
323323
$!user_progname := '-e';
@@ -633,25 +633,25 @@ class HLL::Compiler {
633633
634634
# If we've previously cached C<linepos> for target, we use it.
635635
unless cache goto linepos_build
636-
linepos = getprop '!linepos', target
636+
linepos = getprop target, '!linepos'
637637
unless null linepos goto linepos_done
638638
639639
# calculate a new linepos array.
640-
linepos_build:
640+
linepos_build:
641641
linepos = new ['ResizableIntegerArray']
642642
unless cache goto linepos_build_1
643643
setprop target, '!linepos', linepos
644-
linepos_build_1:
644+
linepos_build_1:
645645
.local string s
646646
.local int jpos, eos
647647
s = target
648648
eos = length s
649649
jpos = 0
650650
# Search for all of the newline markers in C<target>. When we
651651
# find one, mark the ending offset of the line in C<linepos>.
652-
linepos_loop:
652+
linepos_loop:
653653
jpos = find_cclass .CCLASS_NEWLINE, s, jpos, eos
654-
unless jpos < eos goto linepos_done
654+
unless jpos < eos goto linepos_done_1
655655
$I0 = ord s, jpos
656656
inc jpos
657657
push linepos, jpos
@@ -661,23 +661,28 @@ class HLL::Compiler {
661661
if $I0 != 10 goto linepos_loop
662662
inc jpos
663663
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
675676
$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)
681686
};
682687
}
683688

0 commit comments

Comments
 (0)