aboutsummaryrefslogtreecommitdiff
path: root/dexmaker/src/main/java/com/android/dx/Code.java
diff options
context:
space:
mode:
Diffstat (limited to 'dexmaker/src/main/java/com/android/dx/Code.java')
-rw-r--r--dexmaker/src/main/java/com/android/dx/Code.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/dexmaker/src/main/java/com/android/dx/Code.java b/dexmaker/src/main/java/com/android/dx/Code.java
index 721d659..715d2b4 100644
--- a/dexmaker/src/main/java/com/android/dx/Code.java
+++ b/dexmaker/src/main/java/com/android/dx/Code.java
@@ -534,13 +534,24 @@ public final class Code {
*/
public <T> void compare(Comparison comparison, Label trueLabel, Local<T> a, Local<T> b) {
adopt(trueLabel);
- // TODO: ops to compare with zero/null: just omit the 2nd local in StdTypeList.make()
Rop rop = comparison.rop(StdTypeList.make(a.type.ropType, b.type.ropType));
addInstruction(new PlainInsn(rop, sourcePosition, null,
RegisterSpecList.make(a.spec(), b.spec())), trueLabel);
}
/**
+ * Check if an int or reference equals to zero. If the comparison is true,
+ * execution jumps to {@code trueLabel}. If it is false, execution continues to
+ * the next instruction.
+ */
+ public <T> void compareZ(Comparison comparison, Label trueLabel, Local<?> a) {
+ adopt(trueLabel);
+ Rop rop = comparison.rop(StdTypeList.make(a.type.ropType));
+ addInstruction(new PlainInsn(rop, sourcePosition, null,
+ RegisterSpecList.make(a.spec())), trueLabel);
+ }
+
+ /**
* Compare floats or doubles. This stores -1 in {@code target} if {@code
* a < b}, 0 in {@code target} if {@code a == b} and 1 in target if {@code
* a > b}. This stores {@code nanValue} in {@code target} if either value
@@ -576,7 +587,7 @@ public final class Code {
* Copies the value in instance field {@code fieldId} of {@code instance} to
* {@code target}.
*/
- public <D, V> void iget(FieldId<D, V> fieldId, Local<V> target, Local<D> instance) {
+ public <D, V> void iget(FieldId<D, ? extends V> fieldId, Local<V> target, Local<D> instance) {
addInstruction(new ThrowingCstInsn(Rops.opGetField(target.type.ropType), sourcePosition,
RegisterSpecList.make(instance.spec()), catches, fieldId.constant));
moveResult(target, true);
@@ -586,7 +597,7 @@ public final class Code {
* Copies the value in {@code source} to the instance field {@code fieldId}
* of {@code instance}.
*/
- public <D, V> void iput(FieldId<D, V> fieldId, Local<D> instance, Local<V> source) {
+ public <D, V> void iput(FieldId<D, V> fieldId, Local<? extends D> instance, Local<? extends V> source) {
addInstruction(new ThrowingCstInsn(Rops.opPutField(source.type.ropType), sourcePosition,
RegisterSpecList.make(source.spec(), instance.spec()), catches, fieldId.constant));
}
@@ -594,7 +605,7 @@ public final class Code {
/**
* Copies the value in the static field {@code fieldId} to {@code target}.
*/
- public <V> void sget(FieldId<?, V> fieldId, Local<V> target) {
+ public <V> void sget(FieldId<?, ? extends V> fieldId, Local<V> target) {
addInstruction(new ThrowingCstInsn(Rops.opGetStatic(target.type.ropType), sourcePosition,
RegisterSpecList.EMPTY, catches, fieldId.constant));
moveResult(target, true);
@@ -603,7 +614,7 @@ public final class Code {
/**
* Copies the value in {@code source} to the static field {@code fieldId}.
*/
- public <V> void sput(FieldId<?, V> fieldId, Local<V> source) {
+ public <V> void sput(FieldId<?, V> fieldId, Local<? extends V> source) {
addInstruction(new ThrowingCstInsn(Rops.opPutStatic(source.type.ropType), sourcePosition,
RegisterSpecList.make(source.spec()), catches, fieldId.constant));
}