A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / DoStatement.java
index 32dfabd..fa656a7 100644 (file)
@@ -22,6 +22,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
 public class DoStatement extends Statement {
 
        public Expression condition;
+
        public Statement action;
 
        private Label breakLabel, continueLabel;
@@ -37,119 +38,118 @@ public class DoStatement extends Statement {
                this.action = action;
        }
 
-       public FlowInfo analyseCode(
-               BlockScope currentScope,
-               FlowContext flowContext,
-               FlowInfo flowInfo) {
+       public FlowInfo analyseCode(BlockScope currentScope,
+                       FlowContext flowContext, FlowInfo flowInfo) {
 
                breakLabel = new Label();
                continueLabel = new Label();
-               LoopingFlowContext loopingContext =
-                       new LoopingFlowContext(
-                               flowContext,
-                               this,
-                               breakLabel,
-                               continueLabel,
-                               currentScope);
+               LoopingFlowContext loopingContext = new LoopingFlowContext(flowContext,
+                               this, breakLabel, continueLabel, currentScope);
 
                Constant cst = condition.constant;
-               boolean isConditionTrue = cst != NotAConstant && cst.booleanValue() == true;
+               boolean isConditionTrue = cst != NotAConstant
+                               && cst.booleanValue() == true;
                cst = condition.optimizedBooleanConstant();
-               boolean isConditionOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
-               boolean isConditionOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
+               boolean isConditionOptimizedTrue = cst != NotAConstant
+                               && cst.booleanValue() == true;
+               boolean isConditionOptimizedFalse = cst != NotAConstant
+                               && cst.booleanValue() == false;
 
                int previousMode = flowInfo.reachMode();
-                               
+
                if ((action != null) && !action.isEmptyBlock()) {
-                       flowInfo = action.analyseCode(currentScope, loopingContext, flowInfo);
+                       flowInfo = action.analyseCode(currentScope, loopingContext,
+                                       flowInfo);
 
-                       // code generation can be optimized when no need to continue in the loop
-                       if (!flowInfo.isReachable() && !loopingContext.initsOnContinue.isReachable()) {
+                       // code generation can be optimized when no need to continue in the
+                       // loop
+                       if (!flowInfo.isReachable()
+                                       && !loopingContext.initsOnContinue.isReachable()) {
                                continueLabel = null;
                        }
                }
-               /* Reset reach mode, to address following scenario.
-                *   final blank;
-                *   do { if (true) break; else blank = 0; } while(false);
-                *   blank = 1; // may be initialized already 
+               /*
+                * Reset reach mode, to address following scenario. final blank; do { if
+                * (true) break; else blank = 0; } while(false); blank = 1; // may be
+                * initialized already
                 */
                flowInfo.setReachMode(previousMode);
-               
-               flowInfo =
-                       condition.analyseCode(
-                               currentScope,
-                               loopingContext,
-                               (action == null
-                                       ? flowInfo
-                                       : (flowInfo.mergedWith(loopingContext.initsOnContinue))));
+
+               flowInfo = condition.analyseCode(currentScope, loopingContext,
+                               (action == null ? flowInfo : (flowInfo
+                                               .mergedWith(loopingContext.initsOnContinue))));
                if (!isConditionOptimizedFalse && continueLabel != null) {
-                       loopingContext.complainOnFinalAssignmentsInLoop(currentScope, flowInfo);
+                       loopingContext.complainOnFinalAssignmentsInLoop(currentScope,
+                                       flowInfo);
                }
 
                // infinite loop
                FlowInfo mergedInfo;
                if (isConditionTrue) {
                        mergedInfo = loopingContext.initsOnBreak;
-                       if (!mergedInfo.isReachable()) mergedInfo.addPotentialInitializationsFrom(flowInfo.initsWhenFalse());
+                       if (!mergedInfo.isReachable())
+                               mergedInfo.addPotentialInitializationsFrom(flowInfo
+                                               .initsWhenFalse());
                } else {
                        // end of loop: either condition false or break
-                       mergedInfo =
-                               flowInfo.initsWhenFalse().unconditionalInits().mergedWith(
-                                       loopingContext.initsOnBreak);
-                       if (isConditionOptimizedTrue && !loopingContext.initsOnBreak.isReachable()) {
+                       mergedInfo = flowInfo.initsWhenFalse().unconditionalInits()
+                                       .mergedWith(loopingContext.initsOnBreak);
+                       if (isConditionOptimizedTrue
+                                       && !loopingContext.initsOnBreak.isReachable()) {
                                mergedInfo.setReachMode(FlowInfo.UNREACHABLE);
                        }
                }
-               mergedInitStateIndex =
-                       currentScope.methodScope().recordInitializationStates(mergedInfo);
+               mergedInitStateIndex = currentScope.methodScope()
+                               .recordInitializationStates(mergedInfo);
                return mergedInfo;
        }
 
        /**
         * Do statement code generation
-        *
+        * 
         */
-//     public void generateCode(BlockScope currentScope, CodeStream codeStream) {
-//
-//             if ((bits & IsReachableMASK) == 0) {
-//                     return;
-//             }
-//             int pc = codeStream.position;
-//
-//             // labels management
-//             Label actionLabel = new Label(codeStream);
-//             actionLabel.place();
-//             breakLabel.codeStream = codeStream;
-//             if (continueLabel != null) {
-//                     continueLabel.codeStream = codeStream;
-//             }
-//
-//             // generate action
-//             if (action != null) {
-//                     action.generateCode(currentScope, codeStream);
-//             }
-//             // generate condition
-//             if (continueLabel != null) {
-//                     continueLabel.place();
-//                     condition.generateOptimizedBoolean(
-//                             currentScope,
-//                             codeStream,
-//                             actionLabel,
-//                             null,
-//                             true);
-//             }
-//             breakLabel.place();
-//
-//             // May loose some local variable initializations : affecting the local variable attributes
-//             if (mergedInitStateIndex != -1) {
-//                     codeStream.removeNotDefinitelyAssignedVariables(
-//                             currentScope,
-//                             mergedInitStateIndex);
-//             }
-//             codeStream.recordPositionsFrom(pc, this.sourceStart);
-//
-//     }
-
+       // public void generateCode(BlockScope currentScope, CodeStream codeStream)
+       // {
+       //
+       // if ((bits & IsReachableMASK) == 0) {
+       // return;
+       // }
+       // int pc = codeStream.position;
+       //
+       // // labels management
+       // Label actionLabel = new Label(codeStream);
+       // actionLabel.place();
+       // breakLabel.codeStream = codeStream;
+       // if (continueLabel != null) {
+       // continueLabel.codeStream = codeStream;
+       // }
+       //
+       // // generate action
+       // if (action != null) {
+       // action.generateCode(currentScope, codeStream);
+       // }
+       // // generate condition
+       // if (continueLabel != null) {
+       // continueLabel.place();
+       // condition.generateOptimizedBoolean(
+       // currentScope,
+       // codeStream,
+       // actionLabel,
+       // null,
+       // true);
+       // }
+       // breakLabel.place();
+       //
+       // // May loose some local variable initializations : affecting the local
+       // variable attributes
+       // if (mergedInitStateIndex != -1) {
+       // codeStream.removeNotDefinitelyAssignedVariables(
+       // currentScope,
+       // mergedInitStateIndex);
+       // }
+       // codeStream.recordPositionsFrom(pc, this.sourceStart);
+       //
+       // }
        public void resetStateForCodeGeneration() {
                if (this.breakLabel != null) {
                        this.breakLabel.resetStateForCodeGeneration();
@@ -161,11 +161,13 @@ public class DoStatement extends Statement {
 
        public void resolve(BlockScope scope) {
 
-               TypeBinding type = condition.resolveTypeExpecting(scope, BooleanBinding);
+               TypeBinding type = condition
+                               .resolveTypeExpecting(scope, BooleanBinding);
                condition.implicitWidening(type, type);
                if (action != null)
                        action.resolve(scope);
        }
+
        public StringBuffer printStatement(int indent, StringBuffer output) {
 
                printIndent(indent, output).append("do"); //$NON-NLS-1$
@@ -178,6 +180,7 @@ public class DoStatement extends Statement {
                output.append("while ("); //$NON-NLS-1$
                return condition.printExpression(0, output).append(");"); //$NON-NLS-1$
        }
+
        public String toString(int tab) {
 
                String inFront, s = tabString(tab);