mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-27 05:44:51 +00:00
#489 Hex decode very large integers
This commit is contained in:
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
@@ -31,6 +32,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.IntegerValueTypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -45,6 +47,74 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item implements Integer
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
if (Configuration.smartNumberFormatting.get()) {
|
||||
if (value >= 256 && value <= 0xffffffffL) {
|
||||
int intVal = (int) (long) (value & 0xffffff);
|
||||
int r = (intVal >> 16) & 0xff;
|
||||
int g = (intVal >> 8) & 0xff;
|
||||
int b = intVal & 0xff;
|
||||
if ((r == b && b == g) // gray
|
||||
|| (((intVal & 0x0f0000) == 0 || (intVal & 0x0f0000) == 0x0f0000) // a(0/F)b(0/F)c(0/F)
|
||||
&& ((intVal & 0x000f00) == 0 || (intVal & 0x000f00) == 0x000f00)
|
||||
&& ((intVal & 0x00000f) == 0 || (intVal & 0x00000f) == 0x00000f))
|
||||
|| ((((intVal & 0xf00000) >> 20) == ((intVal & 0x0f0000) >> 16)) // aabbcc
|
||||
&& (((intVal & 0x00f000) >> 12) == ((intVal & 0x000f00) >> 8))
|
||||
&& (((intVal & 0x0000f0) >> 4) == ((intVal & 0x00000f))))) {
|
||||
return writer.append("0x").append(Long.toHexString(value));
|
||||
}
|
||||
}
|
||||
|
||||
long value2 = (long) value;
|
||||
if (value2 > 0 && value2 % 60 == 0) {
|
||||
int thousandCount = 0;
|
||||
value2 /= 60;
|
||||
boolean isHour = false;
|
||||
boolean isDay = false;
|
||||
if (value2 % 60 == 0) {
|
||||
value2 /= 60;
|
||||
isHour = true;
|
||||
if (value2 % 24 == 0) {
|
||||
value2 /= 24;
|
||||
isDay = true;
|
||||
}
|
||||
}
|
||||
|
||||
// check milli, micro and nanoseconds
|
||||
while (thousandCount < 3) {
|
||||
if (value2 % 1000 == 0) {
|
||||
thousandCount++;
|
||||
value2 /= 1000;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (value2 < 1000) {
|
||||
List<Integer> factors = new ArrayList<>();
|
||||
if (value2 > 1) {
|
||||
factors.add((int) value2);
|
||||
}
|
||||
if (isDay) {
|
||||
factors.add(24);
|
||||
}
|
||||
if (isHour) {
|
||||
factors.add(60);
|
||||
}
|
||||
factors.add(60);
|
||||
for (int i = 0; i < thousandCount; i++) {
|
||||
factors.add(1000);
|
||||
}
|
||||
for (int i = 0; i < factors.size(); i++) {
|
||||
if (i != 0) {
|
||||
writer.append(" * ");
|
||||
}
|
||||
writer.append(factors.get(i));
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return writer.append(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,19 +149,19 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
public String toStringNoH(ConstantPool constants) {
|
||||
if (value instanceof Double) {
|
||||
if (Double.compare((double) (Double) value, 0) == 0) {
|
||||
return ("0");
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
if (Float.compare((float) (Float) value, 0) == 0) {
|
||||
return ("0");
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return (this.constants.get(((ConstantIndex) value).index));
|
||||
return this.constants.get(((ConstantIndex) value).index);
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@@ -487,6 +487,10 @@ public class Configuration {
|
||||
@ConfigurationCategory("script")
|
||||
public static final ConfigurationItem<Boolean> ignoreCLikePackages = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("script")
|
||||
public static final ConfigurationItem<Boolean> smartNumberFormatting = null;
|
||||
|
||||
private enum OSId {
|
||||
|
||||
WINDOWS, OSX, UNIX
|
||||
|
||||
@@ -165,7 +165,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
|
||||
int a = (argb >> 24) & 0xff;
|
||||
int r = (argb >> 16) & 0xff;
|
||||
int g = (argb >> 8) & 0xff;
|
||||
int b = (argb) & 0xff;
|
||||
int b = argb & 0xff;
|
||||
|
||||
r = r * a / 255;
|
||||
g = g * a / 255;
|
||||
|
||||
Reference in New Issue
Block a user