mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-16 01:38:29 +00:00
chained assignments
This commit is contained in:
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugLineIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
@@ -1195,12 +1196,12 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
AVM2LocalData avm2LocalData = (AVM2LocalData) localData;
|
||||
SetLocalAVM2Item setLocal = (SetLocalAVM2Item) output.get(output.size() - 1);
|
||||
int setLocalIp = avm2LocalData.code.code.indexOf(setLocal.getSrc());
|
||||
int setLocalIp = InstructionDefinition.getItemIp(avm2LocalData, setLocal);;
|
||||
Set<Integer> allUsages = new HashSet<>(avm2LocalData.setLocalPosToGetLocalPos.get(setLocalIp));
|
||||
for (GraphTargetItem otherSide : otherSides.values()) {
|
||||
if (otherSide instanceof LocalRegAVM2Item) {
|
||||
LocalRegAVM2Item otherLog = (LocalRegAVM2Item) otherSide;
|
||||
int getLocalIp = avm2LocalData.code.code.indexOf(otherLog.getSrc());
|
||||
int getLocalIp = InstructionDefinition.getItemIp(avm2LocalData, otherLog);
|
||||
allUsages.remove((Integer) getLocalIp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -312,15 +313,23 @@ public abstract class InstructionDefinition implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getItemIp(AVM2LocalData localData, GraphTargetItem item) {
|
||||
GraphSourceItem src = item.getSrc();
|
||||
if (src == null) {
|
||||
return -1;
|
||||
}
|
||||
return localData.code.adr2pos(src.getAddress());
|
||||
}
|
||||
|
||||
public void cleanTempRegisters(AVM2LocalData localData, List<GraphTargetItem> output, List<LocalRegAVM2Item> usedLocalRegs) {
|
||||
for (LocalRegAVM2Item reg : usedLocalRegs) {
|
||||
for (int i = output.size() - 1; i >= 0; i--) {
|
||||
if (output.get(i) instanceof SetLocalAVM2Item) {
|
||||
SetLocalAVM2Item setLocal = (SetLocalAVM2Item) output.get(i);
|
||||
if (setLocal.regIndex == reg.regIndex) {
|
||||
int setLocalIp = localData.code.code.indexOf(setLocal.getSrc());
|
||||
int setLocalIp = getItemIp(localData, setLocal);
|
||||
Set<Integer> usages = localData.setLocalPosToGetLocalPos.get(setLocalIp);
|
||||
int usageIp = localData.code.code.indexOf(reg.getSrc());
|
||||
int usageIp = getItemIp(localData, reg);
|
||||
if (usages.size() == 1 && usages.iterator().next().equals(usageIp)) {
|
||||
output.remove(i);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
@@ -32,7 +34,9 @@ import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.NotCompileTimeItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -81,6 +85,28 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
|
||||
if (assignCount > 5) { //Do not allow change register more than 5 - for deobfuscation
|
||||
//computedValue = new NotCompileTimeItem(ins, localData.lineStartInstruction, computedValue);
|
||||
}
|
||||
|
||||
if (output.size() >= 2) {
|
||||
if ((output.get(output.size() - 1) instanceof SetTypeAVM2Item) && (output.get(output.size() - 2) instanceof SetLocalAVM2Item)) {
|
||||
SetLocalAVM2Item setLocal = (SetLocalAVM2Item) output.get(output.size() - 2);
|
||||
GraphTargetItem setItem = output.get(output.size() - 1);
|
||||
if (setLocal.regIndex == regId
|
||||
&& (setLocal.value instanceof DuplicateItem)
|
||||
&& (setLocal.value.value == setItem.value.getNotCoerced())) {
|
||||
|
||||
int setLocalIp = getItemIp(localData, setLocal);
|
||||
int getLocalIp = localData.code.adr2pos(ins.getAddress());
|
||||
Set<Integer> usages = localData.setLocalPosToGetLocalPos.get(setLocalIp);
|
||||
if (usages.size() == 1 && usages.iterator().next().equals(getLocalIp)) {
|
||||
output.remove(output.size() - 1);
|
||||
output.remove(output.size() - 1);
|
||||
stack.push(setItem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stack.push(new LocalRegAVM2Item(ins, localData.lineStartInstruction, regId, computedValue));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -61,6 +62,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = getRegisterId(ins);
|
||||
GraphTargetItem value = stack.pop();
|
||||
|
||||
/*if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, localData.lineStartInstruction, value));
|
||||
} else {
|
||||
@@ -126,9 +128,8 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if(val.startsWith("catchscope ")) return;
|
||||
//if(val.startsWith("newactivation()")) return;
|
||||
GraphTargetItem result = new SetLocalAVM2Item(ins, localData.lineStartInstruction, regId, value);
|
||||
output.add(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -43,7 +44,9 @@ public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIn
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem result = new SetGlobalSlotAVM2Item(ins, localData.lineStartInstruction, ins.operands[0], value);
|
||||
output.add(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -166,8 +166,8 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
|
||||
}
|
||||
}
|
||||
|
||||
output.add(new SetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, value));
|
||||
|
||||
GraphTargetItem result = new SetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, value);
|
||||
output.add(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -160,7 +160,8 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
}
|
||||
}
|
||||
|
||||
output.add(new SetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objnoreg, slotIndex, slotname, value));
|
||||
GraphTargetItem result = new SetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objnoreg, slotIndex, slotname, value);
|
||||
output.add(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -50,9 +51,11 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns {
|
||||
int multinameIndex = ins.operands[0];
|
||||
|
||||
GraphTargetItem value = stack.pop();
|
||||
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins);
|
||||
GraphTargetItem obj = stack.pop();
|
||||
GraphTargetItem obj = stack.pop();
|
||||
GraphTargetItem result = new SetSuperAVM2Item(ins, localData.lineStartInstruction, value, obj, multiname);
|
||||
output.add(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
@@ -48,8 +49,10 @@ public class DuplicateItem extends GraphTargetItem implements SimpleValue {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (((value instanceof SimpleValue) && (((SimpleValue) value).isSimpleValue())) || !Configuration.displayDupInstructions.get()) {
|
||||
if (!Configuration.displayDupInstructions.get()) {
|
||||
if (((value instanceof SimpleValue) && (((SimpleValue) value).isSimpleValue())) || !Configuration.displayDupInstructions.get()) {
|
||||
return value.appendTry(writer, localData);
|
||||
}
|
||||
}
|
||||
writer.append("§§dup(");
|
||||
value.appendTry(writer, localData);
|
||||
|
||||
Reference in New Issue
Block a user