Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start to differentiate between where we need to derive a dispatcher a…
…nd when we need to auto-gen a proto for lexical multis.
  • Loading branch information
jnthn committed Jul 9, 2011
1 parent 1e5e666 commit ce6e224
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/Perl6/Actions.pm
Expand Up @@ -1131,13 +1131,29 @@ class Perl6::Actions is HLL::Actions {
# XXX Also need to auto-multi things with a proto in scope.
my $name := '&' ~ ~$<deflongname>[0].ast;
if $*MULTINESS eq 'multi' {
# Locate the proto - or what we hope will be it.
my %proto_sym := $outer.symbol($name);
unless %proto_sym {
$/.CURSOR.panic("proto and dispatch auto-generation for multis not yet implemented");
# Do we have a proto in the current scope?
my $proto;
if $outer.symbol($name) {
$proto := $outer.symbol($name)<value>;
}
else {
# None; search outer scopes.
try {
$proto := $*ST.find_symbol([$name]);
}
if $proto {
# Found in outer scope. Need to derive.
$/.CURSOR.panic("proto derivation NYI");
}
else {
$/.CURSOR.panic("proto auto-gen NYI");
}
}

# Ensure it's actually a dispatcher.
unless $proto.is_dispatcher {
$/.CURSOR.panic("Cannot declare a multi when an only is in scope");
}
my $proto := %proto_sym<value>;
# XXX ensure it's actuall a proto or dispatch...

# Install the candidate.
$*ST.add_dispatchee_to_proto($proto, $code);
Expand Down

0 comments on commit ce6e224

Please sign in to comment.