mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 20:30:51 +00:00
Fixed: #2459 AS1/2 StoreRegister improper declaration position
This commit is contained in:
@@ -49,6 +49,7 @@ import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.graph.AbstractGraphTargetVisitor;
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
@@ -272,6 +273,8 @@ public class ActionGraph extends Graph {
|
||||
return !isSwitch;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void finalProcess(GraphTargetItem parent, List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
|
||||
@@ -288,7 +291,7 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
}
|
||||
list.addAll(0, removed);
|
||||
}
|
||||
}
|
||||
|
||||
int targetStart;
|
||||
int targetEnd;
|
||||
@@ -672,7 +675,7 @@ public class ActionGraph extends Graph {
|
||||
sr.define = !definedRegisters.contains(sr.register.number);
|
||||
definedRegisters.add(sr.register.number);
|
||||
if (sr.define && sr != ti) {
|
||||
list.add(ri.getVal(), new StoreRegisterActionItem(null, null, sr.register, new DirectValueActionItem(Null.INSTANCE), true));
|
||||
list.add(ri.getVal(), new StoreRegisterActionItem(null, null, sr.register, new DirectValueActionItem(Undefined.INSTANCE), true));
|
||||
sr.define = false;
|
||||
ri.setVal(ri.getVal() + 1);
|
||||
}
|
||||
@@ -703,7 +706,27 @@ public class ActionGraph extends Graph {
|
||||
for (List<GraphTargetItem> items : b.getSubs()) {
|
||||
makeDefineRegistersUp(items, definedRegisters);
|
||||
}
|
||||
|
||||
|
||||
for (List<GraphTargetItem> items : b.getSubs()) {
|
||||
for (int j = 0; j < items.size(); j++) {
|
||||
GraphTargetItem item = items.get(j);
|
||||
if (item instanceof StoreRegisterActionItem) {
|
||||
StoreRegisterActionItem sr = (StoreRegisterActionItem) item;
|
||||
if (sr.define) {
|
||||
list.add(ri.getVal(), new StoreRegisterActionItem(null, null, sr.register, new DirectValueActionItem(Undefined.INSTANCE), true));
|
||||
sr.define = false;
|
||||
if ((sr.value instanceof DirectValueActionItem) && (((DirectValueActionItem) sr.value).value == Undefined.INSTANCE)) {
|
||||
items.remove(j);
|
||||
j--;
|
||||
}
|
||||
ri.setVal(ri.getVal() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i = ri.getVal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -104,7 +105,7 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
|
||||
} else {
|
||||
stripQuotes(name, localData, writer);
|
||||
}
|
||||
if (value == null) {
|
||||
if (value == null || ((value instanceof DirectValueActionItem) && ((DirectValueActionItem) value).value == Undefined.INSTANCE)) {
|
||||
return writer;
|
||||
}
|
||||
writer.append(" = ");
|
||||
@@ -126,7 +127,7 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (value == null) {
|
||||
if (value == null || (value instanceof DirectValueActionItem && ((DirectValueActionItem) value).value == Undefined.INSTANCE)) {
|
||||
return toSourceMerge(localData, generator, name, new ActionDefineLocal2());
|
||||
} else {
|
||||
return toSourceMerge(localData, generator, name, value, new ActionDefineLocal());
|
||||
|
||||
+5
-2
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -133,8 +134,10 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction
|
||||
writer.append("= ");
|
||||
return compoundValue.toString(writer, localData);
|
||||
}
|
||||
writer.append(" = ");
|
||||
value.toString(writer, localData);
|
||||
if (value != null && !(value instanceof DirectValueActionItem && (((DirectValueActionItem) value).value == Undefined.INSTANCE))) {
|
||||
writer.append(" = ");
|
||||
value.toString(writer, localData);
|
||||
}
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1143,7 +1143,7 @@ public class ActionScript2Parser {
|
||||
ret = new VariableActionItem(varIdentifier, varval, true);
|
||||
variables.add((VariableActionItem) ret);
|
||||
} else {
|
||||
ret = new VariableActionItem(varIdentifier, null, true);
|
||||
ret = new VariableActionItem(varIdentifier, new DirectValueActionItem(Undefined.INSTANCE), true);
|
||||
variables.add((VariableActionItem) ret);
|
||||
lexer.pushback(s);
|
||||
}
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -99,7 +100,7 @@ public class VariableActionItem extends ActionItem {
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (it == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
return it.toSourceIgnoreReturnValue(localData, generator);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user