new html templates
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / FlowInfo.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.flow;
12
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;
17
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() {
23         return this;
24 }
25 public boolean complainIfUnreachable(Statement statement, BlockScope scope) {
26         // Report an error if necessary
27
28         return false;
29 }
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);
33 }
34 abstract public FlowInfo copy();
35 public static UnconditionalFlowInfo initial(int maxFieldCount) {
36         UnconditionalFlowInfo info = new UnconditionalFlowInfo();
37         info.maxFieldCount = maxFieldCount;
38         return info;
39 }
40 abstract public FlowInfo initsWhenFalse();
41 abstract public FlowInfo initsWhenTrue();
42 final public boolean isDeadEnd() {
43         return this == DeadEnd;
44 }
45 /**
46  * Check status of definite assignment for a field.
47  */
48  abstract public boolean isDefinitelyAssigned(FieldBinding field);   
49 /**
50  * Check status of definite assignment for a local.
51  */
52 public abstract boolean isDefinitelyAssigned(LocalVariableBinding local);
53 abstract public boolean isFakeReachable();
54 /**
55  * Check status of potential assignment for a field.
56  */
57  abstract public boolean isPotentiallyAssigned(FieldBinding field);   
58 /**
59  * Check status of potential assignment for a local variable.
60  */
61  abstract public boolean isPotentiallyAssigned(LocalVariableBinding field);   
62 /**
63  * Record a field got definitely assigned.
64  */
65 abstract public void markAsDefinitelyAssigned(FieldBinding field);
66 /**
67  * Record a local got definitely assigned.
68  */
69 abstract public void markAsDefinitelyAssigned(LocalVariableBinding local);
70 /**
71  * Clear the initialization info for a field
72  */
73 abstract public void markAsDefinitelyNotAssigned(FieldBinding field);
74 /**
75  * Clear the initialization info for a local variable
76  */
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(){
81         if (this == DeadEnd){
82                 return "FlowInfo.DeadEnd"; //$NON-NLS-1$
83         }
84         return super.toString();
85 }
86 abstract public UnconditionalFlowInfo unconditionalInits();
87 }