- java.lang.Object
-
- de.carne.mcd.instruction.InstructionIndex
-
- All Implemented Interfaces:
InstructionIndexParameters,java.io.Closeable,java.lang.AutoCloseable
public final class InstructionIndex extends java.lang.Object implements InstructionIndexParameters, java.io.Closeable
Loads and searches a persistent index for mapping opcode bytes to Instruction instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInstructionIndex.LookupResultIndex lookup result.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intentryCount()Gets the number instructions stored in this index.@Nullable InstructionIndex.LookupResultlookupNextInstruction(MCDInputBuffer buffer, boolean eager)Looks up the next Instruction instance corresponding to the opcode bytes provided via the given MCDInputBuffer instance.intopcodeBytes()Gets the number of bytes used to encode an InstructionOpcode in the index's lookup table.static InstructionIndexopen(InstructionFactory instructionFactory, java.net.URL url)Opens an InstructionIndex previously created via the InstructionIndexBuilder class.intpositionBytes()Gets the number of bytes used to encode a file position in the index's lookup table.-
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
-
open
public static InstructionIndex open(InstructionFactory instructionFactory, java.net.URL url) throws java.io.IOException
Opens an InstructionIndex previously created via the InstructionIndexBuilder class.- Parameters:
instructionFactory- the InstructionFactory to use for this index.url- the URL to use for index data access.- Returns:
- the opened InstructionIndex instance.
- Throws:
java.io.IOException- if an I/O error occurs.
-
lookupNextInstruction
public @Nullable InstructionIndex.LookupResult lookupNextInstruction(MCDInputBuffer buffer, boolean eager) throws java.io.IOException
Looks up the next Instruction instance corresponding to the opcode bytes provided via the given MCDInputBuffer instance.- Parameters:
buffer- the MCDInputBuffer to read the opcode bytes from.eager- whether to match the maximum length opcode or not.- Returns:
- the resolved Instruction instance (or
nullif EOF is reached). - 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.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-