Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First cut of nested lexical multis, which derive a dispatcher based o…
…n the one in the outer lexical scope.
  • Loading branch information
jnthn committed Jul 9, 2011
1 parent ce6e224 commit 86fd89b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -1138,16 +1138,21 @@ class Perl6::Actions is HLL::Actions {
}
else {
# None; search outer scopes.
my $new_proto;
try {
$proto := $*ST.find_symbol([$name]);
}
if $proto {
# Found in outer scope. Need to derive.
$/.CURSOR.panic("proto derivation NYI");
$new_proto := $*ST.derive_dispatcher($proto);
}
else {
$/.CURSOR.panic("proto auto-gen NYI");
}

# Install in current scope.
$*ST.install_lexical_symbol($outer, $name, $new_proto);
$proto := $new_proto;
}

# Ensure it's actually a dispatcher.
Expand Down
17 changes: 17 additions & 0 deletions src/Perl6/SymbolTable.pm
Expand Up @@ -626,6 +626,23 @@ class Perl6::SymbolTable is HLL::Compiler::SerializationContextBuilder {
)));
}

# Derives a proto to get a dispatch.
method derive_dispatcher($proto) {
# Immediately do so and add to SC.
my $derived := $proto.derive_dispatcher();
my $slot := self.add_object($derived);

# Add deserialization action.
my $des := PAST::Op.new(
:pasttype('callmethod'), :name('derive_dispatcher'),
self.get_object_sc_ref_past($proto));
self.add_event(:deserialize_past(
self.set_slot_past($slot, self.set_cur_sc($des))
));

return $derived;
}

# Creates a new container descriptor and adds it to the SC.
method create_container_descriptor($of, $rw, $name) {
# Create descriptor object now.
Expand Down

0 comments on commit 86fd89b

Please sign in to comment.