mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-08 07:05:06 +00:00
@@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.RegExpAvm2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.helpers.Reference;
|
||||
@@ -108,7 +109,7 @@ public class ConstructPropIns extends InstructionDefinition {
|
||||
|
||||
if (obj instanceof FindPropertyAVM2Item) {
|
||||
multiname.property = false; //can be type
|
||||
}
|
||||
}
|
||||
stack.push(new ConstructPropAVM2Item(ins, localData.lineStartInstruction, obj, multiname, args, type.getVal(), isStatic.getVal()));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -75,12 +78,45 @@ public class ConstructAVM2Item extends AVM2Item {
|
||||
|| (object instanceof CallStaticAVM2Item)
|
||||
|| (object instanceof CallSuperAVM2Item);
|
||||
|
||||
if (object.getPrecedence() > getPrecedence() || objectIsCall) {
|
||||
writer.append("(");
|
||||
boolean isGetDefinition = false;
|
||||
if (object instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item getProperty = (GetPropertyAVM2Item) object;
|
||||
if (getProperty.propertyName instanceof FullMultinameAVM2Item) {
|
||||
FullMultinameAVM2Item fm = (FullMultinameAVM2Item) getProperty.propertyName;
|
||||
if (fm.multinameIndex > 0) {
|
||||
Multiname m = localData.abc.constants.getMultiname(fm.multinameIndex);
|
||||
if (m.kind == Multiname.MULTINAMEL) {
|
||||
if (m.getNamespaceSet(localData.abc.constants).namespaces.length == 1) {
|
||||
isGetDefinition = true;
|
||||
writer.append("(");
|
||||
if (localData.fullyQualifiedNames.contains(DottedChain.parseNoSuffix("flash.utils.getDefinitionByName"))) {
|
||||
writer.append("flash.utils.getDefinitionByName");
|
||||
} else {
|
||||
writer.append("getDefinitionByName");
|
||||
}
|
||||
writer.append("(");
|
||||
String nname = m.getSingleNamespace(localData.abc.constants).getName(localData.abc.constants).toRawString();
|
||||
if (!nname.isEmpty()) {
|
||||
writer.append("\"");
|
||||
writer.append(Helper.escapeActionScriptString(nname));
|
||||
writer.append("\"+\".\"+");
|
||||
}
|
||||
fm.name.appendTo(writer, localData);
|
||||
writer.append("))");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
object.toString(writer, localData);
|
||||
if (object.getPrecedence() > getPrecedence() || objectIsCall) {
|
||||
writer.append(")");
|
||||
|
||||
if (!isGetDefinition) {
|
||||
if (object.getPrecedence() > getPrecedence() || objectIsCall) {
|
||||
writer.append("(");
|
||||
}
|
||||
object.toString(writer, localData);
|
||||
if (object.getPrecedence() > getPrecedence() || objectIsCall) {
|
||||
writer.append(")");
|
||||
}
|
||||
}
|
||||
writer.spaceBeforeCallParenthesis(args.size());
|
||||
if (object instanceof InitVectorAVM2Item) {
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -86,7 +89,36 @@ public class ConstructPropAVM2Item extends AVM2Item {
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("new ");
|
||||
formatProperty(writer, object, propertyName, localData, isStatic, false);
|
||||
boolean isGetDefinition = false;
|
||||
if (propertyName instanceof FullMultinameAVM2Item) {
|
||||
FullMultinameAVM2Item fm = (FullMultinameAVM2Item) propertyName;
|
||||
if (fm.multinameIndex > 0) {
|
||||
Multiname m = localData.abc.constants.getMultiname(fm.multinameIndex);
|
||||
if (m.kind == Multiname.MULTINAMEL) {
|
||||
if (m.getNamespaceSet(localData.abc.constants).namespaces.length == 1) {
|
||||
isGetDefinition = true;
|
||||
writer.append("(");
|
||||
if (localData.fullyQualifiedNames.contains(DottedChain.parseNoSuffix("flash.utils.getDefinitionByName"))) {
|
||||
writer.append("flash.utils.getDefinitionByName");
|
||||
} else {
|
||||
writer.append("getDefinitionByName");
|
||||
}
|
||||
writer.append("(");
|
||||
String nname = m.getSingleNamespace(localData.abc.constants).getName(localData.abc.constants).toRawString();
|
||||
if (!nname.isEmpty()) {
|
||||
writer.append("\"");
|
||||
writer.append(Helper.escapeActionScriptString(nname));
|
||||
writer.append("\"+\".\"+");
|
||||
}
|
||||
fm.name.appendTo(writer, localData);
|
||||
writer.append("))");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isGetDefinition) {
|
||||
formatProperty(writer, object, propertyName, localData, isStatic, false);
|
||||
}
|
||||
writer.spaceBeforeCallParenthesis(args.size());
|
||||
writer.append("(");
|
||||
for (int a = 0; a < args.size(); a++) {
|
||||
|
||||
@@ -989,7 +989,7 @@ public class Multiname {
|
||||
* @return True if this MULTINAME kind with only one namespace
|
||||
*/
|
||||
public boolean isMULTINAMEwithOneNs(AVM2ConstantPool pool) {
|
||||
return kind == MULTINAME && pool.getNamespaceSet(namespace_set_index).namespaces.length == 1;
|
||||
return (kind == MULTINAME || kind == MULTINAMEL || kind == MULTINAMELA) && pool.getNamespaceSet(namespace_set_index).namespaces.length == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,10 +21,13 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.AlchemyTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructPropIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewClassIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetOuterScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
|
||||
@@ -196,6 +199,7 @@ public class DependencyParser {
|
||||
}
|
||||
}
|
||||
boolean wasNewClass = false;
|
||||
AVM2Instruction prevIns = null;
|
||||
for (int i = 0; i < body.getCode().code.size(); i++) {
|
||||
AVM2Instruction ins = body.getCode().code.get(i);
|
||||
|
||||
@@ -245,6 +249,26 @@ public class DependencyParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ins.definition instanceof ConstructPropIns) {
|
||||
Multiname m = abc.constants.getMultiname(ins.operands[0]);
|
||||
if (m != null) {
|
||||
if (m.kind == Multiname.MULTINAMEL) {
|
||||
Dependency dep = new Dependency(DottedChain.parseNoSuffix("flash.utils.getDefinitionByName"), DependencyType.NAMESPACE);
|
||||
dependencies.add(dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: what if there's jump between getproperty and construct?
|
||||
if (ins.definition instanceof ConstructIns && prevIns != null && prevIns.definition instanceof GetPropertyIns) {
|
||||
Multiname m = abc.constants.getMultiname(prevIns.operands[0]);
|
||||
if (m != null) {
|
||||
if (m.kind == Multiname.MULTINAMEL) {
|
||||
Dependency dep = new Dependency(DottedChain.parseNoSuffix("flash.utils.getDefinitionByName"), DependencyType.NAMESPACE);
|
||||
dependencies.add(dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (classIndex > -1 && ins.definition instanceof GetOuterScopeIns) {
|
||||
if (ins.operands[0] > 0) { //first is global
|
||||
DottedChain type = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true);
|
||||
@@ -282,6 +306,7 @@ public class DependencyParser {
|
||||
numberContextRef.setVal(ins.operands[k]);
|
||||
}
|
||||
}
|
||||
prevIns = ins;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user