mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-23 16:15:36 +00:00
fixes
This commit is contained in:
@@ -52,7 +52,9 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionWith;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionTry;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
@@ -976,9 +978,11 @@ public abstract class Action implements GraphSourceItem {
|
||||
List<GraphTargetItem> out;
|
||||
try {
|
||||
HashMap<Integer, String> regNames = cnt.getRegNames();
|
||||
for (Map.Entry<Integer, String> e : registerNames.entrySet()) {
|
||||
if (!regNames.containsKey(e.getKey())) {
|
||||
regNames.put(e.getKey(), e.getValue());
|
||||
if (action instanceof ActionWith || action instanceof ActionTry) {
|
||||
for (Map.Entry<Integer, String> e : registerNames.entrySet()) {
|
||||
if (!regNames.containsKey(e.getKey())) {
|
||||
regNames.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
out = ActionGraph.translateViaGraph(regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName));
|
||||
|
||||
@@ -52,12 +52,12 @@ public class AsciiToCharActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
Double res = EcmaScript.toNumber(value.getResult());
|
||||
if (Double.isNaN(res) || Double.compare(res, 0) == 0) {
|
||||
int res = (int) (double) (EcmaScript.toNumber(value.getResult()));
|
||||
if (res == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return ((Character) (char) res.intValue()).toString();
|
||||
return ((Character) (char) res).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -157,7 +157,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
if (value instanceof String) {
|
||||
return writer.append("\"").append(Helper.escapeActionScriptString(EcmaScript.toString(value))).append("\"");
|
||||
return writer.append("\"").append(Helper.escapeActionScriptString((String) value)).append("\"");
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return writer.append("\"").append(Helper.escapeActionScriptString(this.constants.get(((ConstantIndex) value).index))).append("\"");
|
||||
@@ -165,7 +165,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
if (value instanceof RegisterNumber) {
|
||||
return writer.append(((RegisterNumber) value).translate());
|
||||
}
|
||||
return writer.append(EcmaScript.toString(value));
|
||||
return writer.append(EcmaScript.toString(value, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,12 +52,12 @@ public class MBAsciiToCharActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
Double res = EcmaScript.toNumber(value.getResult());
|
||||
if (Double.isNaN(res) || Double.compare(res, 0) == 0) {
|
||||
int res = (int) (double) (EcmaScript.toNumber(value.getResult()));
|
||||
if (res == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return ((Character) (char) res.intValue()).toString();
|
||||
return ((Character) (char) res).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.action.swf5;
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
@@ -40,7 +42,13 @@ public class ActionDefineLocal extends Action {
|
||||
public void translate(TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem name = stack.pop();
|
||||
variables.put(name.toStringNoQuotes(LocalData.empty), value);
|
||||
String nameStr;
|
||||
if (name instanceof DirectValueActionItem) {
|
||||
nameStr = name.toStringNoQuotes(LocalData.empty);
|
||||
} else {
|
||||
nameStr = EcmaScript.toString(name.getResult());
|
||||
}
|
||||
variables.put(nameStr, value);
|
||||
output.add(new DefineLocalActionItem(this, name, value));
|
||||
}
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ public class EcmaFloatingDecimal {
|
||||
/*
|
||||
* FIRST IMPORTANT CONSTRUCTOR: DOUBLE
|
||||
*/
|
||||
public EcmaFloatingDecimal(double d) {
|
||||
public EcmaFloatingDecimal(double d, boolean maxPrecision) {
|
||||
long dBits = Double.doubleToLongBits(d);
|
||||
long fractBits;
|
||||
int binExp;
|
||||
@@ -499,6 +499,19 @@ public class EcmaFloatingDecimal {
|
||||
binExp -= expBias;
|
||||
// call the routine that actually does all the hard work.
|
||||
dtoa(binExp, fractBits, nSignificantBits);
|
||||
|
||||
if (!maxPrecision) {
|
||||
if (nDigits > 15) {
|
||||
nDigits = 15;
|
||||
if (digits[15] >= '5') {
|
||||
roundup();
|
||||
}
|
||||
|
||||
while (nDigits > 0 && digits[nDigits - 1] == '0') {
|
||||
nDigits--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -769,7 +782,7 @@ public class EcmaFloatingDecimal {
|
||||
* Thus we will need more than one digit if we're using
|
||||
* E-form
|
||||
*/
|
||||
if (decExp <= -3 || decExp >= 8) {
|
||||
if (decExp <= -6 || decExp >= 8) {
|
||||
high = low = false;
|
||||
}
|
||||
while (!low && !high) {
|
||||
@@ -822,7 +835,7 @@ public class EcmaFloatingDecimal {
|
||||
* Thus we will need more than one digit if we're using
|
||||
* E-form
|
||||
*/
|
||||
if (decExp <= -3 || decExp >= 8) {
|
||||
if (decExp <= -6 || decExp >= 8) {
|
||||
high = low = false;
|
||||
}
|
||||
while (!low && !high) {
|
||||
@@ -885,7 +898,7 @@ public class EcmaFloatingDecimal {
|
||||
* Thus we will need more than one digit if we're using
|
||||
* E-form
|
||||
*/
|
||||
if (decExp <= -3 || decExp >= 8) {
|
||||
if (decExp <= -6 || decExp >= 8) {
|
||||
high = low = false;
|
||||
}
|
||||
while (!low && !high) {
|
||||
@@ -924,17 +937,6 @@ public class EcmaFloatingDecimal {
|
||||
roundup();
|
||||
}
|
||||
}
|
||||
|
||||
if (nDigits > 15) {
|
||||
nDigits = 15;
|
||||
if (digits[15] >= '5') {
|
||||
roundup();
|
||||
}
|
||||
|
||||
while (nDigits > 0 && digits[nDigits - 1] == '0') {
|
||||
nDigits--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -293,6 +293,10 @@ public class EcmaScript {
|
||||
}
|
||||
|
||||
public static String toString(Object o) {
|
||||
return toString(o, false);
|
||||
}
|
||||
|
||||
public static String toString(Object o, boolean maxPrecision) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
@@ -300,7 +304,7 @@ public class EcmaScript {
|
||||
if (o instanceof Number) {
|
||||
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.8.1
|
||||
Number n = (Number) o;
|
||||
return new EcmaFloatingDecimal(n.doubleValue()).toJavaFormatString();
|
||||
return new EcmaFloatingDecimal(n.doubleValue(), maxPrecision).toJavaFormatString();
|
||||
}
|
||||
|
||||
return o.toString();
|
||||
|
||||
Reference in New Issue
Block a user