Class IsaPrimitive

  • Direct Known Subclasses:
    Immediate

    public abstract class IsaPrimitive
    extends java.lang.Object
    The IsaPrimitive class implements base functionality of addressing modes and operations.
    • Constructor Detail

      • IsaPrimitive

        public IsaPrimitive​(java.util.Map<java.lang.String,​IsaPrimitive> arguments)
        Constructs a primitive and saves the table of its arguments.
        Parameters:
        arguments - Primitive arguments.
        Throws:
        java.lang.IllegalArgumentException - if the parameter is null.
      • IsaPrimitive

        public IsaPrimitive()
        Constructs a primitive.
    • Method Detail

      • getCurrentOperation

        public static java.lang.String getCurrentOperation()
        Returns the name of the currently executed primitive or an empty string if no primitive is being executed.
        Returns:
        Name of the executed primitive.
      • getName

        public final java.lang.String getName()
        Returns the primitive name.
        Returns:
        Primitive name.
      • getArguments

        public final java.util.Map<java.lang.String,​IsaPrimitive> getArguments()
        Returns the primitive argument table.
        Returns:
        Primitive arguments.
      • addArgument

        protected final void addArgument​(java.lang.String name,
                                         IsaPrimitive value)
        Registers an argument in the argument table.
        Parameters:
        name - Argument name.
        value - Argument.
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null.
      • setLabelReference

        protected final void setLabelReference​(LabelReference labelReference)
      • init

        public void init​(TemporaryVariables temporaryVariables)
        Performs initialization of temporary variables that can be used in other attributes except for decode (action, syntax, and image).

        This attribute is implicitly called inside of the above mentioned attributes. When needed, it can be called explicitly by other primitives.

        Parameters:
        temporaryVariables - temporary variables.
      • decode

        public void decode​(TemporaryVariables temporaryVariables)
        Provides a hint to construct the decoder.
        Parameters:
        temporaryVariables - temporary variables.
      • text

        public final java.lang.String text​(TemporaryVariables temporaryVariables)
        Returns assembly text of the specified primitive. Takes into account labels that might be associated with a specific primitive (mode).
        Parameters:
        temporaryVariables - temporary variables.
        Returns:
        Assembly text.
      • syntax

        protected java.lang.String syntax​(TemporaryVariables temporaryVariables)
        Returns assembly format of the specified primitive.

        Default implementation is provided to allow using primitives that have no explicitly specified syntax attribute. This method does not do any useful work and should never be called. It is needed only to let inherited classes compile.

        Parameters:
        temporaryVariables - temporary variables.
        Returns:
        Assembly text.
      • image

        public java.lang.String image​(TemporaryVariables temporaryVariables)
        Returns binary representation of the specified primitive.

        Default implementation is provided to allow using primitives that have no explicitly specified image attribute. This method does not do any useful work and should never be called. It is needed only to let inherited classes compile.

        Parameters:
        temporaryVariables - temporary variables.
        Returns:
        Binary text.
      • execute

        public final void execute​(ProcessingElement processingElement,
                                  TemporaryVariables temporaryVariables)
        Runs execution of the current primitive's action.
        Parameters:
        processingElement - Processing element instance.
        temporaryVariables - Temporary variables.
      • action

        protected void action​(ProcessingElement processingElement,
                              TemporaryVariables temporaryVariables)
        Runs the action associated with the primitive.

        Default implementation is provided to allow using primitives that have no explicitly specified action attribute. This method does not do any useful work and should never be called. It is needed only to let inherited classes compile.

        Parameters:
        processingElement - Processing element instance.
        temporaryVariables - Temporary variables.
      • access

        public Location access​(ProcessingElement processingElement,
                               TemporaryVariables temporaryVariables)
        Returns the location the primitive object points to (when initialized with specific parameters). Applicable only to addressing modes that have a return expression.

        Default implementation is provided to allow using primitives that do not have a return expression. This method does not do any useful work and should never be called. It is needed only to let inherited classes compile.

        Parameters:
        processingElement - Processing element instance.
        temporaryVariables - Temporary variables.
        Returns:
        Memory location.
      • access

        public final Location access()