diff --git a/src/Perl6/Metamodel/GenericHOW.nqp b/src/Perl6/Metamodel/GenericHOW.nqp index c8cebdec397..6391d3c9948 100644 --- a/src/Perl6/Metamodel/GenericHOW.nqp +++ b/src/Perl6/Metamodel/GenericHOW.nqp @@ -1,12 +1,11 @@ -# A HOW that represents a generic type. It's something of a -# placeholder for a type that we don't actually know yet. -# It sits anywhere that a type could, and possession of one -# of these confers genericity on the holder. +#- Metamodel::GenericHOW ------------------------------------------------------- +# A HOW that represents a generic type. It's something of a placeholder for +# a type that we don't actually know yet. It sits anywhere that a type could, +# and possession of one of these confers genericity on the holder. class Perl6::Metamodel::GenericHOW does Perl6::Metamodel::Naming - does Perl6::Metamodel::BUILDALL { - my $archetypes := Perl6::Metamodel::Archetypes.new( :generic(1) ); + my $archetypes := Perl6::Metamodel::Archetypes.new(:generic); method archetypes($XXX?) { $archetypes } # The name we're created with is both the name we'll claim @@ -14,46 +13,43 @@ class Perl6::Metamodel::GenericHOW # supplied type environment when we want to instantiate # ourself. method new_type(:$name) { - my $meta := self.new(); - my $obj := nqp::settypehll(nqp::newtype($meta, 'Uninstantiable'), 'Raku'); - $meta.set_name($obj, $name); - $obj + my $HOW := nqp::create(self); + my $type := nqp::newtype($HOW, 'Uninstantiable'); + nqp::settypehll($type, 'Raku'); + + $HOW.set_name($type, $name); + $type } method instantiate_generic($target, $type_environment) { - my $found := nqp::null(); - my $name := self.name($target); - my $te-kind := $type_environment.HOW.name($type_environment); + my str $name := self.name($target); + my str $kind := $type_environment.HOW.name($type_environment); + #?if !jvm - if $te-kind eq 'BOOTContext' { + my $found := $kind eq 'BOOTContext' #?endif #?if jvm - if $te-kind eq 'ContextRef' { + my $found := $kind eq 'ContextRef' { #?endif - $found := nqp::getlexrel($type_environment, $name); - } - elsif $te-kind eq 'BOOTHash' { - $found := nqp::atkey($type_environment, $name); - } - elsif nqp::isconcrete($type_environment) && $type_environment.EXISTS-KEY($name) { - $found := nqp::decont($type_environment.AT-KEY($name)); - } - nqp::isnull($found) - ?? $target - !! $found.HOW.archetypes($found).generic - ?? $found.HOW.instantiate_generic($found, $type_environment) - !! $found - } + ?? nqp::getlexrel($type_environment, $name) + !! $kind eq 'BOOTHash' + ?? nqp::atkey($type_environment, $name) + !! nqp::isconcrete($type_environment) + && $type_environment.EXISTS-KEY($name) + ?? nqp::decont($type_environment.AT-KEY($name)) + !! nqp::null; - method compose($target) { $target } - - method find_method($XXX, $name, *%c) { - nqp::null() + nqp::isnull($found) + ?? $target + !! $found.HOW.archetypes($found).generic + ?? $found.HOW.instantiate_generic($found, $type_environment) + !! $found } - method type_check($XXX, $checkee) { - 0 - } + # General methods that are expected to work + method compose($target) { $target } + method find_method($XXX, $name, *%_) { nqp::null } + method type_check($XXX, $checkee) { 0 } } # vim: expandtab sw=4