mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 12:40:47 +00:00
AS3 pcode search improvements
This commit is contained in:
@@ -41,6 +41,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitType;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.abc.usages.ClassNameMultinameUsage;
|
||||
import com.jpexs.decompiler.flash.abc.usages.ConstVarNameMultinameUsage;
|
||||
@@ -58,6 +59,7 @@ import com.jpexs.decompiler.flash.abc.usages.TypeNameMultinameUsage;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSpecial;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSpecialType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin;
|
||||
import com.jpexs.decompiler.flash.importers.As3ScriptReplaceException;
|
||||
import com.jpexs.decompiler.flash.importers.As3ScriptReplacerInterface;
|
||||
@@ -1426,6 +1428,30 @@ public class ABC {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getGlobalTraitId(TraitType type, boolean isStatic, int classIndex, int index) {
|
||||
if (type == TraitType.INITIALIZER) {
|
||||
if (!isStatic) {
|
||||
return GraphTextWriter.TRAIT_INSTANCE_INITIALIZER;
|
||||
} else {
|
||||
return GraphTextWriter.TRAIT_CLASS_INITIALIZER;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == TraitType.SCRIPT_INITIALIZER) {
|
||||
return GraphTextWriter.TRAIT_SCRIPT_INITIALIZER;
|
||||
}
|
||||
|
||||
if (classIndex == -1) {
|
||||
return index;
|
||||
}
|
||||
|
||||
if (isStatic) {
|
||||
return index;
|
||||
} else {
|
||||
return class_info.get(classIndex).static_traits.traits.size() + index;
|
||||
}
|
||||
}
|
||||
|
||||
private void removeClassFromTraits(Traits traits, int index) {
|
||||
for (Trait t : traits.traits) {
|
||||
if (t instanceof TraitClass) {
|
||||
|
||||
@@ -620,12 +620,12 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
|
||||
public void getMethodInfos(List<MethodId> methodInfos) {
|
||||
int script_init = abc.script_info.get(scriptIndex).init_index;
|
||||
methodInfos.add(new MethodId(-1, script_init));
|
||||
methodInfos.add(new MethodId(GraphTextWriter.TRAIT_SCRIPT_INITIALIZER, -1, script_init));
|
||||
|
||||
List<Trait> traits = abc.script_info.get(scriptIndex).traits.traits;
|
||||
for (int t = 0; t < traitIndices.size(); t++) {
|
||||
for (int t : traitIndices) {
|
||||
Trait trait = traits.get(t);
|
||||
trait.getMethodInfos(abc, -1, methodInfos);
|
||||
trait.getMethodInfos(abc, GraphTextWriter.TRAIT_UNKNOWN, -1, methodInfos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,5 +511,5 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract void getMethodInfos(ABC abc, int classIndex, List<MethodId> methodInfos);
|
||||
public abstract void getMethodInfos(ABC abc, int traitId, int classIndex, List<MethodId> methodInfos);
|
||||
}
|
||||
|
||||
@@ -278,19 +278,19 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMethodInfos(ABC abc, int classIndex, List<MethodId> methodInfos) {
|
||||
public void getMethodInfos(ABC abc, int traitId, int classIndex, List<MethodId> methodInfos) {
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
|
||||
//class initializer
|
||||
methodInfos.add(new MethodId(class_info, classInfo.cinit_index));
|
||||
methodInfos.add(new MethodId(GraphTextWriter.TRAIT_CLASS_INITIALIZER, class_info, classInfo.cinit_index));
|
||||
|
||||
//constructor - instance initializer
|
||||
methodInfos.add(new MethodId(class_info, instanceInfo.iinit_index));
|
||||
methodInfos.add(new MethodId(GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, class_info, instanceInfo.iinit_index));
|
||||
|
||||
//static variables,constants & methods
|
||||
classInfo.static_traits.getMethodInfos(abc, class_info, methodInfos);
|
||||
classInfo.static_traits.getMethodInfos(abc, true, class_info, methodInfos);
|
||||
|
||||
instanceInfo.instance_traits.getMethodInfos(abc, class_info, methodInfos);
|
||||
instanceInfo.instance_traits.getMethodInfos(abc, false, class_info, methodInfos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMethodInfos(ABC abc, int classIndex, List<MethodId> methodInfos) {
|
||||
methodInfos.add(new MethodId(classIndex, method_info));
|
||||
public void getMethodInfos(ABC abc, int traitId, int classIndex, List<MethodId> methodInfos) {
|
||||
methodInfos.add(new MethodId(traitId, classIndex, method_info));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -228,7 +228,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMethodInfos(ABC abc, int classIndex, List<MethodId> methodInfos) {
|
||||
methodInfos.add(new MethodId(classIndex, method_info));
|
||||
public void getMethodInfos(ABC abc, int traitId, int classIndex, List<MethodId> methodInfos) {
|
||||
methodInfos.add(new MethodId(traitId, classIndex, method_info));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -247,6 +247,6 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMethodInfos(ABC abc, int classIndex, List<MethodId> methodInfos) {
|
||||
public void getMethodInfos(ABC abc, int traitId, int classIndex, List<MethodId> methodInfos) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2016 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum TraitType {
|
||||
METHOD,
|
||||
VAR,
|
||||
CONST,
|
||||
INITIALIZER,
|
||||
SCRIPT_INITIALIZER;
|
||||
|
||||
public static TraitType getTypeForTrait(Trait t) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
return METHOD;
|
||||
}
|
||||
if (t instanceof TraitSlotConst) {
|
||||
if (((TraitSlotConst) t).isConst()) {
|
||||
return CONST;
|
||||
} else {
|
||||
return VAR;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -171,12 +171,7 @@ public class Traits implements Cloneable, Serializable {
|
||||
continue;
|
||||
}
|
||||
writer.newLine();
|
||||
int h = t;
|
||||
if (classIndex != -1) {
|
||||
if (!isStatic) {
|
||||
h += abc.class_info.get(classIndex).static_traits.traits.size();
|
||||
}
|
||||
}
|
||||
int h = abc.getGlobalTraitId(TraitType.METHOD /*non-initializer*/, isStatic, classIndex, t);
|
||||
if (trait instanceof TraitClass) {
|
||||
writer.startClass(((TraitClass) trait).class_info);
|
||||
} else {
|
||||
@@ -252,10 +247,10 @@ public class Traits implements Cloneable, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void getMethodInfos(ABC abc, int classIndex, List<MethodId> methodInfos) {
|
||||
public void getMethodInfos(ABC abc, boolean isStatic, int classIndex, List<MethodId> methodInfos) {
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
Trait trait = traits.get(t);
|
||||
trait.getMethodInfos(abc, classIndex, methodInfos);
|
||||
trait.getMethodInfos(abc, abc.getGlobalTraitId(TraitType.METHOD /*non-initializer*/, isStatic, classIndex, t), classIndex, methodInfos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user