Class PairedPcodeArithmetic<L,R>
- Type Parameters:
L
- the type of the left ("control") elementR
- the type of the right ("auxiliary") element
- All Implemented Interfaces:
PcodeArithmetic<org.apache.commons.lang3.tuple.Pair<L,
R>>
The new arithmetic operates on tuples where each is subject to its respective arithmetic. One
exception is toConcrete(Pair, Purpose)
. This arithmetic defers to left ("control")
arithmetic. Thus, conventionally, when part of the pair represents the concrete value, it should
be the left.
See PairedPcodeExecutorStatePiece
regarding composing three or more elements. Generally,
it's recommended the client provide its own "record" type and the corresponding arithmetic and
state piece to manipulate it. Nesting pairs would work, but is not recommended.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.pcode.exec.PcodeArithmetic
PcodeArithmetic.Purpose
-
Field Summary
Fields inherited from interface ghidra.pcode.exec.PcodeArithmetic
SIZEOF_SIZEOF
-
Constructor Summary
ConstructorDescriptionPairedPcodeArithmetic
(PcodeArithmetic<L> leftArith, PcodeArithmetic<R> rightArith) Construct a composed arithmetic from the given two -
Method Summary
Modifier and TypeMethodDescriptionbinaryOp
(int opcode, int sizeout, int sizein1, org.apache.commons.lang3.tuple.Pair<L, R> in1, int sizein2, org.apache.commons.lang3.tuple.Pair<L, R> in2) Apply a binary operator to the given inputsbinaryOp
(PcodeOp op, org.apache.commons.lang3.tuple.Pair<L, R> in1, org.apache.commons.lang3.tuple.Pair<L, R> in2) Apply a binary operator to the given inputboolean
fromConst
(byte[] value) Convert the given constant concrete value to typeT
having the same size.Get the endianness of this arithmeticgetLeft()
Get the left ("control") arithmeticgetRight()
Get the right ("rider") arithmeticmodAfterLoad
(int sizeout, int sizeinAddress, org.apache.commons.lang3.tuple.Pair<L, R> inAddress, int sizeinValue, org.apache.commons.lang3.tuple.Pair<L, R> inValue) Apply any modifications after a value is loadedmodBeforeStore
(int sizeout, int sizeinAddress, org.apache.commons.lang3.tuple.Pair<L, R> inAddress, int sizeinValue, org.apache.commons.lang3.tuple.Pair<L, R> inValue) Apply any modifications before a value is storedlong
Get the size in bytes, if possible, of the given abstract valuebyte[]
toConcrete
(org.apache.commons.lang3.tuple.Pair<L, R> value, PcodeArithmetic.Purpose purpose) Convert, if possible, the given abstract value to a concrete byte arrayApply a unary operator to the given inputApply a unary operator to the given inputMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.pcode.exec.PcodeArithmetic
fromConst, fromConst, fromConst, isTrue, ptrAdd, ptrSub, sizeOfAbstract, toBigInteger, toLong
-
Constructor Details
-
PairedPcodeArithmetic
Construct a composed arithmetic from the given two- Parameters:
leftArith
- the left ("control") arithmeticrightArith
- the right ("rider") arithmetic
-
-
Method Details
-
equals
-
getEndian
Description copied from interface:PcodeArithmetic
Get the endianness of this arithmeticOften T is a byte array, or at least represents one abstractly. Ideally, it is an array where each element is an abstraction of a byte. If that is the case, then the arithmetic likely has to interpret those bytes as integral values according to an endianness. This should return that endianness.
If the abstraction has no notion of endianness, return null. In that case, the both
PcodeArithmetic.fromConst(BigInteger, int, boolean)
andPcodeArithmetic.fromConst(long, int)
must be overridden. Furthermore, unlessPcodeArithmetic.toConcrete(Object, Purpose)
is guaranteed to throw an exception, thenPcodeArithmetic.toBigInteger(Object, Purpose)
andPcodeArithmetic.toLong(Object, Purpose)
must also be overridden.- Specified by:
getEndian
in interfacePcodeArithmetic<L>
- Returns:
- the endianness or null
-
unaryOp
public org.apache.commons.lang3.tuple.Pair<L,R> unaryOp(int opcode, int sizeout, int sizein1, org.apache.commons.lang3.tuple.Pair<L, R> in1) Description copied from interface:PcodeArithmetic
Apply a unary operator to the given inputNote the sizes of variables are given, because values don't necessarily have an intrinsic size. For example, a
BigInteger
may have a minimum encoding size, but that does not necessarily reflect the size of the variable from which is was read.- Specified by:
unaryOp
in interfacePcodeArithmetic<L>
- Parameters:
opcode
- the p-code opcodesizeout
- the size (in bytes) of the output variablesizein1
- the size (in bytes) of the input variablein1
- the input value- Returns:
- the output value
-
unaryOp
public org.apache.commons.lang3.tuple.Pair<L,R> unaryOp(PcodeOp op, org.apache.commons.lang3.tuple.Pair<L, R> in1) Description copied from interface:PcodeArithmetic
Apply a unary operator to the given inputThis provides the full p-code op, allowing deeper inspection of the code. For example, an arithmetic may wish to distinguish immediate (constant) values from variables. By default, this unpacks the details and defers to
PcodeArithmetic.unaryOp(int, int, int, Object)
.- Specified by:
unaryOp
in interfacePcodeArithmetic<L>
- Parameters:
op
- the operationin1
- the input value- Returns:
- the output value
-
binaryOp
public org.apache.commons.lang3.tuple.Pair<L,R> binaryOp(int opcode, int sizeout, int sizein1, org.apache.commons.lang3.tuple.Pair<L, R> in1, int sizein2, org.apache.commons.lang3.tuple.Pair<L, R> in2) Description copied from interface:PcodeArithmetic
Apply a binary operator to the given inputsNote the sizes of variables are given, because values don't necessarily have an intrinsic size. For example, a
BigInteger
may have a minimum encoding size, but that does not necessarily reflect the size of the variable from which is was read.- Specified by:
binaryOp
in interfacePcodeArithmetic<L>
- Parameters:
opcode
- the operation's opcode. SeePcodeOp
.sizeout
- the size (in bytes) of the output variablesizein1
- the size (in bytes) of the first (left) input variablein1
- the first (left) input valuesizein2
- the size (in bytes) of the second (right) input variablein2
- the second (right) input value- Returns:
- the output value
-
binaryOp
public org.apache.commons.lang3.tuple.Pair<L,R> binaryOp(PcodeOp op, org.apache.commons.lang3.tuple.Pair<L, R> in1, org.apache.commons.lang3.tuple.Pair<L, R> in2) Description copied from interface:PcodeArithmetic
Apply a binary operator to the given inputThis provides the full p-code op, allowing deeper inspection of the code. For example, an arithmetic may wish to distinguish immediate (constant) values from variables. By default, this unpacks the details and defers to
PcodeArithmetic.binaryOp(int, int, int, Object, int, Object)
.- Specified by:
binaryOp
in interfacePcodeArithmetic<L>
- Parameters:
op
- the operationin1
- the first (left) input valuein2
- the second (right) input value- Returns:
- the output value
-
modBeforeStore
public org.apache.commons.lang3.tuple.Pair<L,R> modBeforeStore(int sizeout, int sizeinAddress, org.apache.commons.lang3.tuple.Pair<L, R> inAddress, int sizeinValue, org.apache.commons.lang3.tuple.Pair<L, R> inValue) Description copied from interface:PcodeArithmetic
Apply any modifications before a value is storedThis implements any abstractions associated with
PcodeOp.STORE
. This is called on the address/offset and the value before the value is actually stored into the state.- Specified by:
modBeforeStore
in interfacePcodeArithmetic<L>
- Parameters:
sizeout
- the size (in bytes) of the output variablesizeinAddress
- the size (in bytes) of the variable used for indirectioninAddress
- the value used as the address (or offset)sizeinValue
- the size (in bytes) of the variable to storeinValue
- the value to store- Returns:
- the modified value to store
-
modAfterLoad
public org.apache.commons.lang3.tuple.Pair<L,R> modAfterLoad(int sizeout, int sizeinAddress, org.apache.commons.lang3.tuple.Pair<L, R> inAddress, int sizeinValue, org.apache.commons.lang3.tuple.Pair<L, R> inValue) Description copied from interface:PcodeArithmetic
Apply any modifications after a value is loadedThis implements any abstractions associated with
PcodeOp.LOAD
. This is called on the address/offset and the value after the value is actually loaded from the state.- Specified by:
modAfterLoad
in interfacePcodeArithmetic<L>
- Parameters:
sizeout
- the size (in bytes) of the output variablesizeinAddress
- the size (in bytes) of the variable used for indirectioninAddress
- the value used as the address (or offset)sizeinValue
- the size (in bytes) of the variable loadedinValue
- the value loaded- Returns:
- the modified value loaded
-
fromConst
Description copied from interface:PcodeArithmetic
Convert the given constant concrete value to typeT
having the same size.- Specified by:
fromConst
in interfacePcodeArithmetic<L>
- Parameters:
value
- the constant value- Returns:
- the value as a
T
-
toConcrete
public byte[] toConcrete(org.apache.commons.lang3.tuple.Pair<L, R> value, PcodeArithmetic.Purpose purpose) Description copied from interface:PcodeArithmetic
Convert, if possible, the given abstract value to a concrete byte array- Specified by:
toConcrete
in interfacePcodeArithmetic<L>
- Parameters:
value
- the abstract valuepurpose
- the purpose for which the emulator needs a concrete value- Returns:
- the array
-
sizeOf
Description copied from interface:PcodeArithmetic
Get the size in bytes, if possible, of the given abstract valueIf the abstract value does not conceptually have a size, throw an exception.
- Specified by:
sizeOf
in interfacePcodeArithmetic<L>
- Parameters:
value
- the abstract value- Returns:
- the size in bytes
-
getLeft
Get the left ("control") arithmetic- Returns:
- the arithmetic
-
getRight
Get the right ("rider") arithmetic- Returns:
- the arithmetic
-