Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
check for eval()ness by walking the call chain
  • Loading branch information
moritz committed Jun 9, 2010
1 parent 3657ad7 commit c77e278
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Perl6/Actions.pm
Expand Up @@ -62,13 +62,16 @@ method comp_unit($/, $key?) {
}

# run MAIN subs
# TODO: run this only when not in a module and not in eval
$mainline.push(
PAST::Op.new(
:pasttype('call'),
:name('&MAIN_HELPER')
)
);
# TODO: run this only when not in a module
# TODO: find a less hacky solution than IN_EVAL
unless IN_EVAL() {
$mainline.push(
PAST::Op.new(
:pasttype('call'),
:name('&MAIN_HELPER')
)
);
}

# Create a block for the entire compilation unit.
our $?RAKUDO_HLL;
Expand Down
23 changes: 23 additions & 0 deletions src/glue/run.pir
Expand Up @@ -21,6 +21,29 @@ of the compilation unit.
.include 'sysinfo.pasm'
.include 'iglobals.pasm'

.sub 'IN_EVAL'
.local pmc interp
.local int level
.local int result
result = 0
level = 0
interp = getinterp
loop:
inc level
$P0 = interp['sub'; level]
if null $P0 goto done
$S0 = $P0
if $S0 == 'eval' goto has_eval
goto loop

has_eval:
result = 1

done:
$P0 = box result
.return($P0)
.end

.sub '!UNIT_START'
.param pmc mainline
.param pmc args :slurpy
Expand Down

0 comments on commit c77e278

Please sign in to comment.