Package ghidra.program.model.lang
Class PcodeInjectLibrary
- java.lang.Object
-
- ghidra.program.model.lang.PcodeInjectLibrary
-
public class PcodeInjectLibrary extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected SleighLanguage
language
protected long
uniqueBase
-
Constructor Summary
Constructors Constructor Description PcodeInjectLibrary(SleighLanguage l)
PcodeInjectLibrary(PcodeInjectLibrary op2)
Clone a library so that a Program can extend the library without modifying the base library from Language.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adjustUniqueBase(OpTpl[] opTemplates)
InjectPayload
allocateInject(java.lang.String sourceName, java.lang.String name, int tp)
The main InjectPayload factory interface.InjectContext
buildInjectContext()
PcodeInjectLibrary
clone()
boolean
equals(java.lang.Object obj)
java.lang.String[]
getCallFixupNames()
java.lang.String[]
getCallotherFixupNames()
ConstantPool
getConstantPool(Program program)
Get the constant pool associated with the given ProgramInjectPayload
getPayload(int type, java.lang.String name)
InjectPayloadSleigh[]
getProgramPayloads()
protected long
getUniqueBase()
int
hashCode()
boolean
hasProgramPayload(java.lang.String nm, int type)
Determine if the given payload name and type exists and is an extension of the program.boolean
hasUserDefinedOp(java.lang.String name)
Determine if the language has a given user-defined op.boolean
isOverride(java.lang.String nm, int type)
Check if a specific payload has been overridden by a user extensionvoid
parseInject(InjectPayload payload)
Convert the XML string representation of the given payload to a ConstructTpl The payload should be unattached (not already installed in the library)protected void
registerInject(InjectPayload payload)
protected void
registerProgramInject(java.util.List<InjectPayloadSleigh> userPayloads)
protected boolean
removeMechanismPayload(java.lang.String nm)
Remove a specific call mechanism payload.InjectPayload
restoreXmlInject(java.lang.String source, java.lang.String name, int tp, XmlPullParser parser)
void
saveCompilerSpecXml(java.lang.StringBuilder buffer)
Save the parts of the inject library that come from the compiler spec to the output stream as XML tagsprotected void
uninstallProgramPayloads()
-
-
-
Field Detail
-
language
protected SleighLanguage language
-
uniqueBase
protected long uniqueBase
-
-
Constructor Detail
-
PcodeInjectLibrary
public PcodeInjectLibrary(SleighLanguage l)
-
PcodeInjectLibrary
public PcodeInjectLibrary(PcodeInjectLibrary op2)
Clone a library so that a Program can extend the library without modifying the base library from Language. InjectPayloads can be considered immutable and don't need to be cloned.- Parameters:
op2
- is the library to clone
-
-
Method Detail
-
clone
public PcodeInjectLibrary clone()
- Overrides:
clone
in classjava.lang.Object
- Returns:
- A clone of this library
-
getProgramPayloads
public InjectPayloadSleigh[] getProgramPayloads()
- Returns:
- an array of all the program specific payloads (or null)
-
hasProgramPayload
public boolean hasProgramPayload(java.lang.String nm, int type)
Determine if the given payload name and type exists and is an extension of the program.- Parameters:
nm
- is the payload nametype
- is the payload type- Returns:
- true if the program extension exists
-
isOverride
public boolean isOverride(java.lang.String nm, int type)
Check if a specific payload has been overridden by a user extension- Parameters:
nm
- is the name of the payloadtype
- is the type of payload- Returns:
- true if the payload is overridden
-
getPayload
public InjectPayload getPayload(int type, java.lang.String name)
-
parseInject
public void parseInject(InjectPayload payload) throws SleighException
Convert the XML string representation of the given payload to a ConstructTpl The payload should be unattached (not already installed in the library)- Parameters:
payload
- is the given payload whose XML should be converted- Throws:
SleighException
- if there is any parsing issue
-
adjustUniqueBase
protected void adjustUniqueBase(OpTpl[] opTemplates)
-
getCallFixupNames
public java.lang.String[] getCallFixupNames()
- Returns:
- a list of names for all installed call-fixups
-
getCallotherFixupNames
public java.lang.String[] getCallotherFixupNames()
- Returns:
- a list of names for all installed callother-fixups
-
buildInjectContext
public InjectContext buildInjectContext()
-
hasUserDefinedOp
public boolean hasUserDefinedOp(java.lang.String name)
Determine if the language has a given user-defined op. In which case, a CALLOTHER_FIXUP can be installed for it.- Parameters:
name
- is the putative name of the user-defined op- Returns:
- true if the user-defined op exists
-
registerInject
protected void registerInject(InjectPayload payload)
-
removeMechanismPayload
protected boolean removeMechanismPayload(java.lang.String nm)
Remove a specific call mechanism payload.- Parameters:
nm
- is the name of the payload- Returns:
- true if a payload was successfully removed
-
uninstallProgramPayloads
protected void uninstallProgramPayloads()
-
registerProgramInject
protected void registerProgramInject(java.util.List<InjectPayloadSleigh> userPayloads)
-
allocateInject
public InjectPayload allocateInject(java.lang.String sourceName, java.lang.String name, int tp)
The main InjectPayload factory interface. This can be overloaded by derived libraries to produce custom dynamic payloads.- Parameters:
sourceName
- is a description of the source of the payloadname
- is the formal name of the payloadtp
- is the type of payload: CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.- Returns:
- the newly minted InjectPayload
-
saveCompilerSpecXml
public void saveCompilerSpecXml(java.lang.StringBuilder buffer)
Save the parts of the inject library that come from the compiler spec to the output stream as XML tags- Parameters:
buffer
- is the output stream
-
restoreXmlInject
public InjectPayload restoreXmlInject(java.lang.String source, java.lang.String name, int tp, XmlPullParser parser) throws XmlParseException
- Throws:
XmlParseException
-
getConstantPool
public ConstantPool getConstantPool(Program program) throws java.io.IOException
Get the constant pool associated with the given Program- Parameters:
program
- is the given Program- Returns:
- the ConstantPool associated with the Program
- Throws:
java.io.IOException
- for issues constructing the object
-
getUniqueBase
protected long getUniqueBase()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-