Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make IN_EVAL more robust, with input from jnthn++
  • Loading branch information
moritz committed Jun 9, 2010
1 parent 9f05efa commit 11366ab
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/glue/run.pir
Expand Up @@ -25,33 +25,28 @@ of the compilation unit.
.local pmc interp
.local int level
.local int result

# walk tha call chain to determine if we're inside an eval()
# this is a bit clumsy and brittle because the compilation process
# already contains a sub or method named 'eval', so we have to check if
# there are at least two subs named 'eval' in the call chain.
.local pmc eval

result = 0
level = 0
interp = getinterp
eval = get_hll_global '&eval'
eval = getattribute eval, '$!do'

# interp[sub;$to_high_level] throws an exception
# so when we catch one, we're done walking the call chain
push_eh done
loop:
inc level
$P0 = interp['sub'; level]
if null $P0 goto done
$S0 = $P0
if $S0 == 'eval' goto has_eval
eq_addr $P0, eval, has_eval
goto loop

has_eval:
inc result
if result == 2 goto done
goto loop

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

0 comments on commit 11366ab

Please sign in to comment.