Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some more pir:: => nqp:: in the MOP/BOOTSTRAP.
  • Loading branch information
jnthn committed Apr 10, 2013
1 parent 400fb2c commit 9642243
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/Perl6/Metamodel/Archetypes.pm
@@ -1,3 +1,5 @@
use Perl6::Ops;

# Provides various properties of the type of type a given meta-object
# implements. This are used in various ways by the compiler and meta-model
# to do correct code generation or to detect illegal use of types in
Expand Down
38 changes: 18 additions & 20 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -174,31 +174,29 @@ BEGIN {
Attribute, '$!auto_viv_container');
}));
Attribute.HOW.add_method(Attribute, 'has_accessor', static(sub ($self) {
pir::perl6_booleanize__PI(
nqp::getattr_i(nqp::decont($self),
Attribute, '$!has_accessor'));
nqp::p6bool(nqp::getattr_i(nqp::decont($self),
Attribute, '$!has_accessor'));
}));
Attribute.HOW.add_method(Attribute, 'rw', static(sub ($self) {
pir::perl6_booleanize__PI(
nqp::getattr_i(nqp::decont($self),
Attribute, '$!rw'));
nqp::p6bool(nqp::getattr_i(nqp::decont($self),
Attribute, '$!rw'));
}));
Attribute.HOW.add_method(Attribute, 'set_rw', static(sub ($self) {
nqp::bindattr_i(nqp::decont($self),
Attribute, '$!rw', 1);
pir::perl6_booleanize__PI(1)
nqp::p6bool(1)
}));
Attribute.HOW.add_method(Attribute, 'set_readonly', static(sub ($self) {
nqp::bindattr_i(nqp::decont($self),
Attribute, '$!ro', 1);
pir::perl6_booleanize__PI(1)
nqp::p6bool(1)
}));
Attribute.HOW.add_method(Attribute, 'default_to_rw', static(sub ($self) {
my $dcself := nqp::decont($self);
unless nqp::getattr_i($dcself, Attribute, '$!ro') {
nqp::bindattr_i($dcself, Attribute, '$!rw', 1);
}
pir::perl6_booleanize__PI(1)
nqp::p6bool(1)
}));
Attribute.HOW.add_method(Attribute, 'set_build', static(sub ($self, $closure) {
nqp::bindattr(nqp::decont($self), Attribute, '$!build_closure', $closure);
Expand All @@ -211,7 +209,7 @@ BEGIN {
Attribute.HOW.add_method(Attribute, 'set_box_target', static(sub ($self) {
nqp::bindattr_i(nqp::decont($self),
Attribute, '$!box_target', 1);
pir::perl6_booleanize__PI(1)
nqp::p6bool(1)
}));
Attribute.HOW.add_method(Attribute, 'box_target', static(sub ($self) {
nqp::getattr_i(nqp::decont($self),
Expand All @@ -225,7 +223,7 @@ BEGIN {
Attribute, '$!package');
my $build := nqp::getattr(nqp::decont($dcself),
Attribute, '$!build_closure');
pir::perl6_booleanize__PI($type.HOW.archetypes.generic || $package.HOW.archetypes.generic || nqp::defined($build));
nqp::p6bool($type.HOW.archetypes.generic || $package.HOW.archetypes.generic || nqp::defined($build));
}));
Attribute.HOW.add_method(Attribute, 'instantiate_generic', static(sub ($self, $type_environment) {
my $dcself := nqp::decont($self);
Expand All @@ -240,7 +238,7 @@ BEGIN {
$type.HOW.instantiate_generic($type, $type_environment));
my $cd_ins := $cd.instantiate_generic($type_environment);
nqp::bindattr($ins, Attribute, '$!container_descriptor', $cd_ins);
my $avc_var := pir::perl6_var__PP($avc);
my $avc_var := nqp::p6var($avc);
my $avc_copy := nqp::clone($avc_var);
my @avc_mro := $avc_var.HOW.mro($avc_var);
my $i := 0;
Expand Down Expand Up @@ -301,10 +299,10 @@ BEGIN {
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!STORE>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_method(Proxy, 'FETCH', ($PROXY_FETCH := static(sub ($cont) {
nqp::decont(
nqp::getattr($cont, Proxy, '&!FETCH')(pir::perl6_var__PP($cont)))
nqp::getattr($cont, Proxy, '&!FETCH')(nqp::p6var($cont)))
})));
Proxy.HOW.add_method(Proxy, 'STORE', static(sub ($cont, $val) {
nqp::getattr($cont, Proxy, '&!STORE')(pir::perl6_var__PP($cont), $val)
nqp::getattr($cont, Proxy, '&!STORE')(nqp::p6var($cont), $val)
}));
Proxy.HOW.add_method(Proxy, 'new', static(sub ($type, :$FETCH, :$STORE) {
my $cont := nqp::create(Proxy);
Expand Down Expand Up @@ -350,7 +348,7 @@ BEGIN {
my $is_generic := $_.is_generic();
if $is_generic { return $is_generic }
}
return pir::perl6_booleanize__PI(0);
return nqp::p6bool(0);
}));
Signature.HOW.add_method(Signature, 'instantiate_generic', static(sub ($self, $type_environment) {
# Go through parameters, builidng new list. If any
Expand All @@ -375,7 +373,7 @@ BEGIN {
Signature, '$!returns', nqp::decont($type));
}));
Signature.HOW.add_method(Signature, 'has_returns', static(sub ($self) {
pir::perl6_booleanize__PI(
nqp::p6bool(
nqp::not_i(
nqp::isnull(
nqp::getattr(nqp::decont($self),
Expand Down Expand Up @@ -417,7 +415,7 @@ BEGIN {
Parameter.HOW.add_method(Parameter, 'is_generic', static(sub ($self) {
# If nonimnal type is generic, so are we.
my $type := nqp::getattr($self, Parameter, '$!nominal_type');
pir::perl6_booleanize__PI($type.HOW.archetypes.generic)
nqp::p6bool($type.HOW.archetypes.generic)
}));
Parameter.HOW.add_method(Parameter, 'instantiate_generic', static(sub ($self, $type_environment) {
# Clone with the type instantiated.
Expand Down Expand Up @@ -596,7 +594,7 @@ BEGIN {
Routine.HOW.add_method(Routine, 'is_dispatcher', static(sub ($self) {
my $dc_self := nqp::decont($self);
my $disp_list := nqp::getattr($dc_self, Routine, '$!dispatchees');
pir::perl6_booleanize__PI(nqp::defined($disp_list));
nqp::p6bool(nqp::defined($disp_list));
}));
Routine.HOW.add_method(Routine, 'add_dispatchee', static(sub ($self, $dispatchee) {
my $dc_self := nqp::decont($self);
Expand Down Expand Up @@ -1066,7 +1064,7 @@ BEGIN {
$new_possibles := [] unless nqp::islist($new_possibles);

my $sig := nqp::getattr($sub, Code, '$!signature');
if pir::perl6_is_sig_bindable__IPP($sig, $capture) {
if nqp::p6isbindable($sig, $capture) {
nqp::push($new_possibles, nqp::atpos(@possibles, $i));
unless $many {
# Terminate the loop.
Expand Down Expand Up @@ -1870,7 +1868,7 @@ nqp::sethllconfig('perl6', nqp::hash(
'foreign_type_num', Num,
'foreign_type_str', Str,
'foreign_transform_array', -> $array {
pir::perl6_parcel_from_rpa__PPP($array, Mu)
nqp::p6parcel($array, Mu)
},
'foreign_transform_hash', -> $hash {
my $result := nqp::create(Hash);
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Metamodel/MROBasedTypeChecking.pm
Expand Up @@ -8,7 +8,7 @@ role Perl6::Metamodel::MROBasedTypeChecking {
}

method does($obj, $type) {
pir::perl6_booleanize__Pi(nqp::istype($obj, $type))
nqp::p6bool(nqp::istype($obj, $type))
}

method type_check($obj, $checkee) {
Expand Down
4 changes: 2 additions & 2 deletions src/Perl6/Metamodel/SubsetHOW.pm
Expand Up @@ -61,13 +61,13 @@ class Perl6::Metamodel::SubsetHOW

# Do check when we're on LHS of smartmatch (e.g. Even ~~ Int).
method type_check($obj, $checkee) {
pir::perl6_booleanize__PI(nqp::istrue($checkee.HOW =:= self) ||
nqp::p6bool(nqp::istrue($checkee.HOW =:= self) ||
nqp::istype($!refinee, $checkee))
}

# Here we check the value itself (when on RHS on smartmatch).
method accepts_type($obj, $checkee) {
pir::perl6_booleanize__PI(
nqp::p6bool(
nqp::istype($checkee, $!refinee) &&
nqp::istrue($!refinement.ACCEPTS($checkee)))
}
Expand Down
12 changes: 10 additions & 2 deletions src/Perl6/Ops.pm
Expand Up @@ -39,7 +39,7 @@ $ops.add_hll_op('perl6', 'p6getcallsig', -> $qastcomp, $op {
$ops.push_pirop('set', $reg, 'CALL_SIG');
$ops
});
$ops.add_hll_op('perl6', 'p6bool', :inlinable(1), -> $qastcomp, $op {
my $p6bool := -> $qastcomp, $op {
my $cpost := $qastcomp.as_post($op[0]);
my $reg := $*REGALLOC.fresh_p();
my $ops := $qastcomp.post_new('Ops', :result($reg));
Expand All @@ -53,7 +53,15 @@ $ops.add_hll_op('perl6', 'p6bool', :inlinable(1), -> $qastcomp, $op {
$ops.push_pirop('perl6_booleanize', $reg, $reg_i);
}
$ops
});
}
$ops.add_hll_op('perl6', 'p6bool', :inlinable(1), $p6bool);

# Make some of them also available from NQP land, since we use them in the
# metamodel and bootstrap.
$ops.add_hll_op('nqp', 'p6bool', :inlinable(1), $p6bool);
$ops.add_hll_pirop_mapping('nqp', 'p6var', 'perl6_var', 'PP', :inlinable(1));
$ops.add_hll_pirop_mapping('nqp', 'p6parcel', 'perl6_parcel_from_rpa', 'PPP', :inlinable(1));
$ops.add_hll_pirop_mapping('nqp', 'p6isbindable', 'perl6_is_sig_bindable', 'IPP');

# Override defor to avoid v-table call.
$ops.add_hll_op('perl6', 'defor', :inlinable(1), -> $qastcomp, $op {
Expand Down

0 comments on commit 9642243

Please sign in to comment.