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
|
|
| 1701 | 1701 | $P0 = get_hll_global ['POST'], 'Ops' |
| 1702 | 1702 | ops = $P0.'new'('node'=>node) |
| 1703 | 1703 | |
| | 1704 | .local int nopopeh |
| | 1705 | nopopeh = node.'nopopeh'() |
| | 1706 | |
| 1704 | 1707 | .local pmc catchlabel, endlabel |
| 1705 | 1708 | $P0 = get_hll_global ['POST'], 'Label' |
| 1706 | 1709 | $S0 = self.'unique'('catch_') |
| … |
… |
|
| 1716 | 1719 | trypost = self.'as_post'(trypast, 'rtype'=>rtype) |
| 1717 | 1720 | ops.'push_pirop'('push_eh', catchlabel) |
| 1718 | 1721 | ops.'push'(trypost) |
| | 1722 | if nopopeh goto skippop |
| 1719 | 1723 | ops.'push_pirop'('pop_eh') |
| | 1724 | skippop: |
| 1720 | 1725 | .local pmc elsepast, elsepost |
| 1721 | 1726 | elsepast = node[2] |
| 1722 | 1727 | if null elsepast goto else_done |
| … |
… |
|
| 1730 | 1735 | if null catchpast goto catch_done |
| 1731 | 1736 | catchpost = self.'as_post'(catchpast, 'rtype'=>'v') |
| 1732 | 1737 | ops.'push'(catchpost) |
| | 1738 | if nopopeh goto catch_done |
| 1733 | 1739 | ops.'push_pirop'('pop_eh') # FIXME: should be before catchpost |
| 1734 | 1740 | catch_done: |
| 1735 | 1741 | ops.'push'(endlabel) |
diff --git a/compilers/pct/src/PAST/Node.pir b/compilers/pct/src/PAST/Node.pir
index 26310af7..382308e 100644
|
a
|
b
|
|
| 380 | 380 | .tailcall self.'attr'('pasttype', value, has_value) |
| 381 | 381 | .end |
| 382 | 382 | |
| | 383 | =item nopopeh([flag]) |
| | 384 | |
| | 385 | Get/set the node's C<nopopeh> (for C<try> nodes) attribute to C<flag>. A true |
| | 386 | value indicates that no C<pop_eh> instructions should be output; the client |
| | 387 | code provides its own. Otherwise C<pop_eh> instructions will be output after |
| | 388 | the first child (the handler is popped after the code has executed |
| | 389 | successfully), and after the second child (the handler is popped after the |
| | 390 | recovery 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 |
| 383 | 399 | |
| 384 | 400 | =item pirop([opcode]) |
| 385 | 401 | |