Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add an nqp::p6decont and eliminate pir::perl6_decontainerize in the s…
…etting in favor of it.
  • Loading branch information
jnthn committed Oct 23, 2011
1 parent ee65d38 commit 18dea93
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 65 deletions.
1 change: 1 addition & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -13,6 +13,7 @@ INIT {
p6parcel => 'perl6_parcel_from_rpa__PPP',
p6listiter => 'perl6_iter_from_rpa__PPP',
p6list => 'perl6_list_from_rpa__PPPP',
p6decont => 'perl6_decontainerize__PP',
attrinited => 'repr_is_attr_initialized__IPPs',

istype => 'type_check__IPP',
Expand Down
16 changes: 8 additions & 8 deletions src/core/Attribute.pm
Expand Up @@ -6,15 +6,15 @@ my class Attribute {
my $name := self.name;
my $meth_name := nqp::substr(nqp::unbox_s($name), 2);
unless $package.HOW.declares_method($package, $meth_name) {
my $dcpkg := pir::perl6_decontainerize__PP($package);
my $dcpkg := nqp::p6decont($package);
my $meth;
my int $attr_type = pir::repr_get_primitive_type_spec__IP($!type);
if self.rw {
$meth := nqp::p6bool(nqp::iseq_i($attr_type, 0))
??
method (Mu $self:) is rw {
nqp::getattr(
pir::perl6_decontainerize__PP($self),
nqp::p6decont($self),
$dcpkg,
nqp::unbox_s($name))
}
Expand All @@ -26,7 +26,7 @@ my class Attribute {
??
method (Mu $self:) {
nqp::getattr(
pir::perl6_decontainerize__PP($self),
nqp::p6decont($self),
$dcpkg,
nqp::unbox_s($name))
}
Expand All @@ -36,7 +36,7 @@ my class Attribute {
method (Mu $self:) {
nqp::p6box_i(
nqp::getattr_i(
pir::perl6_decontainerize__PP($self),
nqp::p6decont($self),
$dcpkg,
nqp::unbox_s($name))
);
Expand All @@ -47,7 +47,7 @@ my class Attribute {
method (Mu $self:) {
nqp::p6box_n(
nqp::getattr_n(
pir::perl6_decontainerize__PP($self),
nqp::p6decont($self),
$dcpkg,
nqp::unbox_s($name))
);
Expand All @@ -56,7 +56,7 @@ my class Attribute {
method (Mu $self:) {
nqp::p6box_s(
nqp::getattr_s(
pir::perl6_decontainerize__PP($self),
nqp::p6decont($self),
$dcpkg,
nqp::unbox_s($name))
);
Expand All @@ -77,7 +77,7 @@ my class Attribute {
}

method get_value(Mu $obj) {
my $decont := pir::perl6_decontainerize__PP($obj);
my $decont := nqp::p6decont($obj);
given nqp::p6box_i(pir::repr_get_primitive_type_spec__IP($!type)) {
when 0 { nqp::getattr($decont, $!package, $!name) }
when 1 { nqp::p6box_i(nqp::getattr_i($decont, $!package, $!name)) }
Expand All @@ -87,7 +87,7 @@ my class Attribute {
}

method set_value(Mu $obj, Mu \$value) {
my $decont := pir::perl6_decontainerize__PP($obj);
my $decont := nqp::p6decont($obj);
given nqp::p6box_i(pir::repr_get_primitive_type_spec__IP($!type)) {
when 0 { nqp::bindattr($decont, $!package, $!name, $value) }
when 1 { nqp::p6box_i(nqp::bindattr_i($decont, $!package, $!name, $value)) }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Backtrace.pm
Expand Up @@ -26,7 +26,7 @@ my class Backtrace is List {
proto method new(|$) {*}

multi method new(Exception $e, Int $offset = 0) {
self.new(nqp::getattr(pir::perl6_decontainerize__PP($e), Exception, '$!ex').backtrace, $offset);
self.new(nqp::getattr(nqp::p6decont($e), Exception, '$!ex').backtrace, $offset);
}

# note that parrot backtraces are RPAs, marshalled to us as Parcel
Expand Down
4 changes: 2 additions & 2 deletions src/core/Buf.pm
Expand Up @@ -69,8 +69,8 @@ multi infix:<~>(Buf:D $a, Buf:D $b) {
my Buf $r := nqp::create(Buf);
my Mu $br := pir::new__PS('ByteBuffer');

my Mu $ba := nqp::getattr(pir::perl6_decontainerize__PP($a), Buf, '$!buffer');
my Mu $bb := nqp::getattr(pir::perl6_decontainerize__PP($b), Buf, '$!buffer');
my Mu $ba := nqp::getattr(nqp::p6decont($a), Buf, '$!buffer');
my Mu $bb := nqp::getattr(nqp::p6decont($b), Buf, '$!buffer');
pir::set__vPs($br, nqp::concat_s($ba.get_string('binary'), $bb.get_string('binary')));
nqp::bindattr($r, Buf, '$!buffer', $br);
$r;
Expand Down
64 changes: 32 additions & 32 deletions src/core/Complex.pm
Expand Up @@ -191,20 +191,20 @@ multi sub prefix:<->(Complex:D \$a) returns Complex:D {
my $new := nqp::create(Complex);
nqp::bindattr_n( $new, Complex, '$!re',
nqp::neg_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re')
nqp::getattr_n(nqp::p6decont($a), Complex, '$!re')
)
);
nqp::bindattr_n( $new, Complex, '$!im',
nqp::neg_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im')
nqp::getattr_n(nqp::p6decont($a), Complex, '$!im')
)
);
$new;
}

multi sub prefix:<abs>(Complex:D \$a) {
my num $re = nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re');
my num $im = nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im');
my num $re = nqp::getattr_n(nqp::p6decont($a), Complex, '$!re');
my num $im = nqp::getattr_n(nqp::p6decont($a), Complex, '$!im');
my num $res = pir::sqrt__NN(nqp::add_n(nqp::mul_n($re, $re), nqp::mul_n($im, $im)));
nqp::want(nqp::p6box_n($res), 'Nn', $res);
}
Expand All @@ -213,14 +213,14 @@ multi sub infix:<+>(Complex:D \$a, Complex:D \$b) returns Complex:D {
my $new := nqp::create(Complex);
nqp::bindattr_n( $new, Complex, '$!re',
nqp::add_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re'),
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!re'),
)
);
nqp::bindattr_n( $new, Complex, '$!im',
nqp::add_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im'),
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!im'),
)
);
$new;
Expand All @@ -230,12 +230,12 @@ multi sub infix:<+>(Complex:D \$a, Real \$b) returns Complex:D {
my $new := nqp::create(Complex);
nqp::bindattr_n( $new, Complex, '$!re',
nqp::add_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!re'),
nqp::unbox_n($b.Num)
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!im'),
);
$new
}
Expand All @@ -245,11 +245,11 @@ multi sub infix:<+>(Real \$a, Complex:D \$b) returns Complex:D {
nqp::bindattr_n($new, Complex, '$!re',
nqp::add_n(
nqp::unbox_n($a.Num),
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!im'),
);
$new;
}
Expand All @@ -258,14 +258,14 @@ multi sub infix:<->(Complex:D \$a, Complex:D \$b) returns Complex:D {
my $new := nqp::create(Complex);
nqp::bindattr_n( $new, Complex, '$!re',
nqp::sub_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re'),
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::sub_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im'),
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!im'),
)
);
$new
Expand All @@ -275,12 +275,12 @@ multi sub infix:<->(Complex:D \$a, Real \$b) returns Complex:D {
my $new := nqp::create(Complex);
nqp::bindattr_n( $new, Complex, '$!re',
nqp::sub_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!re'),
$b.Num,
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im')
nqp::getattr_n(nqp::p6decont($a), Complex, '$!im')
);
$new
}
Expand All @@ -290,22 +290,22 @@ multi sub infix:<->(Real \$a, Complex:D \$b) returns Complex:D {
nqp::bindattr_n( $new, Complex, '$!re',
nqp::sub_n(
$a.Num,
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::neg_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im')
nqp::getattr_n(nqp::p6decont($b), Complex, '$!im')
)
);
$new
}

multi sub infix:<*>(Complex:D \$a, Complex:D \$b) returns Complex:D {
my num $a_re = nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re');
my num $a_im = nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im');
my num $b_re = nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re');
my num $b_im = nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im');
my num $a_re = nqp::getattr_n(nqp::p6decont($a), Complex, '$!re');
my num $a_im = nqp::getattr_n(nqp::p6decont($a), Complex, '$!im');
my num $b_re = nqp::getattr_n(nqp::p6decont($b), Complex, '$!re');
my num $b_im = nqp::getattr_n(nqp::p6decont($b), Complex, '$!im');
my $new := nqp::create(Complex);
nqp::bindattr_n($new, Complex, '$!re',
nqp::sub_n(nqp::mul_n($a_re, $b_re), nqp::mul_n($a_im, $b_im)),
Expand All @@ -321,13 +321,13 @@ multi sub infix:<*>(Complex:D \$a, Real \$b) returns Complex:D {
my num $b_num = $b.Num;
nqp::bindattr_n($new, Complex, '$!re',
nqp::mul_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!re'),
$b_num,
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::mul_n(
nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($a), Complex, '$!im'),
$b_num,
)
);
Expand All @@ -340,23 +340,23 @@ multi sub infix:<*>(Real \$a, Complex:D \$b) returns Complex:D {
nqp::bindattr_n($new, Complex, '$!re',
nqp::mul_n(
$a_num,
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::mul_n(
$a_num,
nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont($b), Complex, '$!im'),
)
);
$new
}

multi sub infix:</>(Complex:D \$a, Complex:D \$b) returns Complex:D {
my num $a_re = nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!re');
my num $a_im = nqp::getattr_n(pir::perl6_decontainerize__PP($a), Complex, '$!im');
my num $b_re = nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!re');
my num $b_im = nqp::getattr_n(pir::perl6_decontainerize__PP($b), Complex, '$!im');
my num $a_re = nqp::getattr_n(nqp::p6decont($a), Complex, '$!re');
my num $a_im = nqp::getattr_n(nqp::p6decont($a), Complex, '$!im');
my num $b_re = nqp::getattr_n(nqp::p6decont($b), Complex, '$!re');
my num $b_im = nqp::getattr_n(nqp::p6decont($b), Complex, '$!im');
my num $d = nqp::add_n(nqp::mul_n($b_re, $b_re), nqp::mul_n($b_im, $b_im));
my $new := nqp::create(Complex);
nqp::bindattr_n($new, Complex, '$!re',
Expand Down
2 changes: 1 addition & 1 deletion src/core/Exception.pm
Expand Up @@ -10,7 +10,7 @@ my class Exception {
method throw() {
nqp::bindattr(self, Exception, '$!ex', pir::new('Exception'))
unless pir::defined($!ex);
pir::setattribute__vPsP($!ex, 'payload', pir::perl6_decontainerize__PP(self));
pir::setattribute__vPsP($!ex, 'payload', nqp::p6decont(self));
pir::throw__0P($!ex)
}
method rethrow() {
Expand Down
4 changes: 2 additions & 2 deletions src/core/IO.pm
Expand Up @@ -101,7 +101,7 @@ class IO {

method write(IO:D: Buf:D $buf) {
my Mu $b := nqp::getattr(
pir::perl6_decontainerize__PP($buf),
nqp::p6decont($buf),
Buf,
'$!buffer'
);
Expand Down Expand Up @@ -247,7 +247,7 @@ multi sub mkdir($path as Str, $mode = 0o777) {
$PROCESS::IN = open('-');
$PROCESS::OUT = open('-', :w);
$PROCESS::ERR = IO.new;
nqp::bindattr(pir::perl6_decontainerize__PP($PROCESS::ERR),
nqp::bindattr(nqp::p6decont($PROCESS::ERR),
IO, '$!PIO', pir::getstderr__P());


2 changes: 1 addition & 1 deletion src/core/Iterator.pm
Expand Up @@ -2,7 +2,7 @@ my class Iterator {
# declared in BOOTSTRAP.pm
# is Iterable; # parent class

method iterator() { pir::perl6_decontainerize__PP(self) }
method iterator() { nqp::p6decont(self) }
method list() { (self,).list }
method flat() { (self,).flat }

Expand Down
8 changes: 4 additions & 4 deletions src/core/Junction.pm
Expand Up @@ -63,15 +63,15 @@ sub AUTOTHREAD(&call, **@pos, *%named) {
loop (my $i = 0; $i < +@pos; $i++) {
# Junctional positional argument?
if @pos[$i] ~~ Junction {
my @states := nqp::getattr(pir::perl6_decontainerize__PP(@pos[$i]), Junction, '$!storage');
my @states := nqp::getattr(nqp::p6decont(@pos[$i]), Junction, '$!storage');
my @pre := @pos[0 ..^ $i];
my @post := @pos[$i + 1 ..^ +@pos];
my @result;
for @states -> $s {
push @result, call(|@pre, $s, |@post, |%named);
}
return Junction.new(@result,
:type(nqp::getattr(pir::perl6_decontainerize__PP(@pos[$i]), Junction, '$!type')));
:type(nqp::getattr(nqp::p6decont(@pos[$i]), Junction, '$!type')));
}
}

Expand All @@ -82,13 +82,13 @@ sub AUTOTHREAD(&call, **@pos, *%named) {
for %named.kv -> $kk, $vk {
if $kk ne $k { %other_nameds{$kk} = $vk }
}
my @states := nqp::getattr(pir::perl6_decontainerize__PP($v), Junction, '$!storage');
my @states := nqp::getattr(nqp::p6decont($v), Junction, '$!storage');
my @result;
for @states -> $s {
push @result, call(|@pos, |{ $k => $s }, |%other_nameds);
}
return Junction.new(@result,
:type(nqp::getattr(pir::perl6_decontainerize__PP($v), Junction, '$!type')));
:type(nqp::getattr(nqp::p6decont($v), Junction, '$!type')));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/MapIter.pm
Expand Up @@ -29,8 +29,8 @@ my class MapIter is Iterator {
}
$count = 1 if $count < 1;
my Mu $rpa := nqp::list();
my $list := pir::perl6_decontainerize__PP($!list);
my $block := pir::perl6_decontainerize__PP($!block); ### TODO: Why?
my $list := nqp::p6decont($!list);
my $block := nqp::p6decont($!block); ### TODO: Why?
my $munched := $!list.munch($argc * $count);
my Mu $args := Q:PIR {
.local int count, argc, munchpos
Expand Down
2 changes: 1 addition & 1 deletion src/core/Match.pm
Expand Up @@ -72,7 +72,7 @@ my class Match is Capture is Cool {

sub make(Mu $ast) {
nqp::bindattr(
pir::perl6_decontainerize__PP(pir::find_caller_lex__Ps('$/')),
nqp::p6decont(pir::find_caller_lex__Ps('$/')),
Match,
'$!ast',
$ast
Expand Down
2 changes: 1 addition & 1 deletion src/core/Mu.pm
Expand Up @@ -192,7 +192,7 @@ my class Mu {
}

method clone() {
my $cloned := pir::repr_clone__PP(pir::perl6_decontainerize__PP(self));
my $cloned := pir::repr_clone__PP(nqp::p6decont(self));
# XXX Probably need to clone containery things a level deeper.
$cloned
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Parcel.pm
Expand Up @@ -72,7 +72,7 @@ my class Parcel does Positional {
if nqp::iscont($x) {
# container: scalar assignment
nqp::push($tv, $x);
nqp::push($tv, $rhs.gimme(1) ?? pir::perl6_decontainerize__PP($rhs.shift) !! Nil);
nqp::push($tv, $rhs.gimme(1) ?? nqp::p6decont($rhs.shift) !! Nil);
}
elsif nqp::istype($x, Whatever) {
# Whatever: skip assigning value
Expand Down
2 changes: 1 addition & 1 deletion src/core/Str.pm
Expand Up @@ -468,7 +468,7 @@ my class Str does Stringy {
pir::set__vPs(nqp::getattr($buf, Buf, '$!buffer'),
pir::trans_encoding__ssi(
nqp::unbox_s(self),
pir::find_encoding__is(nqp::unbox_s(pir::perl6_decontainerize__PP($encoding.lc)))
pir::find_encoding__is(nqp::unbox_s(nqp::p6decont($encoding.lc)))
)
);
$buf;
Expand Down

0 comments on commit 18dea93

Please sign in to comment.