From 113d9e5c5dc2072dd627f54374d484d6b0dcd3a9 Mon Sep 17 00:00:00 2001 From: jnthn Date: Thu, 15 Sep 2011 13:58:59 +0200 Subject: [PATCH] Fix things like 'role A::B { }; class A { has A::B $!x }', which stopped Pies working. --- src/Perl6/SymbolTable.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Perl6/SymbolTable.pm b/src/Perl6/SymbolTable.pm index b33984b3592..cf43f38724e 100644 --- a/src/Perl6/SymbolTable.pm +++ b/src/Perl6/SymbolTable.pm @@ -311,20 +311,38 @@ class Perl6::SymbolTable is HLL::Compiler::SerializationContextBuilder { self.install_lexical_symbol($cur_lex, $name, $symbol); } if $create_scope eq 'our' { + if pir::exists($cur_pkg.WHO, $name) { + self.steal_WHO($symbol, ($cur_pkg.WHO){$name}); + } self.install_package_symbol($cur_pkg, $name, $symbol); } 1; } + # If we declare class A::B { }, then class A { }, then A.WHO must be the + # .WHO we already created for the stub package A. + method steal_WHO($thief, $victim) { + pir::set_who__vP($thief, $victim.WHO); + if self.is_precompilation_mode() { + self.add_event(:deserialize_past(PAST::Op.new( + :pirop('set_who vP'), + self.get_object_sc_ref_past($thief), + PAST::Op.new( :pirop('get_who PP'), + self.get_object_sc_ref_past($victim))))); + } + } + # Installs a lexical symbol. Takes a PAST::Block object, name and # the object to install. Does an immediate installation in the # compile-time block symbol table, and ensures that the installation # gets fixed up at runtime too. method install_lexical_symbol($block, $name, $obj, :$clone) { # Install the object directly as a block symbol. + unless $block.symbol($name) { + $block[0].push(PAST::Var.new( :scope('lexical_6model'), :name($name), :isdecl(1) )); + } $block.symbol($name, :scope('lexical_6model'), :value($obj)); - $block[0].push(PAST::Var.new( :scope('lexical_6model'), :name($name), :isdecl(1) )); # Add a clone if needed. # XXX Horrible workaround here. We don't have proper serialization