public abstract class BaseMachine extends java.lang.Object implements Machine
Machine.
Note: For the most part, the documentation for this class
ignores the distinction between Type and TypeBearer.
| Constructor and Description |
|---|
BaseMachine(Prototype prototype)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addResult(TypeBearer result)
Adds an additional element to the list of results.
|
protected TypeBearer |
arg(int n)
Gets the
nth primary argument. |
protected int |
argCount()
Gets the number of primary arguments.
|
protected int |
argWidth()
Gets the width of the arguments (where a category-2 value counts as
two).
|
void |
auxCstArg(Constant cst)
Indicates that there is an auxiliary (inline, not stack) object
argument, with the value based on the given constant.
|
void |
auxInitValues(java.util.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.
|
void |
auxIntArg(int value)
Indicates that there is an auxiliary (inline, not stack)
argument of type
int, with the given value. |
void |
auxSwitchArg(SwitchList cases)
Indicates that there is an auxiliary (inline, not stack) argument
consisting of a
switch* table. |
void |
auxTargetArg(int target)
Indicates that there is an auxiliary (inline, not stack) argument
indicating a branch target.
|
void |
auxType(Type type)
Indicates that the salient type of this operation is as
given.
|
void |
clearArgs()
Clears the regular and auxiliary arguments area.
|
protected void |
clearResult()
Clears the results.
|
protected SwitchList |
getAuxCases()
Gets the switch cases auxiliary argument.
|
protected Constant |
getAuxCst()
Gets the constant auxiliary argument.
|
protected int |
getAuxInt()
Gets the
int auxiliary argument. |
protected int |
getAuxTarget()
Gets the branch target auxiliary argument.
|
protected Type |
getAuxType()
Gets the type auxiliary argument.
|
protected java.util.ArrayList<Constant> |
getInitValues()
Gets the init values auxiliary argument.
|
protected int |
getLocalIndex()
Gets the last local index accessed.
|
protected boolean |
getLocalInfo()
Gets whether the loaded local has info in the local variable table.
|
protected RegisterSpec |
getLocalTarget(boolean isMove)
Gets the target local register spec of the current operation, if any.
|
Prototype |
getPrototype()
Gets the effective prototype of the method that this instance is
being used for.
|
void |
localArg(Frame frame,
int idx)
Loads the local variable with the given index as the sole argument in
the arguments area.
|
void |
localInfo(boolean local)
Used to specify if a loaded local variable has info in the local
variable table.
|
void |
localTarget(int idx,
Type type,
LocalItem local)
Indicates that the target of this operation is the given local.
|
void |
popArgs(Frame frame,
int count)
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 |
popArgs(Frame frame,
Prototype prototype)
Pops values from the stack of the types indicated by the given
Prototype (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. |
void |
popArgs(Frame frame,
Type type)
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.
|
void |
popArgs(Frame frame,
Type type1,
Type type2)
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.
|
void |
popArgs(Frame frame,
Type type1,
Type type2,
Type type3)
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 TypeBearer |
result(int n)
Gets the
nth result value. |
protected int |
resultCount()
Gets the count of results.
|
protected int |
resultWidth()
Gets the width of the results (where a category-2 value counts as
two).
|
protected void |
setResult(TypeBearer result)
Sets the results list to be the given single value.
|
protected 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.
|
public BaseMachine(Prototype prototype)
prototype - non-null; the prototype for the
associated methodpublic Prototype getPrototype()
this argument for instance methods.getPrototype in interface Machinenon-null; the method prototypepublic final void clearArgs()
public final void popArgs(Frame frame, int count)
public void popArgs(Frame frame, Prototype prototype)
Prototype (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.public final void popArgs(Frame frame, Type type)
Machinepublic final void popArgs(Frame frame, Type type1, Type type2)
public final void popArgs(Frame frame, Type type1, Type type2, Type type3)
public final void localArg(Frame frame, int idx)
public final void localInfo(boolean local)
public final void auxType(Type type)
Machine are collapsed to the int
variant. (See BytecodeArray.parseInstruction(int, com.android.dx.cf.code.BytecodeArray.Visitor) for
details.)public final void auxIntArg(int value)
int, with the given value.
Note: Perhaps unintuitively, the stack manipulation
ops (e.g., dup and swap) 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-1
dup2_x1 sets this to 0x12312, and the
other form of that op sets this to
0x121.
Also Note: For switch* instructions, this is
used to indicate the padding value (which is only useful for
verification).
public final void auxCstArg(Constant cst)
Note: Some opcodes use both int and
constant auxiliary arguments.
public final void auxTargetArg(int target)
auxTargetArg in interface Machinetarget - the argument valuepublic final void auxSwitchArg(SwitchList cases)
switch* table.
Note: This is generally used in conjunction with
Machine.auxIntArg(int) (which holds the padding).
auxSwitchArg in interface Machinecases - non-null; the list of key-target pairs, plus the default
targetpublic final void auxInitValues(java.util.ArrayList<Constant> initValues)
auxInitValues in interface MachineinitValues - non-null; the list of constant values to initialize
the arraypublic final void localTarget(int idx,
Type type,
LocalItem local)
localTarget in interface Machineidx - >= 0; the local variable indextype - non-null; the type of the locallocal - null-ok; the name and signature of the local, if knownprotected final int argCount()
>= 0; the number of primary argumentsprotected final int argWidth()
>= 0; the argument widthprotected final TypeBearer arg(int n)
nth primary argument.n - >= 0, < argCount(); which argumentnon-null; the indicated argumentprotected final Type getAuxType()
null-ok; the salient typeprotected final int getAuxInt()
int auxiliary argument.protected final Constant getAuxCst()
null-ok; the argument valueprotected final int getAuxTarget()
protected final SwitchList getAuxCases()
null-ok; the argument valueprotected final java.util.ArrayList<Constant> getInitValues()
null-ok; the argument valueprotected final int getLocalIndex()
>= -1; the salient local index or -1 if none
was set since the last time clearArgs() was calledprotected final boolean getLocalInfo()
true if local arg has info in the local variable tableprotected final RegisterSpec getLocalTarget(boolean isMove)
localTarget with the type of what
should be the sole result set by a call to setResult(com.android.dx.rop.type.TypeBearer) (or
the combination clearResult() then addResult(com.android.dx.rop.type.TypeBearer).isMove - true if the operation being performed on the
local is a move. This will cause constant values to be propagated
to the returned localnull-ok; the salient register spec or null if no
local target was set since the last time clearArgs() was
calledprotected final void clearResult()
protected final void setResult(TypeBearer result)
Note: If there is more than one result value, the
others may be added by using addResult(com.android.dx.rop.type.TypeBearer).
result - non-null; result valueprotected final void addResult(TypeBearer result)
result - non-null; result valuesetResult(com.android.dx.rop.type.TypeBearer)protected final int resultCount()
>= 0; the countprotected final int resultWidth()
>= 0; the result widthprotected final TypeBearer result(int n)
nth result value.n - >= 0, < resultCount(); which resultnon-null; the indicated result valueprotected final void storeResults(Frame frame)
localTarget), then the sole
result is stored to that target; otherwise any results are pushed
onto the stack.frame - non-null; frame to operate onpublic static void throwLocalMismatch(TypeBearer found, TypeBearer local)
found - non-null; the encountered typelocal - non-null; the local variable's claimed typeCopyright © 2020. All Rights Reserved.