-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- don't bother with BUILDALL, since the only attributes that need to be set, are set with set_name already - some re-arranging of ifs to ternaries
- Loading branch information
Showing
1 changed file
with
32 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,55 @@ | ||
# 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 | ||
# to be if asked, but also the name we'll look up in a | ||
# 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 |