mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-15 08:01:53 +00:00
Issue #302 AS3 goto local variable declaration
Ant upload release/nightly task
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ public class LocalRegAVM2Item extends AVM2Item {
|
||||
}
|
||||
}
|
||||
this.computedValue = computedValue;
|
||||
srcData.put("regIndex", ""+regIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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 {
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
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(":");
|
||||
|
||||
@@ -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<Integer, String> 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);
|
||||
|
||||
@@ -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<String,String> 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;
|
||||
}
|
||||
|
||||
@@ -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<String>()/*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();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> 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<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> 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
|
||||
|
||||
@@ -77,6 +77,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
@Override
|
||||
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> 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<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String, String> data) {
|
||||
writeToFile(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public FileTextWriter append(String str, long offset) {
|
||||
writeToFile(str);
|
||||
|
||||
@@ -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<String,String> data;
|
||||
|
||||
}
|
||||
|
||||
@@ -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, Map<String,String> data) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -99,10 +103,14 @@ public abstract class GraphTextWriter {
|
||||
}
|
||||
|
||||
public GraphTextWriter hilightSpecial(String text, String type) {
|
||||
public GraphTextWriter hilightSpecial(String text, String type) {
|
||||
return hilightSpecial(text, type, 0);
|
||||
}
|
||||
|
||||
public GraphTextWriter hilightSpecial(String text, String type, int index) {
|
||||
return hilightSpecial(text, type, 0, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
public GraphTextWriter hilightSpecial(String text, String type, int index, Map<String,String> data) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -110,6 +118,8 @@ public abstract class GraphTextWriter {
|
||||
return "";
|
||||
}
|
||||
|
||||
public abstract GraphTextWriter appendWithData(String str, Map<String,String> data);
|
||||
|
||||
public abstract GraphTextWriter append(String str);
|
||||
|
||||
public abstract GraphTextWriter append(String str, long offset);
|
||||
|
||||
@@ -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
|
||||
@Override
|
||||
public HilightedTextWriter startOffset(GraphSourceItem src, int pos, Map<String,String> 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) {
|
||||
public HilightedTextWriter hilightSpecial(String text, String type, int index) {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("subtype", type);
|
||||
data.put("index", Long.toString(index));
|
||||
return hilightSpecial(text, type, index, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HilightedTextWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
|
||||
Map<String, String> 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<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HilightedTextWriter appendWithData(String str, Map<String,String> data) {
|
||||
Highlighting h = null;
|
||||
if (!offsets.empty()) {
|
||||
GraphSourceItemPosition itemPos = offsets.peek();
|
||||
GraphSourceItem src = itemPos.graphSourceItem;
|
||||
int pos = itemPos.position;
|
||||
if (src != null && hilight) {
|
||||
if (src != null && hilight) {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("offset", Long.toString(src.getOffset() + pos + 1));
|
||||
Map<String,String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String, String> data) {
|
||||
stringAdded = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public NulWriter append(String str) {
|
||||
stringAdded = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendWithData(String str, Map<String, String> data) {
|
||||
stringAdded = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public NulWriter append(String str, long offset) {
|
||||
stringAdded = true;
|
||||
|
||||
@@ -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<String, String> 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<Highlighting> list, String property, String value) {
|
||||
return search(list, -1, property, value, -1, -1);
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, Map<String,String> properties) {
|
||||
return search(list, -1, properties, -1, -1);
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, String property, String value, int from, int to) {
|
||||
return search(list, -1, property, value, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, Map<String,String> properties, int from, int to) {
|
||||
return search(list, -1, properties, from, to);
|
||||
}
|
||||
|
||||
public static Highlighting search(List<Highlighting> list, long pos, String property, String value, long from, long to) {
|
||||
Map<String,String> map= new HashMap<>();
|
||||
map.put(property, value);
|
||||
return search(list, pos, map, from, to);
|
||||
}
|
||||
public static Highlighting search(List<Highlighting> list, long pos, Map<String,String> properties, long from, long to) {
|
||||
Highlighting ret = null;
|
||||
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)) {
|
||||
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<Highlighting> searchAll(List<Highlighting> list, long pos, String property, String value, long from, long to) {
|
||||
List<Highlighting> 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
|
||||
*
|
||||
|
||||
@@ -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<GraphSourceItemPos> moreSrc = new ArrayList<>();
|
||||
public GraphPart firstPart;
|
||||
public GraphTargetItem value;
|
||||
protected Map<String,String> srcData = new HashMap<String, String>();
|
||||
|
||||
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 {
|
||||
public GraphTextWriter toStringSemicoloned(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
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 {
|
||||
public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
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 {
|
||||
public GraphTextWriter toStringNoQuotes(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
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 {
|
||||
public GraphTextWriter toStringNL(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.startOffset(src, pos, srcData);
|
||||
appendTo(writer, localData);
|
||||
if (needsNewLine()) {
|
||||
writer.newLine();
|
||||
|
||||
Reference in New Issue
Block a user