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 Detail

      • 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()
      • 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 StackFrames.

        Returns:
        the value of the 'Local Variables' containment reference list.
        See Also:
        EmftvmPackage.getCodeBlock_LocalVariables(), LocalVariable.getOwningBlock()
      • 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()
      • 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()
      • 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()
      • 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()
      • 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()
      • 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()
      • 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

        java.lang.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.
      • 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.