- java.lang.Object
-
- de.carne.mcd.bootstrap.InstructionIndexBuilder
-
- All Implemented Interfaces:
InstructionIndexParameters
public final class InstructionIndexBuilder extends java.lang.Object implements InstructionIndexParameters
Helper class used to create an InstructionIndex resource file.
-
-
Constructor Summary
Constructors Constructor Description InstructionIndexBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(InstructionOpcode opcode, Instruction instruction)Adds an InstructionOpcode to Instruction mapping to the index.intentryCount()Gets the number instructions stored in this index.intopcodeBytes()Gets the number of bytes used to encode an InstructionOpcode in the index's lookup table.intpositionBytes()Gets the number of bytes used to encode a file position in the index's lookup table.longsave(java.io.File file)Saves the current state of this instance to a file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.carne.mcd.instruction.InstructionIndexParameters
parameters
-
-
-
-
Method Detail
-
add
public void add(InstructionOpcode opcode, Instruction instruction) throws java.io.IOException
Adds an InstructionOpcode to Instruction mapping to the index.- Parameters:
opcode- the InstructionOpcode to map from.instruction- the Instruction to map to.- Throws:
java.io.IOException- if an I/O error occurs.
-
save
public long save(java.io.File file) throws java.io.IOExceptionSaves the current state of this instance to a file.The resulting output can accessed via InstructionIndex.open(InstructionFactory, java.net.URL).
- Parameters:
file- the file write to.- Returns:
- the size of the stored index.
- Throws:
java.io.IOException- if an I/O error occurs.
-
entryCount
public int entryCount()
Description copied from interface:InstructionIndexParametersGets the number instructions stored in this index.- Specified by:
entryCountin interfaceInstructionIndexParameters- Returns:
- the number instructions stored in this index.
-
opcodeBytes
public int opcodeBytes()
Description copied from interface:InstructionIndexParametersGets the number of bytes used to encode an InstructionOpcode in the index's lookup table.- Specified by:
opcodeBytesin interfaceInstructionIndexParameters- Returns:
- the number of bytes used to encode an InstructionOpcode in the index's lookup table.
-
positionBytes
public int positionBytes()
Description copied from interface:InstructionIndexParametersGets the number of bytes used to encode a file position in the index's lookup table.- Specified by:
positionBytesin interfaceInstructionIndexParameters- Returns:
- the number of bytes used to encode a file position in the index's lookup table.
-
-