82e84fd2cf47c4a8fc233038ed5d81c839191950
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Statement.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.codegen.CodeStream;
14 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
15 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
16 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
17 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
18 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
19 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
20 import net.sourceforge.phpdt.internal.compiler.problem.ShouldNotImplement;
21 import net.sourceforge.phpdt.internal.compiler.util.Util;
22
23 public abstract class Statement extends AstNode {
24         
25         /**
26          * Statement constructor comment.
27          */
28         public Statement() {
29                 super();
30         }
31         
32         public FlowInfo analyseCode(
33                 BlockScope currentScope,
34                 FlowContext flowContext,
35                 FlowInfo flowInfo) {
36                 return flowInfo;
37         }
38         
39         public void generateCode(BlockScope currentScope, CodeStream codeStream) {
40                 throw new ShouldNotImplement(Util.bind("ast.missingStatement")); //$NON-NLS-1$
41         }
42         
43         public boolean isEmptyBlock() {
44                 return false;
45         }
46         
47         public boolean isValidJavaStatement() {
48                 //the use of this method should be avoid in most cases
49                 //and is here mostly for documentation purpose.....
50                 //while the parser is responsable for creating
51                 //welled formed expression statement, which results
52                 //in the fact that java-non-semantic-expression-used-as-statement
53                 //should not be parsable...thus not being built.
54                 //It sounds like the java grammar as help the compiler job in removing
55                 //-by construction- some statement that would have no effect....
56                 //(for example all expression that may do side-effects are valid statement
57                 // -this is an appromative idea.....-)
58
59                 return true;
60         }
61         
62         public void resolve(BlockScope scope) {
63         }
64         
65         public Constant resolveCase(
66                 BlockScope scope,
67                 TypeBinding testType,
68                 SwitchStatement switchStatement) {
69                 // statement within a switch that are not case are treated as normal statement.... 
70
71                 resolve(scope);
72                 return null;
73         }
74         
75         public void resetStateForCodeGeneration() {
76         }
77         
78         /**
79          * INTERNAL USE ONLY.
80          * Do nothing by default. This is used to redirect inter-statements jumps.
81          */
82         public void branchChainTo(Label label) {
83         }
84 }