diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java index 553358925..3b553bb51 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java @@ -34,6 +34,9 @@ public class GetLexAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { + + String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); + srcData.put("localName",localName); return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java index 9eeb23118..7e783c250 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java @@ -39,7 +39,7 @@ public class GetSlotAVM2Item extends AVM2Item { if (slotName == null) { return writer.append("/*UnknownSlot*/"); } - srcData.put("slotName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + srcData.put("localName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index 6687ff22b..1f7872a92 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -55,8 +55,7 @@ public class LocalRegAVM2Item extends AVM2Item { computedResult = null; } } - this.computedValue = computedValue; - srcData.put("regIndex", ""+regIndex); + this.computedValue = computedValue; } @Override @@ -64,7 +63,9 @@ public class LocalRegAVM2Item extends AVM2Item { if (computedValue instanceof FilterAVM2Item) { return computedValue.toString(writer, localData); } - return writer.append(localRegName(localData.localRegNames, regIndex)); + String localName = localRegName(localData.localRegNames, regIndex); + srcData.put("localName", localName); + return writer.append(localName); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java index 194dfa8c8..478329c90 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java @@ -42,13 +42,14 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig public SetLocalAVM2Item(AVM2Instruction instruction, int regIndex, GraphTargetItem value) { super(instruction, PRECEDENCE_ASSIGMENT); this.regIndex = regIndex; - this.value = value; - srcData.put("regIndex", ""+regIndex); + this.value = value; } @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.append(localRegName(localData.localRegNames, regIndex) + " = "); + String localName = localRegName(localData.localRegNames, regIndex); + srcData.put("localName", localName); + writer.append(localName + " = "); return value.toString(writer, localData); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java index 74c30145e..525c8e0b0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java @@ -45,7 +45,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - srcData.put("slotName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + srcData.put("localName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); getName(writer, localData); writer.append(" = "); return value.toString(writer, localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java index 2beec664b..53facbd52 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java @@ -16,15 +16,19 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.clauses; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.types.InstanceInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.ArrayList; /** * @@ -43,13 +47,15 @@ public class DeclarationAVM2Item extends AVM2Item { public DeclarationAVM2Item(GraphTargetItem assignment) { this(assignment, null); - } + } @Override - public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + if (assignment instanceof SetLocalAVM2Item) { SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment; - srcData.put("regIndex",""+lti.regIndex); + String localName = localRegName(localData.localRegNames, lti.regIndex); + srcData.put("localName",localName); srcData.put("declaration", "true"); GraphTargetItem coerType = TypeItem.UNBOUNDED; if (lti.value instanceof CoerceAVM2Item) { @@ -59,19 +65,20 @@ public class DeclarationAVM2Item extends AVM2Item { coerType = ((ConvertAVM2Item) lti.value).type; } writer.append("var "); - writer.append(localRegName(localData.localRegNames, lti.regIndex)); - writer.append(":"); + writer.append(localName); + writer.append(":"); coerType.appendTo(writer, localData); writer.append(" = "); return lti.value.toString(writer, localData); } if (assignment instanceof SetSlotAVM2Item) { SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment; - srcData.put("slotName",""+ssti.getNameAsStr(localData)); + srcData.put("localName",ssti.getNameAsStr(localData)); srcData.put("declaration", "true"); writer.append("var "); ssti.getName(writer, localData); writer.append(":"); + type.appendTo(writer, localData); writer.append(" = "); return ssti.value.toString(writer, localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index b96b61b08..7676f9b71 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -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.model.clauses; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -31,7 +32,9 @@ import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.ContinueItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class TryAVM2Item extends AVM2Item implements Block { @@ -74,7 +77,15 @@ public class TryAVM2Item extends AVM2Item implements Block { writer.endBlock(); for (int e = 0; e < catchExceptions.size(); e++) { writer.newLine(); - writer.append("catch(" + catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames) + ")"); + writer.append("catch("); + String localName = catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames); + Map data=new HashMap<>(); + data.put("localName", localName); + data.put("declaration", "true"); + writer.hilightSpecial(localName, "try.name",e,data); + writer.append(":"); + writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames),"try.type",e); + writer.append(")"); writer.startBlock(); List commands = catchCommands.get(e); for (GraphTargetItem ti : commands) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java index 83ee4083c..19feb5750 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.types.traits.Traits; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; @@ -52,28 +53,13 @@ public class InstanceInfo { return "name_index=" + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames); } - public String getClassHeaderStr(ABC abc, List fullyQualifiedNames) { - String supIndexStr = ""; - if (super_index > 0) { - supIndexStr = " extends " + abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index - } - String implStr = ""; - if (interfaces.length > 0) { - if (isInterface()) { - implStr = " extends "; - } else { - implStr = " implements "; - } - for (int i = 0; i < interfaces.length; i++) { - if (i > 0) { - implStr += ", "; - } - implStr += abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false); - } - } + public GraphTextWriter getClassHeaderStr(GraphTextWriter writer,ABC abc, List fullyQualifiedNames, boolean allowPrivate) { String modifiers; Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants); modifiers = ns.getPrefix(abc); + if(!allowPrivate && modifiers.equals("private")){ + modifiers = ""; + } if (!modifiers.isEmpty()) { modifiers += " "; } @@ -88,7 +74,31 @@ public class InstanceInfo { if (isInterface()) { objType = "interface "; } - return modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList()/* No full names here*/, false) + supIndexStr + implStr; + writer.appendNoHilight(modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList()/* No full names here*/, false)); + + + + if (super_index > 0) { + String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true); + writer.appendNoHilight(" extends "); + writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false),"typename",typeName); + } + if (interfaces.length > 0) { + if (isInterface()) { + writer.appendNoHilight(" extends "); + } else { + writer.appendNoHilight(" implements "); + } + for (int i = 0; i < interfaces.length; i++) { + if (i > 0) { + writer.append(", "); + } + String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true); + writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false),"typename",typeName); + } + } + + return writer; } public Multiname getName(AVM2ConstantPool constants) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java index 9e4b57986..f3d9c47b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -279,10 +279,9 @@ public class MethodInfo { writer.appendNoHilight(", "); } pdata=new HashMap<>(); - pdata.put("declaration", "true"); - pdata.put("regIndex", ""+(i+1)); + pdata.put("declaration", "true"); if (!localRegNames.isEmpty()) { - pdata.put("slotName", localRegNames.get(i + 1)); //assuming it is a slot + pdata.put("localName", localRegNames.get(i + 1)); //assuming it is a slot writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(i + 1)),"paramname",i,pdata); } else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) { writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,constants.getString(paramNames[i])),"paramname",i,pdata); @@ -309,14 +308,16 @@ public class MethodInfo { restAdd += ", "; } restAdd += "... "; + String restName; if (!localRegNames.isEmpty()) { - restAdd += localRegNames.get(param_types.length + 1); + restName = localRegNames.get(param_types.length + 1); } else { - restAdd += "rest"; + restName = "rest"; } + restAdd += restName; pdata=new HashMap<>(); pdata.put("declaration", "true"); - pdata.put("regIndex", ""+(param_types.length + 1)); + pdata.put("localName",restName); writer.hilightSpecial(restAdd, "flag.NEED_REST",0,pdata); } return writer; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index d9c375399..2c4a7d1b0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -348,8 +348,8 @@ public class TraitClass extends Trait implements TraitWithSlot { @Override public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { - String classHeader = abc.instance_info.get(class_info).getClassHeaderStr(abc, fullyQualifiedNames); - return writer.appendNoHilight(classHeader); + abc.instance_info.get(class_info).getClassHeaderStr(writer,abc, fullyQualifiedNames,false); + return writer; } @Override @@ -447,11 +447,8 @@ public class TraitClass extends Trait implements TraitWithSlot { } //class header - String classHeader = abc.instance_info.get(class_info).getClassHeaderStr(abc, fullyQualifiedNames); - if (classHeader.startsWith("private ")) { - classHeader = classHeader.substring("private ".length()); - } - writer.appendNoHilight(classHeader).startBlock(); + abc.instance_info.get(class_info).getClassHeaderStr(writer,abc, fullyQualifiedNames,false); + writer.startBlock(); int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index); if (bodyIndex != -1) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java index eb7080d5c..02e89608a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java @@ -49,13 +49,13 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable { } @Override - public FileTextWriter hilightSpecial(String text, String type, int index) { + public FileTextWriter hilightSpecial(String text, String type, String index) { writeToFile(text); return this; } @Override - public GraphTextWriter hilightSpecial(String text, String type, int index, Map data) { + public GraphTextWriter hilightSpecial(String text, String type, String index, Map data) { writeToFile(text); return this; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java index 9852ae9e6..5aaf474a5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java @@ -103,14 +103,23 @@ public abstract class GraphTextWriter { } public GraphTextWriter hilightSpecial(String text, String type) { - return hilightSpecial(text, type, 0); - } - - public GraphTextWriter hilightSpecial(String text, String type, int index) { - return hilightSpecial(text, type, 0, new HashMap()); + return hilightSpecial(text, type, "0"); } + public GraphTextWriter hilightSpecial(String text, String type, int index) { + return hilightSpecial(text, type, ""+index); + } + + public GraphTextWriter hilightSpecial(String text, String type, String index) { + return hilightSpecial(text, type, "0", new HashMap()); + } + + public GraphTextWriter hilightSpecial(String text, String type, int index, Map data) { + return hilightSpecial(text, type, ""+index, data); + } + + public GraphTextWriter hilightSpecial(String text, String type, String index, Map data) { return this; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java index 099762b60..c8170e100 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java @@ -144,20 +144,20 @@ public class HilightedTextWriter extends GraphTextWriter { @Override public HilightedTextWriter hilightSpecial(String text, String type) { - return hilightSpecial(text, type, 0); + return hilightSpecial(text, type, "0"); } @Override - public HilightedTextWriter hilightSpecial(String text, String type, int index) { + public HilightedTextWriter hilightSpecial(String text, String type, String index) { return hilightSpecial(text, type, index, new HashMap()); } @Override - public HilightedTextWriter hilightSpecial(String text, String type, int index, Map data) { + public HilightedTextWriter hilightSpecial(String text, String type, String index, Map data) { Map ndata = new HashMap<>(); ndata.putAll(data); ndata.put("subtype", type); - ndata.put("index", Long.toString(index)); + ndata.put("index", index); start(ndata, HilightType.SPECIAL); appendNoHilight(text); return end(HilightType.SPECIAL); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/NulWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/NulWriter.java index 90484e158..b2c30357f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/NulWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/NulWriter.java @@ -99,13 +99,13 @@ public class NulWriter extends GraphTextWriter { } @Override - public NulWriter hilightSpecial(String text, String type, int index) { + public NulWriter hilightSpecial(String text, String type, String index) { stringAdded = true; return this; } @Override - public NulWriter hilightSpecial(String text, String type, int index, Map data) { + public NulWriter hilightSpecial(String text, String type, String index, Map data) { stringAdded = true; return this; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java index c7c24290a..3474b5fa8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java @@ -93,6 +93,16 @@ public class Highlighting implements Serializable { public static Highlighting search(List list, long pos, Map properties, long from, long to) { Highlighting ret = null; looph:for (Highlighting h : list) { + if (from > -1) { + if (h.startPos < from) { + continue; + } + } + if (to > -1) { + if (h.startPos > to) { + continue; + } + } for(String property:properties.keySet()){ if (property != null) { String v = h.getPropertyString(property); @@ -108,16 +118,7 @@ public class Highlighting implements Serializable { } } } - if (from > -1) { - if (h.startPos < from) { - continue; - } - } - if (to > -1) { - if (h.startPos > to) { - continue; - } - } + if (pos == -1 || (pos >= h.startPos && (pos < h.startPos + h.len))) { if (ret == null || h.startPos > ret.startPos) { //get the closest one ret = h; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java index f246b5ca8..6eb0a8596 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java @@ -12,15 +12,21 @@ * 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; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.types.InstanceInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.decompiler.graph.model.UnboundedTypeItem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -67,16 +73,17 @@ public class TypeItem extends GraphTargetItem { return true; } + @Override - public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { if (localData.fullyQualifiedNames.contains(fullTypeName)) { - writer.append(fullTypeName); + writer.hilightSpecial(fullTypeName,"typename",fullTypeName); } else { String simpleName = fullTypeName; if (simpleName.contains(".")) { simpleName = simpleName.substring(simpleName.lastIndexOf('.') + 1); } - writer.append(simpleName); + writer.hilightSpecial(simpleName,"typename",fullTypeName); } return writer; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index c170dbe70..edaf6a605 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -540,6 +540,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se private boolean hasDeclaration(int pos) { int multinameIndex = decompiledTextArea.getMultinameAtPos(pos); if (multinameIndex > -1) { + if(multinameIndex == 0){ + return false; + } List usages = abc.findMultinameDefinition(swf.abcList, multinameIndex); Multiname m = abc.constants.constant_multiname.get(multinameIndex); @@ -561,10 +564,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se if (!usages.isEmpty()) { return true; } - } else { - return decompiledTextArea.getLocalDeclarationOfPos(pos) != -1; - } - return false; + } + + return decompiledTextArea.getLocalDeclarationOfPos(pos) != -1; } private void gotoDeclaration(int pos) { @@ -591,15 +593,18 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se if (usages.size() > 1) { UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, true); usageFrame.setVisible(true); + return; } else if (!usages.isEmpty()) { //one UsageFrame.gotoUsage(ABCPanel.this, usages.get(0)); - } - } else { - int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos); - if (dpos > -1) { - decompiledTextArea.setCaretPosition(dpos); + return; } } + + int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos); + if (dpos > -1) { + decompiledTextArea.setCaretPosition(dpos); + } + } private class CtrlClickHandler extends KeyAdapter implements MouseListener, MouseMotionListener { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 3e88449e8..981bd8f27 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -113,7 +113,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi addCaretListener(this); } - public void hilighSpecial(String type, int index) { + public void hilighSpecial(String type, String index) { Highlighting h2 = null; for (Highlighting sh : specialHilights) { if (type.equals(sh.getPropertyString("subtype"))) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index e074b73db..918fc7cee 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -20,6 +20,10 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ScriptPack; 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.construction.ConstructSuperIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperVoidIns; +import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction; @@ -205,7 +209,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } Highlighting sh = Highlighting.search(specialHighlights, pos); if (sh != null) { - methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), (int) (long) sh.getPropertyLong("index")); + methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), sh.getPropertyString("index")); success = true; } return success; @@ -234,35 +238,39 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL public int getLocalDeclarationOfPos(int pos) { Highlighting sh = Highlighting.search(specialHighlights, pos); Highlighting h = Highlighting.search(highlights, pos); - Highlighting tm = Highlighting.search(methodHighlights, pos); - if (tm == null) { - return -1; - } - List tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1); - if (h == null) { - return -1; - } - //is it already declaration? - if ("true".equals(h.getPropertyString("declaration")) || (sh != null && "true".equals(sh.getPropertyString("declaration")))) { - return -1; //no jump - } - Map search = h.getProperties(); - search.remove("index"); - search.remove("subtype"); - search.remove("offset"); - if (search.isEmpty()) { + List tms = Highlighting.searchAll(methodHighlights, pos, null, null, -1, -1); + if (tms.isEmpty()) { return -1; } - search.put("declaration", "true"); + for (Highlighting tm : tms) { - for (Highlighting tm1 : tms) { - Highlighting rh = Highlighting.search(highlights, search, tm1.startPos, tm1.startPos + tm1.len); - if (rh == null) { - rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len); + List tm_tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1); + if (h == null) { + return -1; } - if (rh != null) { - return rh.startPos; + //is it already declaration? + if ("true".equals(h.getPropertyString("declaration")) || (sh != null && "true".equals(sh.getPropertyString("declaration")))) { + return -1; //no jump + } + + Map search = h.getProperties(); + search.remove("index"); + search.remove("subtype"); + search.remove("offset"); + if (search.isEmpty()) { + return -1; + } + search.put("declaration", "true"); + + for (Highlighting tm1 : tm_tms) { + Highlighting rh = Highlighting.search(highlights, search, tm1.startPos, tm1.startPos + tm1.len); + if (rh == null) { + rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len); + } + if (rh != null) { + return rh.startPos; + } } } @@ -271,48 +279,70 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL public int getMultinameAtPos(int pos) { Highlighting tm = Highlighting.search(methodHighlights, pos); - if (tm == null) { - return -1; - } - int mi = (int) (long) tm.getPropertyLong("index"); - int bi = abc.findBodyIndex(mi); - Highlighting h = Highlighting.search(highlights, pos); - if (h != null) { - List list = abc.bodies.get(bi).getCode().code; - AVM2Instruction lastIns = null; - long inspos = 0; - AVM2Instruction selIns = null; - for (AVM2Instruction ins : list) { - if (h.getPropertyLong("offset") == ins.getOffset()) { - selIns = ins; - break; + Trait currentTrait = null; + int currentMethod = -1; + if (tm != null) { + + int mi = (int) (long) tm.getPropertyLong("index"); + int bi = abc.findBodyIndex(mi); + Highlighting h = Highlighting.search(highlights, pos); + if (h != null) { + List list = abc.bodies.get(bi).getCode().code; + AVM2Instruction lastIns = null; + long inspos = 0; + AVM2Instruction selIns = null; + for (AVM2Instruction ins : list) { + if (h.getPropertyLong("offset") == ins.getOffset()) { + selIns = ins; + break; + } + if (ins.getOffset() > h.getPropertyLong("offset")) { + inspos = h.getPropertyLong("offset") - lastIns.offset; + selIns = lastIns; + break; + } + lastIns = ins; } - if (ins.getOffset() > h.getPropertyLong("offset")) { - inspos = h.getPropertyLong("offset") - lastIns.offset; - selIns = lastIns; - break; - } - lastIns = ins; - } - if (selIns != null) { - for (int i = 0; i < selIns.definition.operands.length; i++) { - if (selIns.definition.operands[i] == AVM2Code.DAT_MULTINAME_INDEX) { - return selIns.operands[i]; + if (selIns != null) { + if ((selIns.definition instanceof ConstructSuperIns) || (selIns.definition instanceof CallSuperIns)|| (selIns.definition instanceof CallSuperVoidIns)) { + Highlighting tc = Highlighting.search(classHighlights, pos); + if(tc!=null){ + int cindex = (int)(long)tc.getPropertyLong("index"); + if(cindex>-1){ + return abc.instance_info.get(cindex).super_index; + } + } + } else { + for (int i = 0; i < selIns.definition.operands.length; i++) { + if (selIns.definition.operands[i] == AVM2Code.DAT_MULTINAME_INDEX) { + return selIns.operands[i]; + } + } } } } - } - int currentMethod = -1; - Trait currentTrait = getCurrentTrait(); - if (currentTrait instanceof TraitMethodGetterSetter) { - currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info; - } - if (currentMethodHighlight != null) { - currentMethod = (int) (long) currentMethodHighlight.getPropertyLong("index"); + + currentTrait = getCurrentTrait(); + if (currentTrait instanceof TraitMethodGetterSetter) { + currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info; + } + if (currentMethodHighlight != null) { + currentMethod = (int) (long) currentMethodHighlight.getPropertyLong("index"); + } } Highlighting sh = Highlighting.search(specialHighlights, pos); if (sh != null) { switch (sh.getPropertyString("subtype")) { + case "typename": + String typeName = sh.getPropertyString("index"); + for (int i = 1; i < abc.constants.constant_multiname.size(); i++) { + Multiname m = abc.constants.constant_multiname.get(i); + if (m != null) { + if (typeName.equals(m.getNameWithNamespace(abc.constants, true))) { + return i; + } + } + } case "traittypename": if (currentTrait instanceof TraitSlotConst) { TraitSlotConst ts = (TraitSlotConst) currentTrait; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java b/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java index 3b1758fe0..085fb098b 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java @@ -64,7 +64,7 @@ public class MethodCodePanel extends JPanel implements ActionListener { sourceTextArea.hilighOffset(offset); } - public void hilighSpecial(String type, int index) { + public void hilighSpecial(String type, String index) { sourceTextArea.hilighSpecial(type, index); }