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.ObjectEMFTVM 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 CodeBlockgetCodeBlock()Returns the codeBlock.ExecEnvgetEnv()Returns theExecEnv.LineNumbergetLineNumber()Returns the source code line number of the current instruction location (for debugger).java.lang.ObjectgetLocal(int slot)Returns the local variable value with the given slot.java.lang.ObjectgetLocal(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).intgetLocation()Returns the current instruction pointer value (starts at 0, for debugger).java.lang.reflect.MethodgetNativeMethod()Returns the nativeMethod.CodeBlockgetOperation()Returns theCodeBlock(for debugger).java.lang.StringgetOpName()Returns the "operation" name for this stack frame (for debugger).StackFramegetParent()Returns the parent stack frame.intgetPc()Returns the pc.java.lang.StringgetSourceLocation()Returns the source code location of the current instruction location (for debugger).LazyList<StackFrame>getStack()Gets a sequence of nested stacks (for debugger).StackFramegetSubFrame(CodeBlock cb, java.lang.Object context)Retrieves a new stack frame that is a sub-frame ofthis.StackFramegetSubFrame(CodeBlock cb, java.lang.Object[] args)Retrieves a new stack frame that is a sub-frame ofthis.StackFramegetSubFrame(CodeBlock cb, java.lang.Object context, java.lang.Object arg)Retrieves a new stack frame that is a sub-frame ofthis.StackFramegetSubFrame(CodeBlock cb, java.lang.Object context, java.lang.Object[] args)Retrieves a new stack frame that is a sub-frame ofthis.StackFrameprepareNativeArgs(java.lang.reflect.Method method, java.lang.Object[] args)Preparesargsinstances ofCodeBlockby setting their parent frame (for VM re-entry), and instances ofEnumLiteralfor conversion to the method's corresponding parameter type.StackFrameprepareNativeArgs(java.lang.reflect.Method method, java.lang.Object context, java.lang.Object[] args)Preparescontextandargsinstances ofCodeBlockby setting their parent frame (for VM re-entry), and instances ofEnumLiteralfor conversion to the method's corresponding parameter type.StackFrameprepareNativeContext(java.lang.reflect.Method method, java.lang.Object context)Preparescontextinstances ofCodeBlockby setting their parent frame (for VM re-entry).java.lang.StringresolveVariableName(int slot)Returns the local variable name at the givenslot(for debugger).voidsetLocal(java.lang.Object value, int slot)Sets local variable with givenslottovalue.voidsetLocal(java.lang.Object value, int cbOffset, int slot)Sets local variable with givenslottovalue.voidsetLocals(java.lang.Object[] values)Sets the first local variables to the given values.voidsetLocals(java.lang.Object self, java.lang.Object[] values)Sets the first local variables to the given values.voidsetPc(int pc)Sets the pc.java.lang.StringtoString()
-
-
-
Constructor Detail
-
StackFrame
public StackFrame(ExecEnv env, CodeBlock codeBlock)
Creates a newStackFrame. Use only for root frames!- Parameters:
env- the currentExecEnvcodeBlock- 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 givenslottovalue.- 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 givenslottovalue.- 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:
toStringin 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- theselfargument 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- theselfargument 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- theselfargument 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)
Preparesargsinstances ofCodeBlockby setting their parent frame (for VM re-entry), and instances ofEnumLiteralfor 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)
Preparescontextandargsinstances ofCodeBlockby setting their parent frame (for VM re-entry), and instances ofEnumLiteralfor 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)
Preparescontextinstances ofCodeBlockby 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
-
-