Skip to content

Commit

Permalink
Re-enable :lang attribute for eval. Now we can eval Perl 5 code using…
Browse files Browse the repository at this point in the history
… Blizkost.
  • Loading branch information
jnthn committed Apr 27, 2010
1 parent e51d6f9 commit a27dfef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cheats/eval.pm
@@ -1,12 +1,16 @@
our sub eval(Str $code) {
our sub eval(Str $code, :$lang = 'perl6') {
my $*IN_EVAL = 1;
Q:PIR {
.local pmc interp, caller, code, pbc, result, exception, parrotex
.local string lang
interp = getinterp
caller = interp['context';1]
code = find_lex '$code'
push_eh catch
$P0 = find_lex '$lang'
lang = $P0
if lang != 'perl6' goto foreign
$P0 = compreg 'perl6'
code = find_lex '$code'
pbc = $P0.'compile'(code, 'outer_ctx'=>caller)

# set the outer context for the compiled code
Expand All @@ -16,7 +20,15 @@ our sub eval(Str $code) {

# invoke the compiled code
result = pbc()
goto success

foreign:
# Load the langauge and delegate to its eval.
load_language lang
$P0 = compreg lang
result = $P0.'eval'(code, 'outer_ctx'=>caller)

success:
# no exception occurred, so generate a dummy exception
exception = '!FAIL'()
goto done
Expand Down

0 comments on commit a27dfef

Please sign in to comment.