mirror of
https://github.com/revanced/smali.git
synced 2025-05-20 16:07:05 +02:00
Move the value type constants from EncodedValue to a new ValueType class
This commit is contained in:
parent
bf95959ae4
commit
a8d9abfc24
51
dexlib2/src/main/java/org/jf/dexlib2/ValueType.java
Normal file
51
dexlib2/src/main/java/org/jf/dexlib2/ValueType.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2;
|
||||
|
||||
public abstract class ValueType {
|
||||
public static final int BYTE = 0x00;
|
||||
public static final int SHORT = 0x02;
|
||||
public static final int CHAR = 0x03;
|
||||
public static final int INT = 0x04;
|
||||
public static final int LONG = 0x06;
|
||||
public static final int FLOAT = 0x10;
|
||||
public static final int DOUBLE = 0x11;
|
||||
public static final int STRING = 0x17;
|
||||
public static final int TYPE = 0x18;
|
||||
public static final int FIELD = 0x19;
|
||||
public static final int METHOD = 0x1a;
|
||||
public static final int ENUM = 0x1b;
|
||||
public static final int ARRAY = 0x1c;
|
||||
public static final int ANNOTATION = 0x1d;
|
||||
public static final int NULL = 0x1e;
|
||||
public static final int BOOLEAN = 0x1f;
|
||||
}
|
@ -32,22 +32,5 @@
|
||||
package org.jf.dexlib2.iface.value;
|
||||
|
||||
public interface EncodedValue {
|
||||
public static final int BYTE = 0;
|
||||
public static final int SHORT = 2;
|
||||
public static final int CHAR = 3;
|
||||
public static final int INT = 4;
|
||||
public static final int LONG = 6;
|
||||
public static final int FLOAT = 16;
|
||||
public static final int DOUBLE = 17;
|
||||
public static final int STRING = 23;
|
||||
public static final int TYPE = 24;
|
||||
public static final int FIELD = 25;
|
||||
public static final int METHOD = 26;
|
||||
public static final int ENUM = 27;
|
||||
public static final int ARRAY = 28;
|
||||
public static final int ANNOTATION = 29;
|
||||
public static final int NULL = 30;
|
||||
public static final int BOOLEAN = 31;
|
||||
|
||||
int getType();
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.immutable.ImmutableBaseAnnotation;
|
||||
import org.jf.dexlib2.iface.BaseAnnotation;
|
||||
@ -43,12 +44,12 @@ public class ImmutableAnnotationEncodedValue extends ImmutableEncodedValue imple
|
||||
public final ImmutableBaseAnnotation value;
|
||||
|
||||
public ImmutableAnnotationEncodedValue(@Nonnull BaseAnnotation value) {
|
||||
super(EncodedValue.ANNOTATION);
|
||||
super(ValueType.ANNOTATION);
|
||||
this.value = ImmutableBaseAnnotation.of(value);
|
||||
}
|
||||
|
||||
public ImmutableAnnotationEncodedValue(@Nonnull ImmutableBaseAnnotation value) {
|
||||
super(EncodedValue.ANNOTATION);
|
||||
super(ValueType.ANNOTATION);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.ArrayEncodedValue;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
|
||||
@ -43,12 +44,12 @@ public class ImmutableArrayEncodedValue extends ImmutableEncodedValue implements
|
||||
public final ImmutableList<? extends ImmutableEncodedValue> value;
|
||||
|
||||
public ImmutableArrayEncodedValue(@Nonnull List<? extends EncodedValue> value) {
|
||||
super(EncodedValue.ARRAY);
|
||||
super(ValueType.ARRAY);
|
||||
this.value = ImmutableEncodedValue.immutableListOf(value);
|
||||
}
|
||||
|
||||
public ImmutableArrayEncodedValue(@Nonnull ImmutableList<ImmutableEncodedValue> value) {
|
||||
super(EncodedValue.ARRAY);
|
||||
super(ValueType.ARRAY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.BooleanEncodedValue;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
|
||||
public class ImmutableBooleanEncodedValue extends ImmutableEncodedValue implements BooleanEncodedValue {
|
||||
public final boolean value;
|
||||
|
||||
public ImmutableBooleanEncodedValue(boolean value) {
|
||||
super(EncodedValue.BOOLEAN);
|
||||
super(ValueType.BOOLEAN);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.ByteEncodedValue;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
|
||||
public class ImmutableByteEncodedValue extends ImmutableEncodedValue implements ByteEncodedValue {
|
||||
public final byte value;
|
||||
|
||||
public ImmutableByteEncodedValue(byte value) {
|
||||
super(EncodedValue.BYTE);
|
||||
super(ValueType.BYTE);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.CharEncodedValue;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
|
||||
public class ImmutableCharEncodedValue extends ImmutableEncodedValue implements CharEncodedValue {
|
||||
public final char value;
|
||||
|
||||
public ImmutableCharEncodedValue(char value) {
|
||||
super(EncodedValue.CHAR);
|
||||
super(ValueType.CHAR);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.DoubleEncodedValue;
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
|
||||
public class ImmutableDoubleEncodedValue extends ImmutableEncodedValue implements DoubleEncodedValue {
|
||||
public final double value;
|
||||
|
||||
public ImmutableDoubleEncodedValue(double value) {
|
||||
super(EncodedValue.DOUBLE);
|
||||
super(ValueType.DOUBLE);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.*;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
|
||||
@ -48,37 +49,37 @@ public class ImmutableEncodedValue implements EncodedValue {
|
||||
|
||||
public static ImmutableEncodedValue of(EncodedValue encodedValue) {
|
||||
switch (encodedValue.getType()) {
|
||||
case BYTE:
|
||||
case ValueType.BYTE:
|
||||
return ImmutableByteEncodedValue.of((ByteEncodedValue)encodedValue);
|
||||
case SHORT:
|
||||
case ValueType.SHORT:
|
||||
return ImmutableShortEncodedValue.of((ShortEncodedValue)encodedValue);
|
||||
case CHAR:
|
||||
case ValueType.CHAR:
|
||||
return ImmutableCharEncodedValue.of((CharEncodedValue)encodedValue);
|
||||
case INT:
|
||||
case ValueType.INT:
|
||||
return ImmutableIntEncodedValue.of((IntEncodedValue)encodedValue);
|
||||
case LONG:
|
||||
case ValueType.LONG:
|
||||
return ImmutableLongEncodedValue.of((LongEncodedValue)encodedValue);
|
||||
case FLOAT:
|
||||
case ValueType.FLOAT:
|
||||
return ImmutableFloatEncodedValue.of((FloatEncodedValue)encodedValue);
|
||||
case DOUBLE:
|
||||
case ValueType.DOUBLE:
|
||||
return ImmutableDoubleEncodedValue.of((DoubleEncodedValue)encodedValue);
|
||||
case STRING:
|
||||
case ValueType.STRING:
|
||||
return ImmutableStringEncodedValue.of((StringEncodedValue)encodedValue);
|
||||
case TYPE:
|
||||
case ValueType.TYPE:
|
||||
return ImmutableTypeEncodedValue.of((TypeEncodedValue)encodedValue);
|
||||
case FIELD:
|
||||
case ValueType.FIELD:
|
||||
return ImmutableFieldEncodedValue.of((FieldEncodedValue)encodedValue);
|
||||
case METHOD:
|
||||
case ValueType.METHOD:
|
||||
return ImmutableMethodEncodedValue.of((MethodEncodedValue)encodedValue);
|
||||
case ENUM:
|
||||
case ValueType.ENUM:
|
||||
return ImmutableEnumEncodedValue.of((EnumEncodedValue)encodedValue);
|
||||
case ARRAY:
|
||||
case ValueType.ARRAY:
|
||||
return ImmutableArrayEncodedValue.of((ArrayEncodedValue)encodedValue);
|
||||
case ANNOTATION:
|
||||
case ValueType.ANNOTATION:
|
||||
return ImmutableAnnotationEncodedValue.of((AnnotationEncodedValue)encodedValue);
|
||||
case NULL:
|
||||
case ValueType.NULL:
|
||||
return ImmutableNullEncodedValue.INSTANCE;
|
||||
case BOOLEAN:
|
||||
case ValueType.BOOLEAN:
|
||||
return ImmutableBooleanEncodedValue.of((BooleanEncodedValue)encodedValue);
|
||||
default:
|
||||
Preconditions.checkArgument(false);
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.EnumEncodedValue;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -40,7 +40,7 @@ public class ImmutableEnumEncodedValue extends ImmutableEncodedValue implements
|
||||
@Nonnull public final String value;
|
||||
|
||||
public ImmutableEnumEncodedValue(@Nonnull String value) {
|
||||
super(EncodedValue.ENUM);
|
||||
super(ValueType.ENUM);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.FieldEncodedValue;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -40,7 +40,7 @@ public class ImmutableFieldEncodedValue extends ImmutableEncodedValue implements
|
||||
@Nonnull public final String value;
|
||||
|
||||
public ImmutableFieldEncodedValue(@Nonnull String value) {
|
||||
super(EncodedValue.FIELD);
|
||||
super(ValueType.FIELD);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.FloatEncodedValue;
|
||||
|
||||
public class ImmutableFloatEncodedValue extends ImmutableEncodedValue implements FloatEncodedValue {
|
||||
public final float value;
|
||||
|
||||
public ImmutableFloatEncodedValue(float value) {
|
||||
super(EncodedValue.FLOAT);
|
||||
super(ValueType.FLOAT);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.IntEncodedValue;
|
||||
|
||||
public class ImmutableIntEncodedValue extends ImmutableEncodedValue implements IntEncodedValue {
|
||||
public final int value;
|
||||
|
||||
public ImmutableIntEncodedValue(int value) {
|
||||
super(EncodedValue.INT);
|
||||
super(ValueType.INT);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.LongEncodedValue;
|
||||
|
||||
public class ImmutableLongEncodedValue extends ImmutableEncodedValue implements LongEncodedValue {
|
||||
public final long value;
|
||||
|
||||
public ImmutableLongEncodedValue(long value) {
|
||||
super(EncodedValue.LONG);
|
||||
super(ValueType.LONG);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.MethodEncodedValue;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -41,7 +41,7 @@ public class ImmutableMethodEncodedValue extends ImmutableEncodedValue implement
|
||||
public final String value;
|
||||
|
||||
public ImmutableMethodEncodedValue(@Nonnull String value) {
|
||||
super(EncodedValue.METHOD);
|
||||
super(ValueType.METHOD);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,13 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.NullEncodedValue;
|
||||
|
||||
public class ImmutableNullEncodedValue extends ImmutableEncodedValue implements NullEncodedValue {
|
||||
public static final ImmutableNullEncodedValue INSTANCE = new ImmutableNullEncodedValue();
|
||||
|
||||
public ImmutableNullEncodedValue() {
|
||||
super(EncodedValue.NULL);
|
||||
super(ValueType.NULL);
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,14 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.ShortEncodedValue;
|
||||
|
||||
public class ImmutableShortEncodedValue extends ImmutableEncodedValue implements ShortEncodedValue {
|
||||
public final short value;
|
||||
|
||||
public ImmutableShortEncodedValue(short value) {
|
||||
super(EncodedValue.SHORT);
|
||||
super(ValueType.SHORT);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.StringEncodedValue;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -41,7 +41,7 @@ public class ImmutableStringEncodedValue extends ImmutableEncodedValue implement
|
||||
public final String value;
|
||||
|
||||
public ImmutableStringEncodedValue(@Nonnull String value) {
|
||||
super(EncodedValue.STRING);
|
||||
super(ValueType.STRING);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.immutable.value;
|
||||
|
||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||
import org.jf.dexlib2.ValueType;
|
||||
import org.jf.dexlib2.iface.value.TypeEncodedValue;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -41,7 +41,7 @@ public class ImmutableTypeEncodedValue extends ImmutableEncodedValue implements
|
||||
public final String value;
|
||||
|
||||
public ImmutableTypeEncodedValue(@Nonnull String value) {
|
||||
super(EncodedValue.TYPE);
|
||||
super(ValueType.TYPE);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user