Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Generalize type parameterization. T[...] now calls T.^parameterize(..…

….), and ParametricRoleGroupHOW gets to decide about CurriedRoleHOW, which is now an implementation details.
  • Loading branch information...
commit 7a8679dcb85a97e4418081e0dab6f492de79b695 1 parent 2344572
@jnthn jnthn authored
View
14 src/Perl6/Actions.pm
@@ -2705,18 +2705,18 @@ class Perl6::Actions is HLL::Actions {
}
}
if $all_compile_time {
- my $curried := $*ST.curry_role(%*HOW<role-curried>,
- $role, $<arglist>, $/);
+ my $curried := $*ST.parameterize_type($role, $<arglist>, $/);
$past := $*ST.get_object_sc_ref_past($curried);
$past<has_compile_time_value> := 1;
$past<compile_time_value> := $curried;
}
else {
+ my $rref := $*ST.get_object_sc_ref_past($role);
$past := $<arglist>[0].ast;
$past.pasttype('callmethod');
- $past.name('new_type');
- $past.unshift($*ST.get_object_sc_ref_past($role));
- $past.unshift($*ST.get_object_sc_ref_past(%*HOW<role-curried>));
+ $past.name('parameterize');
+ $past.unshift($rref);
+ $past.unshift(PAST::Op.new( :pirop('get_how PP'), $rref ));
}
}
elsif ~$<longname> eq 'GLOBAL' {
@@ -3475,10 +3475,10 @@ class Perl6::Actions is HLL::Actions {
my $type := $*ST.find_symbol(Perl6::Grammar::parse_name(
Perl6::Grammar::canonical_type_longname($<longname>)));
if $<arglist> {
- $type := $*ST.curry_role(%*HOW<role-curried>, $type, $<arglist>, $/);
+ $type := $*ST.parameterize_type($type, $<arglist>, $/);
}
if $<typename> {
- $type := $*ST.curry_role_with_args(%*HOW<role-curried>, $type,
+ $type := $*ST.parameterize_type_with_args($type,
[$<typename>[0].ast], hash());
}
make $type;
View
1  src/Perl6/Metamodel/EXPORTHOW.pm
@@ -9,7 +9,6 @@ my module EXPORTHOW {
($?PACKAGE.WHO)<role> := Perl6::Metamodel::ParametricRoleHOW;
($?PACKAGE.WHO)<role-attr> := Attribute;
($?PACKAGE.WHO)<role-group> := Perl6::Metamodel::ParametricRoleGroupHOW;
- ($?PACKAGE.WHO)<role-curried> := Perl6::Metamodel::CurriedRoleHOW;
($?PACKAGE.WHO)<grammar> := Perl6::Metamodel::GrammarHOW;
($?PACKAGE.WHO)<grammar-attr> := Attribute;
($?PACKAGE.WHO)<native> := Perl6::Metamodel::NativeHOW;
View
11 src/Perl6/Metamodel/ParametricRoleGroupHOW.pm
@@ -10,6 +10,7 @@
# group of those, and know how to specialize to a certain parameter
# list by multi-dispatching over the set of possibilities to pick
# a particular candidate.
+my $currier := Perl6::Metamodel::CurriedRoleHOW;
class Perl6::Metamodel::ParametricRoleGroupHOW
does Perl6::Metamodel::Naming
does Perl6::Metamodel::Stashing
@@ -36,6 +37,10 @@ class Perl6::Metamodel::ParametricRoleGroupHOW
self.add_stash(pir::repr_type_object_for__PPS($meta, 'Uninstantiable'));
}
+ method parameterize($obj, *@pos_args, *%named_args) {
+ $currier.new_type($obj, |@pos_args, |%named_args)
+ }
+
method add_possibility($obj, $possible) {
@!possibilities[+@!possibilities] := $possible;
@!add_to_selector[+@!add_to_selector] := $possible;
@@ -46,10 +51,10 @@ class Perl6::Metamodel::ParametricRoleGroupHOW
# Locate correct parametric role and type environment.
my $error;
my @result;
- try {
+ #try {
@result := (self.get_selector($obj))(|@pos_args, |%named_args);
- CATCH { $error := $! }
- }
+ # CATCH { $error := $! }
+ #}
if $error {
pir::die("None of the parametric role variants for '" ~
self.name($obj) ~ "' matched the arguments supplied.\n" ~
View
15 src/Perl6/SymbolTable.pm
@@ -1357,7 +1357,7 @@ class Perl6::SymbolTable is HLL::Compiler::SerializationContextBuilder {
}
# Builds a curried role based on a parsed argument list.
- method curry_role($curryhow, $role, $arglist, $/) {
+ method parameterize_type($role, $arglist, $/) {
# Build a list of compile time arguments to the role; whine if
# we find something without one.
my @pos_args;
@@ -1376,21 +1376,22 @@ class Perl6::SymbolTable is HLL::Compiler::SerializationContextBuilder {
}
}
- self.curry_role_with_args($curryhow, $role, @pos_args, %named_args);
+ self.parameterize_type_with_args($role, @pos_args, %named_args);
}
# Curries a role with the specified arguments.
- method curry_role_with_args($curryhow, $role, @pos_args, %named_args) {
+ method parameterize_type_with_args($role, @pos_args, %named_args) {
# Make the curry right away and add it to the SC.
- my $curried := $curryhow.new_type($role, |@pos_args, |%named_args);
+ my $curried := $role.HOW.parameterize($role, |@pos_args, |%named_args);
my $slot := self.add_object($curried);
# Serialize call.
if self.is_precompilation_mode() {
+ my $rref := self.get_object_sc_ref_past($role);
my $setup_call := PAST::Op.new(
- :pasttype('callmethod'), :name('new_type'),
- self.get_object_sc_ref_past($curryhow),
- self.get_object_sc_ref_past($role)
+ :pasttype('callmethod'), :name('parameterize'),
+ PAST::Op.new( :pirop('get_how PP'), $rref ),
+ $rref
);
for @pos_args {
$setup_call.push(self.get_object_sc_ref_past($_));
View
1  src/core/EXPORTHOW.pm
@@ -9,7 +9,6 @@ my module EXPORTHOW {
nqp::bindkey($?PACKAGE.WHO, 'role', Perl6::Metamodel::ParametricRoleHOW);
nqp::bindkey($?PACKAGE.WHO, 'role-attr', Attribute);
nqp::bindkey($?PACKAGE.WHO, 'role-group', Perl6::Metamodel::ParametricRoleGroupHOW);
- nqp::bindkey($?PACKAGE.WHO, 'role-curried', Perl6::Metamodel::CurriedRoleHOW);
nqp::bindkey($?PACKAGE.WHO, 'grammar', Perl6::Metamodel::GrammarHOW);
nqp::bindkey($?PACKAGE.WHO, 'grammar-attr', Attribute);
nqp::bindkey($?PACKAGE.WHO, 'native', Perl6::Metamodel::NativeHOW);
Please sign in to comment.
Something went wrong with that request. Please try again.