Package ghidra.program.util
Class AddressEvaluator
java.lang.Object
generic.expressions.ExpressionEvaluator
ghidra.program.util.AddressEvaluator
Class for evaluating expressions as an Address. See 
 
ExpressionOperator for the full list of supported operators. All values are interpreted
 as longs or symbols that resolve to an address.
 ExpressionEvaluators can operate in either decimal or hex mode. If in hex mode, all numbers are assumed to be hexadecimal values. In decimal mode, numbers are assumed to be decimal values, but hexadecimal values can still be specified by prefixing them with "0x".
 There are also two convenience static methods that can be called to evaluate address expressions.
 These methods will either return an Address as the result or null if there was an error
 evaluating the expression. To get error messages related to parsing the expression, instantiate 
 an AddressEvaluator and call parseAsAddress(String) which will throw a 
 ExpressionException when the expression can't be evaluated.
- 
Constructor SummaryConstructorsConstructorDescriptionAddressEvaluator(AddressFactory factory, boolean assumeHex) Constructs an AdddressEvaluator without a full program.AddressEvaluator(Program program, boolean assumeHex) Constructs an AddressEvalutor for the given program and in the specified hex/decimal mode.AddressEvaluator(Program program, AddressSpace defaultSpace, boolean assumeHex) Constructs an AddressEvalutor for the given program and in the specified hex/decimal mode.
- 
Method SummaryModifier and TypeMethodDescriptionstatic AddressGets a valid address for the specified program as indicated by the input expression.static AddressGets a valid address for the specified program as indicated by the input expression.protected ExpressionValueevaluateSymbol(String input) Returns theAddressFactorybeing used by this address evaluatorparseAsAddress(String input) Evaluates the given input expression as an address.parseAsRelativeAddress(String input, Address baseAddress) Evaluates the given input expression as a relative offset that will be added to the given base address.voidSets theAddressSpaceto be used to convert long values into addresses.Methods inherited from class generic.expressions.ExpressionEvaluatorevaluateToLong, evaluateToLong, parse, parse, parseAsLong, setAssumeHex
- 
Constructor Details- 
AddressEvaluatorConstructs an AddressEvalutor for the given program and in the specified hex/decimal mode.- Parameters:
- program- the program to use to evaluate expressions into valid addresses.
- assumeHex- if true, all numeric values are assumed to be hexadecimal numbers.
 
- 
AddressEvaluatorConstructs an AdddressEvaluator without a full program. This version will not be able to evaluate symbol or memory block names. This is mostly for backwards compatibility.- Parameters:
- factory- the address factory for creating addresses
- assumeHex- if true, all numeric values are assumed to be hexadecimal numbers.
 
- 
AddressEvaluatorConstructs an AddressEvalutor for the given program and in the specified hex/decimal mode.- Parameters:
- program- the program to use to evaluate expressions into valid addresses.
- defaultSpace- The address space to use when converting long values into addresses. If this value is null, then the default address space will be used.
- assumeHex- if true, all numeric values are assumed to be hexadecimal numbers.
 
 
- 
- 
Method Details- 
evaluateGets a valid address for the specified program as indicated by the input expression.- Parameters:
- p- the program to use for determining the address.
- inputExpression- string representation of the address desired.
- Returns:
- the address. Otherwise, return null if the string fails to evaluate to a unique legitimate address.
 
- 
evaluateGets a valid address for the specified program as indicated by the input expression.- Parameters:
- p- the program to use for determining the address.
- baseAddr- the base address to use for relative addressing.
- inputExpression- string representation of the address desired.
- Returns:
- the address. Otherwise, return null if the string fails to evaluate to a unique legitimate address.
 
- 
parseAsAddressEvaluates the given input expression as an address.- Parameters:
- input- the expression to evaluate
- Returns:
- the Address the expression evaluates to
- Throws:
- ExpressionException- if the input expression can't be evaluated to a valid, unique address.
 
- 
parseAsRelativeAddressEvaluates the given input expression as a relative offset that will be added to the given base address.- Parameters:
- input- the expression to evaluate as an offset
- baseAddress- the base address the evaluted expression will be added to to get the resulting address.
- Returns:
- the Address after the evaluated offset is added to the given base address.
- Throws:
- ExpressionException- if the input expression can't be evaluated to a valid, unique address.
 
- 
getAddressFactoryReturns theAddressFactorybeing used by this address evaluator- Returns:
- the AddressFactorybeing used by this address evaluator
 
- 
setPreferredAddressSpaceSets theAddressSpaceto be used to convert long values into addresses.- Parameters:
- space- the address space to convert long values into addresses
 
- 
evaluateSymbol- Overrides:
- evaluateSymbolin class- ExpressionEvaluator
 
 
-