Package org.eclipse.m2m.atl.emftvm.util

# Class StackFrame

java.lang.Object
org.eclipse.m2m.atl.emftvm.util.StackFrame

public final class StackFrame extends Object
EMFTVM stack frame. Stores local variables and code block invocation stack.

## Constructor Summary

Constructors
Constructor
Description
`StackFrame(ExecEnv env, CodeBlock codeBlock)`
Creates a new `StackFrame`.
`StackFrame(StackFrame parent, Method nativeMethod)`
Creates a new `StackFrame`.
`StackFrame(StackFrame parent, String opName)`
Creates a new `StackFrame`.
`StackFrame(StackFrame parent, CodeBlock codeBlock)`
Creates a new `StackFrame`.

## Method Summary

Modifier and Type
Method
Description
`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).
`Object`
`getLocal(int slot)`
Returns the local variable value with the given slot.
`Object`
`getLocal(int cbOffset, int slot)`
Returns the local variable value with the given slot.
`Map<String,Object>`
`getLocalVariables()`
Returns the local variables map (for debugger).
`int`
`getLocation()`
Returns the current instruction pointer value (starts at 0, for debugger).
`Method`
`getNativeMethod()`
Returns the nativeMethod.
`CodeBlock`
`getOperation()`
Returns the `CodeBlock` (for debugger).
`String`
`getOpName()`
Returns the "operation" name for this stack frame (for debugger).
`StackFrame`
`getParent()`
Returns the parent stack frame.
`int`
`getPc()`
Returns the pc.
`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, Object context)`
Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame`
`getSubFrame(CodeBlock cb, Object[] args)`
Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame`
`getSubFrame(CodeBlock cb, Object context, Object arg)`
Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame`
`getSubFrame(CodeBlock cb, Object context, Object[] args)`
Retrieves a new stack frame that is a sub-frame of `this`.
`StackFrame`
`prepareNativeArgs(Method method, 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(Method method, Object context, 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(Method method, Object context)`
Prepares `context` instances of `CodeBlock` by setting their parent frame (for VM re-entry).
`String`
`resolveVariableName(int slot)`
Returns the local variable name at the given `slot` (for debugger).
`void`
`setLocal(Object value, int slot)`
Sets local variable with given `slot` to `value`.
`void`
`setLocal(Object value, int cbOffset, int slot)`
Sets local variable with given `slot` to `value`.
`void`
`setLocals(Object[] values)`
Sets the first local variables to the given values.
`void`
`setLocals(Object self, Object[] values)`
Sets the first local variables to the given values.
`void`
`setPc(int pc)`
Sets the pc.
`String`
`toString()`

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

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

## Constructor Details

### 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, 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, String opName)
Creates a new `StackFrame`.

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

## Method Details

### setLocal

public void setLocal(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(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(Object self, 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(Object[] values)
Sets the first local variables to the given values.

Parameters:
  `values` - the local variable values

### getLocal

public 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 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 Method getNativeMethod()
Returns the nativeMethod.

Returns:
  the nativeMethod

### toString

public String toString()

Overrides:
  `toString` in class `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, 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, Object context, 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, 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, Object context, 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(Method method, 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(Method method, Object context, 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(Method method, 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 Map<String,Object> getLocalVariables()
Returns the local variables map (for debugger).

Returns:
  the local variables map

### resolveVariableName

public 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 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 String getOpName()
Returns the "operation" name for this stack frame (for debugger).

Returns:
  the "operation" name for this stack frame