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
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.flow;
13 import net.sourceforge.phpdt.internal.compiler.ast.Statement;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
16 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
18 public abstract class FlowInfo {
19 public static final UnconditionalFlowInfo DeadEnd = new UnconditionalFlowInfo(); // Represents a dead branch status of initialization
20 abstract public UnconditionalFlowInfo addInitializationsFrom(UnconditionalFlowInfo otherInits);
21 abstract public UnconditionalFlowInfo addPotentialInitializationsFrom(UnconditionalFlowInfo otherInits);
22 public FlowInfo asNegatedCondition() {
25 public boolean complainIfUnreachable(Statement statement, BlockScope scope) {
26 // Report an error if necessary
30 public static FlowInfo conditional(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse){
31 // if (initsWhenTrue.equals(initsWhenFalse)) return initsWhenTrue; -- could optimize if #equals is defined
32 return new ConditionalFlowInfo(initsWhenTrue, initsWhenFalse);
34 abstract public FlowInfo copy();
35 public static UnconditionalFlowInfo initial(int maxFieldCount) {
36 UnconditionalFlowInfo info = new UnconditionalFlowInfo();
37 info.maxFieldCount = maxFieldCount;
40 abstract public FlowInfo initsWhenFalse();
41 abstract public FlowInfo initsWhenTrue();
42 final public boolean isDeadEnd() {
43 return this == DeadEnd;
46 * Check status of definite assignment for a field.
48 abstract public boolean isDefinitelyAssigned(FieldBinding field);
50 * Check status of definite assignment for a local.
52 public abstract boolean isDefinitelyAssigned(LocalVariableBinding local);
53 abstract public boolean isFakeReachable();
55 * Check status of potential assignment for a field.
57 abstract public boolean isPotentiallyAssigned(FieldBinding field);
59 * Check status of potential assignment for a local variable.
61 abstract public boolean isPotentiallyAssigned(LocalVariableBinding field);
63 * Record a field got definitely assigned.
65 abstract public void markAsDefinitelyAssigned(FieldBinding field);
67 * Record a local got definitely assigned.
69 abstract public void markAsDefinitelyAssigned(LocalVariableBinding local);
71 * Clear the initialization info for a field
73 abstract public void markAsDefinitelyNotAssigned(FieldBinding field);
75 * Clear the initialization info for a local variable
77 abstract public void markAsDefinitelyNotAssigned(LocalVariableBinding local);
78 abstract public FlowInfo markAsFakeReachable(boolean isFakeReachable);
79 abstract public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits);
80 public String toString(){
82 return "FlowInfo.DeadEnd"; //$NON-NLS-1$
84 return super.toString();
86 abstract public UnconditionalFlowInfo unconditionalInits();