1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.codegen.CaseLabel;
15 import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
16 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
17 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
18 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
19 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
20 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
22 public class DefaultCase extends Statement {
24 public CaseLabel targetLabel;
26 * DefautCase constructor comment.
28 public DefaultCase(int sourceEnd, int sourceStart) {
30 this.sourceStart = sourceStart;
31 this.sourceEnd = sourceEnd;
34 public FlowInfo analyseCode(
35 BlockScope currentScope,
36 FlowContext flowContext,
43 * Default case code generation
45 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
46 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
48 public void generateCode(BlockScope currentScope, CodeStream codeStream) {
50 if ((bits & IsReachableMASK) == 0) {
53 int pc = codeStream.position;
55 codeStream.recordPositionsFrom(pc, this.sourceStart);
58 public Constant resolveCase(
61 SwitchStatement switchStatement) {
63 // remember the default case into the associated switch statement
64 if (switchStatement.defaultCase != null)
65 scope.problemReporter().duplicateDefaultCase(this);
67 // on error the last default will be the selected one .... (why not) ....
68 switchStatement.defaultCase = this;
73 public String toString(int tab) {
75 String s = tabString(tab);
76 s = s + "default : "; //$NON-NLS-1$
81 IAbstractSyntaxTreeVisitor visitor,
82 BlockScope blockScope) {
84 visitor.visit(this, blockScope);
85 visitor.endVisit(this, blockScope);