Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Couple of other extra fixes to get us handling the spectests again.
  • Loading branch information
jnthn committed Oct 6, 2009
1 parent d39a7de commit 0f4d0cd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
6 changes: 3 additions & 3 deletions perl6.pir
Expand Up @@ -61,7 +61,7 @@ Creates the Perl 6 compiler by subclassing a C<PCT::HLLCompiler> object.
.local pmc p6meta, perl6
p6meta = get_hll_global ['Perl6Object'], '$!P6META'
perl6 = p6meta.'new_class'('Perl6::Compiler', 'parent'=>'PCT::HLLCompiler')
p6meta.'new_class'('Perl6::Compiler::Signature', 'attr'=>'$!entries')
p6meta.'new_class'('Perl6::Compiler::Signature', 'attr'=>'$!entries $!default_type')
load_bytecode 'config.pbc'
Expand Down Expand Up @@ -212,9 +212,9 @@ and report exceptions.
.param pmc adverbs :slurpy :named

$P0 = get_root_global ['parrot';'PCT';'HLLCompiler'], 'eval'
#push_eh trap_errors
push_eh trap_errors
$P0 = $P0(self, code, args :flat, adverbs :flat :named)
#pop_eh
pop_eh
.return ($P0)

trap_errors:
Expand Down
12 changes: 12 additions & 0 deletions src/classes/Signature.pir
Expand Up @@ -191,6 +191,18 @@ Ensures that if there is no explicit invocant, we add one.
.end
=item !set_default_param_type
Sets the default parameter type.
=cut
.sub '!set_default_param_type' :method
.param pmc type
setattribute self, '$!default_type', type
.end
=item params
Get the array of parameter describing hashes.
Expand Down
6 changes: 3 additions & 3 deletions src/parser/actions.pm
Expand Up @@ -1042,9 +1042,6 @@ method signature($/, $key) {
}
}

## handle end of multi-invocant sequence
if $<param_sep>[$i][0] eq ';;' { $multi_inv_suppress := 1; }

## add var node to block
$sigpast.push( $var );

Expand All @@ -1060,6 +1057,9 @@ method signature($/, $key) {
:types( $var<type> )
);

## handle end of multi-invocant sequence
if $<param_sep>[$i][0] eq ';;' { $multi_inv_suppress := 1; }

$i++;
}

Expand Down
31 changes: 18 additions & 13 deletions src/parser/signature.pm
Expand Up @@ -53,19 +53,9 @@ method add_invocant() {

# Sets the default type of the parameters.
method set_default_parameter_type($type_name) {
my @entries := self.entries;
for @entries {
unless $_<types> && +@($_<types>) || substr($_<var_name>, 0, 1) ne "$" {
$_<types> := PAST::Op.new(
:name('all'),
:pasttype('call'),
PAST::Var.new(
:namespace(list()),
:name($type_name),
:scope('package')
)
);
}
Q:PIR {
$P0 = find_lex "$type_name"
setattribute self, '$!default_type', $P0
}
}
Expand Down Expand Up @@ -99,6 +89,21 @@ method ast($high_level?) {
));
my $sig_var := PAST::Var.new( :name('signature'), :scope('register') );

# Set default type, if any.
Q:PIR {
$P0 = getattribute self, '$!default_type'
if null $P0 goto default_type_done
};
$ast.push(PAST::Op.new(
:pasttype('callmethod'),
:name('!set_default_param_type'),
$sig_var,
PAST::Var.new( :name(Q:PIR { %r = $P0 }), :namespace(list()), :scope('package') )
));
Q:PIR {
default_type_done:
};

# For each of the parameters, emit a call to add the parameter.
for self.entries {
my $add_param := PAST::Op.new(
Expand Down

0 comments on commit 0f4d0cd

Please sign in to comment.