overture
overture copied to clipboard
Support Java code-generation of trap statements
We need Java code-generation of trap statements in the AGCO project. Below are some test scenarios.
class Entry
operations
-- Result is 2
public noExcRaised : () ==> nat
noExcRaised () ==
trap - with return 6 in
return 2;
-- Result is 18
public excCaught : () ==> nat
excCaught () ==
trap a with return a + a in
exit 9;
-- Result is mk_(9, true)
public excCaughtTupRes : () ==> nat * bool
excCaughtTupRes () ==
trap mk_(b,n) with return mk_(n,b) in
exit mk_(true, 9);
-- Produces error (exception not caught)
public excNotCaught : () ==> nat * bool
excNotCaught () ==
trap mk_('a', 9) with return mk_(5,false) in
exit mk_(true, 9);
-- Produces error (exception not caught because 9 does not match 2)
public excBindNotCaught : () ==> nat
excBindNotCaught () ==
trap s in set {2} with return s
in
exit 9;
-- Result is 9
public excBindCaught : () ==> nat
excBindCaught () ==
trap s in set {9} with return s
in
exit 9;
end Entry