I can see two ways to go:
Store the exception (or an array of unhandled exceptions) in the
interpreter and make exceptions available as:
a) e = interpinfo .INTERPINFO_EXCEPTION
b) via the get_params opcode
The latter would reflect the exception call being an internal
continuation invocation:
push_eh handler
# throw
handler: # handler:
get_params "(0)", e # .param pmc e
(Except that .param isn't allowed in arbitrary position currently)
Proposals welcome,
leo
If arbitary-position .param for inner subroutines can be made to work,
b) is by far more straightforward. This also plays well P6's notion
that all non-local exits, including return(), are conceptually
exceptions, so it makes sense to use the same pairs of calling
convention opcodes.
Thanks,
/Autrijus/
Leo, did you change the handling of P5? I have some PIR code that works
differently under 0.2.3 and 0.3.0:
.sub "main" @MAIN
push_eh MAIN_HANDLER
foo()
clear_eh
end
MAIN_HANDLER:
print "in main handler\n"
rethrow P5
.end
.sub "foo"
push_eh FOO_HANDLER
new $P1, .Exception
$P1["_message"] = "my_error_message"
throw $P1
clear_eh
.return()
FOO_HANDLER:
print "in foo handler\n"
rethrow P5
.end
Under 0.2.3 it prints
in foo handler
in main handler
before failing, which in my opinion is the expected behaviour. Under
0.3.0 it prints this before failing:
in foo handler
in main handler
in main handler
If you agree that the 0.3.0 behaviour is wrong, I'll file a bug report.
Regards,
Roger Browne
> Leo, did you change the handling of P5? I have some PIR code that works
> differently under 0.2.3 and 0.3.0:
The exception object iss still P5 in the handler, no changes here yet.
> If you agree that the 0.3.0 behaviour is wrong, I'll file a bug report.
But the MAIN_HANDLER is catching twice, which looks like a bug to me.
> Regards,
> Roger Browne
leo
> in foo handler
> in main handler
> in main handler
Fixed. Now the main handler catches just once.
> Regards,
> Roger Browne
Thanks for testing,
leo