From 8d9598e3ca7ffd599956d6e246bd60f7758565f9 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 21:39:10 +0100 Subject: [PATCH 01/11] Various corrections to handling of where clauses and type captures, which was the main issue we faced in getting us doing most of S06-multi/type-based.t again. --- src/Perl6/Compiler/Parameter.pm | 11 ++++++++++- src/Perl6/Compiler/Signature.pm | 6 +++--- src/binder/bind.c | 5 +++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Perl6/Compiler/Parameter.pm b/src/Perl6/Compiler/Parameter.pm index 5a3b2f9c168..a230f6df1ab 100644 --- a/src/Perl6/Compiler/Parameter.pm +++ b/src/Perl6/Compiler/Parameter.pm @@ -86,7 +86,16 @@ method default_from_outer($default_from_outer?) { } method nom_type($nom_type?) { - if $nom_type { $!nom_type := $nom_type } + if $nom_type { + if $nom_type.isa(PAST::Op) && $nom_type.name() eq 'new' { + # It's a thunk (cretion of a new code block); we'll make this + # a constraint. + self.cons_types.push($nom_type) + } + else { + $!nom_type := $nom_type + } + } $!nom_type } diff --git a/src/Perl6/Compiler/Signature.pm b/src/Perl6/Compiler/Signature.pm index a1b514e5733..3ba94971e89 100644 --- a/src/Perl6/Compiler/Signature.pm +++ b/src/Perl6/Compiler/Signature.pm @@ -232,16 +232,16 @@ method ast($high_level?) { :scope('package') ); } - else { + else { $nom_type := $_.nom_type; - } + } } elsif $_.sigil ne "" && !$_.invocant { # May well be a parametric role based type. my $role_name; if $_.sigil eq "@" { $role_name := "Positional" } elsif $_.sigil eq "%" { $role_name := "Associative" } - elsif $_.sigil ne ":" { $role_name := "Callable" } + elsif $_.sigil eq "&" { $role_name := "Callable" } if $role_name { my $role_type := PAST::Var.new( :name($role_name), :namespace(''), :scope('package') ); if !$_.nom_type { diff --git a/src/binder/bind.c b/src/binder/bind.c index 38140f27fc6..55de3842895 100644 --- a/src/binder/bind.c +++ b/src/binder/bind.c @@ -311,8 +311,9 @@ Rakudo_binding_bind_one_param(PARROT_INTERP, PMC *lexpad, llsig_element *sig_inf for (i = 0; i < num_constraints; i++) { PMC *cons_type = VTABLE_get_pmc_keyed_int(interp, constraints, i); PMC *accepts_meth = VTABLE_find_method(interp, cons_type, ACCEPTS); - if (VTABLE_isa(interp, cons_type, string_from_literal(interp, "Sub"))) - Parrot_capture_lex(interp, cons_type); + if (VTABLE_isa(interp, cons_type, string_from_literal(interp, "Block"))) + Parrot_capture_lex(interp, VTABLE_get_attr_str(interp, cons_type, + string_from_literal(interp, "$!do"))); Parrot_ext_call(interp, accepts_meth, "PiP->P", cons_type, value, &result); if (!VTABLE_get_bool(interp, result)) { if (error) From 9df5b4a1376f4473f808a2574ece8a820cad10b0 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 21:39:30 +0100 Subject: [PATCH 02/11] Turn S06-multi/type-based.t and S06-multi/proto.t back on. --- t/spectest.data | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/spectest.data b/t/spectest.data index 4eb8d3ca595..d356e4ef675 100644 --- a/t/spectest.data +++ b/t/spectest.data @@ -268,9 +268,9 @@ S06-advanced_subroutine_features/lexical-subs.t # S06-currying/assuming-and-mmd.t # S06-currying/named.t # S06-multi/lexical-multis.t -# S06-multi/proto.t +S06-multi/proto.t S06-multi/syntax.t -# S06-multi/type-based.t +S06-multi/type-based.t S06-multi/value-based.t # S06-operator-overloading/imported-subs.t # S06-operator-overloading/sub.t From 5c09ebb9d0696917581c01547adc9cda7237f25b Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 21:49:20 +0100 Subject: [PATCH 03/11] Implement Bool.ACCEPTS. --- src/core/Bool.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Bool.pm b/src/core/Bool.pm index 46f488c0be8..0a6d334f561 100644 --- a/src/core/Bool.pm +++ b/src/core/Bool.pm @@ -1,3 +1,4 @@ augment class Bool { method Bool { self } -} \ No newline at end of file + method ACCEPTS($topic) { self } +} From cad6d1243189f1095cb0a55c2cb61c7cc404e640 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 21:50:51 +0100 Subject: [PATCH 04/11] Turn S03-smartmatch/any-bool.t back on. --- t/spectest.data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/spectest.data b/t/spectest.data index d356e4ef675..79369d5f586 100644 --- a/t/spectest.data +++ b/t/spectest.data @@ -154,7 +154,7 @@ S03-operators/scalar-assign.t # S03-smartmatch/any-any.t # S03-smartmatch/any-array-slice.t # S03-smartmatch/any-array.t -# S03-smartmatch/any-bool.t +S03-smartmatch/any-bool.t S03-smartmatch/any-callable.t S03-smartmatch/any-complex.t # S03-smartmatch/any-hash-pair.t From 0161485a108dcc38bdea33511bffc0f9d40d3ca4 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Tue, 16 Feb 2010 14:02:38 -0500 Subject: [PATCH 05/11] Remove fossil "is export" from Any.sec. (Someday those functions might properly be "is export", but not today.) --- src/core/Any-num.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Any-num.pm b/src/core/Any-num.pm index d3608656bee..64a4842f9d0 100644 --- a/src/core/Any-num.pm +++ b/src/core/Any-num.pm @@ -84,7 +84,7 @@ augment class Any { self.Num.tan($base); } - our Num multi method sec($base = 'radians') is export { + our Num multi method sec($base = 'radians') { self.Num.sec($base); } From 40e481e92f874fc0f5c6a7130bc287186f4d3c41 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Tue, 16 Feb 2010 14:13:58 -0500 Subject: [PATCH 06/11] Fix the definition of cosech. --- src/core/Num.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Num.pm b/src/core/Num.pm index 05c45979214..2c4fa57d8f7 100644 --- a/src/core/Num.pm +++ b/src/core/Num.pm @@ -135,7 +135,7 @@ augment class Num { } multi method cosech($base = 'radians') { - 1 / self.cosh($base); + 1 / self.sinh($base); } multi method acosech($base = 'radians') { From 3030f555727a4a4b111cd9c18edbd346b0ea7405 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 22:28:08 +0100 Subject: [PATCH 07/11] Make sure we don't crash and burn if somebody writes double semicolon in their code! --- src/Perl6/Actions.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm index 8b42d5d0e5b..6f2a0df62c8 100644 --- a/src/Perl6/Actions.pm +++ b/src/Perl6/Actions.pm @@ -97,13 +97,15 @@ method statementlist($/) { if $ { for $ { my $ast := $_.ast; - if $ast.isa(PAST::Block) && !$ast.blocktype { - $ast := block_immediate($ast); - } - elsif $ast && !$ast.blocktype { - $ast := block_immediate($ast); + if $ast { + if $ast.isa(PAST::Block) && !$ast.blocktype { + $ast := block_immediate($ast); + } + elsif $ast && !$ast.blocktype { + $ast := block_immediate($ast); + } + $past.push( $ast ); } - $past.push( $ast ); } } make $past; From a73f7b33e52cebb97364639d0a2100e2f482d750 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 22:28:22 +0100 Subject: [PATCH 08/11] Turn S06-advanced_subroutine_features/return.t back on. --- t/spectest.data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/spectest.data b/t/spectest.data index 79369d5f586..8cb4a06168e 100644 --- a/t/spectest.data +++ b/t/spectest.data @@ -263,7 +263,7 @@ S05-metasyntax/single-quotes.t # S05-transliteration/with-closure.t S06-advanced_subroutine_features/lexical-subs.t # S06-advanced_subroutine_features/recurse.t -# S06-advanced_subroutine_features/return.t +S06-advanced_subroutine_features/return.t # S06-advanced_subroutine_features/wrap.t # S06-currying/assuming-and-mmd.t # S06-currying/named.t From 88f3c6ed9b0829713b5cc71f633606fb8335a7e3 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 23:12:33 +0100 Subject: [PATCH 09/11] Add a missing case of unspace. --- src/Perl6/Grammar.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm index fdb3483f971..eb7c6b5b0c1 100644 --- a/src/Perl6/Grammar.pm +++ b/src/Perl6/Grammar.pm @@ -944,6 +944,8 @@ token postfixish { # last whitespace didn't end here + [ <.unsp> | '\\' ]? + ? [ | From 3603f51846fe20ee26b67241476d16313d18423e Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 23:12:54 +0100 Subject: [PATCH 10/11] Add back reviewed assuming implementation. --- src/builtins/Routine.pir | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/builtins/Routine.pir b/src/builtins/Routine.pir index 4fbc1cea4ee..33a0d3216ad 100644 --- a/src/builtins/Routine.pir +++ b/src/builtins/Routine.pir @@ -26,6 +26,35 @@ wrappable executable objects. =over 4 +=item assumming() + +Returns a curried version of self. + +=cut + +.sub 'assuming' :method :subid('assuming') + .param pmc args :slurpy + .param pmc named_args :slurpy :named + .local pmc curried + .lex '@args', args + .lex '%args', named_args + .lex '$obj', self + .const 'Sub' curried = 'assuming_helper' + $P0 = newclosure curried + .return ($P0) +.end + +.sub '' :outer('assuming') :subid('assuming_helper') + .param pmc args :slurpy + .param pmc named_args :slurpy :named + .local pmc obj, assumed_args, assumed_named_args, result + find_lex obj, '$obj' + find_lex assumed_args, '@args' + find_lex assumed_named_args, '%args' + .tailcall obj(assumed_args :flat, args :flat, assumed_named_args :flat :named, named_args :flat :named) +.end + + =item wrap =cut From ff97a288246e6cd568c638334ac867433b3846fd Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 16 Feb 2010 23:13:05 +0100 Subject: [PATCH 11/11] Turn two assuming tests back on. --- t/spectest.data | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/spectest.data b/t/spectest.data index 8cb4a06168e..1cceac9707b 100644 --- a/t/spectest.data +++ b/t/spectest.data @@ -265,8 +265,8 @@ S06-advanced_subroutine_features/lexical-subs.t # S06-advanced_subroutine_features/recurse.t S06-advanced_subroutine_features/return.t # S06-advanced_subroutine_features/wrap.t -# S06-currying/assuming-and-mmd.t -# S06-currying/named.t +S06-currying/assuming-and-mmd.t +S06-currying/named.t # S06-multi/lexical-multis.t S06-multi/proto.t S06-multi/syntax.t