Package ghidra.program.model.listing
Class AutoParameterImpl
- java.lang.Object
-
- ghidra.program.model.listing.ParameterImpl
-
- ghidra.program.model.listing.AutoParameterImpl
-
public class AutoParameterImpl extends ParameterImpl
-
-
Field Summary
-
Fields inherited from class ghidra.program.model.listing.ParameterImpl
ordinal
-
Fields inherited from interface ghidra.program.model.listing.Parameter
RETURN_NAME, RETURN_ORIDINAL, UNASSIGNED_ORDINAL
-
-
Constructor Summary
Constructors Constructor Description AutoParameterImpl(DataType dataType, int ordinal, VariableStorage storage, Function function)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Variable otherVar)
boolean
equals(java.lang.Object obj)
java.lang.String
getComment()
Get the Comment for this variableVarnode
getFirstStorageVarnode()
Get the first storage varnode for this variableFunction
getFunction()
Returns the function that contains this Variable.Varnode
getLastStorageVarnode()
Get the last storage varnode for this variableint
getLength()
Get the length of this variableAddress
getMinAddress()
java.lang.String
getName()
Get the Name of this variable or null if not assigned or not-applicableProgram
getProgram()
Returns the program that contains this variable or is the intended targetRegister
getRegister()
java.util.List<Register>
getRegisters()
SourceType
getSource()
Get the source of this variableint
getStackOffset()
Symbol
getSymbol()
VariableStorage
getVariableStorage()
Get the variable storage associated with this variable.boolean
hasAssignedStorage()
int
hashCode()
boolean
hasStackStorage()
boolean
isCompoundVariable()
boolean
isEquivalent(Variable otherVar)
Determine is another variable is equivalent to this variable.boolean
isMemoryVariable()
boolean
isRegisterVariable()
boolean
isStackVariable()
boolean
isUniqueVariable()
boolean
isValid()
Verify that the variable is valid (i.e., storage is valid and size matches variable data type size)protected boolean
isVoidAllowed()
void
setComment(java.lang.String comment)
Set the comment for this variablevoid
setDataType(DataType type, boolean align, boolean force, SourceType source)
Set the Data Type of this variable.void
setDataType(DataType type, VariableStorage storage, boolean force, SourceType source)
Set the Data Type of this variable and the associated storage whose size matches the data type length.void
setDataType(DataType type, SourceType source)
Set the Data Type of this variable using the default alignment behavior (implementation specific).void
setName(java.lang.String name, SourceType source)
Set the name of this variable.java.lang.String
toString()
-
Methods inherited from class ghidra.program.model.listing.ParameterImpl
getAutoParameterType, getDataType, getFirstUseOffset, getFormalDataType, getOrdinal, hasDefaultName, isAutoParameter, isForcedIndirect
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.listing.Variable
getComment, getFirstStorageVarnode, getLastStorageVarnode, getLength, getMinAddress, getName, getProgram, getRegister, getRegisters, getSource, getStackOffset, getSymbol, getVariableStorage, hasAssignedStorage, hasStackStorage, isCompoundVariable, isEquivalent, isMemoryVariable, isRegisterVariable, isStackVariable, isUniqueVariable, isValid, setDataType
-
-
-
-
Constructor Detail
-
AutoParameterImpl
public AutoParameterImpl(DataType dataType, int ordinal, VariableStorage storage, Function function) throws InvalidInputException
- Throws:
InvalidInputException
-
-
Method Detail
-
getFunction
public Function getFunction()
Description copied from interface:Variable
Returns the function that contains this Variable. May be null if the variable is not in a function.- Specified by:
getFunction
in interfaceVariable
- Returns:
- containing function or null
-
setDataType
public void setDataType(DataType type, VariableStorage storage, boolean force, SourceType source) throws InvalidInputException
Description copied from interface:Variable
Set the Data Type of this variable and the associated storage whose size matches the data type length.NOTE: The storage and source are ignored if the function does not have custom storage enabled.
- Specified by:
setDataType
in interfaceVariable
- Parameters:
type
- the data typestorage
- properly sized storage for the new data typeforce
- overwrite conflicting variablessource
- variable storage source (used only for function parameters and return)- Throws:
InvalidInputException
- if data type is not a fixed length or violates storage constraints.VariableSizeException
- if force is false and data type size causes a conflict with other variables
-
setDataType
public void setDataType(DataType type, SourceType source) throws InvalidInputException
Description copied from interface:Variable
Set the Data Type of this variable using the default alignment behavior (implementation specific). The given dataType must have a fixed length. If contained within a stack-frame, data-type size will be constrained by existing variables (e.g., equivalent to force=false) Note: stack offset will be maintained for stack variables.- Specified by:
setDataType
in interfaceVariable
- Parameters:
type
- the data typesource
- signature source- Throws:
InvalidInputException
- if data type is not a fixed length or violates storage constraints.VariableSizeException
- if data type size causes a conflict with other variables- See Also:
Variable.setDataType(DataType, boolean, boolean, SourceType)
-
setComment
public void setComment(java.lang.String comment)
Description copied from interface:Variable
Set the comment for this variable- Specified by:
setComment
in interfaceVariable
- Parameters:
comment
- the comment
-
setName
public void setName(java.lang.String name, SourceType source) throws InvalidInputException
Description copied from interface:Variable
Set the name of this variable.- Specified by:
setName
in interfaceVariable
- Parameters:
name
- the namesource
- the source of this variable name- Throws:
InvalidInputException
- if name contains blank characters, is zero length, or is null
-
isVoidAllowed
protected boolean isVoidAllowed()
- Returns:
- true if a zero-sized void type is permitted
-
isValid
public final boolean isValid()
Description copied from interface:Variable
Verify that the variable is valid (i.e., storage is valid and size matches variable data type size)
-
getComment
public final java.lang.String getComment()
Description copied from interface:Variable
Get the Comment for this variable- Specified by:
getComment
in interfaceVariable
- Returns:
- the comment
-
setDataType
public final void setDataType(DataType type, boolean align, boolean force, SourceType source) throws InvalidInputException
Description copied from interface:Variable
Set the Data Type of this variable. The given dataType must have a fixed length.- Specified by:
setDataType
in interfaceVariable
- Parameters:
type
- the data typealign
- maintain proper stack alignment/justification if supported by implementation. If false and this is a stack variable, the current stack address/offset will not change. If true, the affect is implementation dependent since alignment can not be performed without access to a compiler specification.force
- overwrite conflicting variablessource
- signature source- Throws:
InvalidInputException
- if data type is not a fixed length or violates storage constraints.VariableSizeException
- if force is false and data type size causes a conflict with other variables
-
getProgram
public final Program getProgram()
Description copied from interface:Variable
Returns the program that contains this variable or is the intended target- Specified by:
getProgram
in interfaceVariable
- Returns:
- the program.
-
getLength
public final int getLength()
Description copied from interface:Variable
Get the length of this variable
-
getName
public final java.lang.String getName()
Description copied from interface:Variable
Get the Name of this variable or null if not assigned or not-applicable
-
getSource
public final SourceType getSource()
Description copied from interface:Variable
Get the source of this variable
-
getSymbol
public final Symbol getSymbol()
-
hasAssignedStorage
public final boolean hasAssignedStorage()
- Specified by:
hasAssignedStorage
in interfaceVariable
- Returns:
- true if this variable has been assigned storage. This is equivalent to
Variable.getVariableStorage()
!= null
-
getVariableStorage
public final VariableStorage getVariableStorage()
Description copied from interface:Variable
Get the variable storage associated with this variable.- Specified by:
getVariableStorage
in interfaceVariable
- Returns:
- the variable storage for this variable
-
getFirstStorageVarnode
public final Varnode getFirstStorageVarnode()
Description copied from interface:Variable
Get the first storage varnode for this variable- Specified by:
getFirstStorageVarnode
in interfaceVariable
- Returns:
- the first storage varnode associated with this variable
- See Also:
Variable.getVariableStorage()
-
getLastStorageVarnode
public final Varnode getLastStorageVarnode()
Description copied from interface:Variable
Get the last storage varnode for this variable- Specified by:
getLastStorageVarnode
in interfaceVariable
- Returns:
- the last storage varnode associated with this variable
- See Also:
Variable.getVariableStorage()
-
isStackVariable
public final boolean isStackVariable()
- Specified by:
isStackVariable
in interfaceVariable
- Returns:
- true if this is a simple variable consisting of a single stack varnode
which will be returned by either the
Variable.getFirstStorageVarnode()
orVariable.getLastStorageVarnode()
methods. The stack offset can be obtained using:getFirstStorageVarnode().getOffset()
-
hasStackStorage
public final boolean hasStackStorage()
- Specified by:
hasStackStorage
in interfaceVariable
- Returns:
- true if this variable uses simple or compound storage which contains a stack element. If true, the last storage varnode will always be the stack element.
- See Also:
Variable.getLastStorageVarnode()
-
isRegisterVariable
public final boolean isRegisterVariable()
- Specified by:
isRegisterVariable
in interfaceVariable
- Returns:
- true if this is a simple variable consisting of a single register varnode
which will be returned by either the
Variable.getFirstStorageVarnode()
orVariable.getLastStorageVarnode()
methods. The register can be obtained using theVariable.getRegister()
method.
-
getRegister
public final Register getRegister()
- Specified by:
getRegister
in interfaceVariable
- Returns:
- first storage register associated with this variable, else null is returned. A variable with compound storage may have more than one register or other storage in addition to the register returned by this method.
- See Also:
Variable.isRegisterVariable()
-
getRegisters
public final java.util.List<Register> getRegisters()
- Specified by:
getRegisters
in interfaceVariable
- Returns:
- all storage register(s) associated with this variable, else null is returned if no registers are used. A variable with compound storage may have more than one register or other storage in addition to the register(s) returned by this method.
- See Also:
Variable.isRegisterVariable()
,Variable.isCompoundVariable()
-
getMinAddress
public final Address getMinAddress()
- Specified by:
getMinAddress
in interfaceVariable
- Returns:
- the minimum address corresponding to the first varnode of this storage
or null if this is a special empty storage:
VariableStorage.BAD_STORAGE
,VariableStorage.UNASSIGNED_STORAGE
,VariableStorage.VOID_STORAGE
-
getStackOffset
public final int getStackOffset()
- Specified by:
getStackOffset
in interfaceVariable
- Returns:
- the stack offset associated with simple stack variable (i.e.,
Variable.isStackVariable()
returns true).
-
isMemoryVariable
public final boolean isMemoryVariable()
- Specified by:
isMemoryVariable
in interfaceVariable
- Returns:
- true if this is a simple variable consisting of a single storage memory element
which will be returned by either the
Variable.getFirstStorageVarnode()
orVariable.getVariableStorage()
methods.
-
isUniqueVariable
public final boolean isUniqueVariable()
- Specified by:
isUniqueVariable
in interfaceVariable
- Returns:
- true if this is a simple variable consisting of a single storage unique/hash element
which will be returned by either the
Variable.getFirstStorageVarnode()
orVariable.getVariableStorage()
methods. The unique hash can be obtained from the storage address offset corresponding to the single storage element.
-
isCompoundVariable
public final boolean isCompoundVariable()
- Specified by:
isCompoundVariable
in interfaceVariable
- Returns:
- true if this variable uses compound storage consisting of two or more storage elements
which will be returned by the
Variable.getVariableStorage()
method. Compound variables will always use a register(s) optionally followed by other storage (i.e., stack).
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public final int compareTo(Variable otherVar)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Variable>
-
isEquivalent
public final boolean isEquivalent(Variable otherVar)
Description copied from interface:Variable
Determine is another variable is equivalent to this variable.- Specified by:
isEquivalent
in interfaceVariable
- Parameters:
otherVar
- other variable- Returns:
- true if the specified variable is equivalent to this variable
-
-