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
`StackFrame​(ExecEnv env, CodeBlock codeBlock)` Creates a new `StackFrame`.
`StackFrame​(StackFrame parent, java.lang.reflect.Method nativeMethod)` Creates a new `StackFrame`.
`StackFrame​(StackFrame parent, java.lang.String opName)` Creates a new `StackFrame`.
`StackFrame​(StackFrame parent, CodeBlock codeBlock)` Creates a new `StackFrame`.

### Method Summary

All Methods Instance Methods Concrete Methods
`CodeBlock` `getCodeBlock()` Returns the codeBlock.
`ExecEnv` `getEnv()` Returns the `ExecEnv`.
`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 the `CodeBlock` (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 of `this`.
`StackFrame` `getSubFrame​(CodeBlock cb, java.lang.Object[] args)` Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame` `getSubFrame​(CodeBlock cb, java.lang.Object context, java.lang.Object arg)` Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame` `getSubFrame​(CodeBlock cb, java.lang.Object context, java.lang.Object[] args)` Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame` `prepareNativeArgs​(java.lang.reflect.Method method, java.lang.Object[] args)` Prepares `args` instances of `CodeBlock` by setting their parent frame (for VM re-entry), and instances of `EnumLiteral` for conversion to the method's corresponding parameter type.
`StackFrame` `prepareNativeArgs​(java.lang.reflect.Method method, java.lang.Object context, java.lang.Object[] args)` Prepares `context` and `args` instances of `CodeBlock` by setting their parent frame (for VM re-entry), and instances of `EnumLiteral` for conversion to the method's corresponding parameter type.
`StackFrame` `prepareNativeContext​(java.lang.reflect.Method method, java.lang.Object context)` Prepares `context` instances of `CodeBlock` by setting their parent frame (for VM re-entry).
`java.lang.String` `resolveVariableName​(int slot)` Returns the local variable name at the given `slot` (for debugger).
`void` `setLocal​(java.lang.Object value, int slot)` Sets local variable with given `slot` to `value`.
`void` `setLocal​(java.lang.Object value, int cbOffset, int slot)` Sets local variable with given `slot` to `value`.
`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()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### StackFrame

    public StackFrame​(ExecEnv env,
                      CodeBlock codeBlock)

Creates a new `StackFrame`. Use only for root frames!

Parameters:
  `env` - the current `ExecEnv`
  `codeBlock` - the codeBlock context for this stack frame

#### StackFrame

    public StackFrame​(StackFrame parent,
                      CodeBlock codeBlock)

Creates a new `StackFrame`.

Parameters:
  `parent` - the parent stack frame, if any
  `codeBlock` - the codeBlock context for this stack frame

#### StackFrame

    public StackFrame​(StackFrame parent,
                      java.lang.reflect.Method nativeMethod)

Creates a new `StackFrame`.

Parameters:
  `parent` - the parent stack frame, if any
  `nativeMethod` - the native Java method context for this stack frame

#### StackFrame

    public StackFrame​(StackFrame parent,
                      java.lang.String opName)

Creates a new `StackFrame`.

Parameters:
  `parent` - the parent stack frame, if any
  `opName` - the operation name for the debugger

### Method Detail

#### setLocal

    public void setLocal​(java.lang.Object value,
                         int cbOffset,
                         int slot)

Sets local variable with given `slot` to `value`.

Parameters:
  `value` - the value to set
  `cbOffset` - the codeblock offset
  `slot` - the variable slot

#### setLocal

    public void setLocal​(java.lang.Object value,
                         int slot)

Sets local variable with given `slot` to `value`.

Parameters:
  `value` - the value to set
  `slot` - 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 value
  `values` - 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 offset
  `slot` - 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

#### getEnv

    public ExecEnv getEnv()

Returns the `ExecEnv`.

Returns:
  the env

#### getNativeMethod

    public java.lang.reflect.Method getNativeMethod()

Returns the nativeMethod.

Returns:
  the nativeMethod

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.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 of `this`.

Parameters:
  `cb` - the code block of the sub-frame
  `args` - 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 of `this`.

Parameters:
  `cb` - the code block of the sub-frame
  `context` - the `self` argument to pass into the sub-frame
  `args` - 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 of `this`.

Parameters:
  `cb` - the code block of the sub-frame
  `context` - the `self` 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 of `this`.

Parameters:
  `cb` - the code block of the sub-frame
  `context` - the `self` argument to pass into the sub-frame
  `arg` - 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)

Prepares `args` instances of `CodeBlock` by setting their parent frame (for VM re-entry), and instances of `EnumLiteral` 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 invoked
  `args` - 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)

Prepares `context` and `args` instances of `CodeBlock` by setting their parent frame (for VM re-entry), and instances of `EnumLiteral` 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 invoked
  `context` - 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)

Prepares `context` instances of `CodeBlock` 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 invoked
  `context` - 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 given `slot` (for debugger).

Parameters:
  `slot` - the local variable slot
Returns:
  the variable name at the given slot

#### getOperation

    public CodeBlock getOperation()

Returns the `CodeBlock` (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