Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make EVAL() and .EVAL really Cool
  • Loading branch information
lizmat committed Jul 9, 2014
1 parent 3bd00dd commit 95e3ca4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/core/Cool.pm
Expand Up @@ -214,12 +214,8 @@ my class Cool { # declared in BOOTSTRAP
method trim-leading () { self.Stringy.trim-leading };
method trim-trailing() { self.Stringy.trim-trailing };

method eval(*%opts) { # is DEPRECATED doesn't work in settings
DEPRECATED("'EVAL'");
EVAL(self.Stringy, context => CALLER::, |%opts);
}
method EVAL(*%opts) {
EVAL(self.Stringy, context => CALLER::, |%opts);
EVAL(self, context => CALLER::, |%opts);
}

multi method Real() { self.Numeric.Real }
Expand Down
4 changes: 2 additions & 2 deletions src/core/control.pm
Expand Up @@ -161,13 +161,13 @@ multi sub warn(*@msg) is hidden_from_backtrace {
}

proto sub EVAL($, *%) {*}
multi sub EVAL(Str $code, :$lang = 'perl6', PseudoStash :$context) {
multi sub EVAL(Cool $code, :$lang = 'perl6', PseudoStash :$context) {
my $eval_ctx := nqp::getattr(nqp::decont($context // CALLER::), PseudoStash, '$!ctx');
my $?FILES := 'EVAL_' ~ (state $no)++;
my $compiler := nqp::getcomp($lang);
X::Eval::NoSuchLang.new(:$lang).throw
if nqp::isnull($compiler);
my $compiled := $compiler.compile($code, :outer_ctx($eval_ctx), :global(GLOBAL));
my $compiled := $compiler.compile($code.Stringy, :outer_ctx($eval_ctx), :global(GLOBAL));
nqp::forceouterctx(nqp::getattr($compiled, ForeignCode, '$!do'), $eval_ctx);
$compiled();
}
Expand Down

0 comments on commit 95e3ca4

Please sign in to comment.