Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pull in changes from rakudo d3bd8dfbfe8b282d879643a5b06a724304b8e048
  • Loading branch information
FROGGS committed Aug 19, 2013
1 parent 8e29495 commit 6c54f53
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 32 deletions.
74 changes: 49 additions & 25 deletions lib/Perl5/World.nqp
Expand Up @@ -8,72 +8,96 @@ class Perl5::World {
our sub container_type_info($/, $sigil, @value_type, $shape?) {
my %info;
if $sigil eq '@' {
%info<container_base> := $*W.find_symbol(['Array']);
%info<container_base> := $*W.find_symbol(['Array']);
%info<bind_constraint> := $*W.find_symbol(['Positional']);
if @value_type {
%info<container_type> := $*W.parameterize_type_with_args(
%info<container_type> := $*W.parameterize_type_with_args(
%info<container_base>, [@value_type[0]], nqp::hash());
%info<bind_constraint> := $*W.parameterize_type_with_args(
%info<bind_constraint>, [@value_type[0]], nqp::hash());
%info<value_type> := @value_type[0];
%info<value_type> := @value_type[0];
%info<default_value> := @value_type[0];
}
else {
%info<container_type> := %info<container_base>;
%info<value_type> := $*W.find_symbol(['Mu']);
%info<value_type> := $*W.find_symbol(['Mu']);
%info<default_value> := $*W.find_symbol(['Any']);
}
%info<default_value> := %info<value_type>;
if $shape {
$*W.throw($/, 'X::Comp::NYI', feature => 'Shaped arrays');
}
}
elsif $sigil eq '%' {
%info<container_base> := $*W.find_symbol(['Hash']);
%info<container_base> := $*W.find_symbol(['Hash']);
%info<bind_constraint> := $*W.find_symbol(['Associative']);
if $shape {
@value_type[0] := $*W.find_symbol(['Mu']) unless +@value_type;
my $shape_ast := $shape.ast;
if $shape_ast.isa(QAST::Stmts) && +@($shape_ast) == 1 && $shape_ast[0].has_compile_time_value {
@value_type[1] := $shape_ast[0].compile_time_value;
}
else {
nqp::die("Invalid hash shape; type expected");
@value_type[0] := $*W.find_symbol(['Any']) unless +@value_type;
my $shape_ast := $shape[0].ast;
if $shape_ast.isa(QAST::Stmts) {
if +@($shape_ast) == 1 {
if $shape_ast[0].has_compile_time_value {
@value_type[1] := $shape_ast[0].compile_time_value;
} elsif (my $op_ast := $shape_ast[0]).isa(QAST::Op) {
if $op_ast.op eq "call" && +@($op_ast) == 2 {
if !nqp::isconcrete($op_ast[0].value) && !nqp::isconcrete($op_ast[1].value) {
$*W.throw($/, 'X::Comp::NYI',
feature => "coercive type declarations");
}
}
} else {
$*W.throw($/, "X::Comp::AdHoc",
payload => "Invalid hash shape; type expected");
}
} elsif +@($shape_ast) > 1 {
$*W.throw($/, 'X::Comp::NYI',
feature => "multidimensional shaped hashes");
}
} else {
$*W.throw($/, "X::Comp::AdHoc",
payload => "Invalid hash shape; type expected");
}
}
if @value_type {
%info<container_type> := $*W.parameterize_type_with_args(
%info<container_type> := $*W.parameterize_type_with_args(
%info<container_base>, @value_type, nqp::hash());
%info<bind_constraint> := $*W.parameterize_type_with_args(
%info<bind_constraint>, @value_type, nqp::hash());
%info<value_type> := @value_type[0];
%info<value_type> := @value_type[0];
%info<default_value> := @value_type[0];
}
else {
%info<container_type> := %info<container_base>;
%info<value_type> := $*W.find_symbol(['Mu']);
%info<value_type> := $*W.find_symbol(['Mu']);
%info<default_value> := $*W.find_symbol(['Any']);
}
}
elsif $sigil eq '&' {
%info<container_base> := $*W.find_symbol(['Scalar']);
%info<container_type> := %info<container_base>;
%info<container_base> := $*W.find_symbol(['Scalar']);
%info<container_type> := %info<container_base>;
%info<bind_constraint> := $*W.find_symbol(['Callable']);
if @value_type {
%info<bind_constraint> := $*W.parameterize_type_with_args(
%info<bind_constraint>, [@value_type[0]], nqp::hash());
}
%info<value_type> := %info<bind_constraint>;
%info<default_value> := $*W.find_symbol(['Any']);
%info<value_type> := %info<bind_constraint>;
%info<default_value> := $*W.find_symbol(['Any']);
%info<scalar_value> := $*W.find_symbol(['Any']);
}
else {
%info<container_base> := $*W.find_symbol(['Scalar']);
%info<container_type> := %info<container_base>;
%info<container_base> := $*W.find_symbol(['Scalar']);
%info<container_type> := %info<container_base>;
if @value_type {
%info<bind_constraint> := @value_type[0];
%info<value_type> := @value_type[0];
%info<default_value> := @value_type[0];
%info<value_type> := @value_type[0];
%info<default_value> := @value_type[0];
}
else {
%info<bind_constraint> := $*W.find_symbol(['Mu']);
%info<value_type> := $*W.find_symbol(['Any']);
%info<default_value> := $*W.find_symbol(['Any']);
%info<value_type> := $*W.find_symbol(['Mu']);
%info<default_value> := $*W.find_symbol(['Any']);
}
%info<scalar_value> := %info<default_value>;
}
%info
}
Expand Down
14 changes: 7 additions & 7 deletions rakudo.patch
@@ -1,5 +1,5 @@
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 7ae4968..ae04e8a 100644
index 9f0e4b2..927c9e2 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -820,6 +820,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
Expand Down Expand Up @@ -29,7 +29,7 @@ index 7ae4968..ae04e8a 100644

<.install_doc_phaser>

@@ -1218,10 +1222,18 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
@@ -1225,10 +1229,18 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*IN_DECL := 'use';
:my $*HAS_SELF := '';
:my $*SCOPE := 'use';
Expand All @@ -49,7 +49,7 @@ index 7ae4968..ae04e8a 100644
| <module_name>
{
$longname := $<module_name><longname>;
@@ -1272,6 +1284,15 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
@@ -1279,6 +1291,15 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}
]
]
Expand All @@ -66,10 +66,10 @@ index 7ae4968..ae04e8a 100644
}

diff --git a/src/Perl6/ModuleLoader.nqp b/src/Perl6/ModuleLoader.nqp
index 0059e19..6387950 100644
index 6ee6130..6a45d4f 100644
--- a/src/Perl6/ModuleLoader.nqp
+++ b/src/Perl6/ModuleLoader.nqp
@@ -25,14 +25,31 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
@@ -23,14 +23,31 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
$*CTXSAVE := 0;
}

Expand Down Expand Up @@ -102,7 +102,7 @@ index 0059e19..6387950 100644
return @INC;
}
}
@@ -56,14 +73,14 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
@@ -54,14 +71,14 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
return %language_module_loaders{%opts<from>}.load_module($module_name,
%opts, |@GLOBALish, :$line, :$file);
}
Expand All @@ -121,7 +121,7 @@ index 0059e19..6387950 100644
my @candidates := self.locate_candidates($module_name, @prefixes, :$file);
if +@candidates == 0 {
if nqp::defined($file) {
@@ -145,7 +162,7 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
@@ -143,7 +160,7 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
# Get the compiler and compile the code, then run it
# (which runs the mainline and captures UNIT).
my $?FILES := %chosen<pm>;
Expand Down

0 comments on commit 6c54f53

Please sign in to comment.