Skip to content

Commit

Permalink
IN_EVAL needs to count the number of eval()s, since there is always o…
Browse files Browse the repository at this point in the history
…ne in the compilation call chain
  • Loading branch information
moritz committed Jun 9, 2010
1 parent c77e278 commit d33a958
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/glue/run.pir
Expand Up @@ -25,9 +25,18 @@ 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.

result = 0
level = 0
interp = getinterp
# 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]
Expand All @@ -37,9 +46,11 @@ of the compilation unit.
goto loop

has_eval:
result = 1
inc result
goto loop

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

0 comments on commit d33a958

Please sign in to comment.