public class FrameStack extends Object
A FrameStack is a stack of frames that stores the variables created during the execution of an EOL program.
A FrameStack is divided into two distinct regions, one for global variables and one for local variables. The global region always contains at least one frame, while the local region can be empty.
Frame
Modifier and Type | Field and Description |
---|---|
protected HashMap<String,Variable> |
builtInVariables |
protected org.eclipse.epsilon.eol.execute.context.FrameStackRegion |
globals |
protected org.eclipse.epsilon.eol.execute.context.FrameStackRegion |
locals |
Constructor and Description |
---|
FrameStack()
Creates a new frame stack
|
Modifier and Type | Method and Description |
---|---|
FrameStack |
clone() |
boolean |
contains(String name)
Returns true if a variable with the
specified name exists in the scope
|
boolean |
containsGlobal(String name)
Returns true if a global variable with the
specified name exists.
|
boolean |
containsLocal(String name)
Returns true if a local variable with the
specified name exists.
|
protected int |
countGlobalFrames() |
void |
dispose() |
Frame |
enter(FrameType type,
ModuleElement entryPoint,
Variable... variables)
Deprecated.
Use
#enterLocal(FrameType, AST, Variable...) instead.
This method will be removed from a future version of Epsilon. |
Frame |
enterGlobal(FrameType type,
ModuleElement entryPoint,
Variable... variables)
Enters a new global frame.
|
Frame |
enterLocal(FrameType type,
ModuleElement entryPoint,
Variable... variables)
Enters a new local frame.
|
Variable |
get(String name)
Returns the variable with the specified
name and if it does not exist returns
null . |
ModuleElement |
getCurrentStatement() |
int |
getDepth() |
List<SingleFrame> |
getFrames()
Returns a list with all local (from top to bottom) and global (from top
to bottom) stack frames, in that order.
|
Variable |
getGlobal(String name)
Returns the global variable with the specified name
If the global variable does not exist, this method
returns
null . |
Frame |
getGlobals()
Deprecated.
Use the designated methods for manipulating global variables
(e.g.
#enterGlobal(FrameType, AST, Variable...) ,
putGlobal(Variable) and getGlobal(String) ).
If no appropriate method exists, please open a bug report to
request it. This method will be removed in a future version
of Epsilon. |
Variable |
getLocal(String name)
Returns the local variable with the specified name
If the local variable does not exist, this method
returns
null . |
Frame |
getTopFrame() |
boolean |
isInLoop() |
void |
leave(ModuleElement entryPoint)
Deprecated.
Use
#leaveLocal(AST) instead.
This method will be removed from a future version of Epsilon. |
void |
leave(ModuleElement entryPoint,
boolean dispose)
Deprecated.
Use
#leaveLocal(AST, boolean) instead.
This method will be removed from a future version of Epsilon. |
void |
leaveGlobal(ModuleElement entryPoint)
Convenience method for
#leaveGlobal(AST, boolean) which disposes of the
global stack frame that was left. |
void |
leaveGlobal(ModuleElement entryPoint,
boolean dispose)
Leaves the current global stack frame and returns to the previous frame
in the stack.
|
void |
leaveLocal(ModuleElement entryPoint)
Convenience method for
#leaveLocal(AST, boolean)) which disposes of the stack
frame that was left. |
void |
leaveLocal(ModuleElement entryPoint,
boolean dispose)
Leaves the current local frame and returns to the previous frame in the
stack.
|
void |
put(Variable... variables)
Puts one or more new variables in the topmost frame of the scope.
|
void |
put(Variable variable)
Puts a new variable in the topmost frame of the scope.
|
void |
putGlobal(Variable... variables)
Puts one or more new variables in the topmost global stack frame.
|
void |
putGlobal(Variable variable)
Puts a new variable in the topmost global stack frame.
|
void |
remove(String variable)
Removes a variable by name from the topmost frame of the scope.
|
void |
setCurrentStatement(ModuleElement ast) |
String |
toString() |
protected org.eclipse.epsilon.eol.execute.context.FrameStackRegion globals
protected org.eclipse.epsilon.eol.execute.context.FrameStackRegion locals
public void dispose()
public Frame enterGlobal(FrameType type, ModuleElement entryPoint, Variable... variables)
type
- The type of the frame: variables in lower stack frames are
visible from an FrameType.UNPROTECTED
frame, and
invisible from a FrameType.PROTECTED
frame.entryPoint
- The AST from which the entry is performedvariables
- Zero or more variables that will be added to the new frame.public Frame enterLocal(FrameType type, ModuleElement entryPoint, Variable... variables)
type
- The type of the frame: variables in lower stack frames are
visible from an FrameType.UNPROTECTED
frame, and
invisible from a FrameType.PROTECTED
frame.entryPoint
- The AST from which the entry is performedvariables
- Zero or more variables that will be added to the new frame.public Frame enter(FrameType type, ModuleElement entryPoint, Variable... variables)
#enterLocal(FrameType, AST, Variable...)
instead.
This method will be removed from a future version of Epsilon.public void leaveLocal(ModuleElement entryPoint, boolean dispose)
#leaveGlobal(AST, boolean)
for that.public void leaveLocal(ModuleElement entryPoint)
#leaveLocal(AST, boolean))
which disposes of the stack
frame that was left.public void leaveGlobal(ModuleElement entryPoint, boolean dispose)
#leaveLocal(AST, boolean)
for that. This method will not leave the
last remaining global stack frame.public void leaveGlobal(ModuleElement entryPoint)
#leaveGlobal(AST, boolean)
which disposes of the
global stack frame that was left.public void leave(ModuleElement entryPoint, boolean dispose)
#leaveLocal(AST, boolean)
instead.
This method will be removed from a future version of Epsilon.public void leave(ModuleElement entryPoint)
#leaveLocal(AST)
instead.
This method will be removed from a future version of Epsilon.#leaveLocal(AST)
which disposes of the stack
frame that was left.public void put(Variable... variables)
public void put(Variable variable)
public void putGlobal(Variable... variables)
public void putGlobal(Variable variable)
public void remove(String variable)
public Variable get(String name)
null
. Note
that variables in a higher frame shadow variables with
the same name in lower frames. Similarly, local variables
shadow global variables with the same name.name
- The name of the variablenull
public Variable getLocal(String name)
Returns the local variable with the specified name
If the local variable does not exist, this method
returns null
.
Note: this method does not respect the
usual shadowing semantics of the FrameStack, and consequently
most clients should call get(String)
(i.e., only call
this method if you really know what you are doing!)
name
- The name of the local variablenull
public Variable getGlobal(String name)
Returns the global variable with the specified name
If the global variable does not exist, this method
returns null
.
Note: this method does not respect the
usual shadowing semantics of the FrameStack, and consequently
most clients should call get(String)
(i.e., only call
this method if you really know what you are doing!)
name
- The name of the global variablenull
public boolean isInLoop()
public boolean contains(String name)
name
- public boolean containsLocal(String name)
Note: this method does not respect the
usual shadowing semantics of the FrameStack, and consequently
most clients should call contains(String)
(i.e., only call
this method if you really know what you are doing!)
name
- public boolean containsGlobal(String name)
Note: this method does not respect the
usual shadowing semantics of the FrameStack, and consequently
most clients should call contains(String)
(i.e., only call
this method if you really know what you are doing!)
name
- @Deprecated public Frame getGlobals()
#enterGlobal(FrameType, AST, Variable...)
,
putGlobal(Variable)
and getGlobal(String)
).
If no appropriate method exists, please open a bug report to
request it. This method will be removed in a future version
of Epsilon.public List<SingleFrame> getFrames()
public int getDepth()
public FrameStack clone()
public Frame getTopFrame()
public ModuleElement getCurrentStatement()
public void setCurrentStatement(ModuleElement ast)
protected int countGlobalFrames()
Copyright © 2018. All rights reserved.