Class ContextStack
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.ContextStack
-
class ContextStack extends java.lang.ObjectRealizes a context stack for evaluating nested self expressions.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classContextStack.StackFrameImplements a poolable stack frame.
-
Field Summary
Fields Modifier and Type Field Description private intcurrentStartprivate static Pool<ContextStack.StackFrame>POOLprivate java.util.Stack<ContextStack.StackFrame>stack
-
Constructor Summary
Constructors Constructor Description ContextStack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclear()Clears the whole stack.private voidensureCapacity(IDecisionVariable var, ContextStack.StackFrame frame)Ensures the capacity of a container variable.(package private) ValuegetSelfValue()Returns the value for self in the current context.(package private) voidpop()Pops a context frame.(package private) voidpush()Pushes an empty frame.(package private) voidpush(ContainerInitializer init)Pushes a frame with given initializer.(package private) voidpush(EvaluationAccessor ex)Pushes a context frame for the given expression.(package private) voidsetCompoundSlot(java.lang.String slot)Sets the compound slot in the actual frame.(package private) voidsetContainerIndex(int index)Sets the container index in the actual frame.(package private) voidsetContainerInitializer(ContainerInitializer init)Sets the container initializer in the actual frame.(package private) voidsetVariable(DecisionVariableDeclaration var)Sets the (top-level) variable in the actual frame.
-
-
-
Field Detail
-
POOL
private static final Pool<ContextStack.StackFrame> POOL
-
stack
private java.util.Stack<ContextStack.StackFrame> stack
-
currentStart
private int currentStart
-
-
Method Detail
-
push
void push(EvaluationAccessor ex)
Pushes a context frame for the given expression.- Parameters:
ex- the expression (will not be released
-
push
void push()
Pushes an empty frame.
-
push
void push(ContainerInitializer init)
Pushes a frame with given initializer.- Parameters:
init- the initializer- See Also:
push(),setContainerIndex(int)
-
setVariable
void setVariable(DecisionVariableDeclaration var)
Sets the (top-level) variable in the actual frame. Requirespush()before.- Parameters:
var- the variable
-
setContainerInitializer
void setContainerInitializer(ContainerInitializer init)
Sets the container initializer in the actual frame. Requirespush()before.- Parameters:
init- the initializer- See Also:
push()
-
setContainerIndex
void setContainerIndex(int index)
Sets the container index in the actual frame. Requirespush()before.- Parameters:
index- the index value- See Also:
push()
-
setCompoundSlot
void setCompoundSlot(java.lang.String slot)
Sets the compound slot in the actual frame. Requirespush()before.- Parameters:
slot- the new slot- See Also:
push()
-
pop
void pop()
Pops a context frame.
-
clear
void clear()
Clears the whole stack.
-
getSelfValue
Value getSelfValue()
Returns the value for self in the current context.- Returns:
- the expression for self
-
ensureCapacity
private void ensureCapacity(IDecisionVariable var, ContextStack.StackFrame frame)
Ensures the capacity of a container variable.- Parameters:
var- the variableframe- the stack frame with the access index to ensure fore
-
-