diff --git a/.gitignore b/.gitignore index 59f9e7f03..2abda6812 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,9 @@ hs_err_pid*.log /jpexs_website.properties /version.properties /tools.properties -/nbproject/private/ \ No newline at end of file +/nbproject/private/ +/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/HighlightType.java +/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedText.java +/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/HighlightData.java +/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java +/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/hilight/HighlightSpecialType.java \ No newline at end of file diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 06a0fd634..e27cb8fc9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -563,7 +563,7 @@ public class ABC { loadNamespaceMap(); /*for(int i=0;i()); } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index d70aad830..ba06a9607 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -221,7 +221,8 @@ import com.jpexs.decompiler.flash.dumpview.DumpInfo; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.graph.Block; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphPart; @@ -927,10 +928,10 @@ public class AVM2Code implements Cloneable { if (trait instanceof TraitFunction) { TraitFunction tf = (TraitFunction) trait; writer.appendNoHilight("trait "); - writer.hilightSpecial("function ", "traittype"); - writer.hilightSpecial(constants.multinameToString(tf.name_index), "traitname"); + writer.hilightSpecial("function ", HighlightSpecialType.TRAIT_TYPE); + writer.hilightSpecial(constants.multinameToString(tf.name_index), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight(" slotid "); - writer.hilightSpecial("" + tf.slot_id, "slotid"); + writer.hilightSpecial("" + tf.slot_id, HighlightSpecialType.SLOT_ID); writer.newLine(); } if (trait instanceof TraitMethodGetterSetter) { @@ -938,70 +939,70 @@ public class AVM2Code implements Cloneable { writer.appendNoHilight("trait "); switch (tm.kindType) { case Trait.TRAIT_METHOD: - writer.hilightSpecial("method ", "traittype"); + writer.hilightSpecial("method ", HighlightSpecialType.TRAIT_TYPE); break; case Trait.TRAIT_GETTER: - writer.hilightSpecial("getter ", "traittype"); + writer.hilightSpecial("getter ", HighlightSpecialType.TRAIT_TYPE); break; case Trait.TRAIT_SETTER: - writer.hilightSpecial("setter ", "traittype"); + writer.hilightSpecial("setter ", HighlightSpecialType.TRAIT_TYPE); break; } - writer.hilightSpecial(constants.multinameToString(tm.name_index), "traitname"); + writer.hilightSpecial(constants.multinameToString(tm.name_index), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight(" dispid "); - writer.hilightSpecial("" + tm.disp_id, "dispid"); + writer.hilightSpecial("" + tm.disp_id, HighlightSpecialType.DISP_ID); writer.newLine(); } } if (info != null) { writer.appendNoHilight("method").newLine(); writer.appendNoHilight("name "); - writer.hilightSpecial(info.name_index == 0 ? "null" : "\"" + Helper.escapeString(info.getName(constants)) + "\"", "methodname"); + writer.hilightSpecial(info.name_index == 0 ? "null" : "\"" + Helper.escapeString(info.getName(constants)) + "\"", HighlightSpecialType.METHOD_NAME); writer.newLine(); if (info.flagExplicit()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("EXPLICIT", "flag.EXPLICIT"); + writer.hilightSpecial("EXPLICIT", HighlightSpecialType.FLAG_EXPLICIT); writer.newLine(); } if (info.flagHas_optional()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("HAS_OPTIONAL", "flag.HAS_OPTIONAL"); + writer.hilightSpecial("HAS_OPTIONAL", HighlightSpecialType.FLAG_HAS_OPTIONAL); writer.newLine(); writer.appendNoHilight("flag HAS_OPTIONAL").newLine(); } if (info.flagHas_paramnames()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("HAS_PARAM_NAMES", "flag.HAS_PARAM_NAMES"); + writer.hilightSpecial("HAS_PARAM_NAMES", HighlightSpecialType.FLAG_HAS_PARAM_NAMES); writer.newLine(); } if (info.flagIgnore_rest()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("EXPLICIT", "flag.IGNORE_REST"); + writer.hilightSpecial("EXPLICIT", HighlightSpecialType.FLAG_IGNORE_REST); writer.newLine(); } if (info.flagNeed_activation()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("NEED_ACTIVATION", "flag.NEED_ACTIVATION"); + writer.hilightSpecial("NEED_ACTIVATION", HighlightSpecialType.FLAG_NEED_ACTIVATION); writer.newLine(); } if (info.flagNeed_arguments()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("NEED_ARGUMENTS", "flag.NEED_ARGUMENTS"); + writer.hilightSpecial("NEED_ARGUMENTS", HighlightSpecialType.FLAG_NEED_ARGUMENTS); writer.newLine(); } if (info.flagNeed_rest()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("NEED_REST", "flag.NEED_REST"); + writer.hilightSpecial("NEED_REST", HighlightSpecialType.FLAG_NEED_REST); writer.newLine(); } if (info.flagSetsdxns()) { writer.appendNoHilight("flag "); - writer.hilightSpecial("SET_DXNS", "flag.SET_DXNS"); + writer.hilightSpecial("SET_DXNS", HighlightSpecialType.FLAG_SET_DXNS); writer.newLine(); } for (int p = 0; p < info.param_types.length; p++) { writer.appendNoHilight("param "); - writer.hilightSpecial(constants.multinameToString(info.param_types[p]), "param", p); + writer.hilightSpecial(constants.multinameToString(info.param_types[p]), HighlightSpecialType.PARAM, p); writer.newLine(); } if (info.flagHas_paramnames()) { @@ -1021,12 +1022,12 @@ public class AVM2Code implements Cloneable { for (int i = 0; i < info.optional.length; i++) { ValueKind vk = info.optional[i]; writer.appendNoHilight("optional "); - writer.hilightSpecial(vk.toString(constants), "optional", i); + writer.hilightSpecial(vk.toString(constants), HighlightSpecialType.OPTIONAL, i); writer.newLine(); } } writer.appendNoHilight("returns "); - writer.hilightSpecial(constants.multinameToString(info.ret_type), "returns"); + writer.hilightSpecial(constants.multinameToString(info.ret_type), HighlightSpecialType.RETURNS); writer.newLine(); } writer.newLine(); @@ -1068,10 +1069,10 @@ public class AVM2Code implements Cloneable { offsets.add((long) body.exceptions[e].target); writer.appendNoHilight(" type "); - writer.hilightSpecial(body.exceptions[e].type_index == 0 ? "null" : constants.getMultiname(body.exceptions[e].type_index).toString(constants, new ArrayList()), "try.type", e); + writer.hilightSpecial(body.exceptions[e].type_index == 0 ? "null" : constants.getMultiname(body.exceptions[e].type_index).toString(constants, new ArrayList()), HighlightSpecialType.TRY_TYPE, e); writer.appendNoHilight(" name "); - writer.hilightSpecial(body.exceptions[e].name_index == 0 ? "null" : constants.getMultiname(body.exceptions[e].name_index).toString(constants, new ArrayList()), "try.name", e); + writer.hilightSpecial(body.exceptions[e].name_index == 0 ? "null" : constants.getMultiname(body.exceptions[e].name_index).toString(constants, new ArrayList()), HighlightSpecialType.TRY_NAME, e); writer.newLine(); } @@ -2448,7 +2449,7 @@ public class AVM2Code implements Cloneable { invalidateCache(); try { List outputMap = new ArrayList<>(); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer); String src = writer.toString(); @@ -2490,7 +2491,7 @@ public class AVM2Code implements Cloneable { public void removeIgnored(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException { try { List outputMap = new ArrayList<>(); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer); String src = writer.toString(); AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index 6717e7633..8ab37843c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.UnparsedAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TranslateStack; @@ -42,7 +42,7 @@ public class NewClassIns extends InstructionDefinition { @Override public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { int clsIndex = ins.operands[0]; - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); String baseType = writer.toString(); stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(constants, fullyQualifiedNames, false) + ".class extends " + baseType)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java index 8bf732891..b0e3dae2b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java @@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.SetSuperAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TranslateStack; @@ -56,7 +56,7 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns { public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) throws InterruptedException { int multinameIndex = ins.operands[0]; String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, LocalData.create(abc.constants, localRegNames, fullyQualifiedNames)); String obj = writer.toString(); return obj + ".super." + multiname; 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 9ae1a9adb..42821d16c 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 @@ -36,7 +36,7 @@ public class GetLexAVM2Item extends AVM2Item { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); - srcData.put("localName", localName); + srcData.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 9d2ce1a48..d47f0e878 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("localName", getNameAsStr(localData)); + srcData.localName = getNameAsStr(localData); 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 56ec452a9..9d363cd09 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 @@ -64,7 +64,7 @@ public class LocalRegAVM2Item extends AVM2Item { return computedValue.toString(writer, localData); } String localName = localRegName(localData.localRegNames, regIndex); - srcData.put("localName", localName); + srcData.localName = localName; return writer.append(localName); } 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 7bf87a93e..132f10b45 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 @@ -48,7 +48,7 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { String localName = localRegName(localData.localRegNames, regIndex); - srcData.put("localName", localName); + srcData.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 4db39faed..9cfcc2493 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("localName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + srcData.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/ThisAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index 68a53e995..a31f7bcbc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -36,7 +36,7 @@ public class ThisAVM2Item extends AVM2Item { public ThisAVM2Item(GraphSourceItem instruction, Multiname className) { super(instruction, PRECEDENCE_PRIMARY); this.className = className; - srcData.put("localName", "this"); + srcData.localName = "this"; } @Override 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 f23325115..837a3f31c 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 @@ -53,9 +53,9 @@ public class DeclarationAVM2Item extends AVM2Item { if (assignment instanceof LocalRegAVM2Item) { //for..in LocalRegAVM2Item lti = (LocalRegAVM2Item) assignment; String localName = localRegName(localData.localRegNames, lti.regIndex); - srcData.put("localName", localName); - srcData.put("declaration", "true"); - srcData.put("declaredType", "*"); + srcData.localName = localName; + srcData.declaration = true; + srcData.declaredType = "*"; writer.append("var "); writer.append(localName); return writer; @@ -63,9 +63,9 @@ public class DeclarationAVM2Item extends AVM2Item { if (assignment instanceof GetSlotAVM2Item) { //for..in GetSlotAVM2Item sti = (GetSlotAVM2Item) assignment; - srcData.put("localName", sti.getNameAsStr(localData)); - srcData.put("declaration", "true"); - srcData.put("declaredType", "*"); + srcData.localName = sti.getNameAsStr(localData); + srcData.declaration = true; + srcData.declaredType = "*"; writer.append("var "); sti.getName(writer, localData); return writer; @@ -74,8 +74,8 @@ public class DeclarationAVM2Item extends AVM2Item { if (assignment instanceof SetLocalAVM2Item) { SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment; String localName = localRegName(localData.localRegNames, lti.regIndex); - srcData.put("localName", localName); - srcData.put("declaration", "true"); + srcData.localName = localName; + srcData.declaration = true; GraphTargetItem coerType = TypeItem.UNBOUNDED; if (lti.value instanceof CoerceAVM2Item) { @@ -84,7 +84,7 @@ public class DeclarationAVM2Item extends AVM2Item { if (lti.value instanceof ConvertAVM2Item) { coerType = ((ConvertAVM2Item) lti.value).type; } - srcData.put("declaredType", (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName : "*"); + srcData.declaredType = (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName : "*"; writer.append("var "); writer.append(localName); writer.append(":"); @@ -94,9 +94,9 @@ public class DeclarationAVM2Item extends AVM2Item { } if (assignment instanceof SetSlotAVM2Item) { SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment; - srcData.put("localName", ssti.getNameAsStr(localData)); - srcData.put("declaration", "true"); - srcData.put("declaredType", (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName : "*"); + srcData.localName = ssti.getNameAsStr(localData); + srcData.declaration = true; + srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName : "*"; writer.append("var "); ssti.getName(writer, localData); writer.append(":"); 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 6cc12bb7a..2e4bf99cc 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 @@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.NameAVM2Item; import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.graph.Block; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -32,9 +34,7 @@ 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 { @@ -79,16 +79,16 @@ public class TryAVM2Item extends AVM2Item implements Block { writer.newLine(); 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"); + HighlightData data = new HighlightData(); + data.localName = localName; + data.declaration = true; int eti = catchExceptions.get(e).type_index; - data.put("declaredType", eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true)); - writer.hilightSpecial(localName, "try.name", e, data); + data.declaredType = eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true); + writer.hilightSpecial(localName, HighlightSpecialType.TRY_NAME, e, data); writer.append(":"); - writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), "try.type", e); + writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e); writer.append(")"); writer.startBlock(); List commands = catchCommands.get(e); 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 2b19d05d3..537387ac4 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 @@ -20,6 +20,7 @@ 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.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; @@ -76,12 +77,12 @@ public class InstanceInfo { } writer.appendNoHilight(modifiers + objType); - writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList()/* No full names here*/, false), "classname"); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList()/* No full names here*/, false), HighlightSpecialType.CLASS_NAME); 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); + writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName); } if (interfaces.length > 0) { if (isInterface()) { @@ -94,7 +95,7 @@ public class InstanceInfo { 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); + writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName); } } 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 9f7531139..fd0a47147 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 @@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; @@ -272,7 +274,6 @@ public class MethodInfo { if (body != null && Configuration.getLocalNamesFromDebugInfo.get()) { localRegNames = body.getCode().getLocalRegNamesFromDebug(abc); } - Map pdata; for (int i = 0; i < param_types.length; i++) { if (i > 0) { @@ -283,30 +284,30 @@ public class MethodInfo { ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants, false); } - pdata = new HashMap<>(); - pdata.put("declaration", "true"); - pdata.put("declaredType", ptype); + HighlightData pdata = new HighlightData(); + pdata.declaration = true; + pdata.declaredType = ptype; if (!localRegNames.isEmpty()) { - pdata.put("localName", localRegNames.get(i + 1)); //assuming it is a slot - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(i + 1)), "paramname", i, pdata); + pdata.localName = localRegNames.get(i + 1); //assuming it is a slot + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(i + 1)), HighlightSpecialType.PARAM_NAME, i, pdata); } else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) { - pdata.put("localName", constants.getString(paramNames[i])); - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, constants.getString(paramNames[i])), "paramname", i, pdata); + pdata.localName = constants.getString(paramNames[i]); + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, constants.getString(paramNames[i])), HighlightSpecialType.PARAM_NAME, i, pdata); } else { - pdata.put("localName", "param" + (i + 1)); - writer.hilightSpecial("param" + (i + 1), "paramname", i, pdata); + pdata.localName = "param" + (i + 1); + writer.hilightSpecial("param" + (i + 1), HighlightSpecialType.PARAM_NAME, i, pdata); } writer.appendNoHilight(":"); if (param_types[i] == 0) { - writer.hilightSpecial("*", "param", i); + writer.hilightSpecial("*", HighlightSpecialType.PARAM, i); } else { - writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames, false), "param", i); + writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames, false), HighlightSpecialType.PARAM, i); } if (optional != null) { if (i >= param_types.length - optional.length) { int optionalIndex = i - (param_types.length - optional.length); writer.appendNoHilight(" = "); - writer.hilightSpecial(optional[optionalIndex].toString(constants), "optional", optionalIndex); + writer.hilightSpecial(optional[optionalIndex].toString(constants), HighlightSpecialType.OPTIONAL, optionalIndex); } } } @@ -322,12 +323,13 @@ public class MethodInfo { } else { restName = "rest"; } - pdata = new HashMap<>(); - pdata.put("declaration", "true"); - pdata.put("declaredType", "*"); - pdata.put("localName", restName); + + HighlightData pdata = new HighlightData(); + pdata.declaration = true; + pdata.declaredType = "*"; + pdata.localName = restName; writer.append(restAdd); - writer.hilightSpecial(restName, "flag.NEED_REST", 0, pdata); + writer.hilightSpecial(restName, HighlightSpecialType.FLAG_NEED_REST, 0, pdata); } return writer; } @@ -337,7 +339,7 @@ public class MethodInfo { if (ret_type > 0) { rname = IdentifiersDeobfuscation.printIdentifier(true, constants.getMultiname(ret_type).getName(constants, fullyQualifiedNames, true), "void"); } - return writer.hilightSpecial(rname, "returns"); + return writer.hilightSpecial(rname, HighlightSpecialType.RETURNS); } public void setBody(MethodBody body) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index bab331ccc..8d7637326 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; @@ -58,8 +59,8 @@ public class TraitFunction extends Trait implements TraitWithSlot { modifier = ""; } writer.appendNoHilight(modifier); - writer.hilightSpecial("function ", "traittype"); - writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), "traitname"); + writer.hilightSpecial("function ", HighlightSpecialType.TRAIT_TYPE); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight("("); abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(") : "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 069b3a825..c4471e29b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; @@ -66,8 +67,8 @@ public class TraitMethodGetterSetter extends Trait { } writer.appendNoHilight(modifier); - writer.hilightSpecial("function " + addKind, "traittype"); - writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), "traitname"); + writer.hilightSpecial("function " + addKind, HighlightSpecialType.TRAIT_TYPE); + writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight("("); abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(") : "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 03b0cf049..171c2981c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -86,9 +87,9 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { if (val != null && val.isNamespace()) { slotconst = "namespace"; } - writer.hilightSpecial(slotconst + " ", "traittype"); - writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), "traitname"); - writer.hilightSpecial(typeStr, "traittypename"); + writer.hilightSpecial(slotconst + " ", HighlightSpecialType.TRAIT_TYPE); + writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(typeStr, HighlightSpecialType.TRAIT_TYPE_NAME); return writer; } @@ -117,7 +118,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { if (value_kind != 0) { ValueKind val = new ValueKind(value_index, value_kind); - writer.hilightSpecial(val.toString(abc.constants), "traitvalue"); + writer.hilightSpecial(val.toString(abc.constants), HighlightSpecialType.TRAIT_VALUE); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java index ceb51e060..3bca6a1ea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.ArrayList; @@ -53,7 +53,7 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { //ignore } - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); writer.appendNoHilight(super.toString() + " "); if (parentTraitIndex > -1) { if (isStatic) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java index 373e56856..da56df36d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.ArrayList; @@ -57,7 +57,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { ((TraitMethodGetterSetter) traits.traits.get(traitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); } - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); writer.appendNoHilight(super.toString()); writer.appendNoHilight(" "); if (isInitializer) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 044d69629..8e2985a36 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -57,7 +57,7 @@ import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -387,7 +387,7 @@ public class Action implements GraphSourceItem { * */ public static String actionsToString(List listeners, long address, ActionList list, int version, ScriptExportMode exportMode) { - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); actionsToString(listeners, address, list, version, exportMode, writer); return writer.toString(); } @@ -682,7 +682,7 @@ public class Action implements GraphSourceItem { * @throws java.lang.InterruptedException */ public static String actionsToSource(final ASMSource asm, final List actions, final String path) throws InterruptedException { - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); actionsToSource(asm, actions, path, writer); return writer.toString(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index bea8306b8..eb3ab1fed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -33,7 +33,7 @@ import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -302,7 +302,7 @@ public class ActionPush extends Action { @Override public String toString() { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); toString(writer); return writer.toString(); } 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 816eaf346..fa8739966 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 @@ -16,12 +16,13 @@ */ package com.jpexs.decompiler.flash.helpers; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.helpers.utf8.Utf8OutputStreamWriter; import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; import java.io.Writer; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -43,19 +44,7 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable { } @Override - public FileTextWriter hilightSpecial(String text, String type) { - writeToFile(text); - return this; - } - - @Override - public FileTextWriter hilightSpecial(String text, String type, String index) { - writeToFile(text); - return this; - } - - @Override - public GraphTextWriter hilightSpecial(String text, String type, String index, Map data) { + public GraphTextWriter hilightSpecial(String text, HighlightSpecialType type, String specialValue, HighlightData data) { writeToFile(text); return this; } @@ -67,7 +56,7 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable { } @Override - public GraphTextWriter appendWithData(String str, Map data) { + public GraphTextWriter appendWithData(String str, HighlightData data) { writeToFile(str); return this; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java index b02123676..a45b02d9e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphSourceItemPosition.java @@ -16,8 +16,8 @@ */ package com.jpexs.decompiler.flash.helpers; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; import com.jpexs.decompiler.graph.GraphSourceItem; -import java.util.Map; /** * Provides methods for highlighting positions of instructions in the text. @@ -28,6 +28,6 @@ public class GraphSourceItemPosition { public GraphSourceItem graphSourceItem; public int position; - public Map data; + public HighlightData data; } 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 0522e42ee..1f214021d 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 @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.helpers; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.graph.GraphSourceItem; -import java.util.HashMap; -import java.util.Map; /** * Provides methods for highlighting positions of instructions in the text. @@ -52,7 +52,7 @@ public abstract class GraphTextWriter { * @param data * @return GraphTextWriter */ - public GraphTextWriter startOffset(GraphSourceItem src, int pos, Map data) { + public GraphTextWriter startOffset(GraphSourceItem src, int pos, HighlightData data) { return this; } @@ -102,23 +102,23 @@ public abstract class GraphTextWriter { return this; } - public GraphTextWriter hilightSpecial(String text, String type) { - return hilightSpecial(text, type, "0"); + public final GraphTextWriter hilightSpecial(String text, HighlightSpecialType type) { + return hilightSpecial(text, type, ""); } - public GraphTextWriter hilightSpecial(String text, String type, int index) { - return hilightSpecial(text, type, "" + index); + public final GraphTextWriter hilightSpecial(String text, HighlightSpecialType type, int specialValue) { + return hilightSpecial(text, type, Integer.toString(specialValue), new HighlightData()); } - public GraphTextWriter hilightSpecial(String text, String type, String index) { - return hilightSpecial(text, type, "0", new HashMap()); + public final GraphTextWriter hilightSpecial(String text, HighlightSpecialType type, int specialValue, HighlightData data) { + return hilightSpecial(text, type, Integer.toString(specialValue), data); } - public GraphTextWriter hilightSpecial(String text, String type, int index, Map data) { - return hilightSpecial(text, type, "" + index, data); + public final GraphTextWriter hilightSpecial(String text, HighlightSpecialType type, String specialValue) { + return hilightSpecial(text, type, specialValue, new HighlightData()); } - public GraphTextWriter hilightSpecial(String text, String type, String index, Map data) { + public GraphTextWriter hilightSpecial(String text, HighlightSpecialType type, String specialValue, HighlightData data) { return this; } @@ -126,7 +126,7 @@ public abstract class GraphTextWriter { return ""; } - public abstract GraphTextWriter appendWithData(String str, Map data); + public abstract GraphTextWriter appendWithData(String str, HighlightData data); public abstract GraphTextWriter append(String str); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightType.java deleted file mode 100644 index 0ae78288a..000000000 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightType.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010-2014 JPEXS, All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ -package com.jpexs.decompiler.flash.helpers; - -/** - * Provides methods for highlighting positions of instructions in the text. - * - * @author JPEXS - */ -public enum HilightType { - - TRAIT, CLASS, METHOD, OFFSET, SPECIAL - -} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedText.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedText.java deleted file mode 100644 index 13224d3ae..000000000 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedText.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2010-2014 JPEXS, All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ -package com.jpexs.decompiler.flash.helpers; - -import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Provides methods for highlighting positions of instructions in the text. - * - * @author JPEXS - */ -public class HilightedText implements Serializable { - - public String text; - public List traitHilights; - public List classHilights; - public List methodHilights; - public List instructionHilights; - public List specialHilights; - - public List getTraitHighlights() { - return traitHilights; - } - - public List getMethodHighlights() { - return methodHilights; - } - - public List getClassHighlights() { - return classHilights; - } - - public List getSpecialHighligths() { - return specialHilights; - } - - public HilightedText(HilightedTextWriter writer) { - this.text = writer.toString(); - this.traitHilights = writer.traitHilights; - this.classHilights = writer.classHilights; - this.methodHilights = writer.methodHilights; - this.instructionHilights = writer.instructionHilights; - this.specialHilights = writer.specialHilights; - } - - public HilightedText(String text) { - this.text = text; - this.traitHilights = new ArrayList<>(); - this.classHilights = new ArrayList<>(); - this.methodHilights = new ArrayList<>(); - this.instructionHilights = new ArrayList<>(); - this.specialHilights = new ArrayList<>(); - } -} 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 deleted file mode 100644 index 2c51c27ea..000000000 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (C) 2010-2014 JPEXS, All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. - */ -package com.jpexs.decompiler.flash.helpers; - -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.helpers.Helper; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Stack; - -/** - * Provides methods for highlighting positions of instructions in the text. - * - * @author JPEXS - */ -public class HilightedTextWriter extends GraphTextWriter { - - private final StringBuilder sb = new StringBuilder(); - private final boolean hilight; - private boolean newLine = true; - private int indent = 0; - private final Stack offsets = new Stack<>(); - private boolean toStringCalled = false; - private int newLineCount = 0; - - private final Stack hilightStack = new Stack<>(); - public List traitHilights = new ArrayList<>(); - public List classHilights = new ArrayList<>(); - public List methodHilights = new ArrayList<>(); - public List instructionHilights = new ArrayList<>(); - public List specialHilights = new ArrayList<>(); - - public HilightedTextWriter(CodeFormatting formatting, boolean hilight) { - super(formatting); - this.hilight = hilight; - } - - public HilightedTextWriter(CodeFormatting formatting, boolean hilight, int indent) { - super(formatting); - this.hilight = hilight; - this.indent = indent; - } - - @Override - public boolean getIsHighlighted() { - return hilight; - } - - /** - * Highlights specified text as instruction by adding special tags - * - * @param src - * @param pos Offset of instruction - * @param data - * @return HilightedTextWriter - */ - @Override - public HilightedTextWriter startOffset(GraphSourceItem src, int pos, Map data) { - GraphSourceItemPosition itemPos = new GraphSourceItemPosition(); - itemPos.graphSourceItem = src; - itemPos.position = pos; - itemPos.data = data; - offsets.add(itemPos); - return this; - } - - @Override - public HilightedTextWriter endOffset() { - offsets.pop(); - return this; - } - - /** - * Highlights specified text as method by adding special tags - * - * @param index MethodInfo index - * @return HilightedTextWriter - */ - @Override - public HilightedTextWriter startMethod(long index) { - Map data = new HashMap<>(); - data.put("index", Long.toString(index)); - return start(data, HilightType.METHOD); - } - - @Override - public HilightedTextWriter endMethod() { - return end(HilightType.METHOD); - } - - /** - * Highlights specified text as class by adding special tags - * - * @param index Class index - * @return HilightedTextWriter - */ - @Override - public HilightedTextWriter startClass(long index) { - Map data = new HashMap<>(); - data.put("index", Long.toString(index)); - return start(data, HilightType.CLASS); - } - - @Override - public HilightedTextWriter endClass() { - return end(HilightType.CLASS); - } - - /** - * Highlights specified text as trait by adding special tags - * - * @param index Trait index - * @return HilightedTextWriter - */ - @Override - public HilightedTextWriter startTrait(long index) { - Map data = new HashMap<>(); - data.put("index", Long.toString(index)); - return start(data, HilightType.TRAIT); - } - - @Override - public HilightedTextWriter endTrait() { - return end(HilightType.TRAIT); - } - - @Override - public HilightedTextWriter hilightSpecial(String text, String type) { - return hilightSpecial(text, type, "0"); - } - - @Override - public HilightedTextWriter hilightSpecial(String text, String type, String index) { - return hilightSpecial(text, type, index, new HashMap()); - } - - @Override - 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", index); - start(ndata, HilightType.SPECIAL); - appendNoHilight(text); - return end(HilightType.SPECIAL); - } - - @Override - public HilightedTextWriter append(String str) { - return appendWithData(str, new HashMap()); - } - - @Override - public HilightedTextWriter appendWithData(String str, Map data) { - Highlighting h = null; - if (!offsets.empty()) { - GraphSourceItemPosition itemPos = offsets.peek(); - GraphSourceItem src = itemPos.graphSourceItem; - int pos = itemPos.position; - if (src != null && hilight) { - Map ndata = new HashMap<>(); - ndata.putAll(itemPos.data); - ndata.putAll(data); - ndata.put("offset", Long.toString(src.getOffset() + pos + 1)); - h = new Highlighting(sb.length() - newLineCount, ndata, HilightType.OFFSET, str); - instructionHilights.add(h); - } - } - appendToSb(str); - if (h != null) { - h.len = sb.length() - newLineCount - h.startPos; - } - return this; - } - - @Override - public HilightedTextWriter append(String str, long offset) { - Highlighting h = null; - if (hilight) { - Map data = new HashMap<>(); - data.put("offset", Long.toString(offset)); - h = new Highlighting(sb.length() - newLineCount, data, HilightType.OFFSET, str); - instructionHilights.add(h); - } - appendToSb(str); - if (h != null) { - h.len = sb.length() - newLineCount - h.startPos; - } - return this; - } - - @Override - public HilightedTextWriter appendNoHilight(int i) { - appendNoHilight(Integer.toString(i)); - return this; - } - - @Override - public HilightedTextWriter appendNoHilight(String str) { - appendToSb(str); - return this; - } - - @Override - public HilightedTextWriter indent() { - indent++; - return this; - } - - @Override - public HilightedTextWriter unindent() { - indent--; - return this; - } - - @Override - public HilightedTextWriter newLine() { - appendToSb(formatting.newLineChars); - newLine = true; - newLineCount++; - return this; - } - - @Override - public int getLength() { - return sb.length(); - } - - @Override - public int getIndent() { - return indent; - } - - @Override - public String toString() { - if (toStringCalled) { - throw new Error("HilightedTextWriter.toString() was already called."); - } - if (Configuration.debugMode.get()) { - long stopTime = System.currentTimeMillis(); - long time = stopTime - startTime; - if (time > 500) { - System.out.println("Rendering is too slow: " + Helper.formatTimeSec(time) + " length: " + sb.length()); - } - } - toStringCalled = true; - return sb.toString(); - } - - private HilightedTextWriter start(Map data, HilightType type) { - if (hilight) { - Highlighting h = new Highlighting(sb.length() - newLineCount, data, type, null); - hilightStack.add(h); - } - return this; - } - - private HilightedTextWriter end(HilightType expectedType) { - if (hilight) { - Highlighting h = hilightStack.pop(); - h.len = sb.length() - newLineCount - h.startPos; - - if (!expectedType.equals(h.type)) { - throw new Error("Hilighting mismatch."); - } - - switch (h.type) { - case CLASS: - classHilights.add(h); - break; - case METHOD: - methodHilights.add(h); - break; - case TRAIT: - traitHilights.add(h); - break; - case SPECIAL: - specialHilights.add(h); - break; - case OFFSET: - instructionHilights.add(h); - break; - } - } - return this; - } - - private void appendToSb(String str) { - if (newLine) { - newLine = false; - appendIndent(); - } - sb.append(str); - } - - private void appendIndent() { - for (int i = 0; i < indent; i++) { - appendNoHilight(formatting.indentString); - } - } -} 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 75f10144e..485dda351 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 @@ -16,7 +16,8 @@ */ package com.jpexs.decompiler.flash.helpers; -import java.util.Map; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import java.util.Stack; /** @@ -93,19 +94,7 @@ public class NulWriter extends GraphTextWriter { } @Override - public NulWriter hilightSpecial(String text, String type) { - stringAdded = true; - return this; - } - - @Override - public NulWriter hilightSpecial(String text, String type, String index) { - stringAdded = true; - return this; - } - - @Override - public NulWriter hilightSpecial(String text, String type, String index, Map data) { + public NulWriter hilightSpecial(String text, HighlightSpecialType type, String specialValue, HighlightData data) { stringAdded = true; return this; } @@ -117,7 +106,7 @@ public class NulWriter extends GraphTextWriter { } @Override - public GraphTextWriter appendWithData(String str, Map data) { + public GraphTextWriter appendWithData(String str, HighlightData 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 e046ebf11..69e7ee86f 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 @@ -17,12 +17,9 @@ package com.jpexs.decompiler.flash.helpers.hilight; import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.helpers.HilightType; import java.io.Serializable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Provides methods for highlighting positions of instructions in the text. @@ -31,8 +28,8 @@ import java.util.Map; */ public class Highlighting implements Serializable { - public HilightType type; - public String hilightedText; + public HighlightType type; + public String HighlightedText; /** * Starting position */ @@ -41,55 +38,13 @@ public class Highlighting implements Serializable { * Length of highlighted text */ public int len; - private final Map properties; + private final HighlightData properties; - public Long getPropertyLong(String key) { - String dataStr = getPropertyString(key); - if (dataStr == null) { - return null; - } - try { - return Long.parseLong(dataStr); - } catch (NumberFormatException nfe) { - return null; - } + public HighlightData getProperties() { + return properties; } - public Map getProperties() { - return new HashMap<>(properties); - } - - public String getPropertyString(String key) { - return properties.get(key); - } - - public static Highlighting search(List list, long pos) { - return search(list, pos, null, null, -1, -1); - } - - public static Highlighting search(List list, String property, String value) { - return search(list, -1, property, value, -1, -1); - } - - public static Highlighting search(List list, Map properties) { - return search(list, -1, properties, -1, -1); - } - - public static Highlighting search(List list, String property, String value, int from, int to) { - return search(list, -1, property, value, from, to); - } - - public static Highlighting search(List list, Map properties, int from, int to) { - return search(list, -1, properties, from, to); - } - - public static Highlighting search(List list, long pos, String property, String value, long from, long to) { - Map map = new HashMap<>(); - map.put(property, value); - return search(list, pos, map, from, to); - } - - public static Highlighting search(List list, long pos, Map properties, long from, long to) { + public static Highlighting search(List list, HighlightData properties, long from, long to) { Highlighting ret = null; looph: for (Highlighting h : list) { @@ -103,56 +58,34 @@ public class Highlighting implements Serializable { continue; } } - for (String property : properties.keySet()) { - if (property != null) { - String v = h.getPropertyString(property); - String value = properties.get(property); - if (v == null) { - if (value != null) { - continue looph; - } - } else { - if (!v.equals(value)) { - continue looph; - } - } - } + HighlightData hProp = h.getProperties(); + if (properties.declaration && !hProp.declaration) { + continue; + } + if (properties.declaredType != null && !properties.declaredType.equals(hProp.declaredType)) { + continue; + } + if (properties.localName != null && !properties.localName.equals(hProp.localName)) { + continue; + } + if (properties.specialValue != null && !properties.specialValue.equals(hProp.specialValue)) { + 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; - } - } - if (pos == -1 && ret != null) { - return ret; - } + return h; } - if (Configuration.debugMode.get()) { - if (ret != null) { - System.out.println("Highlight found: " + ret.hilightedText); - } - } - - return ret; + return null; } - public static List searchAll(List list, long pos, String property, String value, long from, long to) { - List ret = new ArrayList<>(); + public static Highlighting searchPos(List list, long pos) { + return searchPos(list, pos, -1, -1); + } + + public static Highlighting searchPos(List list, long pos, long from, long to) { + Highlighting ret = null; + looph: for (Highlighting h : list) { - if (property != null) { - String v = h.getPropertyString(property); - if (v == null) { - if (value != null) { - continue; - } - } else { - if (!v.equals(value)) { - continue; - } - } - } if (from > -1) { if (h.startPos < from) { continue; @@ -164,13 +97,90 @@ public class Highlighting implements Serializable { } } if (pos == -1 || (pos >= h.startPos && (pos < h.startPos + h.len))) { - //if (ret == null || h.startPos > ret.startPos) { //get the closest one - ret.add(h); - //} + if (ret == null || h.startPos > ret.startPos) { //get the closest one + ret = h; + } + } + if (pos == -1 && ret != null) { + return ret; + } + } + + return ret; + } + + public static Highlighting searchOffset(List list, long offset) { + return searchOffset(list, offset, -1, -1); + } + + public static Highlighting searchOffset(List list, long offset, long from, long to) { + looph: + for (Highlighting h : list) { + if (from > -1) { + if (h.startPos < from) { + continue; + } + } + if (to > -1) { + if (h.startPos > to) { + continue; + } + } + if (h.getProperties().offset != offset) { + continue; + } + + return h; + } + + return null; + } + + public static Highlighting searchIndex(List list, long index) { + return searchIndex(list, index, -1, -1); + } + + public static Highlighting searchIndex(List list, long index, long from, long to) { + looph: + for (Highlighting h : list) { + if (from > -1) { + if (h.startPos < from) { + continue; + } + } + if (to > -1) { + if (h.startPos > to) { + continue; + } + } + if (h.getProperties().index != index) { + continue; + } + + return h; + } + + return null; + } + + public static List searchAllPos(List list, long pos) { + List ret = new ArrayList<>(); + for (Highlighting h : list) { + if (pos == -1 || (pos >= h.startPos && (pos < h.startPos + h.len))) { + ret.add(h); + } + } + + return ret; + } + + public static List searchAllIndexes(List list, long index) { + List ret = new ArrayList<>(); + for (Highlighting h : list) { + long i = h.getProperties().index; + if (i == index) { + ret.add(h); } - //if (pos == -1) { - // return ret; - //} } return ret; @@ -193,11 +203,11 @@ public class Highlighting implements Serializable { * @param type Highlighting type * @param text */ - public Highlighting(int startPos, Map data, HilightType type, String text) { + public Highlighting(int startPos, HighlightData data, HighlightType type, String text) { this.startPos = startPos; this.type = type; if (Configuration.debugMode.get()) { - this.hilightedText = text; + this.HighlightedText = text; } this.properties = data; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index d04791ddc..59917a4d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -30,7 +30,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag; import com.jpexs.decompiler.flash.tags.DefineButton2Tag; import com.jpexs.decompiler.flash.tags.DefineButtonCxformTag; @@ -1166,7 +1166,7 @@ public class XFLConverter { } private static String convertActionScript(ASMSource as) { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); try { Action.actionsToSource(as, as.getActions(), as.toString(), writer); } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java index 5d99fdbde..e49e789df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -19,15 +19,14 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; import com.jpexs.decompiler.graph.model.BinaryOp; import com.jpexs.decompiler.graph.model.LocalData; import java.io.Serializable; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; /** @@ -59,7 +58,7 @@ public abstract class GraphTargetItem implements Serializable { public List moreSrc = new ArrayList<>(); public GraphPart firstPart; public GraphTargetItem value; - protected Map srcData = new HashMap<>(); + protected HighlightData srcData = new HighlightData(); public GraphPart getFirstPart() { if (value == null) { @@ -120,7 +119,7 @@ public abstract class GraphTargetItem implements Serializable { public abstract GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException; public String toString(LocalData localData) throws InterruptedException { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); toString(writer, localData); return writer.toString(); } 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 a8793f26c..d4b41d2cd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.decompiler.graph.model.UnboundedTypeItem; import java.util.ArrayList; @@ -72,13 +73,13 @@ public class TypeItem extends GraphTargetItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { if (localData.fullyQualifiedNames.contains(fullTypeName)) { - writer.hilightSpecial(IdentifiersDeobfuscation.printNamespace(localData.constantsAvm2 != null, fullTypeName), "typename", fullTypeName); + writer.hilightSpecial(IdentifiersDeobfuscation.printNamespace(localData.constantsAvm2 != null, fullTypeName), HighlightSpecialType.TYPE_NAME, fullTypeName); } else { String simpleName = fullTypeName; if (simpleName.contains(".")) { simpleName = simpleName.substring(simpleName.lastIndexOf('.') + 1); } - writer.hilightSpecial(IdentifiersDeobfuscation.printNamespace(localData.constantsAvm2 != null, simpleName), "typename", fullTypeName); + writer.hilightSpecial(IdentifiersDeobfuscation.printNamespace(localData.constantsAvm2 != null, simpleName), HighlightSpecialType.TYPE_NAME, fullTypeName); } return writer; diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java index 7b6a598c4..f0145ca31 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.tags.DoActionTag; import java.io.BufferedInputStream; import java.io.FileInputStream; @@ -62,10 +62,10 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase { DoActionTag doa = getFirstActionTag(); doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); Action.actionsToSource(doa, doa.getActions(), "", writer); String actualResult = writer.toString(); - writer = new HilightedTextWriter(new CodeFormatting(), false); + writer = new HighlightedTextWriter(new CodeFormatting(), false); doa.getASMSource(ScriptExportMode.PCODE, writer, null); String decompiled = writer.toString(); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java index 342abfd7f..791a3f870 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java @@ -24,7 +24,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; import com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.graph.CompilationException; import java.io.BufferedInputStream; @@ -56,7 +56,7 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase { private String recompile(String str) throws ActionParseException, IOException, CompilationException, InterruptedException, TimeoutException{ ActionScriptParser par = new ActionScriptParser(SWF.DEFAULT_VERSION); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); List actions = par.actionsFromString(str); byte[] hex = Action.actionsToBytes(actions, true, SWF.DEFAULT_VERSION); ActionList list = ActionListReader.readActionListTimeout(new ArrayList(), new SWFInputStream(swf,hex), SWF.DEFAULT_VERSION, 0, hex.length, ""); @@ -256,7 +256,7 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase { DoActionTag doa = getFirstActionTag(); doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); Action.actionsToSource(doa, doa.getActions(), "", writer); String actualResult = writer.toString(); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java index 02889229f..e3892eb00 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.action.swf5.ActionGetMember; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.tags.DoActionTag; import java.io.BufferedInputStream; import java.io.FileInputStream; @@ -76,7 +76,7 @@ public class ActionScript2ModificationTest extends ActionStript2TestBase { DoActionTag doa = getFirstActionTag(); doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); doa.getASMSource(ScriptExportMode.PCODE, writer, doa.getActions()); String actualResult = normalizeLabels(writer.toString()); @@ -97,7 +97,7 @@ public class ActionScript2ModificationTest extends ActionStript2TestBase { DoActionTag doa = getFirstActionTag(); doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); doa.getASMSource(ScriptExportMode.PCODE, writer, doa.getActions()); String actualResult = normalizeLabels(writer.toString()); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java index 70d5ef741..5d58ef451 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -49,7 +49,7 @@ public class ActionScript2Test extends ActionStript2TestBase { private void compareSrc(int frame, String expectedResult) { DoActionTag doa = getFrameSource(frame); assertNotNull(doa); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); try { Action.actionsToSource(doa, doa.getActions(), "", writer); } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java index bacb4b4bb..1aa7efb14 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -70,10 +70,10 @@ public class ActionScript3Test extends ActionScriptTestBase { private void decompileMethod(String methodName, String expectedResult, boolean isStatic) { int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName); assertTrue(bodyIndex > -1); - HilightedTextWriter writer = null; + HighlightedTextWriter writer = null; try { abc.bodies.get(bodyIndex).convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new ScopeStack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(clsIndex).instance_traits, true); - writer = new HilightedTextWriter(new CodeFormatting(), false); + writer = new HighlightedTextWriter(new CodeFormatting(), false); abc.bodies.get(bodyIndex).toString(methodName, ScriptExportMode.AS, abc, null, abc.constants, abc.method_info, writer, new ArrayList()); } catch (InterruptedException ex) { fail(); @@ -902,7 +902,7 @@ public class ActionScript3Test extends ActionScriptTestBase { int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName); assertTrue(methodInfo > -1); assertTrue(bodyIndex > -1); - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); abc.method_info.get(methodInfo).getParamStr(writer, abc.constants, abc.bodies.get(bodyIndex), abc, new ArrayList()); String actualResult = writer.toString().replaceAll("[ \r\n]", ""); String expectedResult = "p1:Event=null,p2:Number=1,p3:Number=-1,p4:Number=-1.1,p5:Number=-1.1,p6:String=\"a\""; diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java index 84485f140..c103d366f 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/RecompileTest.java @@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -90,7 +90,7 @@ public class RecompileTest { for (int s = 0; s < abc.script_info.size(); s++) { String startAfter = null; - HilightedTextWriter htw = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter htw = new HighlightedTextWriter(new CodeFormatting(), false); MyEntry en = abc.script_info.get(s).getPacks(abc, s).get(0); if (startAfter == null || en.getKey().toString().equals(startAfter)) { dotest = true; @@ -112,7 +112,7 @@ public class RecompileTest { for (ASMSource asm : asms.values()) { try { - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); Action.actionsToSource(asm, asm.getActions(), asm.toString()/*FIXME?*/, writer); String as = writer.toString(); as = asm.removePrefixAndSuffix(as); @@ -122,7 +122,7 @@ public class RecompileTest { } catch (ActionParseException | CompilationException ex) { fail("Unable to parse: " + asm.getSwf().getShortFileName() + "/" + asm.toString()); } - writer = new HilightedTextWriter(new CodeFormatting(), false); + writer = new HighlightedTextWriter(new CodeFormatting(), false); Action.actionsToSource(asm, asm.getActions(), asm.toString()/*FIXME?*/, writer); String as2 = writer.toString(); as2 = asm.removePrefixAndSuffix(as2); @@ -131,7 +131,7 @@ public class RecompileTest { } catch (ActionParseException | CompilationException ex) { fail("Unable to parse: " + asm.getSwf().getShortFileName() + "/" + asm.toString()); } - writer = new HilightedTextWriter(new CodeFormatting(), false); + writer = new HighlightedTextWriter(new CodeFormatting(), false); Action.actionsToSource(asm, asm.getActions(), asm.toString()/*FIXME?*/, writer); String as3 = writer.toString(); as3 = asm.removePrefixAndSuffix(as3); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS2Generator.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS2Generator.java index 16c968476..1f65086a3 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS2Generator.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS2Generator.java @@ -19,7 +19,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; @@ -53,7 +53,7 @@ public class AS2Generator { if (doa == null) { continue; } - HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); Action.actionsToSource(doa, doa.getActions(), "", writer); String src = writer.toString(); if (src.trim().isEmpty()) { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index 231dcbeac..f2c3154fd 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -24,7 +24,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -64,7 +64,7 @@ public class AS3Generator { s.append("(){\r\ndecompileMethod(\""); s.append(name); s.append("\", "); - HilightedTextWriter src = new HilightedTextWriter(new CodeFormatting(), false); + HighlightedTextWriter src = new HighlightedTextWriter(new CodeFormatting(), false); MethodBody b = abc.findBody(((TraitMethodGetterSetter) t).method_info); b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new ScopeStack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(classId).instance_traits, true); b.toString("", ScriptExportMode.AS, abc, null, abc.constants, abc.method_info, src, new ArrayList()); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 981bd8f27..04a24ec98 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -28,8 +28,9 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.GraphDialog; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.HilightedText; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedText; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -54,9 +55,9 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi private final DecompiledEditorPane decompiledEditor; private boolean ignoreCarret = false; private String name; - private HilightedText textWithHex; - private HilightedText textNoHex; - private HilightedText textHexOnly; + private HighlightedText textWithHex; + private HighlightedText textNoHex; + private HighlightedText textHexOnly; private ScriptExportMode exportMode = ScriptExportMode.PCODE; private Trait trait; @@ -68,10 +69,10 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi return exportMode; } - private HilightedText getHilightedText(ScriptExportMode exportMode) { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + private HighlightedText getHighlightedText(ScriptExportMode exportMode) { + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); abc.bodies.get(bodyIndex).getCode().toASMSource(abc.constants, trait, abc.method_info.get(abc.bodies.get(bodyIndex).method_info), abc.bodies.get(bodyIndex), exportMode, writer); - return new HilightedText(writer); + return new HighlightedText(writer); } public void setHex(ScriptExportMode exportMode, boolean force) { @@ -83,21 +84,21 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi if (exportMode == ScriptExportMode.PCODE) { setContentType("text/flasm"); if (textNoHex == null) { - textNoHex = getHilightedText(exportMode); + textNoHex = getHighlightedText(exportMode); } setText(textNoHex); } else if (exportMode == ScriptExportMode.PCODE_HEX) { setContentType("text/flasm"); if (textWithHex == null) { - textWithHex = getHilightedText(exportMode); + textWithHex = getHighlightedText(exportMode); } setText(textWithHex); } else { setContentType("text/plain"); if (textHexOnly == null) { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); Helper.byteArrayToHexWithHeader(writer, abc.bodies.get(bodyIndex).getCode().getBytes()); - textHexOnly = new HilightedText(writer); + textHexOnly = new HighlightedText(writer); } setText(textHexOnly); } @@ -113,11 +114,11 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi addCaretListener(this); } - public void hilighSpecial(String type, String index) { + public void hilighSpecial(HighlightSpecialType type, String specialValue) { Highlighting h2 = null; for (Highlighting sh : specialHilights) { - if (type.equals(sh.getPropertyString("subtype"))) { - if (sh.getPropertyString("index").equals("" + index)) { + if (type.equals(sh.getProperties().subtype)) { + if (sh.getProperties().specialValue.equals(specialValue)) { h2 = sh; break; } @@ -137,7 +138,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi if (isEditable()) { return; } - Highlighting h2 = Highlighting.search(disassembledHilights, "offset", "" + offset); + Highlighting h2 = Highlighting.searchOffset(disassembledHilights, offset); if (h2 != null) { ignoreCarret = true; if (h2.startPos <= getDocument().getLength()) { @@ -236,10 +237,10 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi setCaretPosition(0); } - public void setText(HilightedText hilightedText) { - disassembledHilights = hilightedText.instructionHilights; - specialHilights = hilightedText.specialHilights; - super.setText(hilightedText.text); + public void setText(HighlightedText HighlightedText) { + disassembledHilights = HighlightedText.instructionHilights; + specialHilights = HighlightedText.specialHilights; + super.setText(HighlightedText.text); setCaretPosition(0); } @@ -282,7 +283,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi } public Highlighting getSelectedSpecial() { - return Highlighting.search(specialHilights, getCaretPosition()); + return Highlighting.searchPos(specialHilights, getCaretPosition()); } public long getSelectedOffset() { @@ -294,7 +295,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi } lastH = h; } - return lastH == null ? 0 : lastH.getPropertyLong("offset"); + return lastH == null ? 0 : lastH.getProperties().offset; } @Override @@ -310,7 +311,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi decompiledEditor.hilightOffset(getSelectedOffset()); Highlighting spec = getSelectedSpecial(); if (spec != null) { - decompiledEditor.hilightSpecial(spec.getPropertyString("subtype"), (int) (long) spec.getPropertyLong("index")); + decompiledEditor.hilightSpecial(spec.getProperties().subtype, spec.getProperties().index); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java b/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java index e428163f5..55a98f692 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java @@ -1,65 +1,65 @@ -/* - * Copyright (C) 2010-2014 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 . - */ -package com.jpexs.decompiler.flash.gui.abc; - -import com.jpexs.decompiler.flash.helpers.HilightedText; -import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; -import java.io.Serializable; -import java.util.List; - -/** - * - * @author JPEXS - */ -public class CachedDecompilation implements Serializable { - - public String text; - public List traitHilights; - public List classHilights; - public List methodHilights; - public List instructionHilights; - public List specialHilights; - - public List getInstructionHighlights() { - return instructionHilights; - } - - public List getTraitHighlights() { - return traitHilights; - } - - public List getMethodHighlights() { - return methodHilights; - } - - public List getClassHighlights() { - return classHilights; - } - - public List getSpecialHighligths() { - return specialHilights; - } - - public CachedDecompilation(HilightedText hilightedText) { - this.text = hilightedText.text; - this.traitHilights = hilightedText.traitHilights; - this.classHilights = hilightedText.classHilights; - this.methodHilights = hilightedText.methodHilights; - this.instructionHilights = hilightedText.instructionHilights; - this.specialHilights = hilightedText.specialHilights; - } -} +/* + * Copyright (C) 2010-2014 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 . + */ +package com.jpexs.decompiler.flash.gui.abc; + +import com.jpexs.decompiler.flash.helpers.HighlightedText; +import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; +import java.io.Serializable; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class CachedDecompilation implements Serializable { + + public String text; + public List traitHilights; + public List classHilights; + public List methodHilights; + public List instructionHilights; + public List specialHilights; + + public List getInstructionHighlights() { + return instructionHilights; + } + + public List getTraitHighlights() { + return traitHilights; + } + + public List getMethodHighlights() { + return methodHilights; + } + + public List getClassHighlights() { + return classHilights; + } + + public List getSpecialHighligths() { + return specialHilights; + } + + public CachedDecompilation(HighlightedText HighlightedText) { + this.text = HighlightedText.text; + this.traitHilights = HighlightedText.traitHilights; + this.classHilights = HighlightedText.classHilights; + this.methodHilights = HighlightedText.methodHilights; + this.instructionHilights = HighlightedText.instructionHilights; + this.specialHilights = HighlightedText.specialHilights; + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index f282c657f..3b4d0efc4 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -36,15 +36,16 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.HilightedText; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedText; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.Cache; import java.awt.Point; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Timer; import java.util.TimerTask; import javax.swing.SwingUtilities; @@ -109,7 +110,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null); } - public void hilightSpecial(String type, int index) { + public void hilightSpecial(HighlightSpecialType type, long index) { int startPos; int endPos; if (currentMethodHighlight == null) { @@ -125,7 +126,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL List allh = new ArrayList<>(); for (Highlighting h : traitHighlights) { - if (h.getPropertyString("index").equals("" + lastTraitIndex)) { + if (h.getProperties().index == lastTraitIndex) { for (Highlighting sh : specialHighlights) { if (sh.startPos >= h.startPos && (sh.startPos + sh.len < h.startPos + h.len)) { allh.add(sh); @@ -141,7 +142,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } for (Highlighting h : allh) { - if (h.getPropertyString("subtype").equals(type) && ((long) h.getPropertyLong("index") == index)) { + if (h.getProperties().subtype.equals(type) && (h.getProperties().index == index)) { ignoreCarret = true; if (h.startPos <= getDocument().getLength()) { setCaretPosition(h.startPos); @@ -157,10 +158,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if (currentMethodHighlight == null) { return; } - List allh = new ArrayList<>(); for (Highlighting h : traitHighlights) { - if (h.getPropertyString("index").equals("" + lastTraitIndex)) { - Highlighting h2 = Highlighting.search(highlights, "offset", "" + offset, h.startPos, h.startPos + h.len); + if (h.getProperties().index == lastTraitIndex) { + Highlighting h2 = Highlighting.searchOffset(highlights, offset, h.startPos, h.startPos + h.len); if (h2 != null) { ignoreCarret = true; if (h2.startPos <= getDocument().getLength()) { @@ -208,14 +208,14 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL this.isStatic = isStatic; } boolean success = false; - Highlighting h = Highlighting.search(highlights, pos); + Highlighting h = Highlighting.searchPos(highlights, pos); if (h != null) { - methodCodePanel.hilighOffset(h.getPropertyLong("offset")); + methodCodePanel.hilighOffset(h.getProperties().offset); success = true; } - Highlighting sh = Highlighting.search(specialHighlights, pos); + Highlighting sh = Highlighting.searchPos(specialHighlights, pos); if (sh != null) { - methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), sh.getPropertyString("index")); + methodCodePanel.hilighSpecial(sh.getProperties().subtype, sh.getProperties().specialValue); success = true; } return success; @@ -242,41 +242,43 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } public int getLocalDeclarationOfPos(int pos, Reference type) { - Highlighting sh = Highlighting.search(specialHighlights, pos); - Highlighting h = Highlighting.search(highlights, pos); + Highlighting sh = Highlighting.searchPos(specialHighlights, pos); + Highlighting h = Highlighting.searchPos(highlights, pos); if (h == null) { return -1; } - List tms = Highlighting.searchAll(methodHighlights, pos, null, null, -1, -1); + List tms = Highlighting.searchAllPos(methodHighlights, pos); if (tms.isEmpty()) { return -1; } for (Highlighting tm : tms) { - List tm_tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1); + List tm_tms = Highlighting.searchAllIndexes(methodHighlights, tm.getProperties().index); //is it already declaration? - if ("true".equals(h.getPropertyString("declaration")) || (sh != null && "true".equals(sh.getPropertyString("declaration")))) { + if (h.getProperties().declaration || (sh != null && sh.getProperties().declaration)) { return -1; //no jump } - String lname = h.getPropertyString("localName"); + String lname = h.getProperties().localName; if ("this".equals(lname)) { - Highlighting ch = Highlighting.search(classHighlights, pos); - int cindex = (int) (long) ch.getPropertyLong("index"); + Highlighting ch = Highlighting.searchPos(classHighlights, pos); + int cindex = (int) ch.getProperties().index; type.setVal(abc.instance_info.get(cindex).getName(abc.constants).getNameWithNamespace(abc.constants, true)); return ch.startPos; } - Map search = h.getProperties(); - search.remove("index"); - search.remove("subtype"); - search.remove("offset"); + HighlightData hData = h.getProperties(); + HighlightData search = new HighlightData(); + search.declaration = hData.declaration; + search.declaredType = hData.declaredType; + search.localName = hData.localName; + search.specialValue = hData.specialValue; if (search.isEmpty()) { return -1; } - search.put("declaration", "true"); + search.declaration = true; for (Highlighting tm1 : tm_tms) { Highlighting rh = Highlighting.search(highlights, search, tm1.startPos, tm1.startPos + tm1.len); @@ -284,7 +286,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len); } if (rh != null) { - type.setVal(rh.getPropertyString("declaredType")); + type.setVal(rh.getProperties().declaredType); return rh.startPos; } } @@ -382,27 +384,27 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } public int getMultinameAtPos(int pos, boolean codeOnly) { - Highlighting tm = Highlighting.search(methodHighlights, pos); + Highlighting tm = Highlighting.searchPos(methodHighlights, pos); Trait currentTrait = null; int currentMethod = -1; if (tm != null) { - int mi = (int) (long) tm.getPropertyLong("index"); + int mi = (int) tm.getProperties().index; currentMethod = mi; int bi = abc.findBodyIndex(mi); - Highlighting h = Highlighting.search(highlights, pos); + Highlighting h = Highlighting.searchPos(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()) { + if (h.getProperties().offset == ins.getOffset()) { selIns = ins; break; } - if (ins.getOffset() > h.getPropertyLong("offset")) { - inspos = h.getPropertyLong("offset") - lastIns.offset; + if (ins.getOffset() > h.getProperties().offset) { + inspos = h.getProperties().offset - lastIns.offset; selIns = lastIns; break; } @@ -410,9 +412,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } if (selIns != null) { if (!codeOnly && ((selIns.definition instanceof ConstructSuperIns) || (selIns.definition instanceof CallSuperIns) || (selIns.definition instanceof CallSuperVoidIns))) { - Highlighting tc = Highlighting.search(classHighlights, pos); + Highlighting tc = Highlighting.searchPos(classHighlights, pos); if (tc != null) { - int cindex = (int) (long) tc.getPropertyLong("index"); + int cindex = (int) tc.getProperties().index; if (cindex > -1) { return abc.instance_info.get(cindex).super_index; } @@ -432,22 +434,22 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return -1; } - Highlighting ch = Highlighting.search(classHighlights, pos); + Highlighting ch = Highlighting.searchPos(classHighlights, pos); if (ch != null) { - Highlighting th = Highlighting.search(traitHighlights, pos); + Highlighting th = Highlighting.searchPos(traitHighlights, pos); if (th != null) { - currentTrait = abc.findTraitByTraitId((int) (long) ch.getPropertyLong("index"), (int) (long) th.getPropertyLong("index")); + currentTrait = abc.findTraitByTraitId((int) ch.getProperties().index, (int) th.getProperties().index); } } if (currentTrait instanceof TraitMethodGetterSetter) { currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info; } - Highlighting sh = Highlighting.search(specialHighlights, pos); + Highlighting sh = Highlighting.searchPos(specialHighlights, pos); if (sh != null) { - switch (sh.getPropertyString("subtype")) { - case "typename": - String typeName = sh.getPropertyString("index"); + switch (sh.getProperties().subtype) { + case TYPE_NAME: + String typeName = sh.getProperties().specialValue; for (int i = 1; i < abc.constants.constant_multiname.size(); i++) { Multiname m = abc.constants.constant_multiname.get(i); if (m != null) { @@ -456,25 +458,25 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } } - case "traittypename": + case TRAIT_TYPE_NAME: if (currentTrait instanceof TraitSlotConst) { TraitSlotConst ts = (TraitSlotConst) currentTrait; return ts.type_index; } break; - case "traitname": + case TRAIT_NAME: if (currentTrait != null) { //return currentTrait.name_index; } break; - case "returns": + case RETURNS: if (currentMethod > -1) { return abc.method_info.get(currentMethod).ret_type; } break; - case "param": + case PARAM: if (currentMethod > -1) { - return abc.method_info.get(currentMethod).param_types[(int) (long) sh.getPropertyLong("index")]; + return abc.method_info.get(currentMethod).param_types[(int) sh.getProperties().index]; } break; } @@ -505,12 +507,12 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setIgnoreCarret(true); try { classIndex = -1; - Highlighting cm = Highlighting.search(classHighlights, pos); + Highlighting cm = Highlighting.searchPos(classHighlights, pos); if (cm != null) { - classIndex = (int) (long) cm.getPropertyLong("index"); + classIndex = (int) cm.getProperties().index; displayClass(classIndex, script.scriptIndex); } - Highlighting tm = Highlighting.search(methodHighlights, pos); + Highlighting tm = Highlighting.searchPos(methodHighlights, pos); if (tm != null) { String name = ""; if (abc != null) { @@ -519,9 +521,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } Trait currentTrait = null; - currentTraitHighlight = Highlighting.search(traitHighlights, pos); + currentTraitHighlight = Highlighting.searchPos(traitHighlights, pos); if (currentTraitHighlight != null) { - lastTraitIndex = (int) (long) currentTraitHighlight.getPropertyLong("index"); + lastTraitIndex = (int) currentTraitHighlight.getProperties().index; if ((abc != null) && (classIndex != -1)) { currentTrait = getCurrentTrait(); isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); @@ -531,7 +533,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } - displayMethod(pos, (int) (long) tm.getPropertyLong("index"), name, currentTrait, isStatic); + displayMethod(pos, (int) tm.getProperties().index, name, currentTrait, isStatic); currentMethodHighlight = tm; return; } @@ -541,9 +543,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return; } Trait currentTrait; - currentTraitHighlight = Highlighting.search(traitHighlights, pos); + currentTraitHighlight = Highlighting.searchPos(traitHighlights, pos); if (currentTraitHighlight != null) { - lastTraitIndex = (int) (long) currentTraitHighlight.getPropertyLong("index"); + lastTraitIndex = (int) currentTraitHighlight.getProperties().index; currentTrait = getCurrentTrait(); if (currentTrait != null) { if (currentTrait instanceof TraitSlotConst) { @@ -552,7 +554,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD, currentTrait); abcPanel.detailPanel.setEditMode(false); currentMethodHighlight = null; - Highlighting spec = Highlighting.search(specialHighlights, pos, null, null, currentTraitHighlight.startPos, currentTraitHighlight.startPos + currentTraitHighlight.len); + Highlighting spec = Highlighting.searchPos(specialHighlights, pos, currentTraitHighlight.startPos, currentTraitHighlight.startPos + currentTraitHighlight.len); if (spec != null) { abcPanel.detailPanel.slotConstTraitPanel.hilightSpecial(spec); } @@ -610,9 +612,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return; } - Highlighting tc = Highlighting.search(classHighlights, "index", "" + classIndex); + Highlighting tc = Highlighting.searchIndex(classHighlights, classIndex); if (tc != null) { - Highlighting th = Highlighting.search(traitHighlights, "index", "" + traitId, tc.startPos, tc.startPos + tc.len); + Highlighting th = Highlighting.searchIndex(traitHighlights, traitId, tc.startPos, tc.startPos + tc.len); if (th != null) { ignoreCarret = true; int startPos = th.startPos + th.len - 1; @@ -659,9 +661,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } if (!cache.contains(scriptLeaf)) { boolean parallel = Configuration.parallelSpeedUp.get(); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); scriptLeaf.toSource(writer, abcList, script.traits.traits, ScriptExportMode.AS, parallel); - HilightedText hilightedCode = new HilightedText(writer); + HighlightedText hilightedCode = new HighlightedText(writer); cache.put(scriptLeaf, new CachedDecompilation(hilightedCode)); } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java b/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java index 085fb098b..768c468da 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import java.awt.BorderLayout; import java.awt.Font; import java.awt.Insets; @@ -64,8 +65,8 @@ public class MethodCodePanel extends JPanel implements ActionListener { sourceTextArea.hilighOffset(offset); } - public void hilighSpecial(String type, String index) { - sourceTextArea.hilighSpecial(type, index); + public void hilighSpecial(HighlightSpecialType type, String specialValue) { + sourceTextArea.hilighSpecial(type, specialValue); } public void setBodyIndex(int bodyIndex, ABC abc, Trait trait) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index ad2c7548e..975a36c46 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -24,7 +24,8 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import java.awt.BorderLayout; import java.io.IOException; @@ -63,9 +64,9 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { if (ignoreCaret) { return; } - Highlighting spec = Highlighting.search(specialHilights, slotConstEditor.getCaretPosition()); + Highlighting spec = Highlighting.searchPos(specialHilights, slotConstEditor.getCaretPosition()); if (spec != null) { - editor.hilightSpecial(spec.getPropertyString("subtype"), (int) (long) spec.getPropertyLong("index")); + editor.hilightSpecial(spec.getProperties().subtype, (int) spec.getProperties().index); slotConstEditor.getCaret().setVisible(true); } } @@ -75,8 +76,8 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { public void hilightSpecial(Highlighting special) { Highlighting sel = null; for (Highlighting h : specialHilights) { - if (h.getPropertyString("subtype").equals(special.getPropertyString("subtype"))) { - if (h.getPropertyString("index").equals(special.getPropertyString("index"))) { + if (h.getProperties().subtype.equals(special.getProperties().subtype)) { + if (h.getProperties().index == special.getProperties().index) { sel = h; break; } @@ -93,17 +94,17 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { public void load(TraitSlotConst trait, ABC abc, boolean isStatic) { this.abc = abc; this.trait = trait; - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); writer.appendNoHilight("trait "); - writer.hilightSpecial(abc.constants.multinameToString(trait.name_index), "traitname"); + writer.hilightSpecial(abc.constants.multinameToString(trait.name_index), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight(" "); - writer.hilightSpecial(trait.isConst() ? "const" : "slot", "traittype"); + writer.hilightSpecial(trait.isConst() ? "const" : "slot", HighlightSpecialType.TRAIT_TYPE); writer.appendNoHilight(" slotid "); - writer.hilightSpecial("" + trait.slot_id, "slotid"); + writer.hilightSpecial("" + trait.slot_id, HighlightSpecialType.SLOT_ID); writer.appendNoHilight(" type "); - writer.hilightSpecial(abc.constants.multinameToString(trait.type_index), "traittypename"); + writer.hilightSpecial(abc.constants.multinameToString(trait.type_index), HighlightSpecialType.TRAIT_TYPE_NAME); writer.appendNoHilight(" value "); - writer.hilightSpecial((new ValueKind(trait.value_index, trait.value_kind).toASMString(abc.constants)), "traitvalue"); + writer.hilightSpecial((new ValueKind(trait.value_index, trait.value_kind).toASMString(abc.constants)), HighlightSpecialType.TRAIT_VALUE); String s = writer.toString(); specialHilights = writer.specialHilights; showWarning = trait.isConst() || isStatic; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java b/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java index 3112d43e5..6472697f4 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java @@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.AppStrings; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.ArrayList; @@ -90,12 +90,12 @@ public class TraitsListItem { try { if ((type != Type.INITIALIZER) && isStatic) { abc.class_info.get(classIndex).static_traits.traits.get(index).convertHeader(null, "", abcTags, abc, true, ScriptExportMode.AS, scriptIndex, classIndex, new NulWriter(), new ArrayList(), false); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); abc.class_info.get(classIndex).static_traits.traits.get(index).toStringHeader(null, "", abcTags, abc, true, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList(), false); s = writer.toString(); } else if ((type != Type.INITIALIZER) && (!isStatic)) { abc.instance_info.get(classIndex).instance_traits.traits.get(index).convertHeader(null, "", abcTags, abc, false, ScriptExportMode.AS, scriptIndex, classIndex, new NulWriter(), new ArrayList(), false); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); abc.instance_info.get(classIndex).instance_traits.traits.get(index).toStringHeader(null, "", abcTags, abc, false, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList(), false); s = writer.toString(); } else if (!isStatic) { diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index af5f686a2..f5f544325 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -42,8 +42,8 @@ import com.jpexs.decompiler.flash.gui.SearchResultsDialog; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel; -import com.jpexs.decompiler.flash.helpers.HilightedText; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.HighlightedText; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.CompilationException; @@ -123,9 +123,9 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene private ActionList lastCode; private ASMSource src; public JPanel topButtonsPan; - private HilightedText srcWithHex; - private HilightedText srcNoHex; - private HilightedText srcHexOnly; + private HighlightedText srcWithHex; + private HighlightedText srcNoHex; + private HighlightedText srcHexOnly; private String lastDecompiled = ""; private ASMSource lastASM; public SearchPanel searchPanel; @@ -172,19 +172,19 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } } if (ident == null) { - Highlighting h = Highlighting.search(decompiledHilights, pos); + Highlighting h = Highlighting.searchPos(decompiledHilights, pos); if (h != null) { List list = lastCode; Action lastIns = null; int inspos = 0; Action selIns = null; for (Action ins : list) { - if (h.getPropertyLong("offset") == ins.getOffset()) { + if (h.getProperties().offset == ins.getOffset()) { selIns = ins; break; } - if (ins.getOffset() > h.getPropertyLong("offset")) { - inspos = (int) (h.getPropertyLong("offset") - lastIns.getAddress()); + if (ins.getOffset() > h.getProperties().offset) { + inspos = (int) (h.getProperties().offset - lastIns.getAddress()); selIns = lastIns; break; } @@ -226,7 +226,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene if (actions == null) { actions = src.getActions(); } - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); Action.actionsToSource(src, actions, src.toString()/*FIXME?*/, writer); List hilights = writer.instructionHilights; String srcNoHex = writer.toString(); @@ -306,7 +306,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene }); } - private void setText(final HilightedText text, final String contentType) { + private void setText(final HighlightedText text, final String contentType) { View.execInEventDispatch(new Runnable() { @Override @@ -319,11 +319,11 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } lastH = h; } - String offset = lastH == null ? "0" : lastH.getPropertyString("offset"); + Long offset = lastH == null ? 0 : lastH.getProperties().offset; disassembledHilights = text.instructionHilights; String stripped = text.text; setEditorText(stripped, contentType); - Highlighting h = Highlighting.search(disassembledHilights, "offset", offset); + Highlighting h = Highlighting.searchOffset(disassembledHilights, offset); if (h != null) { if (h.startPos <= editor.getDocument().getLength()) { editor.setCaretPosition(h.startPos); @@ -333,38 +333,38 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene }); } - private HilightedText getHilightedText(ScriptExportMode exportMode) { + private HighlightedText getHighlightedText(ScriptExportMode exportMode) { ASMSource asm = (ASMSource) src; DisassemblyListener listener = getDisassemblyListener(); asm.addDisassemblyListener(listener); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); try { asm.getASMSource(exportMode, writer, lastCode); } catch (InterruptedException ex) { Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex); } asm.removeDisassemblyListener(listener); - return new HilightedText(writer); + return new HighlightedText(writer); } public void setHex(ScriptExportMode exportMode) { if (exportMode != ScriptExportMode.HEX) { if (exportMode == ScriptExportMode.PCODE) { if (srcNoHex == null) { - srcNoHex = getHilightedText(exportMode); + srcNoHex = getHighlightedText(exportMode); } setText(srcNoHex, "text/flasm"); } else { if (srcWithHex == null) { - srcWithHex = getHilightedText(exportMode); + srcWithHex = getHighlightedText(exportMode); } setText(srcWithHex, "text/flasm"); } } else { if (srcHexOnly == null) { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); Helper.byteArrayToHexWithHeader(writer, src.getActionBytes()); - srcHexOnly = new HilightedText(writer); + srcHexOnly = new HighlightedText(writer); } setText(srcHexOnly, "text/plain"); } @@ -606,8 +606,8 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } lastH = h; } - String ofs = lastH == null ? "0" : lastH.getPropertyString("offset"); - Highlighting h2 = Highlighting.search(decompiledHilights, "offset", ofs); + Long ofs = lastH == null ? 0 : lastH.getProperties().offset; + Highlighting h2 = Highlighting.searchOffset(decompiledHilights, ofs); if (h2 != null) { ignoreCarret = true; if (h2.startPos <= decompiledEditor.getDocument().getLength()) { @@ -630,9 +630,9 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } decompiledEditor.getCaret().setVisible(true); int pos = decompiledEditor.getCaretPosition(); - Highlighting h = Highlighting.search(decompiledHilights, pos); + Highlighting h = Highlighting.searchPos(decompiledHilights, pos); if (h != null) { - Highlighting h2 = Highlighting.search(disassembledHilights, "offset", h.getPropertyString("offset")); + Highlighting h2 = Highlighting.searchOffset(disassembledHilights, h.getProperties().offset); if (h2 != null) { ignoreCarret = true; if (h2.startPos > 0 && h2.startPos < editor.getText().length()) {