Package org.eclipse.m2m.atl.emftvm.util
Class StackFrame
- java.lang.Object
-
- org.eclipse.m2m.atl.emftvm.util.StackFrame
-
public final class StackFrame extends java.lang.Object
EMFTVM stack frame. Stores local variables and code block invocation stack.
-
-
Constructor Summary
Constructors Constructor Description StackFrame(ExecEnv env, CodeBlock codeBlock)
Creates a newStackFrame
.StackFrame(StackFrame parent, java.lang.reflect.Method nativeMethod)
Creates a newStackFrame
.StackFrame(StackFrame parent, java.lang.String opName)
Creates a newStackFrame
.StackFrame(StackFrame parent, CodeBlock codeBlock)
Creates a newStackFrame
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CodeBlock
getCodeBlock()
Returns the codeBlock.ExecEnv
getEnv()
Returns theExecEnv
.LineNumber
getLineNumber()
Returns the source code line number of the current instruction location (for debugger).java.lang.Object
getLocal(int slot)
Returns the local variable value with the given slot.java.lang.Object
getLocal(int cbOffset, int slot)
Returns the local variable value with the given slot.java.util.Map<java.lang.String,java.lang.Object>
getLocalVariables()
Returns the local variables map (for debugger).int
getLocation()
Returns the current instruction pointer value (starts at 0, for debugger).java.lang.reflect.Method
getNativeMethod()
Returns the nativeMethod.CodeBlock
getOperation()
Returns theCodeBlock
(for debugger).java.lang.String
getOpName()
Returns the "operation" name for this stack frame (for debugger).StackFrame
getParent()
Returns the parent stack frame.int
getPc()
Returns the pc.java.lang.String
getSourceLocation()
Returns the source code location of the current instruction location (for debugger).LazyList<StackFrame>
getStack()
Gets a sequence of nested stacks (for debugger).StackFrame
getSubFrame(CodeBlock cb, java.lang.Object context)
Retrieves a new stack frame that is a sub-frame ofthis
.StackFrame
getSubFrame(CodeBlock cb, java.lang.Object[] args)
Retrieves a new stack frame that is a sub-frame ofthis
.StackFrame
getSubFrame(CodeBlock cb, java.lang.Object context, java.lang.Object arg)
Retrieves a new stack frame that is a sub-frame ofthis
.StackFrame
getSubFrame(CodeBlock cb, java.lang.Object context, java.lang.Object[] args)
Retrieves a new stack frame that is a sub-frame ofthis
.StackFrame
prepareNativeArgs(java.lang.reflect.Method method, java.lang.Object[] args)
Preparesargs
instances ofCodeBlock
by setting their parent frame (for VM re-entry), and instances ofEnumLiteral
for conversion to the method's corresponding parameter type.StackFrame
prepareNativeArgs(java.lang.reflect.Method method, java.lang.Object context, java.lang.Object[] args)
Preparescontext
andargs
instances ofCodeBlock
by setting their parent frame (for VM re-entry), and instances ofEnumLiteral
for conversion to the method's corresponding parameter type.StackFrame
prepareNativeContext(java.lang.reflect.Method method, java.lang.Object context)
Preparescontext
instances ofCodeBlock
by setting their parent frame (for VM re-entry).java.lang.String
resolveVariableName(int slot)
Returns the local variable name at the givenslot
(for debugger).void
setLocal(java.lang.Object value, int slot)
Sets local variable with givenslot
tovalue
.void
setLocal(java.lang.Object value, int cbOffset, int slot)
Sets local variable with givenslot
tovalue
.void
setLocals(java.lang.Object[] values)
Sets the first local variables to the given values.void
setLocals(java.lang.Object self, java.lang.Object[] values)
Sets the first local variables to the given values.void
setPc(int pc)
Sets the pc.java.lang.String
toString()
-
-
-
Constructor Detail
-
StackFrame
public StackFrame(ExecEnv env, CodeBlock codeBlock)
Creates a newStackFrame
. Use only for root frames!- Parameters:
env
- the currentExecEnv
codeBlock
- the codeBlock context for this stack frame
-
StackFrame
public StackFrame(StackFrame parent, CodeBlock codeBlock)
Creates a newStackFrame
.- Parameters:
parent
- the parent stack frame, if anycodeBlock
- the codeBlock context for this stack frame
-
StackFrame
public StackFrame(StackFrame parent, java.lang.reflect.Method nativeMethod)
Creates a newStackFrame
.- Parameters:
parent
- the parent stack frame, if anynativeMethod
- the native Java method context for this stack frame
-
StackFrame
public StackFrame(StackFrame parent, java.lang.String opName)
Creates a newStackFrame
.- Parameters:
parent
- the parent stack frame, if anyopName
- the operation name for the debugger
-
-
Method Detail
-
setLocal
public void setLocal(java.lang.Object value, int cbOffset, int slot)
Sets local variable with givenslot
tovalue
.- Parameters:
value
- the value to setcbOffset
- the codeblock offsetslot
- the variable slot
-
setLocal
public void setLocal(java.lang.Object value, int slot)
Sets local variable with givenslot
tovalue
.- Parameters:
value
- the value to setslot
- the variable slot
-
setLocals
public void setLocals(java.lang.Object self, java.lang.Object[] values)
Sets the first local variables to the given values.- Parameters:
self
- the "self" variable valuevalues
- the other local variable values
-
setLocals
public void setLocals(java.lang.Object[] values)
Sets the first local variables to the given values.- Parameters:
values
- the local variable values
-
getLocal
public java.lang.Object getLocal(int cbOffset, int slot)
Returns the local variable value with the given slot.- Parameters:
cbOffset
- parent code block offsetslot
- the local variable slot- Returns:
- the local variable value with the given slot.
-
getLocal
public java.lang.Object getLocal(int slot)
Returns the local variable value with the given slot.- Parameters:
slot
- the local variable slot- Returns:
- the local variable value with the given slot.
-
getParent
public StackFrame getParent()
Returns the parent stack frame.- Returns:
- the parent stack frame
-
getCodeBlock
public CodeBlock getCodeBlock()
Returns the codeBlock.- Returns:
- the codeBlock
-
getNativeMethod
public java.lang.reflect.Method getNativeMethod()
Returns the nativeMethod.- Returns:
- the nativeMethod
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setPc
public void setPc(int pc)
Sets the pc.- Parameters:
pc
- the pc to set
-
getPc
public int getPc()
Returns the pc.- Returns:
- the pc
-
getSubFrame
public StackFrame getSubFrame(CodeBlock cb, java.lang.Object[] args)
Retrieves a new stack frame that is a sub-frame ofthis
.- Parameters:
cb
- the code block of the sub-frameargs
- the arguments to pass into the sub-frame- Returns:
- a new stack frame
-
getSubFrame
public StackFrame getSubFrame(CodeBlock cb, java.lang.Object context, java.lang.Object[] args)
Retrieves a new stack frame that is a sub-frame ofthis
.- Parameters:
cb
- the code block of the sub-framecontext
- theself
argument to pass into the sub-frameargs
- the other arguments to pass into the sub-frame- Returns:
- a new stack frame
-
getSubFrame
public StackFrame getSubFrame(CodeBlock cb, java.lang.Object context)
Retrieves a new stack frame that is a sub-frame ofthis
.- Parameters:
cb
- the code block of the sub-framecontext
- theself
argument to pass into the sub-frame- Returns:
- a new stack frame
-
getSubFrame
public StackFrame getSubFrame(CodeBlock cb, java.lang.Object context, java.lang.Object arg)
Retrieves a new stack frame that is a sub-frame ofthis
.- Parameters:
cb
- the code block of the sub-framecontext
- theself
argument to pass into the sub-framearg
- the other argument to pass into the sub-frame- Returns:
- a new stack frame
-
prepareNativeArgs
public StackFrame prepareNativeArgs(java.lang.reflect.Method method, java.lang.Object[] args)
Preparesargs
instances ofCodeBlock
by setting their parent frame (for VM re-entry), and instances ofEnumLiteral
for conversion to the method's corresponding parameter type. Creates a sub-frame only when necessary for VM re-entry.- Parameters:
method
- the native method to be invokedargs
- the method arguments- Returns:
- the sub-frame, if necessary
-
prepareNativeArgs
public StackFrame prepareNativeArgs(java.lang.reflect.Method method, java.lang.Object context, java.lang.Object[] args)
Preparescontext
andargs
instances ofCodeBlock
by setting their parent frame (for VM re-entry), and instances ofEnumLiteral
for conversion to the method's corresponding parameter type. Creates a sub-frame only when necessary for VM re-entry.- Parameters:
method
- the native method to be invokedcontext
- the method context (i.e. self)args
- the method arguments- Returns:
- the sub-frame, if necessary
-
prepareNativeContext
public StackFrame prepareNativeContext(java.lang.reflect.Method method, java.lang.Object context)
Preparescontext
instances ofCodeBlock
by setting their parent frame (for VM re-entry). Creates a sub-frame only when necessary for VM re-entry.- Parameters:
method
- the native method to be invokedcontext
- the method context (i.e. self)- Returns:
- the sub-frame, if necessary
-
getStack
public LazyList<StackFrame> getStack()
Gets a sequence of nested stacks (for debugger).- Returns:
- the Stack list
-
getLocalVariables
public java.util.Map<java.lang.String,java.lang.Object> getLocalVariables()
Returns the local variables map (for debugger).- Returns:
- the local variables map
-
resolveVariableName
public java.lang.String resolveVariableName(int slot)
Returns the local variable name at the givenslot
(for debugger).- Parameters:
slot
- the local variable slot- Returns:
- the variable name at the given slot
-
getOperation
public CodeBlock getOperation()
Returns theCodeBlock
(for debugger).- Returns:
- the
CodeBlock
. - See Also:
getCodeBlock()
-
getLocation
public int getLocation()
Returns the current instruction pointer value (starts at 0, for debugger).- Returns:
- the current instruction pointer value
- See Also:
getPc()
-
getSourceLocation
public java.lang.String getSourceLocation()
Returns the source code location of the current instruction location (for debugger).- Returns:
- the source code location of the instruction at the current location.
- See Also:
getLocation()
,getLineNumber()
-
getLineNumber
public LineNumber getLineNumber()
Returns the source code line number of the current instruction location (for debugger).- Returns:
- the source code line number of the instruction at the current location.
- See Also:
getLocation()
-
getOpName
public java.lang.String getOpName()
Returns the "operation" name for this stack frame (for debugger).- Returns:
- the "operation" name for this stack frame
-
-