Skip to content

Commit

Permalink
Eliminate nqp::p6decont for plain nqp::decont.
Browse files Browse the repository at this point in the history
We'll attach the Rakudo semantics/optimization directly to the type
using the new container spec handling.
  • Loading branch information
jnthn committed Apr 29, 2013
1 parent 86a475e commit f19881b
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 162 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/Actions.nqp
Expand Up @@ -4441,7 +4441,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
# We may need to decontainerize the right, depending on sigil.
my $sigil := nqp::substr($target.name(), 0, 1);
if $sigil eq '@' || $sigil eq '%' {
$source := QAST::Op.new( :op('p6decont'), $source );
$source := QAST::Op.new( :op('decont'), $source );
}

# Now go by scope.
Expand Down Expand Up @@ -4682,7 +4682,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
$zero
),
QAST::Op.new(
:op('p6decont'),
:op('decont'),
QAST::Var.new( :name($id ~ '_orig'), :scope('local') )
)
)),
Expand Down
6 changes: 3 additions & 3 deletions src/core/AST.pm
Expand Up @@ -10,8 +10,8 @@ my class AST {

method incarnate($quasi_context, @unquote_asts) {
my $incarnation = self.clone();
nqp::bindattr(nqp::p6decont($incarnation), AST, '$!past', $incarnation.evaluate_unquotes(@unquote_asts));
nqp::bindattr(nqp::p6decont($incarnation), AST, '$!quasi_context', $quasi_context);
nqp::bindattr(nqp::decont($incarnation), AST, '$!past', $incarnation.evaluate_unquotes(@unquote_asts));
nqp::bindattr(nqp::decont($incarnation), AST, '$!quasi_context', $quasi_context);
return $incarnation;
}

Expand All @@ -24,7 +24,7 @@ my class AST {
expected => AST,
action => 'unquote evaluation',
).throw unless $_ ~~ AST;
nqp::push($pasts, nqp::getattr(nqp::p6decont($_), AST, '$!past'))
nqp::push($pasts, nqp::getattr(nqp::decont($_), AST, '$!past'))
}
$!past.evaluate_unquotes($pasts);
}
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 := nqp::p6decont($package);
my $dcpkg := nqp::decont($package);
my $meth;
my int $attr_type = nqp::objprimspec($!type);
if self.rw {
$meth := nqp::p6bool(nqp::iseq_i($attr_type, 0))
??
method (Mu $self:) is rw {
nqp::getattr(
nqp::p6decont($self),
nqp::decont($self),
$dcpkg,
nqp::unbox_s($name))
}
Expand All @@ -26,7 +26,7 @@ my class Attribute {
??
method (Mu $self:) {
nqp::getattr(
nqp::p6decont($self),
nqp::decont($self),
$dcpkg,
nqp::unbox_s($name))
}
Expand All @@ -36,7 +36,7 @@ my class Attribute {
method (Mu $self:) {
nqp::p6box_i(
nqp::getattr_i(
nqp::p6decont($self),
nqp::decont($self),
$dcpkg,
nqp::unbox_s($name))
);
Expand All @@ -47,7 +47,7 @@ my class Attribute {
method (Mu $self:) {
nqp::p6box_n(
nqp::getattr_n(
nqp::p6decont($self),
nqp::decont($self),
$dcpkg,
nqp::unbox_s($name))
);
Expand All @@ -56,7 +56,7 @@ my class Attribute {
method (Mu $self:) {
nqp::p6box_s(
nqp::getattr_s(
nqp::p6decont($self),
nqp::decont($self),
$dcpkg,
nqp::unbox_s($name))
);
Expand All @@ -77,7 +77,7 @@ my class Attribute {
}

method get_value(Mu $obj) {
my $decont := nqp::p6decont($obj);
my $decont := nqp::decont($obj);
given nqp::p6box_i(nqp::objprimspec($!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 := nqp::p6decont($obj);
my $decont := nqp::decont($obj);
given nqp::p6box_i(nqp::objprimspec($!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 @@ -28,7 +28,7 @@ my class Backtrace is List {
proto method new(|) {*}

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

multi method new() {
Expand Down
8 changes: 4 additions & 4 deletions src/core/Buf.pm
Expand Up @@ -154,8 +154,8 @@ my class Buf does Positional {

multi infix:<eqv>(Buf:D $a, Buf:D $b) {
$a.WHAT === $b.WHAT && nqp::p6bool(nqp::iseq_s(
nqp::getattr_s(nqp::p6decont($a), Buf, '$!buffer'),
nqp::getattr_s(nqp::p6decont($b), Buf, '$!buffer')
nqp::getattr_s(nqp::decont($a), Buf, '$!buffer'),
nqp::getattr_s(nqp::decont($b), Buf, '$!buffer')
));
}
multi prefix:<~^>(Buf:D $a) {
Expand All @@ -164,8 +164,8 @@ multi prefix:<~^>(Buf:D $a) {
multi infix:<~>(Buf:D $a, Buf:D $b) {
my Buf $r := nqp::create(Buf);

my str $ba = nqp::getattr_s(nqp::p6decont($a), Buf, '$!buffer');
my str $bb = nqp::getattr_s(nqp::p6decont($b), Buf, '$!buffer');
my str $ba = nqp::getattr_s(nqp::decont($a), Buf, '$!buffer');
my str $bb = nqp::getattr_s(nqp::decont($b), Buf, '$!buffer');
nqp::bindattr_s($r, Buf, '$!buffer', nqp::concat_s($ba, $bb));
$r;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/Capture.pm
@@ -1,10 +1,10 @@
my class Capture {
submethod BUILD(:@list, :%hash) {
nqp::bindattr(self, Capture, '$!list',
nqp::getattr(nqp::p6decont(@list.Parcel), Parcel, '$!storage')
nqp::getattr(nqp::decont(@list.Parcel), Parcel, '$!storage')
);
nqp::bindattr(self, Capture, '$!hash',
nqp::getattr(nqp::p6decont(%hash), EnumMap, '$!storage')
nqp::getattr(nqp::decont(%hash), EnumMap, '$!storage')
);
1;
}
Expand Down
64 changes: 32 additions & 32 deletions src/core/Complex.pm
Expand Up @@ -192,35 +192,35 @@ 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(nqp::p6decont(a), Complex, '$!re')
nqp::getattr_n(nqp::decont(a), Complex, '$!re')
)
);
nqp::bindattr_n( $new, Complex, '$!im',
nqp::neg_n(
nqp::getattr_n(nqp::p6decont(a), Complex, '$!im')
nqp::getattr_n(nqp::decont(a), Complex, '$!im')
)
);
$new;
}

multi sub abs(Complex:D \a) returns Num:D {
my num $re = nqp::getattr_n(nqp::p6decont(a), Complex, '$!re');
my num $im = nqp::getattr_n(nqp::p6decont(a), Complex, '$!im');
my num $re = nqp::getattr_n(nqp::decont(a), Complex, '$!re');
my num $im = nqp::getattr_n(nqp::decont(a), Complex, '$!im');
nqp::p6box_n(nqp::sqrt_n(nqp::add_n(nqp::mul_n($re, $re), nqp::mul_n($im, $im))));
}

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(nqp::p6decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont(b), Complex, '$!re'),
nqp::getattr_n(nqp::decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::decont(b), Complex, '$!re'),
)
);
nqp::bindattr_n( $new, Complex, '$!im',
nqp::add_n(
nqp::getattr_n(nqp::p6decont(a), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont(b), Complex, '$!im'),
nqp::getattr_n(nqp::decont(a), Complex, '$!im'),
nqp::getattr_n(nqp::decont(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(nqp::p6decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::decont(a), Complex, '$!re'),
nqp::unbox_n(b.Num)
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::getattr_n(nqp::p6decont(a), Complex, '$!im'),
nqp::getattr_n(nqp::decont(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(nqp::p6decont(b), Complex, '$!re'),
nqp::getattr_n(nqp::decont(b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::getattr_n(nqp::p6decont(b), Complex, '$!im'),
nqp::getattr_n(nqp::decont(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(nqp::p6decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::p6decont(b), Complex, '$!re'),
nqp::getattr_n(nqp::decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::decont(b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::sub_n(
nqp::getattr_n(nqp::p6decont(a), Complex, '$!im'),
nqp::getattr_n(nqp::p6decont(b), Complex, '$!im'),
nqp::getattr_n(nqp::decont(a), Complex, '$!im'),
nqp::getattr_n(nqp::decont(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(nqp::p6decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::decont(a), Complex, '$!re'),
b.Num,
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::getattr_n(nqp::p6decont(a), Complex, '$!im')
nqp::getattr_n(nqp::decont(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(nqp::p6decont(b), Complex, '$!re'),
nqp::getattr_n(nqp::decont(b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::neg_n(
nqp::getattr_n(nqp::p6decont(b), Complex, '$!im')
nqp::getattr_n(nqp::decont(b), Complex, '$!im')
)
);
$new
}

multi sub infix:<*>(Complex:D \a, Complex:D \b) returns Complex:D {
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 $a_re = nqp::getattr_n(nqp::decont(a), Complex, '$!re');
my num $a_im = nqp::getattr_n(nqp::decont(a), Complex, '$!im');
my num $b_re = nqp::getattr_n(nqp::decont(b), Complex, '$!re');
my num $b_im = nqp::getattr_n(nqp::decont(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(nqp::p6decont(a), Complex, '$!re'),
nqp::getattr_n(nqp::decont(a), Complex, '$!re'),
$b_num,
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::mul_n(
nqp::getattr_n(nqp::p6decont(a), Complex, '$!im'),
nqp::getattr_n(nqp::decont(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(nqp::p6decont(b), Complex, '$!re'),
nqp::getattr_n(nqp::decont(b), Complex, '$!re'),
)
);
nqp::bindattr_n($new, Complex, '$!im',
nqp::mul_n(
$a_num,
nqp::getattr_n(nqp::p6decont(b), Complex, '$!im'),
nqp::getattr_n(nqp::decont(b), Complex, '$!im'),
)
);
$new
}

multi sub infix:</>(Complex:D \a, Complex:D \b) returns Complex:D {
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 $a_re = nqp::getattr_n(nqp::decont(a), Complex, '$!re');
my num $a_im = nqp::getattr_n(nqp::decont(a), Complex, '$!im');
my num $b_re = nqp::getattr_n(nqp::decont(b), Complex, '$!re');
my num $b_im = nqp::getattr_n(nqp::decont(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/Enumeration.pm
Expand Up @@ -72,7 +72,7 @@ sub ANON_ENUM(*@args) {
Metamodel::EnumHOW.set_composalizer(-> $type, $name, %enum_values {
my Mu $r := Metamodel::ParametricRoleHOW.new_type(:name($name));
$r.HOW.add_attribute($r, Attribute.new(
:name('$!' ~ $name), :type(nqp::p6decont($type)),
:name('$!' ~ $name), :type(nqp::decont($type)),
:has_accessor(1), :package($r)));
for %enum_values.kv -> $key, $value {
my $meth = method () { self."$name"() === $value }
Expand Down
6 changes: 3 additions & 3 deletions src/core/Exception.pm
Expand Up @@ -23,14 +23,14 @@ my class Exception {
method throw() is hidden_from_backtrace {
nqp::bindattr(self, Exception, '$!ex', pir::new__Ps('Exception'))
unless nqp::defined($!ex);
pir::setattribute__vPsP($!ex, 'payload', nqp::p6decont(self));
pir::setattribute__vPsP($!ex, 'payload', nqp::decont(self));
my $msg := self.?message;
pir::setattribute__0PsP($!ex, 'message', nqp::unbox_s($msg.Str))
if $msg.defined;
nqp::throw($!ex)
}
method rethrow() is hidden_from_backtrace {
pir::setattribute__vPsP($!ex, 'payload', nqp::p6decont(self));
pir::setattribute__vPsP($!ex, 'payload', nqp::decont(self));
nqp::rethrow($!ex)
}

Expand Down Expand Up @@ -213,7 +213,7 @@ do {
$_() for nqp::hllize(@*END_PHASERS);
}
if $! {
pir::perl6_based_rethrow__0PP(nqp::getattr(nqp::p6decont($!), Exception, '$!ex'), $ex);
pir::perl6_based_rethrow__0PP(nqp::getattr(nqp::decont($!), Exception, '$!ex'), $ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Hash.pm
Expand Up @@ -38,7 +38,7 @@ my class Hash {
nqp::push($attrs, '$!descriptor');
nqp::push($attrs, $!descriptor );
nqp::push($attrs, '$!storage' );
nqp::push($attrs, nqp::getattr(nqp::p6decont(self), EnumMap, '$!storage'));
nqp::push($attrs, nqp::getattr(nqp::decont(self), EnumMap, '$!storage'));
self.DUMP-OBJECT-ATTRS($attrs, :$indent-step, :%ctx);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/IO.pm
Expand Up @@ -167,7 +167,7 @@ class IO does IO::FileTestable {

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

my class X::IO::Rename { ... }
Expand Down

0 comments on commit f19881b

Please sign in to comment.