Ticket #2008: nopopeh.patch

File nopopeh.patch, 2.4 KB (added by arnsholt, 4 years ago)
  • compilers/pct/src/PAST/Compiler.pir

    From 45b6158b36825ffa8b0954bf85084f44e553ef4b Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Arne=20Skj=C3=A6rholt?= <arnsholt@gmail.com>
    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 b  
    17011701    $P0 = get_hll_global ['POST'], 'Ops' 
    17021702    ops = $P0.'new'('node'=>node) 
    17031703 
     1704    .local int nopopeh 
     1705    nopopeh = node.'nopopeh'() 
     1706 
    17041707    .local pmc catchlabel, endlabel 
    17051708    $P0 = get_hll_global ['POST'], 'Label' 
    17061709    $S0 = self.'unique'('catch_') 
     
    17161719    trypost = self.'as_post'(trypast, 'rtype'=>rtype) 
    17171720    ops.'push_pirop'('push_eh', catchlabel) 
    17181721    ops.'push'(trypost) 
     1722    if nopopeh goto skippop 
    17191723    ops.'push_pirop'('pop_eh') 
     1724  skippop: 
    17201725    .local pmc elsepast, elsepost 
    17211726    elsepast = node[2] 
    17221727    if null elsepast goto else_done 
     
    17301735    if null catchpast goto catch_done 
    17311736    catchpost = self.'as_post'(catchpast, 'rtype'=>'v') 
    17321737    ops.'push'(catchpost) 
     1738    if nopopeh goto catch_done 
    17331739    ops.'push_pirop'('pop_eh')         # FIXME: should be before catchpost 
    17341740  catch_done: 
    17351741    ops.'push'(endlabel) 
  • compilers/pct/src/PAST/Node.pir

    diff --git a/compilers/pct/src/PAST/Node.pir b/compilers/pct/src/PAST/Node.pir
    index 26310af7..382308e 100644
    a b  
    380380    .tailcall self.'attr'('pasttype', value, has_value) 
    381381.end 
    382382 
     383=item nopopeh([flag]) 
     384 
     385Get/set the node's C<nopopeh> (for C<try> nodes) attribute to C<flag>. A true 
     386value indicates that no C<pop_eh> instructions should be output; the client 
     387code provides its own. Otherwise C<pop_eh> instructions will be output after 
     388the first child (the handler is popped after the code has executed 
     389successfully), and after the second child (the handler is popped after the 
     390recovery code has run). 
     391 
     392=cut 
     393 
     394.sub 'nopopeh' :method 
     395    .param pmc value           :optional 
     396    .param int has_value       :opt_flag 
     397    .tailcall self.'attr'('nopopeh', value, has_value) 
     398.end 
    383399 
    384400=item pirop([opcode]) 
    385401