1 /***********************************************************************************************************************************
 
   2  * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made
 
   3  * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
 
   4  * http://www.eclipse.org/legal/cpl-v10.html
 
   6  * Contributors: IBM Corporation - initial API and implementation
 
   7  **********************************************************************************************************************************/
 
   8 package net.sourceforge.phpdt.internal.compiler.ast;
 
  10 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
 
  11 import net.sourceforge.phpdt.internal.compiler.codegen.CaseLabel;
 
  12 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
 
  13 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
 
  14 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
 
  15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 
  16 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
 
  18 public class DefaultCase extends Statement {
 
  20         public CaseLabel targetLabel;
 
  23          * DefautCase constructor comment.
 
  25         public DefaultCase(int sourceEnd, int sourceStart) {
 
  27                 this.sourceStart = sourceStart;
 
  28                 this.sourceEnd = sourceEnd;
 
  31         public FlowInfo analyseCode(BlockScope currentScope,
 
  32                         FlowContext flowContext, FlowInfo flowInfo) {
 
  38          * Default case code generation
 
  41          *            net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
 
  43          *            net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
 
  45         // public void generateCode(BlockScope currentScope, CodeStream codeStream)
 
  48         // if ((bits & IsReachableMASK) == 0) {
 
  51         // int pc = codeStream.position;
 
  52         // targetLabel.place();
 
  53         // codeStream.recordPositionsFrom(pc, this.sourceStart);
 
  57          * No-op : should use resolveCase(...) instead.
 
  59         public void resolve(BlockScope scope) {
 
  62         public Constant resolveCase(BlockScope scope, TypeBinding testType,
 
  63                         SwitchStatement switchStatement) {
 
  65                 // remember the default case into the associated switch statement
 
  66                 if (switchStatement.defaultCase != null)
 
  67                         scope.problemReporter().duplicateDefaultCase(this);
 
  69                 // on error the last default will be the selected one .... (why not)
 
  71                 switchStatement.defaultCase = this;
 
  76         public StringBuffer printStatement(int tab, StringBuffer output) {
 
  78                 printIndent(tab, output);
 
  79                 output.append("default : "); //$NON-NLS-1$
 
  80                 return output.append(';');
 
  83         public String toString(int tab) {
 
  85                 String s = tabString(tab);
 
  86                 s = s + "default : "; //$NON-NLS-1$
 
  90         public void traverse(IAbstractSyntaxTreeVisitor visitor,
 
  91                         BlockScope blockScope) {
 
  93                 visitor.visit(this, blockScope);
 
  94                 visitor.endVisit(this, blockScope);