|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.joanju.cg.bytecode.Bytecode
public abstract class Bytecode
An pseudocode instruction record, either from a compile unit or else as a special system record.
This class implements compareTo, equals, and hashCode for easy storage and sorting. If stored in a TreeSet, the objects would be sorted by the internal compile unit ID and instruction address.
Field Summary | |
---|---|
protected int |
address
|
protected int |
cuid
|
protected InstructionSet |
instrSet
|
protected int |
nodeNum
|
protected java.util.HashSet<Xref> |
xrefs
The set of xref records to be written with this Bytecode instruction. |
Constructor Summary | |
---|---|
Bytecode()
|
|
Bytecode(int cuid,
int address)
|
Method Summary | ||
---|---|---|
void |
addSource(int addr)
|
|
void |
addWhereUsed(int addr)
|
|
void |
beforeWrite(boolean isNewBuild)
Called when a build or checkval is done processing a CU, before writing the new/changed records. |
|
void |
calcValuesAgain(InstructionSet instrs)
This is called by the InstructionSet when it's time to chase where-used chains for local value changes. |
|
abstract void |
calcValueSets()
Calculate the value sets for the instruction. |
|
int |
compareTo(java.lang.Object o)
Compare by cuid and address |
|
boolean |
equals(java.lang.Object obj)
|
|
protected byte[] |
fetchBytesFromDB()
|
|
protected Bytecode |
fetchInCu(int addr)
Fetch a bytecode object for an address in this CU. |
|
byte[] |
generateDataForDB()
|
|
int |
getAddress()
|
|
int |
getCuID()
|
|
int |
getNodeNum()
Currently only implemented for Calls and Procedures. |
|
abstract Opcode |
getOpcode()
|
|
java.util.HashSet<java.lang.Integer> |
getSources()
Returns null. |
|
java.util.HashSet<java.lang.Integer> |
getValues()
Get the set of values for this instruction. |
|
java.util.HashSet<java.lang.Integer> |
getValuesCalcLocal(Bytecode usedBy,
InstructionSet instrs)
Calculate local values. |
|
java.util.HashSet<java.lang.Integer> |
getWhereUsed()
Returns null. |
|
java.util.HashSet<Xref> |
getXrefs()
|
|
int |
hashCode()
|
|
protected void |
initData()
|
|
boolean |
isDataModified()
|
|
boolean |
isFromDB()
|
|
void |
setAddress(int address)
|
|
void |
setCuID(int cuID)
|
|
void |
setDataBytesFromDB(byte[] bytes)
|
|
protected void |
setDataModified()
|
|
void |
setFromDB()
|
|
void |
setInstructionSet(InstructionSet is)
The instructionset assigns this when a Bytecode object is added to it. |
|
void |
setNodeNum(int nodeNum)
|
|
protected abstract void |
setValuesFromByteStream(java.io.DataInputStream in)
|
|
protected boolean |
shouldLoadData()
|
|
static
|
sourcesForXrefTarget(int tgtCuid,
int tgtAddr,
T sampleObject)
Get an ArrayList of Bytecode instructions of subtype T which are xref sources for the specified target. |
|
void |
storeIfModified()
Store this bytecode instruction in the database if its "modified" flag has been set. |
|
java.lang.String |
toString()
|
|
java.lang.String |
toStringFromComments(InstructionSet instrs)
All Bytecode instruction subclasses should override this eventually. |
|
java.lang.String |
toStringFromData()
All Bytecode instruction subclasses should override this eventually. |
|
java.lang.String |
toStringFromName(InstructionSet instrs)
Some subclasses should override this to return the string literal, var name, procedure name, etc. |
|
protected void |
toStringFromSet(java.util.Collection c,
java.lang.StringBuffer buff)
|
|
protected abstract void |
writeValuesToByteStream(java.io.DataOutputStream out)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int cuid
protected int address
protected int nodeNum
protected InstructionSet instrSet
protected java.util.HashSet<Xref> xrefs
Constructor Detail |
---|
public Bytecode()
public Bytecode(int cuid, int address)
Method Detail |
---|
public int compareTo(java.lang.Object o)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void addSource(int addr) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public void addWhereUsed(int addr) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public void beforeWrite(boolean isNewBuild) throws java.sql.SQLException, java.io.IOException
isNewBuild
-
java.sql.SQLException
java.io.IOException
public abstract void calcValueSets() throws java.sql.SQLException, java.io.IOException
Called during build, build-recalc, checkvals, and checkvals-recalc. Implementations should only build from external values once. Calculates which xref records are needed as well.
IMPORTANT: Should only ever be called for instructions belonging to an InstructionSet.
java.sql.SQLException
java.io.IOException
public void calcValuesAgain(InstructionSet instrs) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected Bytecode fetchInCu(int addr) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public int getNodeNum()
public java.util.HashSet<java.lang.Integer> getSources() throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public java.util.HashSet<java.lang.Integer> getValues() throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public final java.util.HashSet<java.lang.Integer> getValuesCalcLocal(Bytecode usedBy, InstructionSet instrs) throws java.sql.SQLException, java.io.IOException
usedBy
- The other instruction that wants this instructions values, otherwise null if
this has been called by a build or refresh process. The usedBy object must always be in the same
compile unit.
java.sql.SQLException
java.io.IOException
public java.util.HashSet<java.lang.Integer> getWhereUsed() throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public java.util.HashSet<Xref> getXrefs()
protected byte[] fetchBytesFromDB() throws java.sql.SQLException
java.sql.SQLException
public byte[] generateDataForDB() throws java.io.IOException
java.io.IOException
public int getAddress()
public int getCuID()
public abstract Opcode getOpcode()
protected void initData() throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public boolean isDataModified()
public boolean isFromDB()
public void setAddress(int address)
public void setCuID(int cuID)
public void setDataBytesFromDB(byte[] bytes) throws java.io.IOException
java.io.IOException
protected abstract void setValuesFromByteStream(java.io.DataInputStream in) throws java.io.IOException
java.io.IOException
protected void setDataModified()
public void setFromDB()
public void setInstructionSet(InstructionSet is)
public void setNodeNum(int nodeNum)
getNodeNum()
protected boolean shouldLoadData()
public static <T extends Bytecode> java.util.ArrayList<T> sourcesForXrefTarget(int tgtCuid, int tgtAddr, T sampleObject) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public void storeIfModified() throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringFromComments(InstructionSet instrs) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String toStringFromData()
public java.lang.String toStringFromName(InstructionSet instrs)
protected void toStringFromSet(java.util.Collection c, java.lang.StringBuffer buff)
protected abstract void writeValuesToByteStream(java.io.DataOutputStream out) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |