org.aspectj.compiler.base.ast
Class ControlContext

java.lang.Object
  extended byorg.aspectj.compiler.base.ast.ControlContext

public final class ControlContext
extends java.lang.Object

A representation of the control context, the lexical context of statements that affect control flow. This is used to handle the control issues arising from labeled statements, breaks and continues, returns and throws, tries and continues, loops (for, while, do), and switches.

See Also:
LabeledStmt, WhileStmt, DoStmt, ForStmt, SwitchStmt, WindingStmt, TryStmt, SynchronizedStmt, BreakStmt, ContinueStmt, ReturnStmt, ThrowStmt

Constructor Summary
ControlContext()
           
 
Method Summary
 void enter(Stmt s)
          Enters the context of a control-effecting statement.
 void exit()
          Exits the context of a previously-entered control-effecting statement.
 Stmt getBreakTarget(java.lang.String label)
          Returns the target statement of a break statement.
 Stmt getContinueTarget(java.lang.String label)
          Returns the target statement of a continue statement.
 java.util.Iterator getWindsUntil(Stmt end)
          Returns an iterator view of the winding statements up to a control target.
 boolean isLabelUsed(java.lang.String label)
          Returns true if a LabeledStmt with a label is in the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlContext

public ControlContext()
Method Detail

enter

public void enter(Stmt s)
Enters the context of a control-effecting statement.


exit

public void exit()
Exits the context of a previously-entered control-effecting statement.


getBreakTarget

public Stmt getBreakTarget(java.lang.String label)
Returns the target statement of a break statement.

Parameters:
label - label of break statement, or null
Returns:
the target of the break statement.
Throws:
java.util.NoSuchElementException - there is no target

getContinueTarget

public Stmt getContinueTarget(java.lang.String label)
Returns the target statement of a continue statement.

Parameters:
label - label of continue statement, or null
Returns:
the target of the continue statement.
Throws:
java.util.NoSuchElementException - there is no target
java.lang.UnsupportedOperationException - the target is not continuable

isLabelUsed

public boolean isLabelUsed(java.lang.String label)
Returns true if a LabeledStmt with a label is in the context.

Parameters:
label - label to check for.
Returns:
true if label is used in the context, false otherwise.

getWindsUntil

public java.util.Iterator getWindsUntil(Stmt end)
Returns an iterator view of the winding statements up to a control target. If null is passed in, will return all winding statements. This iterator is not only non-thread-safe, it cannot be stored anywhere either, since it shares its backing with the context. So as soon as it is returned, it should be iterated over.

Parameters:
end - the control-effecting statement enclosing the winding statements.
Returns:
an iterator view of the winding statements up to a control target.