edu.cmu.cs.crystal.cfg
Class BlockStack<Node extends ICFGNode>

java.lang.Object
  extended by edu.cmu.cs.crystal.cfg.BlockStack<Node>
Type Parameters:
Node -
All Implemented Interfaces:
Cloneable

public class BlockStack<Node extends ICFGNode>
extends Object
implements Cloneable

Protocol to using block Stack is: call push/pop labeled and push/pop breakable in pairs. Between the pair, you may make more push/pop calls. This is a valid set of calls: pushBreakable() pushLabeled() popLabeled() pushLabeled() pushBreakable() popBreakable() popLabeled() popBreakeable() The getContinue and getBreakPoint may be called at any time.

Author:
ciera

Nested Class Summary
 class BlockStack.Block
           
 
Constructor Summary
BlockStack()
           
 
Method Summary
 BlockStack<Node> clone()
           
 Node getBreakPoint(String label)
           
 Node getContinuePoint(String label)
           
 boolean overrideIfExists(ASTNode owner, Node breakPoint, Node continuePoint)
          override the values only if this owner is already on the stack (that is, it got on the stack because it was labeled.
 void popLabeled()
          Pop the top of the stack.
 void popUnlabeled()
          Request a pop from a breakable node.
 void pushLabeled(String label, ASTNode owner)
          Push on a labeled statement.
 void pushUnlabeled(ASTNode owner, Node breakPoint, Node continuePoint)
          Push on a statement.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockStack

public BlockStack()
Method Detail

pushLabeled

public void pushLabeled(String label,
                        ASTNode owner)
Push on a labeled statement. Owner is the statement which is labeled. It will be used as the break point by default. By default, no continue will be set.

Parameters:
label -
owner -

pushUnlabeled

public void pushUnlabeled(ASTNode owner,
                          Node breakPoint,
                          Node continuePoint)
Push on a statement. If this statement already is on the stack (it was labeled), this this will override the break/continue points. If the owner is not on the stack, then it will simply push on with no label known.

Parameters:
owner - The owning statement
breakPoint - The break point; may be null
continuePoint - The continue point; may be null

popLabeled

public void popLabeled()
Pop the top of the stack.


popUnlabeled

public void popUnlabeled()
Request a pop from a breakable node. This will only actually pop if it will not be popped by popLabeled.


overrideIfExists

public boolean overrideIfExists(ASTNode owner,
                                Node breakPoint,
                                Node continuePoint)
override the values only if this owner is already on the stack (that is, it got on the stack because it was labeled.

Parameters:
owner -
breakPoint -
continuePoint -
Returns:
true if it was able to override the the values, false if the owner was not already on the stack

getBreakPoint

public Node getBreakPoint(String label)

getContinuePoint

public Node getContinuePoint(String label)

clone

public BlockStack<Node> clone()
Overrides:
clone in class Object