import eclipse 3.1 M4 compiler
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / SynchronizedStatement.java
index 2a45c54..b49d6ad 100644 (file)
@@ -41,6 +41,8 @@ public class SynchronizedStatement extends SubRoutineStatement {
                FlowContext flowContext,
                FlowInfo flowInfo) {
 
+           // TODO (philippe) shouldn't it be protected by a check whether reachable statement ?
+           
                // mark the synthetic variable as being used
                synchroVariable.useFlag = LocalVariableBinding.USED;
 
@@ -69,7 +71,7 @@ public class SynchronizedStatement extends SubRoutineStatement {
         * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
         */
        public void generateCode(BlockScope currentScope, CodeStream codeStream) {
-
+       
                if ((bits & IsReachableMASK) == 0) {
                        return;
                }
@@ -80,7 +82,7 @@ public class SynchronizedStatement extends SubRoutineStatement {
                        this.anyExceptionLabelsCount = 0;
                }
                int pc = codeStream.position;
-
+       
                // generate the synchronization expression
                expression.generateCode(scope, codeStream, true);
                if (block.isEmptyBlock()) {
@@ -97,7 +99,7 @@ public class SynchronizedStatement extends SubRoutineStatement {
                        // enter the monitor
                        codeStream.store(synchroVariable, true);
                        codeStream.monitorenter();
-
+       
                        // generate  the body of the synchronized block
                        this.enterAnyExceptionHandler(codeStream);
                        block.generateCode(scope, codeStream);
@@ -105,14 +107,16 @@ public class SynchronizedStatement extends SubRoutineStatement {
                        if (!blockExit) {
                                codeStream.load(synchroVariable);
                                codeStream.monitorexit();
+                               this.exitAnyExceptionHandler();
                                codeStream.goto_(endLabel);
+                               this.enterAnyExceptionHandler(codeStream);
                        }
                        // generate the body of the exception handler
-                       this.exitAnyExceptionHandler();
                        this.placeAllAnyExceptionHandlers();
                        codeStream.incrStackSize(1);
                        codeStream.load(synchroVariable);
                        codeStream.monitorexit();
+                       this.exitAnyExceptionHandler();
                        codeStream.athrow();
                        if (!blockExit) {
                                endLabel.place();
@@ -163,8 +167,8 @@ public class SynchronizedStatement extends SubRoutineStatement {
                //continue even on errors in order to have the TC done into the statements
                synchroVariable = new LocalVariableBinding(SecretLocalDeclarationName, type, AccDefault, false);
                scope.addLocalVariable(synchroVariable);
-               synchroVariable.constant = NotAConstant; // not inlinable
-               expression.implicitWidening(type, type);
+               synchroVariable.setConstant(NotAConstant); // not inlinable
+               expression.computeConversion(scope, type, type);
                block.resolveUsing(scope);
        }