From bea3babacfe02c4431e045b3586f3f63715d9acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 31 Oct 2014 16:42:08 +0100 Subject: [PATCH] Issue #302 AS3 goto local variable declaration Ant upload release/nightly task --- .gitignore | 6 +- build.xml | 2 + build_common.xml | 57 +- .../flash/abc/avm2/model/GetSlotAVM2Item.java | 2 + .../abc/avm2/model/LocalRegAVM2Item.java | 1 + .../abc/avm2/model/NewFunctionAVM2Item.java | 9 +- .../abc/avm2/model/SetLocalAVM2Item.java | 1 + .../flash/abc/avm2/model/SetSlotAVM2Item.java | 7 +- .../model/clauses/DeclarationAVM2Item.java | 9 +- .../flash/abc/types/MethodBody.java | 8 +- .../flash/abc/types/MethodInfo.java | 18 +- .../flash/abc/types/traits/TraitClass.java | 4 + .../flash/abc/types/traits/TraitFunction.java | 4 + .../types/traits/TraitMethodGetterSetter.java | 4 + .../flash/helpers/FileTextWriter.java | 12 +- .../helpers/GraphSourceItemPosition.java | 5 +- .../flash/helpers/GraphTextWriter.java | 16 +- .../flash/helpers/HilightedTextWriter.java | 38 +- .../decompiler/flash/helpers/NulWriter.java | 20 +- .../flash/helpers/hilight/Highlighting.java | 87 +- .../decompiler/graph/GraphTargetItem.java | 14 +- libsrc/uploader/build.xml | 12 + libsrc/uploader/manifest.mf | 3 + libsrc/uploader/nbproject/build-impl.xml | 1413 +++++++++++++++++ libsrc/uploader/nbproject/genfiles.properties | 8 + libsrc/uploader/nbproject/project.properties | 75 + libsrc/uploader/nbproject/project.xml | 15 + .../src/com/jpexs/uploader/Uploader.java | 201 +++ .../decompiler/flash/gui/abc/ABCPanel.java | 11 +- .../flash/gui/abc/DecompiledEditorPane.java | 43 +- uploader.jar | Bin 0 -> 7677 bytes 31 files changed, 2051 insertions(+), 54 deletions(-) create mode 100644 libsrc/uploader/build.xml create mode 100644 libsrc/uploader/manifest.mf create mode 100644 libsrc/uploader/nbproject/build-impl.xml create mode 100644 libsrc/uploader/nbproject/genfiles.properties create mode 100644 libsrc/uploader/nbproject/project.properties create mode 100644 libsrc/uploader/nbproject/project.xml create mode 100644 libsrc/uploader/src/com/jpexs/uploader/Uploader.java create mode 100644 uploader.jar diff --git a/.gitignore b/.gitignore index b562aac77..ec7bd22d3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,8 @@ hs_err_pid*.log /libsrc/ttf/build/ /libsrc/tablelayout/nbproject/private/ /libsrc/tablelayout/build/ -/libsrc/tablelayout/dist/ \ No newline at end of file +/libsrc/tablelayout/dist/ +/libsrc/uploader/nbproject/private/ +/libsrc/uploader/build/ +/libsrc/uploader/dist/ +jpexs_website.properties \ No newline at end of file diff --git a/build.xml b/build.xml index d110a5167..dae2f7257 100644 --- a/build.xml +++ b/build.xml @@ -59,5 +59,7 @@ + + diff --git a/build_common.xml b/build_common.xml index a6ea1a799..fde0d5206 100644 --- a/build_common.xml +++ b/build_common.xml @@ -19,7 +19,7 @@ - + @@ -116,6 +116,7 @@ + @@ -129,7 +130,8 @@ - + + @@ -252,6 +254,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -289,7 +339,8 @@ ------------------------------------------------------------------- Please follow instructions on http://www.free-decompiler.com/flash/translations.html - + + 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 4d7e46540..9eeb23118 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,6 +39,8 @@ public class GetSlotAVM2Item extends AVM2Item { if (slotName == null) { return writer.append("/*UnknownSlot*/"); } + srcData.put("slotName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index eade21726..6687ff22b 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 @@ -56,6 +56,7 @@ public class LocalRegAVM2Item extends AVM2Item { } } this.computedValue = computedValue; + srcData.put("regIndex", ""+regIndex); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 5235ec339..f05d982c8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -60,8 +60,9 @@ public class NewFunctionAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { MethodBody body = abc.findBody(methodIndex); - writer.append("function" + (!functionName.isEmpty() ? " " + functionName : "")); - writer.startMethod(methodIndex); + writer.append("function"); + writer.startMethod(methodIndex); + writer.append((!functionName.isEmpty() ? " " + functionName : "")); writer.appendNoHilight("("); methodInfo.get(methodIndex).getParamStr(writer, constants, body, abc, fullyQualifiedNames); writer.appendNoHilight("):"); @@ -70,8 +71,7 @@ public class NewFunctionAVM2Item extends AVM2Item { writer.appendNoHilight(abc.findBodyIndex(methodIndex)); writer.newLine(); } - methodInfo.get(methodIndex).getReturnTypeStr(writer, constants, fullyQualifiedNames); - writer.endMethod(); + methodInfo.get(methodIndex).getReturnTypeStr(writer, constants, fullyQualifiedNames); writer.startBlock(); if (body != null) { if (writer instanceof NulWriter) { @@ -81,6 +81,7 @@ public class NewFunctionAVM2Item extends AVM2Item { } } writer.endBlock(); + writer.endMethod(); return writer; } 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 fad801495..194dfa8c8 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 @@ -43,6 +43,7 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig super(instruction, PRECEDENCE_ASSIGMENT); this.regIndex = regIndex; this.value = value; + srcData.put("regIndex", ""+regIndex); } @Override 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 f59460a9a..74c30145e 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 @@ -35,7 +35,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign super(instruction, PRECEDENCE_ASSIGMENT); this.slotName = slotName; this.value = value; - this.scope = scope; + this.scope = scope; } @Override @@ -45,11 +45,16 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + srcData.put("slotName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); getName(writer, localData); writer.append(" = "); return value.toString(writer, localData); } + public String getNameAsStr(LocalData localData){ + return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); + } + public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) { /*ret = scope.toString(constants, localRegNames) + "."; if (!(scope instanceof NewActivationAVM2Item)) { 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 c4a38e7d8..2beec664b 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 @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.clauses; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; @@ -46,8 +47,10 @@ public class DeclarationAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (assignment instanceof SetLocalAVM2Item) { + if (assignment instanceof SetLocalAVM2Item) { SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment; + srcData.put("regIndex",""+lti.regIndex); + srcData.put("declaration", "true"); GraphTargetItem coerType = TypeItem.UNBOUNDED; if (lti.value instanceof CoerceAVM2Item) { coerType = ((CoerceAVM2Item) lti.value).typeObj; @@ -64,6 +67,8 @@ public class DeclarationAVM2Item extends AVM2Item { } if (assignment instanceof SetSlotAVM2Item) { SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment; + srcData.put("slotName",""+ssti.getNameAsStr(localData)); + srcData.put("declaration", "true"); writer.append("var "); ssti.getName(writer, localData); writer.append(":"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 54e772e22..c708fd97a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -204,23 +204,23 @@ public class MethodBody implements Cloneable { getCode().toASMSource(constants, trait, method_info.get(this.method_info), this, exportMode, writer); } else { if (!Configuration.decompile.get()) { - writer.startMethod(this.method_info); + //writer.startMethod(this.method_info); writer.appendNoHilight("//" + AppResources.translate("decompilation.skipped")).newLine(); - writer.endMethod(); + //writer.endMethod(); return writer; } int timeout = Configuration.decompilationTimeoutSingleMethod.get(); if (convertException == null) { HashMap localRegNames = getLocalRegNames(abc); - writer.startMethod(this.method_info); + //writer.startMethod(this.method_info); if (Configuration.showMethodBodyId.get()) { writer.appendNoHilight("// method body id: "); writer.appendNoHilight(abc.findBodyIndex(this.method_info)); writer.newLine(); } Graph.graphToString(convertedItems, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); - writer.endMethod(); + //writer.endMethod(); } else if (convertException instanceof TimeoutException) { Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); Helper.appendTimeoutComment(writer, timeout); 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 b04153558..3a6811177 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 @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; +import java.util.Map; public class MethodInfo { @@ -271,16 +272,22 @@ public class MethodInfo { if (body != null) { localRegNames = body.getCode().getLocalRegNamesFromDebug(abc); } + Map pdata; + for (int i = 0; i < param_types.length; i++) { if (i > 0) { writer.appendNoHilight(", "); } + pdata=new HashMap<>(); + pdata.put("declaration", "true"); + pdata.put("regIndex", ""+(i+1)); if (!localRegNames.isEmpty()) { - writer.appendNoHilight(Deobfuscation.printIdentifier(localRegNames.get(i + 1))); + pdata.put("slotName", localRegNames.get(i + 1)); //assuming it is a slot + writer.hilightSpecial(Deobfuscation.printIdentifier(localRegNames.get(i + 1)),"paramname",i,pdata); } else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) { - writer.appendNoHilight(Deobfuscation.printIdentifier(constants.getString(paramNames[i]))); + writer.hilightSpecial(Deobfuscation.printIdentifier(constants.getString(paramNames[i])),"paramname",i,pdata); } else { - writer.appendNoHilight("param" + (i + 1)); + writer.hilightSpecial("param" + (i + 1),"paramname",i,pdata); } writer.appendNoHilight(":"); if (param_types[i] == 0) { @@ -307,7 +314,10 @@ public class MethodInfo { } else { restAdd += "rest"; } - writer.hilightSpecial(restAdd, "flag.NEED_REST"); + pdata=new HashMap<>(); + pdata.put("declaration", "true"); + pdata.put("regIndex", ""+(param_types.length + 1)); + writer.hilightSpecial(restAdd, "flag.NEED_REST",0,pdata); } return writer; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 9aea8dc2c..d9c375399 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -458,9 +458,11 @@ public class TraitClass extends Trait implements TraitWithSlot { if (!classInitializerIsEmpty) { writer.newLine(); writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size() + 1); + writer.startMethod(abc.class_info.get(class_info).cinit_index); writer.appendNoHilight("{").newLine(); abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false) + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); writer.appendNoHilight("}").newLine(); + writer.endMethod(); writer.endTrait(); } } else { @@ -486,6 +488,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.newLine(); writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size()); + writer.startMethod(abc.instance_info.get(class_info).iinit_index); writer.appendNoHilight(modifier); writer.appendNoHilight("function "); writer.appendNoHilight(abc.constants.getMultiname(abc.instance_info.get(class_info).name_index).getName(abc.constants, new ArrayList()/*do not want full names here*/, false)); @@ -501,6 +504,7 @@ public class TraitClass extends Trait implements TraitWithSlot { abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false) + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); } writer.endBlock().newLine(); + writer.endMethod(); writer.endTrait(); } 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 df43f607d..bab331ccc 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 @@ -73,6 +73,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { @Override public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + writer.startMethod(method_info); toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); if (abc.instance_info.get(classIndex).isInterface()) { writer.appendNoHilight(";"); @@ -86,11 +87,13 @@ public class TraitFunction extends Trait implements TraitWithSlot { writer.appendNoHilight("}"); } writer.newLine(); + writer.endMethod(); return writer; } @Override public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + writer.startMethod(method_info); convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); if (!abc.instance_info.get(classIndex).isInterface()) { int bodyIndex = abc.findBodyIndex(method_info); @@ -98,6 +101,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, null, true); } } + writer.endMethod(); } @Override 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 72ca419cd..069b3a825 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 @@ -77,6 +77,7 @@ public class TraitMethodGetterSetter extends Trait { @Override public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + writer.startMethod(method_info); path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false); convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); @@ -85,10 +86,12 @@ public class TraitMethodGetterSetter extends Trait { abc.bodies.get(bodyIndex).convert(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, null, true); } } + writer.endMethod(); } @Override public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + writer.startMethod(method_info); path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false); toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); @@ -102,6 +105,7 @@ public class TraitMethodGetterSetter extends Trait { writer.endBlock(); } writer.newLine(); + writer.endMethod(); return writer; } 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 8479ba44f..842d85fa7 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 @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.helpers; import com.jpexs.helpers.utf8.Utf8OutputStreamWriter; @@ -20,6 +21,7 @@ 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; @@ -58,6 +60,14 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable { return this; } + @Override + public GraphTextWriter appendWithData(String str, Map data) { + writeToFile(str); + return this; + } + + + @Override public FileTextWriter append(String str, long offset) { writeToFile(str); 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 bd71903b4..3c2228c3d 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 @@ -12,10 +12,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.graph.GraphSourceItem; +import java.util.Map; /** * Provides methods for highlighting positions of instructions in the text. @@ -26,5 +28,6 @@ public class GraphSourceItemPosition { public GraphSourceItem graphSourceItem; public int position; + public Map 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 bb40a696a..9852ae9e6 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 @@ -12,10 +12,13 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.graph.GraphSourceItem; +import java.util.HashMap; +import java.util.Map; /** * Provides methods for highlighting positions of instructions in the text. @@ -46,9 +49,10 @@ public abstract class GraphTextWriter { * * @param src * @param pos Offset of instruction + * @param data * @return GraphTextWriter */ - public GraphTextWriter startOffset(GraphSourceItem src, int pos) { + public GraphTextWriter startOffset(GraphSourceItem src, int pos, Map data) { return this; } @@ -99,10 +103,14 @@ public abstract class GraphTextWriter { } public GraphTextWriter hilightSpecial(String text, String type) { - return this; + return hilightSpecial(text, type, 0); } public GraphTextWriter hilightSpecial(String text, String type, int index) { + return hilightSpecial(text, type, 0, new HashMap()); + } + + public GraphTextWriter hilightSpecial(String text, String type, int index, Map data) { return this; } @@ -110,6 +118,8 @@ public abstract class GraphTextWriter { return ""; } + public abstract GraphTextWriter appendWithData(String str, Map data); + public abstract GraphTextWriter append(String str); public abstract GraphTextWriter append(String str, long offset); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java index 9027ee6cf..099762b60 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.flash.configuration.Configuration; @@ -68,13 +69,15 @@ public class HilightedTextWriter extends GraphTextWriter { * * @param src * @param pos Offset of instruction + * @param data * @return HilightedTextWriter */ @Override - public HilightedTextWriter startOffset(GraphSourceItem src, int pos) { + 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; } @@ -146,25 +149,42 @@ public class HilightedTextWriter extends GraphTextWriter { @Override public HilightedTextWriter hilightSpecial(String text, String type, int index) { - Map data = new HashMap<>(); - data.put("subtype", type); - data.put("index", Long.toString(index)); - start(data, HilightType.SPECIAL); + return hilightSpecial(text, type, index, new HashMap()); + } + + @Override + public HilightedTextWriter hilightSpecial(String text, String type, int index, Map data) { + Map ndata = new HashMap<>(); + ndata.putAll(data); + ndata.put("subtype", type); + ndata.put("index", Long.toString(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 data = new HashMap<>(); - data.put("offset", Long.toString(src.getOffset() + pos + 1)); - h = new Highlighting(sb.length() - newLineCount, data, HilightType.OFFSET, str); + 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); } } 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 3d19e866a..90484e158 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 @@ -12,9 +12,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.helpers; +import java.util.Map; import java.util.Stack; /** @@ -102,12 +104,28 @@ public class NulWriter extends GraphTextWriter { return this; } + @Override + public NulWriter hilightSpecial(String text, String type, int index, Map data) { + stringAdded = true; + return this; + } + + + @Override public NulWriter append(String str) { stringAdded = true; return this; } + @Override + public GraphTextWriter appendWithData(String str, Map data) { + stringAdded = true; + return this; + } + + + @Override public NulWriter append(String str, long offset) { stringAdded = true; 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 fb8428cc7..c7c24290a 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 @@ -12,12 +12,15 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.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; @@ -52,6 +55,12 @@ public class Highlighting implements Serializable { } } + public Map getProperties() { + return new HashMap<>(properties); + } + + + public String getPropertyString(String key) { return properties.get(key); } @@ -63,23 +72,39 @@ public class Highlighting implements Serializable { 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) { Highlighting ret = null; - 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; + looph:for (Highlighting h : list) { + 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; + } } } } @@ -112,6 +137,44 @@ public class Highlighting implements Serializable { return ret; } + public static List searchAll(List list, long pos, String property, String value, long from, long to) { + List ret = new ArrayList<>(); + 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; + } + } + if (to > -1) { + if (h.startPos > to) { + continue; + } + } + if (pos == -1 ||(pos >= h.startPos && (pos < h.startPos + h.len))) { + //if (ret == null || h.startPos > ret.startPos) { //get the closest one + ret.add(h); + //} + } + //if (pos == -1) { + // return ret; + //} + } + + return ret; + } + /** * Returns a string representation of the object * 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 39fb2e4cd..eaf9d778b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -23,8 +24,10 @@ 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; /** @@ -56,6 +59,7 @@ public abstract class GraphTargetItem implements Serializable { public List moreSrc = new ArrayList<>(); public GraphPart firstPart; public GraphTargetItem value; + protected Map srcData = new HashMap(); public GraphPart getFirstPart() { if (value == null) { @@ -88,7 +92,7 @@ public abstract class GraphTargetItem implements Serializable { } public GraphTextWriter toStringSemicoloned(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.startOffset(src, pos); + writer.startOffset(src, pos, srcData); appendTo(writer, localData); if (needsSemicolon()) { writer.append(";"); @@ -107,7 +111,7 @@ public abstract class GraphTargetItem implements Serializable { } public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.startOffset(src, pos); + writer.startOffset(src, pos, srcData); appendTo(writer, localData); writer.endOffset(); return writer; @@ -152,7 +156,7 @@ public abstract class GraphTargetItem implements Serializable { } public GraphTextWriter toStringNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.startOffset(src, pos); + writer.startOffset(src, pos, srcData); appendToNoQuotes(writer, localData); writer.endOffset(); return writer; @@ -175,7 +179,7 @@ public abstract class GraphTargetItem implements Serializable { } public GraphTextWriter toStringNL(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.startOffset(src, pos); + writer.startOffset(src, pos, srcData); appendTo(writer, localData); if (needsNewLine()) { writer.newLine(); diff --git a/libsrc/uploader/build.xml b/libsrc/uploader/build.xml new file mode 100644 index 000000000..22aa4bc50 --- /dev/null +++ b/libsrc/uploader/build.xml @@ -0,0 +1,12 @@ + + + Builds, tests, and runs the project uploader. + + + + + + + + + diff --git a/libsrc/uploader/manifest.mf b/libsrc/uploader/manifest.mf new file mode 100644 index 000000000..328e8e5bc --- /dev/null +++ b/libsrc/uploader/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/libsrc/uploader/nbproject/build-impl.xml b/libsrc/uploader/nbproject/build-impl.xml new file mode 100644 index 000000000..6a610d8e6 --- /dev/null +++ b/libsrc/uploader/nbproject/build-impl.xml @@ -0,0 +1,1413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/uploader/nbproject/genfiles.properties b/libsrc/uploader/nbproject/genfiles.properties new file mode 100644 index 000000000..ea01b807b --- /dev/null +++ b/libsrc/uploader/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=50abf8ab +build.xml.script.CRC32=319eb7df +build.xml.stylesheet.CRC32=8064a381@1.74.2.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=50abf8ab +nbproject/build-impl.xml.script.CRC32=0856044a +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.74.2.48 diff --git a/libsrc/uploader/nbproject/project.properties b/libsrc/uploader/nbproject/project.properties new file mode 100644 index 000000000..b1f85ffa4 --- /dev/null +++ b/libsrc/uploader/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=uploader +application.vendor=JPEXS +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=../../uploader.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=com.jpexs.uploader.Uploader +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/libsrc/uploader/nbproject/project.xml b/libsrc/uploader/nbproject/project.xml new file mode 100644 index 000000000..5d99e0282 --- /dev/null +++ b/libsrc/uploader/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + uploader + + + + + + + + + diff --git a/libsrc/uploader/src/com/jpexs/uploader/Uploader.java b/libsrc/uploader/src/com/jpexs/uploader/Uploader.java new file mode 100644 index 000000000..c2d7895f7 --- /dev/null +++ b/libsrc/uploader/src/com/jpexs/uploader/Uploader.java @@ -0,0 +1,201 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.jpexs.uploader; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Uploader { + + private static class MultipartUtility { + private final String boundary; + private static final String LINE_FEED = "\r\n"; + private HttpURLConnection httpConn; + private String charset; + private OutputStream outputStream; + private PrintWriter writer; + + /** + * This constructor initializes a new HTTP POST request with content + * type is set to multipart/form-data + * + * @param requestURL + * @param charset + * @throws IOException + */ + public MultipartUtility(String requestURL, String charset) + throws IOException { + this.charset = charset; + + // creates a unique boundary based on time stamp + boundary = "===" + System.currentTimeMillis() + "==="; + + URL url = new URL(requestURL); + httpConn = (HttpURLConnection) url.openConnection(); + httpConn.setUseCaches(false); + httpConn.setDoOutput(true); // indicates POST method + httpConn.setDoInput(true); + httpConn.setRequestProperty("Content-Type", + "multipart/form-data; boundary=" + boundary); + httpConn.setRequestProperty("User-Agent", "JPEXS Uploader"); + outputStream = httpConn.getOutputStream(); + writer = new PrintWriter(new OutputStreamWriter(outputStream, charset), + true); + } + + /** + * Adds a form field to the request + * + * @param name field name + * @param value field value + */ + public void addFormField(String name, String value) { + writer.append("--" + boundary).append(LINE_FEED); + writer.append("Content-Disposition: form-data; name=\"" + name + "\"") + .append(LINE_FEED); + writer.append("Content-Type: text/plain; charset=" + charset).append( + LINE_FEED); + writer.append(LINE_FEED); + writer.append(value).append(LINE_FEED); + writer.flush(); + } + + /** + * Adds a upload file section to the request + * + * @param fieldName name attribute in + * @param uploadFile a File to be uploaded + * @throws IOException + */ + public void addFilePart(String fieldName, File uploadFile) + throws IOException { + String fileName = uploadFile.getName(); + writer.append("--" + boundary).append(LINE_FEED); + writer.append( + "Content-Disposition: form-data; name=\"" + fieldName + + "\"; filename=\"" + fileName + "\"") + .append(LINE_FEED); + writer.append( + "Content-Type: " + + URLConnection.guessContentTypeFromName(fileName)) + .append(LINE_FEED); + writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED); + writer.append(LINE_FEED); + writer.flush(); + + FileInputStream inputStream = new FileInputStream(uploadFile); + byte[] buffer = new byte[4096]; + int bytesRead = -1; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.flush(); + inputStream.close(); + + writer.append(LINE_FEED); + writer.flush(); + } + + /** + * Adds a header field to the request. + * + * @param name - name of the header field + * @param value - value of the header field + */ + public void addHeaderField(String name, String value) { + writer.append(name + ": " + value).append(LINE_FEED); + writer.flush(); + } + + /** + * Completes the request and receives response from the server. + * + * @return a list of Strings as response in case the server returned + * status OK, otherwise an exception is thrown. + * @throws IOException + */ + public List finish() throws IOException { + List response = new ArrayList<>(); + + writer.append(LINE_FEED).flush(); + writer.append("--" + boundary + "--").append(LINE_FEED); + writer.close(); + + // checks server's status code first + int status = httpConn.getResponseCode(); + if (status == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader( + httpConn.getInputStream())); + String line = null; + while ((line = reader.readLine()) != null) { + response.add(line); + } + reader.close(); + httpConn.disconnect(); + } else { + throw new IOException("Server returned non-OK status: " + status); + } + + return response; + } + } + + public static void main(String[] args) { + + if(args.length<1){ + System.err.println("1"); + System.exit(1); + } + + String charset = "UTF-8"; + String requestURL = args[0]; + + try { + MultipartUtility multipart = new MultipartUtility(requestURL, charset); + + multipart.addHeaderField("User-Agent", "JPEXS Uploader"); + + for(int i=1;i response = multipart.finish(); + + + for (String line : response) { + System.out.println(line); + } + System.exit(0); + } catch (IOException ex) { + ex.printStackTrace(); + System.exit(1); + } + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index c6b1461f9..65b89c88a 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -369,7 +369,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se @Override public boolean isLink(Token token) { - return isDeclaration(token.start); + return hasDeclaration(token.start); } @Override @@ -538,7 +538,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se tabbedPane.addTab(AppStrings.translate("constants"), panConstants); } - private boolean isDeclaration(int pos) { + private boolean hasDeclaration(int pos) { int multinameIndex = decompiledTextArea.getMultinameAtPos(pos); if (multinameIndex > -1) { List usages = abc.findMultinameDefinition(swf.abcList, multinameIndex); @@ -562,6 +562,8 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se if (!usages.isEmpty()) { return true; } + }else{ + return decompiledTextArea.getLocalDeclarationOfPos(pos)!=-1; } return false; } @@ -593,6 +595,11 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se } else if (!usages.isEmpty()) { //one UsageFrame.gotoUsage(ABCPanel.this, usages.get(0)); } + }else{ + int dpos=decompiledTextArea.getLocalDeclarationOfPos(pos); + if(dpos>-1){ + decompiledTextArea.setCaretPosition(dpos); + } } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 44fcc3a16..c42203890 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -36,7 +36,9 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.Cache; import java.awt.Point; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Timer; import java.util.TimerTask; import javax.swing.SwingUtilities; @@ -113,7 +115,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } List allh = new ArrayList<>(); - for (Highlighting h : traitHighlights) { + for (Highlighting h : traitHighlights) { if (h.getPropertyString("index").equals("" + lastTraitIndex)) { for (Highlighting sh : specialHighlights) { if (sh.startPos >= h.startPos && (sh.startPos + sh.len < h.startPos + h.len)) { @@ -229,6 +231,45 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return getMultinameAtPos(getCaretPosition()); } + public int getLocalDeclarationOfPos(int pos) { + Highlighting sh=Highlighting.search(specialHighlights,pos); + Highlighting h=Highlighting.search(highlights,pos); + Highlighting tm = Highlighting.search(methodHighlights, pos); + if (tm == null) { + return -1; + } + List tms= Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1); + if(h==null){ + return -1; + } + //is it already declaration? + if("true".equals(h.getPropertyString("declaration")) || (sh!=null && "true".equals(sh.getPropertyString("declaration")))){ + return -1; //no jump + } + + Map search=h.getProperties(); + search.remove("index"); + search.remove("subtype"); + search.remove("offset"); + if(search.isEmpty()){ + return -1; + } + search.put("declaration", "true"); + + for(Highlighting tm1:tms) + { + Highlighting rh= Highlighting.search(highlights, search, tm1.startPos, tm1.startPos+tm1.len); + if(rh==null){ + rh=Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos+tm1.len); + } + if(rh!=null){ + return rh.startPos; + } + } + + return -1; + } + public int getMultinameAtPos(int pos) { Highlighting tm = Highlighting.search(methodHighlights, pos); if (tm == null) { diff --git a/uploader.jar b/uploader.jar new file mode 100644 index 0000000000000000000000000000000000000000..2713c6011fdf6431a152c8acd266a82a8fbebb3f GIT binary patch literal 7677 zcmbt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