1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / DefaultCase.java
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
5  * 
6  * Contributors: IBM Corporation - initial API and implementation
7  **********************************************************************************************************************************/
8 package net.sourceforge.phpdt.internal.compiler.ast;
9
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;
17
18 public class DefaultCase extends Statement {
19
20         public CaseLabel targetLabel;
21
22         /**
23          * DefautCase constructor comment.
24          */
25         public DefaultCase(int sourceEnd, int sourceStart) {
26
27                 this.sourceStart = sourceStart;
28                 this.sourceEnd = sourceEnd;
29         }
30
31         public FlowInfo analyseCode(BlockScope currentScope,
32                         FlowContext flowContext, FlowInfo flowInfo) {
33
34                 return flowInfo;
35         }
36
37         /**
38          * Default case code generation
39          * 
40          * @param currentScope
41          *            net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
42          * @param codeStream
43          *            net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
44          */
45         // public void generateCode(BlockScope currentScope, CodeStream codeStream)
46         // {
47         //
48         // if ((bits & IsReachableMASK) == 0) {
49         // return;
50         // }
51         // int pc = codeStream.position;
52         // targetLabel.place();
53         // codeStream.recordPositionsFrom(pc, this.sourceStart);
54         //
55         // }
56         /**
57          * No-op : should use resolveCase(...) instead.
58          */
59         public void resolve(BlockScope scope) {
60         }
61
62         public Constant resolveCase(BlockScope scope, TypeBinding testType,
63                         SwitchStatement switchStatement) {
64
65                 // remember the default case into the associated switch statement
66                 if (switchStatement.defaultCase != null)
67                         scope.problemReporter().duplicateDefaultCase(this);
68
69                 // on error the last default will be the selected one .... (why not)
70                 // ....
71                 switchStatement.defaultCase = this;
72                 resolve(scope);
73                 return null;
74         }
75
76         public StringBuffer printStatement(int tab, StringBuffer output) {
77
78                 printIndent(tab, output);
79                 output.append("default : "); //$NON-NLS-1$
80                 return output.append(';');
81         }
82
83         public String toString(int tab) {
84
85                 String s = tabString(tab);
86                 s = s + "default : "; //$NON-NLS-1$
87                 return s;
88         }
89
90         public void traverse(IAbstractSyntaxTreeVisitor visitor,
91                         BlockScope blockScope) {
92
93                 visitor.visit(this, blockScope);
94                 visitor.endVisit(this, blockScope);
95         }
96 }