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