Package org.eclipse.m2m.atl.emftvm

# Interface CodeBlock

All Superinterfaces:
  `org.eclipse.emf.ecore.EObject`, `org.eclipse.emf.common.notify.Notifier`

All Known Implementing Classes:
  `CodeBlockImpl`, `NativeCodeBlock`

public interface CodeBlock extends org.eclipse.emf.ecore.EObject
A representation of the model object 'Code Block'.

See Also:
  - `EmftvmPackage.getCodeBlock()`

## Method Summary

Modifier and Type
Method
Description
`Object`
`execute(StackFrame frame)`
Executes the instructions in this `CodeBlock`, using the parameters stored in `frame`.
`org.eclipse.emf.common.util.EList<Instruction>`
`getAllPredecessors(Instruction i)`
Collects the transitive closure of predecessor instructions for `i`.
`Rule`
`getApplierFor()`
Returns the value of the 'Applier For' container reference.
`InputRuleElement`
`getBindingFor()`
Returns the value of the 'Binding For' container reference.
`Operation`
`getBodyFor()`
Returns the value of the 'Body For' container reference.
`org.eclipse.emf.common.util.EList<Instruction>`
`getCode()`
Returns the value of the 'Code' containment reference list.
`Field`
`getField()`
Returns the `Field` that (indirectly) contains this `CodeBlock`, if any.
`Field`
`getInitialiserFor()`
Returns the value of the 'Initialiser For' container reference.
`JITCodeBlock`
`getJITCodeBlock()`
Returns the compiled `JITCodeBlock`, if any.
`org.eclipse.emf.common.util.EList<LineNumber>`
`getLineNumbers()`
Returns the value of the 'Line Numbers' containment reference list.
`org.eclipse.emf.common.util.EList<LocalVariable>`
`getLocalVariables()`
Returns the value of the 'Local Variables' containment reference list.
`Rule`
`getMatcherFor()`
Returns the value of the 'Matcher For' container reference.
`int`
`getMaxLocals()`
Returns the value of the 'Max Locals' attribute.
`int`
`getMaxStack()`
Returns the value of the 'Max Stack' attribute.
`Module`
`getModule()`
Returns the `Module` that (indirectly) contains this `CodeBlock`.
`org.eclipse.emf.common.util.EList<CodeBlock>`
`getNested()`
Returns the value of the 'Nested' containment reference list.
`CodeBlock`
`getNestedFor()`
Returns the value of the 'Nested For' container reference.
`org.eclipse.emf.common.util.EList<Instruction>`
`getNonLoopingPredecessors(Instruction i)`
Collects the direct predecessor instructions for `i` that do not contain `i` in their transitive closure of predecessors.
`Operation`
`getOperation()`
Returns the `Operation` that (indirectly) contains this `CodeBlock`, if any.
`StackFrame`
`getParentFrame()`
Returns the value of the 'Parent Frame' attribute.
`Rule`
`getPostApplyFor()`
Returns the value of the 'Post Apply For' container reference.
`org.eclipse.emf.common.util.EList<Instruction>`
`getPredecessors(Instruction i)`
Collects the direct predecessor instructions for `i`.
`Rule`
`getRule()`
Finds the the `Rule` that contains this codeblock.
`int`
`getStackLevel()`
Calculates the amount of elements on the stack after executing this `CodeBlock`.
`void`
`setApplierFor(Rule value)`
Sets the value of the '`Applier For`' container reference.
`void`
`setBindingFor(InputRuleElement value)`
Sets the value of the '`Binding For`' container reference.
`void`
`setBodyFor(Operation value)`
Sets the value of the '`Body For`' container reference.
`void`
`setInitialiserFor(Field value)`
Sets the value of the '`Initialiser For`' container reference.
`void`
`setJITCodeBlock(JITCodeBlock jcb)`
Sets the compiled `JITCodeBlock`.
`void`
`setMatcherFor(Rule value)`
Sets the value of the '`Matcher For`' container reference.
`void`
`setMaxLocals(int value)`
Sets the value of the '`Max Locals`' attribute.
`void`
`setMaxStack(int value)`
Sets the value of the '`Max Stack`' attribute.
`void`
`setNestedFor(CodeBlock value)`
Sets the value of the '`Nested For`' container reference.
`void`
`setParentFrame(StackFrame value)`
Sets the value of the '`Parent Frame`' attribute.
`void`
`setPostApplyFor(Rule value)`
Sets the value of the '`Post Apply For`' container reference.

### Methods inherited from interface org.eclipse.emf.ecore.EObject

`eAllContents, eClass, eContainer, eContainingFeature, eContainmentFeature, eContents, eCrossReferences, eGet, eGet, eInvoke, eIsProxy, eIsSet, eResource, eSet, eUnset`

### Methods inherited from interface org.eclipse.emf.common.notify.Notifier

`eAdapters, eDeliver, eNotify, eSetDeliver`

## Method Details

### getMaxLocals

int getMaxLocals()
Returns the value of the 'Max Locals' attribute. The default value is `"-1"`.

Represents the amount of local variables slots required. This value is derived automatically from the list of instructions.

Returns:
  the value of the 'Max Locals' attribute.
See Also:
  - `setMaxLocals(int)`
  - `EmftvmPackage.getCodeBlock_MaxLocals()`

### setMaxLocals

void setMaxLocals(int value)
Sets the value of the '`Max Locals`' attribute.

Represents the amount of local variables slots required. This value is derived automatically from the list of instructions.

Parameters:
  `value` - the new value of the 'Max Locals' attribute.
See Also:
  - `getMaxLocals()`

### getMaxStack

int getMaxStack()
Returns the value of the 'Max Stack' attribute. The default value is `"-1"`.

Represents the amount of stack slots required. This value is derived automatically from the list of instructions.

Returns:
  the value of the 'Max Stack' attribute.
See Also:
  - `setMaxStack(int)`
  - `EmftvmPackage.getCodeBlock_MaxStack()`

### setMaxStack

void setMaxStack(int value)
Sets the value of the '`Max Stack`' attribute.

Represents the amount of stack slots required. This value is derived automatically from the list of instructions.

Parameters:
  `value` - the new value of the 'Max Stack' attribute.
See Also:
  - `getMaxStack()`

### getCode

org.eclipse.emf.common.util.EList<Instruction> getCode()
Returns the value of the 'Code' containment reference list. The list contents are of type `Instruction`. It is bidirectional and its opposite is '`Owning Block`'.

Represents the list of instructions to execute.

Returns:
  the value of the 'Code' containment reference list.
See Also:
  - `EmftvmPackage.getCodeBlock_Code()`
  - `Instruction.getOwningBlock()`

### getLineNumbers

org.eclipse.emf.common.util.EList<LineNumber> getLineNumbers()
Returns the value of the 'Line Numbers' containment reference list. The list contents are of type `LineNumber`. It is bidirectional and its opposite is '`Owning Block`'.

Represents the line number information elements for this code block's instructions.

Returns:
  the value of the 'Line Numbers' containment reference list.
See Also:
  - `EmftvmPackage.getCodeBlock_LineNumbers()`
  - `LineNumber.getOwningBlock()`

### getLocalVariables

org.eclipse.emf.common.util.EList<LocalVariable> getLocalVariables()
Returns the value of the 'Local Variables' containment reference list. The list contents are of type `LocalVariable`. It is bidirectional and its opposite is '`Owning Block`'.

Represents the local variable information elements for this code block. This information is used to calculate '`Max Locals`' and local variable slot assignment for the instructions of this code block. The actual local variables are stored in `StackFrame`s.

Returns:
  the value of the 'Local Variables' containment reference list.
See Also:
  - `EmftvmPackage.getCodeBlock_LocalVariables()`
  - `LocalVariable.getOwningBlock()`

### getMatcherFor

Rule getMatcherFor()
Returns the value of the 'Matcher For' container reference. It is bidirectional and its opposite is '`Matcher`'.

This reference is set if this code block serves as a '`Matcher`' code block for a `Rule`.

Returns:
  the value of the 'Matcher For' container reference.
See Also:
  - `setMatcherFor(Rule)`
  - `EmftvmPackage.getCodeBlock_MatcherFor()`
  - `Rule.getMatcher()`

### setMatcherFor

void setMatcherFor(Rule value)
Sets the value of the '`Matcher For`' container reference. This reference is set if this code block serves as a '`Matcher`' code block for a `Rule`.

Parameters:
  `value` - the new value of the 'Matcher For' container reference.
See Also:
  - `getMatcherFor()`

### getApplierFor

Rule getApplierFor()
Returns the value of the 'Applier For' container reference. It is bidirectional and its opposite is '`Applier`'.

This reference is set if this code block serves as an '`Applier`' code block for a `Rule`.

Returns:
  the value of the 'Applier For' container reference.
See Also:
  - `setApplierFor(Rule)`
  - `EmftvmPackage.getCodeBlock_ApplierFor()`
  - `Rule.getApplier()`

### setApplierFor

void setApplierFor(Rule value)
Sets the value of the '`Applier For`' container reference.

This reference is set if this code block serves as an '`Applier`' code block for a `Rule`.

Parameters:
  `value` - the new value of the 'Applier For' container reference.
See Also:
  - `getApplierFor()`

### getPostApplyFor

Rule getPostApplyFor()
Returns the value of the 'Post Apply For' container reference. It is bidirectional and its opposite is '`Post Apply`'.

This reference is set if this code block serves as a '`Post Apply`' code block for a `Rule`.

Returns:
  the value of the 'Post Apply For' container reference.
See Also:
  - `setPostApplyFor(Rule)`
  - `EmftvmPackage.getCodeBlock_PostApplyFor()`
  - `Rule.getPostApply()`

### setPostApplyFor

void setPostApplyFor(Rule value)
Sets the value of the '`Post Apply For`' container reference.

This reference is set if this code block serves as a '`Post Apply`' code block for a `Rule`.

Parameters:
  `value` - the new value of the 'Post Apply For' container reference.
See Also:
  - `getPostApplyFor()`

### getBodyFor

Operation getBodyFor()
Returns the value of the 'Body For' container reference. It is bidirectional and its opposite is '`Body`'.

This reference is set if this code block serves as a '`Body`' code block for an `Operation`.

Returns:
  the value of the 'Body For' container reference.
See Also:
  - `setBodyFor(Operation)`
  - `EmftvmPackage.getCodeBlock_BodyFor()`
  - `Operation.getBody()`

### setBodyFor

void setBodyFor(Operation value)
Sets the value of the '`Body For`' container reference.

This reference is set if this code block serves as a '`Body`' code block for an `Operation`.

Parameters:
  `value` - the new value of the 'Body For' container reference.
See Also:
  - `getBodyFor()`

### getInitialiserFor

Field getInitialiserFor()
Returns the value of the 'Initialiser For' container reference. It is bidirectional and its opposite is '`Initialiser`'.

This reference is set if this code block serves as an '`Initialiser`' code block for a `Field`.

Returns:
  the value of the 'Initialiser For' container reference.
See Also:
  - `setInitialiserFor(Field)`
  - `EmftvmPackage.getCodeBlock_InitialiserFor()`
  - `Field.getInitialiser()`

### setInitialiserFor

void setInitialiserFor(Field value)
Sets the value of the '`Initialiser For`' container reference.

This reference is set if this code block serves as an '`Initialiser`' code block for a `Field`.

Parameters:
  `value` - the new value of the 'Initialiser For' container reference.
See Also:
  - `getInitialiserFor()`

### getNested

org.eclipse.emf.common.util.EList<CodeBlock> getNested()
Returns the value of the 'Nested' containment reference list. The list contents are of type `CodeBlock`. It is bidirectional and its opposite is '`Nested For`'.

Represents the list of nested code blocks (i.e. closures).

Returns:
  the value of the 'Nested' containment reference list.
See Also:
  - `EmftvmPackage.getCodeBlock_Nested()`
  - `getNestedFor()`

### getNestedFor

CodeBlock getNestedFor()
Returns the value of the 'Nested For' container reference. It is bidirectional and its opposite is '`Nested`'.

This reference is set if this code block serves as a '`Nested`' code block (i.e. closure) for a parent `CodeBlock`.

Returns:
  the value of the 'Nested For' container reference.
See Also:
  - `setNestedFor(CodeBlock)`
  - `EmftvmPackage.getCodeBlock_NestedFor()`
  - `getNested()`

### setNestedFor

void setNestedFor(CodeBlock value)
Sets the value of the '`Nested For`' container reference.

This reference is set if this code block serves as a '`Nested`' code block (i.e. closure) for a parent `CodeBlock`.

Parameters:
  `value` - the new value of the 'Nested For' container reference.
See Also:
  - `getNestedFor()`

### getParentFrame

StackFrame getParentFrame()
Returns the value of the 'Parent Frame' attribute.

Represents a placeholder for the `StackFrame` of the invoking native Java method, and allows re-entry into the EMFTVM (with access to lexically scoped local variables, etc.).

Stack frames are stored per thread, which enables the concurrent execution of code blocks.

Returns:
  the value of the 'Parent Frame' attribute.
See Also:
  - `setParentFrame(StackFrame)`
  - `EmftvmPackage.getCodeBlock_ParentFrame()`

### setParentFrame

void setParentFrame(StackFrame value)
Sets the value of the '`Parent Frame`' attribute.

Represents a placeholder for the `StackFrame` of the invoking native Java method, and allows re-entry into the EMFTVM (with access to lexically scoped local variables, etc.).

Stack frames are stored per thread, which enables the concurrent execution of code blocks.

Parameters:
  `value` - the new value of the 'Parent Frame' attribute.
See Also:
  - `getParentFrame()`

### getBindingFor

InputRuleElement getBindingFor()
Returns the value of the 'Binding For' container reference. It is bidirectional and its opposite is '`Binding`'.

This reference is set if this code block serves as a '`Binding`' code block for a rule's `InputRuleElement`. Bindings allow for the EMFTVM `Matcher` to implement a search plan strategy.

Returns:
  the value of the 'Binding For' container reference.
See Also:
  - `setBindingFor(InputRuleElement)`
  - `EmftvmPackage.getCodeBlock_BindingFor()`
  - `InputRuleElement.getBinding()`

### setBindingFor

void setBindingFor(InputRuleElement value)
Sets the value of the '`Binding For`' container reference.

This reference is set if this code block serves as a '`Binding`' code block for a rule's `InputRuleElement`. Bindings allow for the EMFTVM `Matcher` to implement a search plan strategy.

Parameters:
  `value` - the new value of the 'Binding For' container reference.
See Also:
  - `getBindingFor()`

### execute

Object execute(StackFrame frame)
Executes the instructions in this `CodeBlock`, using the parameters stored in `frame`.

Parameters:
  `frame` - the `StackFrame` to use during execution.
Returns:
  the return value.

### getStackLevel

int getStackLevel()
Calculates the amount of elements on the stack after executing this `CodeBlock`.

Returns:
  the amount of elements on the stack after executing this `CodeBlock`.

### getModule

Module getModule()
Returns the `Module` that (indirectly) contains this `CodeBlock`.

Returns:
  the `Module` that (indirectly) contains this `CodeBlock`.

### getOperation

Operation getOperation()
Returns the `Operation` that (indirectly) contains this `CodeBlock`, if any.

Returns:
  the `Operation` that (indirectly) contains this `CodeBlock`, or `null`

### getField

Field getField()
Returns the `Field` that (indirectly) contains this `CodeBlock`, if any.

Returns:
  the `Field` that (indirectly) contains this `CodeBlock`, or `null`

### getPredecessors

org.eclipse.emf.common.util.EList<Instruction> getPredecessors(Instruction i)
Collects the direct predecessor instructions for `i`.

Parameters:
  `i` - the instruction to collect the predecessors for.
Returns:
  the direct predecessor instructions for `i`.

### getAllPredecessors

org.eclipse.emf.common.util.EList<Instruction> getAllPredecessors(Instruction i)
Collects the transitive closure of predecessor instructions for `i`.

Parameters:
  `i` - the instruction to collect the predecessors for.
Returns:
  the transitive closure of predecessor instructions for `i`.

### getNonLoopingPredecessors

org.eclipse.emf.common.util.EList<Instruction> getNonLoopingPredecessors(Instruction i)
Collects the direct predecessor instructions for `i` that do not contain `i` in their transitive closure of predecessors.

Parameters:
  `i` - the instruction to collect the predecessors for.
Returns:
  the non-looping predecessor instructions for `i`.

### getRule

Rule getRule()
Finds the the `Rule` that contains this codeblock.

Returns:
  the `Rule` that contains this codeblock, or `null` if not contained by a `Rule`.

### getJITCodeBlock

JITCodeBlock getJITCodeBlock()
Returns the compiled `JITCodeBlock`, if any.

Returns:
  the compiled `JITCodeBlock`, or `null`

### setJITCodeBlock

void setJITCodeBlock(JITCodeBlock jcb)
Sets the compiled `JITCodeBlock`.

Parameters:
  `jcb` - the compiled `JITCodeBlock`