2
0
Эх сурвалжийг харах

Patched handling of FINALLY in an exclusive section: he exclusive section is unlocked at the end of FINALLY (not before).
We do intentionally not provide an automatic handling of exceptions within an exclusive block. A FINALLY is required in order to leave the monitor in a clean state. Otherwise the result would be unpredictable in many cases.

PROCEDURE Test;
BEGIN{EXCLUSIVE}
HALT(100)
FINALLY
(* do anyhthing, but do not trap again here ! *)
END Test;

if a rethrow is required, the procedure must be wrapped and return an error code. Example:

PROCEDURE TestRethrow(): BOOLEAN;
BEGIN{EXCLUSIVE}
HALT(100);
RETURN TRUE
FINALLY
RETURN FALSE
END Test;

PROCEDURE Test;
BEGIN
IF ~TestRethrow() THEN HALT(100) END; (* keep exception "alive" *)
END Test;




git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7638 8c9fc860-2736-0410-a75d-ab315db34111

felixf 7 жил өмнө
parent
commit
dcdc7ecf36

+ 8 - 4
source/FoxIntermediateBackend.Mod

@@ -10956,6 +10956,14 @@ TYPE
 			IF x.statements # NIL THEN
 				StatementSequence(x.statements);
 			END;
+			
+			IF (x IS SyntaxTree.Body) THEN 
+				IF (x(SyntaxTree.Body).finally # NIL) THEN
+					section.SetFinally(section.pc);
+					StatementSequence(x(SyntaxTree.Body).finally)
+				END;
+			END;			
+			
 			IF x.isExclusive THEN Lock(FALSE); ASSERT(locked); locked := FALSE; END;
 			isUnchecked := previouslyUnchecked;
 			cooperativeSwitches := previouslyCooperativeSwitches;
@@ -11278,10 +11286,6 @@ TYPE
 				ELSE
 					VisitCode(x.code)
 				END;
-				IF x.finally # NIL THEN (*! mark finally block for object file *)
-					ir.SetFinally(ir.pc);
-					StatementSequence(x.finally)
-				END;
 				IF profile & (x.code = NIL) & ~moduleBody THEN (* do not profile assembler code sections *)
 					IF ~backend.cooperative THEN 
 						ProfilerEnterExit(numberProcedures,FALSE);