Class BaseMachine
- All Implemented Interfaces:
Machine
- Direct Known Subclasses:
ValueAwareMachine
Machine
.
Note: For the most part, the documentation for this class
ignores the distinction between Type
and TypeBearer
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addResult
(TypeBearer result) Adds an additional element to the list of results.protected final TypeBearer
arg
(int n) Gets then
th primary argument.protected final int
argCount()
Gets the number of primary arguments.protected final int
argWidth()
Gets the width of the arguments (where a category-2 value counts as two).final void
Indicates that there is an auxiliary (inline, not stack) object argument, with the value based on the given constant.final void
auxInitValues
(ArrayList<Constant> initValues) Indicates that there is an auxiliary (inline, not stack) argument consisting of a list of initial values for a newly created array.final void
auxIntArg
(int value) Indicates that there is an auxiliary (inline, not stack) argument of typeint
, with the given value.final void
auxSwitchArg
(SwitchList cases) Indicates that there is an auxiliary (inline, not stack) argument consisting of aswitch*
table.final void
auxTargetArg
(int target) Indicates that there is an auxiliary (inline, not stack) argument indicating a branch target.final void
Indicates that the salient type of this operation is as given.final void
Clears the regular and auxiliary arguments area.protected final void
Clears the results.protected final SwitchList
Gets the switch cases auxiliary argument.protected final Constant
Gets the constant auxiliary argument.protected final int
Gets theint
auxiliary argument.protected final int
Gets the branch target auxiliary argument.protected final Type
Gets the type auxiliary argument.Gets the init values auxiliary argument.protected final int
Gets the last local index accessed.protected final boolean
Gets whether the loaded local has info in the local variable table.protected final RegisterSpec
getLocalTarget
(boolean isMove) Gets the target local register spec of the current operation, if any.Gets the effective prototype of the method that this instance is being used for.final void
Loads the local variable with the given index as the sole argument in the arguments area.final void
localInfo
(boolean local) Used to specify if a loaded local variable has info in the local variable table.final void
localTarget
(int idx, Type type, LocalItem local) Indicates that the target of this operation is the given local.final void
Pops the given number of values from the stack (of either category), and store them in the arguments area, indicating that there are now that many arguments.void
Pops values from the stack of the types indicated by the givenPrototype
(popped in reverse of the argument order, so the first prototype argument type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments.final void
Pops a value from the stack of the indicated type, and store it in the arguments area, indicating that there are now that many arguments.final void
Pops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments.final void
Pops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments.protected final TypeBearer
result
(int n) Gets then
th result value.protected final int
Gets the count of results.protected final int
Gets the width of the results (where a category-2 value counts as two).protected final void
setResult
(TypeBearer result) Sets the results list to be the given single value.protected final void
storeResults
(Frame frame) Stores the results of the latest operation into the given frame.static void
throwLocalMismatch
(TypeBearer found, TypeBearer local) Throws an exception that indicates a mismatch in local variable types.
-
Constructor Details
-
BaseMachine
Constructs an instance.- Parameters:
prototype
-non-null;
the prototype for the associated method
-
-
Method Details
-
getPrototype
Gets the effective prototype of the method that this instance is being used for. The effective prototype includes an initialthis
argument for instance methods.- Specified by:
getPrototype
in interfaceMachine
- Returns:
non-null;
the method prototype
-
clearArgs
public final void clearArgs()Clears the regular and auxiliary arguments area. -
popArgs
Pops the given number of values from the stack (of either category), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments. -
popArgs
Pops values from the stack of the types indicated by the givenPrototype
(popped in reverse of the argument order, so the first prototype argument type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments. -
popArgs
Description copied from interface:Machine
Pops a value from the stack of the indicated type, and store it in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments. -
popArgs
Pops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments. -
popArgs
Pops values from the stack of the indicated types (popped in reverse argument order, so the first indicated type is for the deepest element of the stack), and store them in the arguments area, indicating that there are now that many arguments. Also, clear the auxiliary arguments. -
localArg
Loads the local variable with the given index as the sole argument in the arguments area. Also, clear the auxiliary arguments. -
localInfo
public final void localInfo(boolean local) Used to specify if a loaded local variable has info in the local variable table. -
auxType
Indicates that the salient type of this operation is as given. This differentiates between, for example, the various arithmetic opcodes, which, by the time they hit aMachine
are collapsed to theint
variant. (SeeBytecodeArray.parseInstruction(int, com.android.dx.cf.code.BytecodeArray.Visitor)
for details.) -
auxIntArg
public final void auxIntArg(int value) Indicates that there is an auxiliary (inline, not stack) argument of typeint
, with the given value.Note: Perhaps unintuitively, the stack manipulation ops (e.g.,
dup
andswap
) use this to indicate the result stack pattern with a straightforward hex encoding of the push order starting with least-significant nibbles getting pushed first). For example, an all-category-1dup2_x1
sets this to0x12312
, and the other form of that op sets this to0x121
.Also Note: For
switch*
instructions, this is used to indicate the padding value (which is only useful for verification). -
auxCstArg
Indicates that there is an auxiliary (inline, not stack) object argument, with the value based on the given constant.Note: Some opcodes use both
int
and constant auxiliary arguments. -
auxTargetArg
public final void auxTargetArg(int target) Indicates that there is an auxiliary (inline, not stack) argument indicating a branch target.- Specified by:
auxTargetArg
in interfaceMachine
- Parameters:
target
- the argument value
-
auxSwitchArg
Indicates that there is an auxiliary (inline, not stack) argument consisting of aswitch*
table.Note: This is generally used in conjunction with
Machine.auxIntArg(int)
(which holds the padding).- Specified by:
auxSwitchArg
in interfaceMachine
- Parameters:
cases
-non-null;
the list of key-target pairs, plus the default target
-
auxInitValues
Indicates that there is an auxiliary (inline, not stack) argument consisting of a list of initial values for a newly created array.- Specified by:
auxInitValues
in interfaceMachine
- Parameters:
initValues
-non-null;
the list of constant values to initialize the array
-
localTarget
Indicates that the target of this operation is the given local.- Specified by:
localTarget
in interfaceMachine
- Parameters:
idx
->= 0;
the local variable indextype
-non-null;
the type of the locallocal
-null-ok;
the name and signature of the local, if known
-
argCount
protected final int argCount()Gets the number of primary arguments.- Returns:
>= 0;
the number of primary arguments
-
argWidth
protected final int argWidth()Gets the width of the arguments (where a category-2 value counts as two).- Returns:
>= 0;
the argument width
-
arg
Gets then
th primary argument.- Parameters:
n
->= 0, < argCount();
which argument- Returns:
non-null;
the indicated argument
-
getAuxType
Gets the type auxiliary argument.- Returns:
null-ok;
the salient type
-
getAuxInt
protected final int getAuxInt()Gets theint
auxiliary argument.- Returns:
- the argument value
-
getAuxCst
Gets the constant auxiliary argument.- Returns:
null-ok;
the argument value
-
getAuxTarget
protected final int getAuxTarget()Gets the branch target auxiliary argument.- Returns:
- the argument value
-
getAuxCases
Gets the switch cases auxiliary argument.- Returns:
null-ok;
the argument value
-
getInitValues
Gets the init values auxiliary argument.- Returns:
null-ok;
the argument value
-
getLocalIndex
protected final int getLocalIndex()Gets the last local index accessed.- Returns:
>= -1;
the salient local index or-1
if none was set since the last timeclearArgs()
was called
-
getLocalInfo
protected final boolean getLocalInfo()Gets whether the loaded local has info in the local variable table.- Returns:
true
if local arg has info in the local variable table
-
getLocalTarget
Gets the target local register spec of the current operation, if any. The local target spec is the combination of the values indicated by a previous call tolocalTarget
with the type of what should be the sole result set by a call tosetResult(com.android.dx.rop.type.TypeBearer)
(or the combinationclearResult()
thenaddResult(com.android.dx.rop.type.TypeBearer)
.- Parameters:
isMove
-true
if the operation being performed on the local is a move. This will cause constant values to be propagated to the returned local- Returns:
null-ok;
the salient register spec ornull
if no local target was set since the last timeclearArgs()
was called
-
clearResult
protected final void clearResult()Clears the results. -
setResult
Sets the results list to be the given single value.Note: If there is more than one result value, the others may be added by using
addResult(com.android.dx.rop.type.TypeBearer)
.- Parameters:
result
-non-null;
result value
-
addResult
Adds an additional element to the list of results.- Parameters:
result
-non-null;
result value- See Also:
-
resultCount
protected final int resultCount()Gets the count of results. This throws an exception if results were never set. (Explicitly clearing the results counts as setting them.)- Returns:
>= 0;
the count
-
resultWidth
protected final int resultWidth()Gets the width of the results (where a category-2 value counts as two).- Returns:
>= 0;
the result width
-
result
Gets then
th result value.- Parameters:
n
->= 0, < resultCount();
which result- Returns:
non-null;
the indicated result value
-
storeResults
Stores the results of the latest operation into the given frame. If there is a local target (seelocalTarget
), then the sole result is stored to that target; otherwise any results are pushed onto the stack.- Parameters:
frame
-non-null;
frame to operate on
-
throwLocalMismatch
Throws an exception that indicates a mismatch in local variable types.- Parameters:
found
-non-null;
the encountered typelocal
-non-null;
the local variable's claimed type
-