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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
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.*;
18 public abstract class Statement extends ASTNode {
20 public abstract FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo);
24 * This is used to redirect inter-statements jumps.
26 public void branchChainTo(Label label) {
27 // do nothing by default
30 // Report an error if necessary
31 public boolean complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, boolean didAlreadyComplain) {
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);
39 return reported; // keep going for fake reachable
44 public abstract void generateCode(BlockScope currentScope, CodeStream codeStream);
46 public boolean isEmptyBlock() {
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.....-)
65 public StringBuffer print(int indent, StringBuffer output) {
66 return printStatement(indent, output);
68 public abstract StringBuffer printStatement(int indent, StringBuffer output);
70 public abstract void resolve(BlockScope scope);
72 public Constant resolveCase(BlockScope scope, TypeBinding testType, SwitchStatement switchStatement) {
73 // statement within a switch that are not case are treated as normal statement....