Makefile fixup
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / Statement.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.impl.*;
14 import org.eclipse.jdt.internal.compiler.codegen.*;
15 import org.eclipse.jdt.internal.compiler.flow.*;
16 import org.eclipse.jdt.internal.compiler.lookup.*;
17
18 public abstract class Statement extends ASTNode {
19         
20         public abstract FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo);
21         
22         /**
23          * INTERNAL USE ONLY.
24          * This is used to redirect inter-statements jumps.
25          */
26         public void branchChainTo(Label label) {
27                 // do nothing by default
28         }
29         
30         // Report an error if necessary
31         public boolean complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, boolean didAlreadyComplain) {
32         
33                 if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0) {
34                         this.bits &= ~ASTNode.IsReachableMASK;
35                         boolean reported = flowInfo == FlowInfo.DEAD_END;
36                         if (!didAlreadyComplain && reported) {
37                                 scope.problemReporter().unreachableCode(this);
38                         }
39                         return reported; // keep going for fake reachable
40                 }
41                 return false;
42         }
43         
44         public abstract void generateCode(BlockScope currentScope, CodeStream codeStream);
45         
46         public boolean isEmptyBlock() {
47                 return false;
48         }
49         
50         public boolean isValidJavaStatement() {
51                 //the use of this method should be avoid in most cases
52                 //and is here mostly for documentation purpose.....
53                 //while the parser is responsable for creating
54                 //welled formed expression statement, which results
55                 //in the fact that java-non-semantic-expression-used-as-statement
56                 //should not be parsable...thus not being built.
57                 //It sounds like the java grammar as help the compiler job in removing
58                 //-by construction- some statement that would have no effect....
59                 //(for example all expression that may do side-effects are valid statement
60                 // -this is an appromative idea.....-)
61
62                 return true;
63         }
64         
65         public StringBuffer print(int indent, StringBuffer output) {
66                 return printStatement(indent, output);
67         }
68         public abstract StringBuffer printStatement(int indent, StringBuffer output);
69
70         public abstract void resolve(BlockScope scope);
71         
72         public Constant resolveCase(BlockScope scope, TypeBinding testType, SwitchStatement switchStatement) {
73                 // statement within a switch that are not case are treated as normal statement.... 
74
75                 resolve(scope);
76                 return null;
77         }
78
79 }