physis.core.virtualmachine
Class Instruction

java.lang.Object
  |
  +--physis.core.virtualmachine.Instruction
All Implemented Interfaces:
java.io.Serializable

public class Instruction
extends java.lang.Object
implements java.io.Serializable

This class represents one instruction for a virtual machine. Instructions are coded as positive integers. Instructions have mnemonics just like in assembly languages. The instructions can be categorized into types. (copy, biological, nop...) Instructions may have operands (although in evolvable languages they are not preferred).

See Also:
Serialized Form

Field Summary
(package private)  boolean hasOperand
          Tells whether the instruction has operand(s) or not.
(package private)  short inst_code
          This is actually the main identifier of the instruction (the instruction itself).
private  java.lang.String instruction_mnemonic
          Actually it is the name of the instruction.
private  int number_of_operands
          The number of operands.
private  int type
          Every instruction has a type.
 
Constructor Summary
Instruction(int type, short code, java.lang.String mnemonic, int number_of_operands)
          This class is immutable, which means that you can not change the state of an instance after you created.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 short getInstructionCode()
           
 java.lang.String getMnemonic()
          Returns the mnemonic (name) of the instruction.
 int getNumberOfOperands()
          Returns the number of operands.
 int getType()
          Returns the type identifier.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

instruction_mnemonic

private java.lang.String instruction_mnemonic
Actually it is the name of the instruction. It is only for people, because we can't read and write machine-code consisting number-like instructions.

type

private int type
Every instruction has a type. (like flow-control, math-op). The typenames are stored in the InstructionSet, this is only an identifier.

inst_code

final short inst_code
This is actually the main identifier of the instruction (the instruction itself). For performance reasons it is directly available in the package.

hasOperand

final boolean hasOperand
Tells whether the instruction has operand(s) or not. For performance reasons it is directly available in the package.

number_of_operands

private int number_of_operands
The number of operands.
Constructor Detail

Instruction

public Instruction(int type,
                   short code,
                   java.lang.String mnemonic,
                   int number_of_operands)
This class is immutable, which means that you can not change the state of an instance after you created. That's why the constructor needs all the information about the instruction.
Method Detail

getMnemonic

public java.lang.String getMnemonic()
Returns the mnemonic (name) of the instruction.

getType

public int getType()
Returns the type identifier.

getNumberOfOperands

public int getNumberOfOperands()
Returns the number of operands.

getInstructionCode

public short getInstructionCode()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object