Skip to content

Commit

Permalink
Substitute several more pir ops by their nqp op counterparts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristof authored and kristof committed Jun 22, 2011
1 parent 9ccc8eb commit b54894d
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/Actions.pm
Expand Up @@ -2848,7 +2848,7 @@ class Perl6::Actions is HLL::Actions {
# steals spaces after a postfixish. Thus "$a $b" would get messed up.
# Here we take them back again. Hacky, better solutions welcome.
sub steal_back_spaces($/, $expr) {
my $pos := pir::length__IS($/) - 1;
my $pos := nqp::chars($/) - 1;
while pir::is_cclass__IISI(32, $/, $pos) {
$pos--;
}
Expand Down Expand Up @@ -3320,7 +3320,7 @@ class Perl6::Actions is HLL::Actions {
# the $usage parameter to make it more helpful.
sub compile_time_value_str($past, $usage, $/) {
if $past<has_compile_time_value> {
pir::repr_unbox_str__SP($past<compile_time_value>);
nqp::unbox_s($past<compile_time_value>);
}
else {
$/.CURSOR.panic("$usage must have a value known at compile time");
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -1730,7 +1730,7 @@ grammar Perl6::Grammar is HLL::Grammar {
sub bracket_ending($matches) {
my $check := $matches[+$matches - 1];
my $str := $check.Str;
my $last := pir::substr($str, pir::length__IS($check) - 1, 1);
my $last := pir::substr($str, nqp::chars($check) - 1, 1);
$last eq ')' || $last eq '}' || $last eq ']' || $last eq '>'
}

Expand Down
6 changes: 3 additions & 3 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -46,15 +46,15 @@ Mu.HOW.add_parrot_vtable_mapping(Mu, 'get_bool',
sub ($self) { $self.Bool() });
Mu.HOW.add_parrot_vtable_mapping(Mu, 'get_integer',
sub ($self) {
pir::repr_unbox_int__IP($self.Int())
nqp::unbox_i($self.Int())
});
Mu.HOW.add_parrot_vtable_mapping(Mu, 'get_number',
sub ($self) {
pir::repr_unbox_num__NP($self.Num())
nqp::unbox_n($self.Num())
});
Mu.HOW.add_parrot_vtable_mapping(Mu, 'get_string',
sub ($self) {
pir::repr_unbox_str__SP($self.Str())
nqp::unbox_s($self.Str())
});
Mu.HOW.add_parrot_vtable_mapping(Mu, 'defined',
sub ($self) { pir::istrue__IP($self.defined()) });
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Module/Loader.pm
Expand Up @@ -30,7 +30,7 @@ method need($name, %name_adverbs?) {
# Need not load file if we already did so.
unless %LOADED{$pm_file} {
# Is there a pre-compiled PIR version?
my $pir_file := pir::substr__SSII($pm_file, 0, pir::index__ISSi($pm_file, '.', pir::length__IS($pm_file)-4)) ~ '.pir';
my $pir_file := pir::substr__SSII($pm_file, 0, pir::index__ISSi($pm_file, '.', nqp::chars($pm_file)-4)) ~ '.pir';
my $loaded_pir := 0;
# stat[7]: modifytime
if pir::stat__ISI($pir_file, 0)
Expand Down
16 changes: 8 additions & 8 deletions src/Perl6/Module/Locator.pm
Expand Up @@ -8,29 +8,29 @@ method find_candidates($lookfor, @inc) {
my @dirs := pir::split__PSS('::', $lookfor);
my $file := @dirs.pop();
my $localpath := +@dirs ?? pir::join__SSP('/', @dirs) ~ '/' !! '';
# pir::say("\nlookfor: $lookfor\nlocalpath: $localpath\nfile: $file");
# nqp::say("\nlookfor: $lookfor\nlocalpath: $localpath\nfile: $file");

# within each @inc path look for "$localpath/$file.pm"
my @candidates;
for @inc {
my $path := "$_/$localpath";
# pir::say(" path: $path");
my $check_path := pir::substr__SSII($path, 0, pir::length__IS($path) - 1);
# nqp::say(" path: $path");
my $check_path := pir::substr__SSII($path, 0, nqp::chars($path) - 1);
if pir::stat__ISI($check_path, 0) && pir::stat__ISI($check_path, 2) {
my @dir := pir::new__PS('OS').readdir($path);
my $candidate := "";
for @dir {
# pir::say(" readdir: $_");
if pir::substr__SSII($_, 0, pir::length__IS($file) + 1) eq $file ~ '.' {
if pir::substr__SSII($_, pir::length__IS($_) - 4, 4) eq '.pm6' ||
!$candidate && pir::substr__SSII($_, pir::length__IS($_) - 3, 3) eq '.pm' {
# nqp::say(" readdir: $_");
if pir::substr__SSII($_, 0, nqp::chars($file) + 1) eq $file ~ '.' {
if pir::substr__SSII($_, nqp::chars($_) - 4, 4) eq '.pm6' ||
!$candidate && pir::substr__SSII($_, nqp::chars($_) - 3, 3) eq '.pm' {
$candidate := "$path$_";
}
}
}
if $candidate {
@candidates.push($candidate);
# pir::say(" found: $candidate");
# nqp::say(" found: $candidate");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Array.pm
Expand Up @@ -23,7 +23,7 @@ class Array {
method STORE(|$) {
# get arguments, shift off invocant
my $args := pir::perl6_current_args_rpa__P();
pir::shift__PP($args);
nqp::shift($args);
# clear our current items, and create a flattening iterator
# that will bring in values from $args
pir::setattribute__vPPsP(self, List, '$!items', Mu);
Expand Down
10 changes: 5 additions & 5 deletions src/core/Cool.pm
Expand Up @@ -4,7 +4,7 @@ my class Cool {
}

method chars() {
nqp::p6box_i(pir::length__IS(nqp::unbox_s(self.Str)));
nqp::p6box_i(nqp::chars(nqp::unbox_s(self.Str)));
}

method substr($start as Int, $length?) {
Expand All @@ -29,11 +29,11 @@ my class Cool {
}

method uc() {
nqp::p6box_s(pir::upcase__SS(nqp::unbox_s(self.Str)))
nqp::p6box_s(nqp::uc(nqp::unbox_s(self.Str)))
}

method lc() {
nqp::p6box_s(pir::downcase__SS(nqp::unbox_s(self.Str)))
nqp::p6box_s(nqp::lc(nqp::unbox_s(self.Str)))
}

method ucfirst() {
Expand All @@ -47,7 +47,7 @@ my class Cool {
}

method ord() {
nqp::p6box_i(pir::ord__IS(nqp::unbox_s(self.Str)))
nqp::p6box_i(nqp::ord(nqp::unbox_s(self.Str)))
}

method flip() {
Expand All @@ -56,7 +56,7 @@ my class Cool {

proto method index(|$) {*}
multi method index(Cool \$needle, Cool $pos = 0) {
my $result := nqp::p6box_i(pir::index__ISSI(
my $result := nqp::p6box_i(nqp::index(
nqp::unbox_s(self.Str),
nqp::unbox_s($needle.Str),
nqp::unbox_i($pos.Int)
Expand Down
6 changes: 3 additions & 3 deletions src/core/EnumMap.pm
Expand Up @@ -5,7 +5,7 @@ my class EnumMap {
method exists(Str \$key) {
nqp::p6bool(
pir::defined($!storage)
&& pir::exists__IQs($!storage, nqp::unbox_s($key))
&& nqp::existskey($!storage, nqp::unbox_s($key))
)
}

Expand All @@ -20,15 +20,15 @@ my class EnumMap {
my Mu $iter := pir::iter__PP($!storage);
my Mu $pair;
while $iter {
$pair := pir::shift__PP($iter);
$pair := nqp::shift($iter);
take Pair.new(:key($pair.key), :value($pair.value));
}
}
}

method at_key(Str \$key) {
self.exists($key)
?? pir::set__PQs($!storage, nqp::unbox_s($key))
?? nqp::atkey($!storage, nqp::unbox_s($key))
!! Any
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/IO.pm
@@ -1,7 +1,7 @@
# XXX Relatively cheaty, just to get us able to output something.
# But you should see what USED to be here! O.O
sub print(*@list) {
pir::print(@list.shift) while @list.gimme(1);
nqp::print(@list.shift) while @list.gimme(1);
1.Bool
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/List.pm
Expand Up @@ -16,7 +16,7 @@ class List {

method at_pos(\$pos) {
self.exists($pos)
?? pir::set__PQi($!items, nqp::unbox_i($pos))
?? nqp::atpos($!items, nqp::unbox_i($pos))
!! Mu
}

Expand All @@ -31,7 +31,7 @@ class List {

method exists(\$pos) {
self.gimme($pos + 1);
nqp::p6bool(pir::exists__IQI($!items, nqp::unbox_i($pos)))
nqp::p6bool(nqp::existspos($!items, nqp::unbox_i($pos)))
}

method flat() {
Expand Down Expand Up @@ -76,7 +76,7 @@ class List {
method munch($n is copy) {
self.gimme($n);
my Mu $rpa := pir::new__Ps('ResizablePMCArray');
pir::push__vPP($rpa, pir::shift__PP($!items))
pir::push__vPP($rpa, nqp::shift($!items))
while $!items && $n-- > 0;
pir__perl6_box_rpa__PP($rpa)
}
Expand All @@ -89,7 +89,7 @@ class List {

method shift() {
# make sure we have at least one item, then shift+return it
self.gimme(1) && pir::shift__PP($!items)
self.gimme(1) && nqp::shift($!items)
}

multi method perl(List:D \$self:) {
Expand All @@ -99,7 +99,7 @@ class List {
}

method STORE_AT_POS(\$pos, Mu \$v) {
pir::set__1QiP($!items, nqp::unbox_i($pos), $v)
nqp::bindpos($!items, nqp::unbox_i($pos), $v)
}

method RPA() {
Expand Down
20 changes: 10 additions & 10 deletions src/core/ListIter.pm
Expand Up @@ -13,7 +13,7 @@ my class ListIter {
my $flattens = $!list.defined && $!list.flattens;
my $eager = Whatever.ACCEPTS($n);
while $!rest && ($eager || $n > 0) {
$x := pir::set__PQi($!rest, 0);
$x := nqp::atpos($!rest, 0);
if pir::not__II(pir::is_container__IP($x)) && $x.defined
&& Iterable.ACCEPTS($x) {
last if $eager && $x.infinite;
Expand All @@ -29,9 +29,9 @@ my class ListIter {
pir__perl6_unbox_rpa__PP($x),
0, 1);
}
elsif Nil.ACCEPTS($x) { pir::shift__PP($!rest) }
elsif Nil.ACCEPTS($x) { nqp::shift($!rest) }
else {
pir::shift__PP($!rest);
nqp::shift($!rest);
$x := $!list.STORE_AT_POS($pos, $x) if $!list.defined;
pir::push__vPP($rpa, $x);
$eager or $n = $n - 1;
Expand All @@ -55,8 +55,8 @@ my class ListIter {

method infinite() {
$!rest
?? Iterable.ACCEPTS(pir::set__PQi($!rest,0))
&& pir::set__PQi($!rest,0).infinite
?? Iterable.ACCEPTS(nqp::atpos($!rest,0))
&& nqp::atpos($!rest,0).infinite
|| Mu
!! 0.Bool
}
Expand All @@ -79,9 +79,9 @@ my class ListIter {
# we leave these here for documentation purposes.
# sub pir::perl6_list_from_rpa__PPPP(|$) {
# my $args := pir::perl6_current_args_rpa__P();
# my $type := pir::shift__PP($args);
# my Mu $rpa := pir::shift__PP($args);
# my $flattens := pir::shift__PP($args);
# my $type := nqp::shift($args);
# my Mu $rpa := nqp::shift($args);
# my $flattens := nqp::shift($args);
#
# my $list := pir::repr_instance_of__PP($type);
# pir::setattribute__vPPsP($list, $type, '$!flattens', $flattens);
Expand All @@ -92,8 +92,8 @@ my class ListIter {
#
# sub pir::perl6_iter_from_rpa__PPP(|$) {
# my $args := pir::perl6_current_args_rpa__P();
# my Mu $rpa := pir::shift__PP($args);
# my $list := pir::shift__PP($args);
# my Mu $rpa := nqp::shift($args);
# my $list := nqp::shift($args);
#
# pir::setattribute__0PPsP(
# pir::setattribute__0PPsP(
Expand Down
4 changes: 2 additions & 2 deletions src/core/Mu.pm
Expand Up @@ -60,14 +60,14 @@ my class Mu {

sub DUMP(|$) {
my Mu $args := pir::perl6_current_args_rpa__P();
my Mu $topic := pir::shift__PP($args);
my Mu $topic := nqp::shift($args);
if pir::isnull__IP($topic) { '(null)' }
elsif pir::isa__IPs($topic, 'ResizablePMCArray') {
my $s = 'RPA<' ~ nqp::p6box_s(pir::get_addr__IP($topic)) ~ '>(';
my $t = '';
$topic := pir::clone__PP($topic);
while $topic {
my Mu $x := pir::shift__PP($topic);
my Mu $x := nqp::shift($topic);
$s = $s ~ $t ~ DUMP($x);
$t = ', ';
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/Parcel.pm
Expand Up @@ -12,17 +12,17 @@ my class Parcel {
multi method gist(Parcel:D:) {
my @gist;
my Mu $rpa := pir::clone__PP($!storage);
@gist.push( pir::shift__PP($rpa).gist ) while $rpa;
@gist.push( nqp::shift($rpa).gist ) while $rpa;
@gist;
}

multi method perl(Parcel:D:) {
my Mu $rpa := pir::clone($!storage);
my $perl = '(';
if $rpa {
$perl = $perl ~ pir::shift__PP($rpa).perl;
$perl = $perl ~ nqp::shift($rpa).perl;
if $rpa {
$perl = $perl ~ ', ' ~ pir::shift__PP($rpa).perl while $rpa;
$perl = $perl ~ ', ' ~ nqp::shift($rpa).perl while $rpa;
}
else {
$perl = $perl ~ ',';
Expand Down Expand Up @@ -65,7 +65,7 @@ sub pir__perl6_box_rpa__PP(|$) {
pir::repr_instance_of__PP(Parcel),
Parcel,
'$!storage',
pir::shift__PP(pir::perl6_current_args_rpa__P()))
nqp::shift(pir::perl6_current_args_rpa__P()))
}

sub pir__perl6_unbox_rpa__PP(\$parcel) {
Expand Down
12 changes: 6 additions & 6 deletions src/core/Str.pm
Expand Up @@ -37,27 +37,27 @@ multi infix:<~>(Str \$a, Str \$b) {
}

multi infix:<eq>(Str \$a, Str \$b) {
nqp::p6bool(pir::iseq__ISS(nqp::unbox_s($a), nqp::unbox_s($b)))
nqp::p6bool(nqp::iseq_s(nqp::unbox_s($a), nqp::unbox_s($b)))
}

multi infix:<ne>(Str \$a, Str \$b) {
nqp::p6bool(pir::isne__ISS(nqp::unbox_s($a), nqp::unbox_s($b)))
nqp::p6bool(nqp::isne_s(nqp::unbox_s($a), nqp::unbox_s($b)))
}

multi infix:<lt>(Str \$a, Str \$b) {
nqp::p6bool(pir::islt__ISS(nqp::unbox_s($a), nqp::unbox_s($b)))
nqp::p6bool(nqp::islt_s(nqp::unbox_s($a), nqp::unbox_s($b)))
}

multi infix:<le>(Str \$a, Str \$b) {
nqp::p6bool(pir::isle__ISS(nqp::unbox_s($a), nqp::unbox_s($b)))
nqp::p6bool(nqp::isle_s(nqp::unbox_s($a), nqp::unbox_s($b)))
}

multi infix:<gt>(Str \$a, Str \$b) {
nqp::p6bool(pir::isgt__ISS(nqp::unbox_s($a), nqp::unbox_s($b)))
nqp::p6bool(nqp::isgt_s(nqp::unbox_s($a), nqp::unbox_s($b)))
}

multi infix:<ge>(Str \$a, Str \$b) {
nqp::p6bool(pir::isge__ISS(nqp::unbox_s($a), nqp::unbox_s($b)))
nqp::p6bool(nqp::isge_s(nqp::unbox_s($a), nqp::unbox_s($b)))
}


Expand Down

0 comments on commit b54894d

Please sign in to comment.