physis.core.virtualmachine
Class InstructionSet

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

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

This class contains the instructons of an instructionset which belongs to one or more virtual machines.
The persistent storage of the instructions is a simple textfile which has the following format:
[instruction_set_name]
TYPE [type_name] [type_code]
[instruction_name] [instruction_code]
...
TYPE ....

CRC
1. ensure access to instruction_names by codes and vice-versa - Instruction

Author:
sirna
See Also:
Serialized Form

Field Summary
private static Instruction BLANK_INSTRUCTION
          The nop instruction should be in all instructionsets.
private static InstructionSet instance
           
private  Instruction[] instcodeArray
           
private  java.util.Hashtable instructions_by_codes
          The keys are Integers, and the values are Instructions.
private  java.util.Hashtable instructions_by_names
          The keys are Strings (the names of the instructions), and the values are Instructions.
private  java.lang.String name
          The identifier name of the instructionset.
private  java.util.Random random
           
private  int size
           
private  java.util.Hashtable type_names
          This hashtable stores the typenames of the instruction categories.
 
Constructor Summary
private InstructionSet(java.lang.String instruction_file_name)
           
 
Method Summary
 Instruction getBlankInstrunction()
           
static InstructionSet getInstance()
           
static InstructionSet getInstance(java.lang.String instructionset_file)
           
 Instruction getInstruction(short instruction_code)
          Gives the thin InstructionCode object according to the given instruction_code.
 Instruction getInstructionByCode(short code)
           
 Instruction getInstructionByName(java.lang.String instname)
           
 short getInstructionCodeRandomly()
          This method is used when mutating the codetape.
 java.lang.String getInstructionMnemonic(short instruction_code)
          Gives the instruction's name (mnemonic) corresponding to the given instruction_code.
 java.lang.String getName()
           
 int getSize()
           
 java.lang.String getTypeName(int instruction_type_code)
          Gives the name of the corresponding integer type code.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

BLANK_INSTRUCTION

private static final Instruction BLANK_INSTRUCTION
The nop instruction should be in all instructionsets. And only its code is allowed to and should be less than zero.

instance

private static InstructionSet instance

type_names

private java.util.Hashtable type_names
This hashtable stores the typenames of the instruction categories. The keys are integers.

instructions_by_codes

private java.util.Hashtable instructions_by_codes
The keys are Integers, and the values are Instructions. With help of this hashtable it's easy to get all the information about instructions.

instructions_by_names

private java.util.Hashtable instructions_by_names
The keys are Strings (the names of the instructions), and the values are Instructions. With help of this hashtable it's easy to get all the information about instructions.

name

private java.lang.String name
The identifier name of the instructionset.

instcodeArray

private Instruction[] instcodeArray

size

private int size

random

private java.util.Random random
Constructor Detail

InstructionSet

private InstructionSet(java.lang.String instruction_file_name)
Method Detail

getInstance

public static InstructionSet getInstance()

getInstance

public static InstructionSet getInstance(java.lang.String instructionset_file)

getTypeName

public java.lang.String getTypeName(int instruction_type_code)
Gives the name of the corresponding integer type code. It is useful only for people, for debugging...

getInstruction

public Instruction getInstruction(short instruction_code)
Gives the thin InstructionCode object according to the given instruction_code.

getInstructionByName

public Instruction getInstructionByName(java.lang.String instname)

getInstructionByCode

public Instruction getInstructionByCode(short code)

getInstructionMnemonic

public java.lang.String getInstructionMnemonic(short instruction_code)
Gives the instruction's name (mnemonic) corresponding to the given instruction_code.

getBlankInstrunction

public Instruction getBlankInstrunction()

getInstructionCodeRandomly

public short getInstructionCodeRandomly()
This method is used when mutating the codetape.

getName

public java.lang.String getName()

getSize

public int getSize()