Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get eval with custom operators to work again.
It stopped working because it relied on global grammar modification
before, which won't fly now we're doing mixins.
  • Loading branch information
jnthn committed Oct 21, 2012
1 parent 13581d0 commit 70b4b22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -520,6 +520,14 @@ grammar Perl6::Grammar is HLL::Grammar {
$*PACKAGE := $*GLOBALish;
}

# If we're eval'ing in the context of a %?LANG, set up our own
# %*LANG based on it.
if $have_outer && $*UNIT_OUTER.symbol('%?LANG') {
for $*UNIT_OUTER.symbol('%?LANG')<value>.FLATTENABLE_HASH() {
%*LANG{$_.key} := $_.value;
}
}

# Install unless we've no setting, in which case we've likely no
# static lexpad class yet either. Also, UNIT needs a code object.
unless %*COMPILING<%?OPTIONS><setting> eq 'NULL' {
Expand Down Expand Up @@ -2915,8 +2923,13 @@ grammar Perl6::Grammar is HLL::Grammar {
self.HOW.mixin(self, Circumfix.HOW.curry(Circumfix, $canname, @parts[0], @parts[1]));
}

# This also becomes the current MAIN.
# This also becomes the current MAIN. If we didn't place the current
# braid into a lexical %?LANG, also do that.
%*LANG<MAIN> := self;
my $curpad := $*W.cur_lexpad();
unless $curpad.symbol('%?LANG') {
$*W.install_lexical_symbol($curpad, '%?LANG', $*W.p6ize_recursive(%*LANG));
}

# May also need to add to the actions.
# XXX Should be mixed in too.
Expand Down
6 changes: 6 additions & 0 deletions src/Perl6/World.pm
Expand Up @@ -1175,6 +1175,12 @@ class Perl6::World is HLL::World {
self.add_object($r);
QAST::WVal.new( :value($r) )
}

# Takes a data structure of non-Perl 6 objects and wraps them up
# recursively.
method p6ize_recursive($data) {
p6ize_recursive($data)
}

# Creates a meta-object for a package, adds it to the root objects and
# returns the created object.
Expand Down

0 comments on commit 70b4b22

Please sign in to comment.