use of org.jf.dexlib2.immutable.value.ImmutableFloatEncodedValue in project soot by Sable.
the class DexPrinter method makeConstantItem.
private EncodedValue makeConstantItem(SootField sf, Tag t) {
if (!(t instanceof ConstantValueTag))
throw new RuntimeException("error: t not ConstantValueTag.");
if (t instanceof IntegerConstantValueTag) {
Type sft = sf.getType();
IntegerConstantValueTag i = (IntegerConstantValueTag) t;
if (sft instanceof BooleanType) {
int v = i.getIntValue();
if (v == 0) {
return ImmutableBooleanEncodedValue.FALSE_VALUE;
} else if (v == 1) {
return ImmutableBooleanEncodedValue.TRUE_VALUE;
} else {
throw new RuntimeException("error: boolean value from int with value != 0 or 1.");
}
} else if (sft instanceof CharType) {
return new ImmutableCharEncodedValue((char) i.getIntValue());
} else if (sft instanceof ByteType) {
return new ImmutableByteEncodedValue((byte) i.getIntValue());
} else if (sft instanceof IntType) {
return new ImmutableIntEncodedValue(i.getIntValue());
} else if (sft instanceof ShortType) {
return new ImmutableShortEncodedValue((short) i.getIntValue());
} else {
throw new RuntimeException("error: unexpected constant tag type: " + t + " for field " + sf);
}
} else if (t instanceof LongConstantValueTag) {
LongConstantValueTag l = (LongConstantValueTag) t;
return new ImmutableLongEncodedValue(l.getLongValue());
} else if (t instanceof DoubleConstantValueTag) {
DoubleConstantValueTag d = (DoubleConstantValueTag) t;
return new ImmutableDoubleEncodedValue(d.getDoubleValue());
} else if (t instanceof FloatConstantValueTag) {
FloatConstantValueTag f = (FloatConstantValueTag) t;
return new ImmutableFloatEncodedValue(f.getFloatValue());
} else if (t instanceof StringConstantValueTag) {
StringConstantValueTag s = (StringConstantValueTag) t;
if (sf.getType().equals(RefType.v("java.lang.String")))
return new ImmutableStringEncodedValue(s.getStringValue());
else
// Results in "Bogus static initialization"
return null;
} else
throw new RuntimeException("Unexpected constant type");
}
Aggregations