Fix fresh methods changes
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/402466da Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/402466da Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/402466da Branch: refs/heads/markdown_v2 Commit: 402466da0f4e24dca5faf2e81b3b81f161665523 Parents: b6de550 Author: Nick Wellnhofer <[email protected]> Authored: Fri Dec 12 11:42:51 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Wed Dec 24 14:56:51 2014 +0100 ---------------------------------------------------------------------- compiler/perl/lib/Clownfish/CFC.xs | 1 - compiler/perl/t/401-class.t | 10 +++++----- compiler/src/CFCClass.c | 6 ++++++ 3 files changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/402466da/compiler/perl/lib/Clownfish/CFC.xs ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs index d13079e..65442a3 100644 --- a/compiler/perl/lib/Clownfish/CFC.xs +++ b/compiler/perl/lib/Clownfish/CFC.xs @@ -396,7 +396,6 @@ PPCODE: case 44: { CFCMethod **fresh = CFCClass_fresh_methods(self); retval = S_array_of_cfcbase_to_av((CFCBase**)fresh); - FREEMEM(fresh); break; } case 46: { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/402466da/compiler/perl/t/401-class.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t index f137cf4..d680c85 100644 --- a/compiler/perl/t/401-class.t +++ b/compiler/perl/t/401-class.t @@ -223,20 +223,20 @@ ok( ( scalar grep { $_->micro_sym eq 'squishy' } @{ $class->member_vars } ), "parsed member var" ); ok( ( scalar grep { $_->micro_sym eq 'init' } @{ $class->functions } ), "parsed function" ); -ok( ( scalar grep { $_->micro_sym eq 'destroy' } @{ $class->methods } ), +ok( ( scalar grep { $_->micro_sym eq 'destroy' } @{ $class->fresh_methods } ), "parsed parcel method" ); -ok( ( scalar grep { $_->micro_sym eq 'bury' } @{ $class->methods } ), +ok( ( scalar grep { $_->micro_sym eq 'bury' } @{ $class->fresh_methods } ), "parsed public method" ); -ok( ( scalar grep { $_->micro_sym eq 'scratch' } @{ $class->methods } ), +ok( ( scalar grep { $_->micro_sym eq 'scratch' } @{ $class->fresh_methods } ), "parsed public abstract nullable method" ); -for my $method ( @{ $class->methods } ) { +for my $method ( @{ $class->fresh_methods } ) { if ( $method->micro_sym eq 'scratch' ) { ok( $method->get_return_type->nullable, "public abstract incremented nullable flagged as nullable" ); } } -is( ( scalar grep { $_->public } @{ $class->methods } ), +is( ( scalar grep { $_->public } @{ $class->fresh_methods } ), 6, "pass acl to Method constructor" ); $class_content = qq| http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/402466da/compiler/src/CFCClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c index b0a47c8..ff20715 100644 --- a/compiler/src/CFCClass.c +++ b/compiler/src/CFCClass.c @@ -687,11 +687,17 @@ CFCClass_functions(CFCClass *self) { CFCMethod** CFCClass_methods(CFCClass *self) { + if (!self->tree_grown) { + CFCUtil_die("Can't call 'methods' before 'grow_tree'"); + } return self->methods; } size_t CFCClass_num_methods(CFCClass *self) { + if (!self->tree_grown) { + CFCUtil_die("Can't call 'num_methods' before 'grow_tree'"); + } return self->num_methods; }
