Some minor changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / DefaultCase.java
index 2a58b73..e8c6d12 100644 (file)
@@ -1,87 +1,36 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v0.5 
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- ******************************************************************************/
 package net.sourceforge.phpdt.internal.compiler.ast;
 
-import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
-import net.sourceforge.phpdt.internal.compiler.codegen.CaseLabel;
-import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
-import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
-import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
-import net.sourceforge.phpdt.internal.compiler.impl.Constant;
-import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
-import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
-
-public class DefaultCase extends Statement {
-
-       public CaseLabel targetLabel;
-       /**
-        * DefautCase constructor comment.
-        */
-       public DefaultCase(int sourceEnd, int sourceStart) {
-
-               this.sourceStart = sourceStart;
-               this.sourceEnd = sourceEnd;
-       }
-
-       public FlowInfo analyseCode(
-               BlockScope currentScope,
-               FlowContext flowContext,
-               FlowInfo flowInfo) {
-
-               return flowInfo;
-       }
-
-       /**
-        * Default case code generation
-        *
-        * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
-        * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
-        */
-       public void generateCode(BlockScope currentScope, CodeStream codeStream) {
-
-               if ((bits & IsReachableMASK) == 0) {
-                       return;
-               }
-               int pc = codeStream.position;
-               targetLabel.place();
-               codeStream.recordPositionsFrom(pc, this.sourceStart);
-
-       }
-       public Constant resolveCase(
-               BlockScope scope,
-               TypeBinding testType,
-               SwitchStatement switchStatement) {
-
-               // remember the default case into the associated switch statement
-               if (switchStatement.defaultCase != null)
-                       scope.problemReporter().duplicateDefaultCase(this);
-
-               // on error the last default will be the selected one .... (why not) ....       
-               switchStatement.defaultCase = this;
-               resolve(scope);
-               return null;
-       }
-
-       public String toString(int tab) {
-
-               String s = tabString(tab);
-               s = s + "default : "; //$NON-NLS-1$
-               return s;
-       }
-
-       public void traverse(
-               IAbstractSyntaxTreeVisitor visitor,
-               BlockScope blockScope) {
-
-               visitor.visit(this, blockScope);
-               visitor.endVisit(this, blockScope);
-       }
-}
\ No newline at end of file
+/**
+ * A default case for a switch.
+ * it's default : .....;
+ * @author Matthieu Casanova
+ */
+public final class DefaultCase extends AbstractCase {
+
+  /**
+   * Create a default case.
+   *
+   * @param statements the statements
+   * @param sourceStart the starting offset
+   * @param sourceEnd the ending offset
+   */
+  public DefaultCase(final Statement[] statements, final int sourceStart, final int sourceEnd) {
+    super(statements, sourceStart, sourceEnd);
+  }
+
+  /**
+   * Return the object into String.
+   *
+   * @param tab how many tabs (not used here
+   * @return a String
+   */
+  public String toString(final int tab) {
+    final StringBuffer buff = new StringBuffer(tabString(tab));
+    buff.append("default : \n"); //$NON-NLS-1$
+    for (int i = 0; i < statements.length; i++) {
+      final Statement statement = statements[i];
+      buff.append(statement.toString(tab + 9));
+    }
+    return buff.toString();
+  }
+}