From 45b6158b36825ffa8b0954bf85084f44e553ef4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Skj=C3=A6rholt?= Date: Sat, 12 Feb 2011 07:48:24 +0100 Subject: [PATCH] Add nopopeh attribute to PAST::Op for suppressing pop_eh attributes in try nodes. --- compilers/pct/src/PAST/Compiler.pir | 6 ++++++ compilers/pct/src/PAST/Node.pir | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/compilers/pct/src/PAST/Compiler.pir b/compilers/pct/src/PAST/Compiler.pir index c0ca392..1c1080f 100644 --- a/compilers/pct/src/PAST/Compiler.pir +++ b/compilers/pct/src/PAST/Compiler.pir @@ -1701,6 +1701,9 @@ handler. $P0 = get_hll_global ['POST'], 'Ops' ops = $P0.'new'('node'=>node) + .local int nopopeh + nopopeh = node.'nopopeh'() + .local pmc catchlabel, endlabel $P0 = get_hll_global ['POST'], 'Label' $S0 = self.'unique'('catch_') @@ -1716,7 +1719,9 @@ handler. trypost = self.'as_post'(trypast, 'rtype'=>rtype) ops.'push_pirop'('push_eh', catchlabel) ops.'push'(trypost) + if nopopeh goto skippop ops.'push_pirop'('pop_eh') + skippop: .local pmc elsepast, elsepost elsepast = node[2] if null elsepast goto else_done @@ -1730,6 +1735,7 @@ handler. if null catchpast goto catch_done catchpost = self.'as_post'(catchpast, 'rtype'=>'v') ops.'push'(catchpost) + if nopopeh goto catch_done ops.'push_pirop'('pop_eh') # FIXME: should be before catchpost catch_done: ops.'push'(endlabel) diff --git a/compilers/pct/src/PAST/Node.pir b/compilers/pct/src/PAST/Node.pir index 26310af7..382308e 100644 --- a/compilers/pct/src/PAST/Node.pir +++ b/compilers/pct/src/PAST/Node.pir @@ -380,6 +380,22 @@ assumes "call". .tailcall self.'attr'('pasttype', value, has_value) .end +=item nopopeh([flag]) + +Get/set the node's C (for C nodes) attribute to C. A true +value indicates that no C instructions should be output; the client +code provides its own. Otherwise C instructions will be output after +the first child (the handler is popped after the code has executed +successfully), and after the second child (the handler is popped after the +recovery code has run). + +=cut + +.sub 'nopopeh' :method + .param pmc value :optional + .param int has_value :opt_flag + .tailcall self.'attr'('nopopeh', value, has_value) +.end =item pirop([opcode]) -- 1.7.4