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.phpeclipse.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, FlowContext flowContext, FlowInfo flowInfo) {
37 * Default case code generation
40 * net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
42 * net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
44 // public void generateCode(BlockScope currentScope, CodeStream codeStream) {
46 // if ((bits & IsReachableMASK) == 0) {
49 // int pc = codeStream.position;
50 // targetLabel.place();
51 // codeStream.recordPositionsFrom(pc, this.sourceStart);
55 * No-op : should use resolveCase(...) instead.
57 public void resolve(BlockScope scope) {
60 public Constant resolveCase(BlockScope scope, TypeBinding testType, SwitchStatement switchStatement) {
62 // remember the default case into the associated switch statement
63 if (switchStatement.defaultCase != null)
64 scope.problemReporter().duplicateDefaultCase(this);
66 // on error the last default will be the selected one .... (why not) ....
67 switchStatement.defaultCase = this;
72 public StringBuffer printStatement(int tab, StringBuffer output) {
74 printIndent(tab, output);
75 output.append("default : "); //$NON-NLS-1$
76 return output.append(';');
79 public String toString(int tab) {
81 String s = tabString(tab);
82 s = s + "default : "; //$NON-NLS-1$
86 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
88 visitor.visit(this, blockScope);
89 visitor.endVisit(this, blockScope);