Class IsaPrimitive
- java.lang.Object
-
- ru.ispras.microtesk.model.IsaPrimitive
-
- Direct Known Subclasses:
Immediate
public abstract class IsaPrimitive extends java.lang.Object
TheIsaPrimitive
class implements base functionality of addressing modes and operations.
-
-
Field Summary
Fields Modifier and Type Field Description Primitive.Modifier
modifier
boolean
terminal
-
Constructor Summary
Constructors Constructor Description IsaPrimitive()
Constructs a primitive.IsaPrimitive(java.util.Map<java.lang.String,IsaPrimitive> arguments)
Constructs a primitive and saves the table of its arguments.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Location
access()
Location
access(ProcessingElement processingElement, TemporaryVariables temporaryVariables)
Returns the location the primitive object points to (when initialized with specific parameters).protected void
action(ProcessingElement processingElement, TemporaryVariables temporaryVariables)
Runs the action associated with the primitive.protected void
addArgument(java.lang.String name, IsaPrimitive value)
Registers an argument in the argument table.protected Location
annotate(Location location, TemporaryVariables tempVars)
void
decode(TemporaryVariables temporaryVariables)
Provides a hint to construct the decoder.void
execute(ProcessingElement processingElement, TemporaryVariables temporaryVariables)
Runs execution of the current primitive's action.java.util.Map<java.lang.String,IsaPrimitive>
getArguments()
Returns the primitive argument table.static java.lang.String
getCurrentOperation()
Returns the name of the currently executed primitive or an empty string if no primitive is being executed.java.lang.String
getName()
Returns the primitive name.java.lang.String
image(TemporaryVariables temporaryVariables)
Returns binary representation of the specified primitive.void
init(TemporaryVariables temporaryVariables)
Performs initialization of temporary variables that can be used in other attributes except fordecode
(action
,syntax
, andimage
).protected void
setLabelReference(LabelReference labelReference)
protected java.lang.String
syntax(TemporaryVariables temporaryVariables)
Returns assembly format of the specified primitive.java.lang.String
text(TemporaryVariables temporaryVariables)
Returns assembly text of the specified primitive.
-
-
-
Field Detail
-
terminal
public boolean terminal
-
modifier
public Primitive.Modifier modifier
-
-
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 isnull
.
-
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 isnull
.
-
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 fordecode
(action
,syntax
, andimage
).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()
-
annotate
protected final Location annotate(Location location, TemporaryVariables tempVars)
-
-