mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-11 12:35:52 +01:00
baksmali: Write comments about possible floating-point values
Conflicts: brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java
This commit is contained in:
parent
5afd6f5e69
commit
a4d5d2299b
@ -65,8 +65,12 @@ public class ArrayDataMethodItem extends InstructionMethodItem<ArrayPayload> {
|
|||||||
for (Number number: elements) {
|
for (Number number: elements) {
|
||||||
LongRenderer.writeSignedIntOrLongTo(writer, number.longValue());
|
LongRenderer.writeSignedIntOrLongTo(writer, number.longValue());
|
||||||
writer.write(suffix);
|
writer.write(suffix);
|
||||||
if (elementWidth == 4)
|
if (elementWidth == 8) {
|
||||||
|
writeDouble(writer, number.longValue());
|
||||||
|
} else if (elementWidth == 4) {
|
||||||
writeResourceId(writer, number.intValue());
|
writeResourceId(writer, number.intValue());
|
||||||
|
writeFloat(writer, number.intValue());
|
||||||
|
}
|
||||||
writer.write("\n");
|
writer.write("\n");
|
||||||
}
|
}
|
||||||
writer.deindent(4);
|
writer.deindent(4);
|
||||||
|
@ -47,6 +47,7 @@ import org.jf.dexlib2.iface.reference.Reference;
|
|||||||
import org.jf.dexlib2.util.ReferenceUtil;
|
import org.jf.dexlib2.util.ReferenceUtil;
|
||||||
import org.jf.util.ExceptionWithContext;
|
import org.jf.util.ExceptionWithContext;
|
||||||
import org.jf.util.IndentingWriter;
|
import org.jf.util.IndentingWriter;
|
||||||
|
import org.jf.util.NumberUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -230,9 +231,13 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
writeFirstRegister(writer);
|
writeFirstRegister(writer);
|
||||||
writer.write(", ");
|
writer.write(", ");
|
||||||
writeLiteral(writer);
|
writeLiteral(writer);
|
||||||
if (instruction.getOpcode().setsWideRegister() == false)
|
if (instruction.getOpcode().setsWideRegister()) {
|
||||||
|
writeDouble(writer);
|
||||||
|
} else {
|
||||||
writeResourceId(writer);
|
writeResourceId(writer);
|
||||||
break;
|
writeFloat(writer);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case Format21t:
|
case Format21t:
|
||||||
case Format31t:
|
case Format31t:
|
||||||
writeOpcode(writer);
|
writeOpcode(writer);
|
||||||
@ -436,6 +441,58 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
LongRenderer.writeSignedIntOrLongTo(writer, ((WideLiteralInstruction)instruction).getWideLiteral());
|
LongRenderer.writeSignedIntOrLongTo(writer, ((WideLiteralInstruction)instruction).getWideLiteral());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void writeFloat(IndentingWriter writer) throws IOException {
|
||||||
|
writeFloat(writer, ((NarrowLiteralInstruction)instruction).getNarrowLiteral());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeFloat(IndentingWriter writer, int val) throws IOException {
|
||||||
|
if (NumberUtils.isLikelyFloat(val)) {
|
||||||
|
writer.write(" # ");
|
||||||
|
float fval = Float.intBitsToFloat(val);
|
||||||
|
if (fval == Float.POSITIVE_INFINITY)
|
||||||
|
writer.write("Float.POSITIVE_INFINITY");
|
||||||
|
else if (fval == Float.NEGATIVE_INFINITY)
|
||||||
|
writer.write("Float.NEGATIVE_INFINITY");
|
||||||
|
else if (fval == Float.NaN)
|
||||||
|
writer.write("Float.NaN");
|
||||||
|
else if (fval == Float.MAX_VALUE)
|
||||||
|
writer.write("Float.MAX_VALUE");
|
||||||
|
else if (fval == (float)Math.PI)
|
||||||
|
writer.write("(float)Math.PI");
|
||||||
|
else if (fval == (float)Math.E)
|
||||||
|
writer.write("(float)Math.E");
|
||||||
|
else {
|
||||||
|
writer.write(Float.toString(fval));
|
||||||
|
writer.write('f');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeDouble(IndentingWriter writer) throws IOException {
|
||||||
|
writeDouble(writer, ((WideLiteralInstruction)instruction).getWideLiteral());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeDouble(IndentingWriter writer, long val) throws IOException {
|
||||||
|
if (NumberUtils.isLikelyDouble(val)) {
|
||||||
|
writer.write(" # ");
|
||||||
|
double dval = Double.longBitsToDouble(val);
|
||||||
|
if (dval == Double.POSITIVE_INFINITY)
|
||||||
|
writer.write("Double.POSITIVE_INFINITY");
|
||||||
|
else if (dval == Double.NEGATIVE_INFINITY)
|
||||||
|
writer.write("Double.NEGATIVE_INFINITY");
|
||||||
|
else if (dval == Double.NaN)
|
||||||
|
writer.write("Double.NaN");
|
||||||
|
else if (dval == Double.MAX_VALUE)
|
||||||
|
writer.write("Double.MAX_VALUE");
|
||||||
|
else if (dval == Math.PI)
|
||||||
|
writer.write("Math.PI");
|
||||||
|
else if (dval == Math.E)
|
||||||
|
writer.write("Math.E");
|
||||||
|
else
|
||||||
|
writer.write(Double.toString(dval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void writeResourceId(IndentingWriter writer) throws IOException {
|
protected void writeResourceId(IndentingWriter writer) throws IOException {
|
||||||
writeResourceId(writer, ((NarrowLiteralInstruction)instruction).getNarrowLiteral());
|
writeResourceId(writer, ((NarrowLiteralInstruction)instruction).getNarrowLiteral());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user