diff --git a/src/cheats/eval.pm b/src/cheats/eval.pm index ec879700b74..0e98783397c 100644 --- a/src/cheats/eval.pm +++ b/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 @@ -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