mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 00:30:45 +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
|
||||
|
||||
+5
-4
@@ -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)) {
|
||||
|
||||
+7
-2
@@ -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(":");
|
||||
|
||||
@@ -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
|
||||
|
||||
+4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user