Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:rakudo/rakudo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Hasselbacher committed Aug 19, 2009
2 parents cf27952 + 2e4bc03 commit c52d1e6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/builtins/control.pir
Expand Up @@ -383,7 +383,7 @@ on error.

# Invoke.
res = invokable()
exception = new ['Failure']
exception = '!FAIL'()
goto done

catch:
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Failure.pir
Expand Up @@ -56,7 +56,7 @@
unless x goto no_args
die "Obsolete use of undef; in Perl 6 please use undefine instead"
no_args:
$P0 = new ['Failure']
$P0 = '!FAIL'()
.return ($P0)
.end

Expand Down
2 changes: 1 addition & 1 deletion src/classes/Nil.pir
Expand Up @@ -52,7 +52,7 @@ src/classes/Nil.pir - Nil objects

.namespace ['Nil']
.sub 'Scalar' :method
$P0 = new ['Failure']
$P0 = '!FAIL'()
.return ($P0)
.end

Expand Down
17 changes: 13 additions & 4 deletions src/parser/actions.pm
Expand Up @@ -625,7 +625,7 @@ method statement_prefix($/) {

## Add an 'else' node to the try op that clears $! if
## no exception occurred.
my $elsepir := " new %r, ['Failure']\n store_lex '$!', %r";
my $elsepir := " %r = '!FAIL'()\n store_lex '$!', %r";
$past.push( PAST::Op.new( :inline( $elsepir ) ) );
}
elsif $sym eq 'gather' {
Expand Down Expand Up @@ -675,6 +675,12 @@ method multi_declarator($/) {
# If it's just a routine, need to mark it as a sub and make sure we
# bind its signature.
if $<routine_def> {
if (+@($past[1])) {
declare_implicit_routine_vars($past);
}
else {
$past[1].push( PAST::Op.new( :name('list') ) );
}
set_block_type($past, 'Sub');
$past[0].push(
PAST::Op.new( :pasttype('call'), :name('!SIGNATURE_BIND') )
Expand Down Expand Up @@ -2484,7 +2490,8 @@ method term($/, $key) {
PAST::Var.new(
:name($short_name),
:namespace(@ns),
:scope('package')
:scope('package'),
:viviself('Failure'),
),
:pasttype('call')
);
Expand All @@ -2502,7 +2509,8 @@ method term($/, $key) {
$past.unshift(PAST::Var.new(
:name($short_name),
:namespace(@ns),
:scope('package')
:scope('package'),
:viviself('Failure'),
));
}
else {
Expand All @@ -2518,7 +2526,8 @@ method term($/, $key) {
$past.unshift(PAST::Var.new(
:name($short_name),
:namespace(@ns),
:scope('package')
:scope('package'),
:viviself('Failure'),
));
}
else {
Expand Down
28 changes: 21 additions & 7 deletions src/pmc/perl6multisub.pmc
Expand Up @@ -256,15 +256,19 @@ static INTVAL is_narrower(PARROT_INTERP, candidate_info *a, candidate_info *b) {
STRING * const ACCEPTS = CONST_STRING(interp, "ACCEPTS");
INTVAL narrower = 0;
INTVAL tied = 0;
INTVAL i;

/* Check if they have the same number of effective parameters - if
* not, incomparable. */
if (a->num_types != b->num_types)
INTVAL i, types_to_check;

/* Work out how many parameters to compare, factoring in slurpiness
* and optionals. */
if (a->num_types == b->num_types)
types_to_check = a->num_types;
else if (a->min_arity == b->min_arity)
types_to_check = a->num_types > b->num_types ? b->num_types : a->num_types;
else
return 0;

/* Analyse each parameter in the two candidates. */
for (i = 0; i < a->num_types; i++) {
for (i = 0; i < types_to_check; i++) {
PMC * const type_obj_a = a->types[i];
PMC * const type_obj_b = b->types[i];
if (type_obj_a == type_obj_b) {
Expand Down Expand Up @@ -297,7 +301,17 @@ static INTVAL is_narrower(PARROT_INTERP, candidate_info *a, candidate_info *b) {
}
}

return narrower >= 1 && narrower + tied == a->num_types;
/* If one is narrower than the other from current analysis, we're done. */
if (narrower >= 1 && narrower + tied == types_to_check)
return 1;

/* If they aren't tied, we're also done. */
else if (tied != types_to_check)
return 0;

/* Otherwise, we see if one has a slurpy and the other not. A lack of
* slurpiness makes the candidate narrower. Otherwise, they're tied. */
return a->max_arity != SLURPY_ARITY && b->max_arity == SLURPY_ARITY;
}


Expand Down
2 changes: 1 addition & 1 deletion t/spectest.data
Expand Up @@ -373,7 +373,7 @@ S29-any/isa.t
S29-context/die.t
S29-context/eval.t
S29-context/sleep.t
S29-conversions/ord_and_chr.t
S29-conversions/ord_and_chr.t #icu
S32-array/delete.t
S32-array/elems.t
S32-array/end.t
Expand Down

0 comments on commit c52d1e6

Please sign in to comment.