mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-04 06:35:10 +00:00
#768 super calls not being correctly recognized fixed
This commit is contained in:
@@ -366,6 +366,21 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return jtt;
|
||||
}
|
||||
|
||||
public String getDocumentClass() {
|
||||
for (Tag t : tags) {
|
||||
if (t instanceof SymbolClassTag) {
|
||||
SymbolClassTag sc = (SymbolClassTag) t;
|
||||
for (int i = 0; i < sc.tags.length; i++) {
|
||||
if (sc.tags[i] == 0) {
|
||||
return sc.names[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void fixCharactersOrder(boolean checkAll) {
|
||||
Set<Integer> addedCharacterIds = new HashSet<>();
|
||||
Set<CharacterTag> movedTags = new HashSet<>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
@@ -1193,20 +1194,8 @@ public class ABC {
|
||||
String scriptName = pack.getPathScriptName() + ".as";
|
||||
int oldIndex = pack.scriptIndex;
|
||||
int newIndex = script_info.size();
|
||||
int newIndex = script_info.size();
|
||||
String documentClass = "";
|
||||
loopt:
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof SymbolClassTag) {
|
||||
SymbolClassTag sc = (SymbolClassTag) t;
|
||||
for (int i = 0; i < sc.tags.length; i++) {
|
||||
if (sc.tags[i] == 0) {
|
||||
documentClass = sc.names[i];
|
||||
break loopt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String documentClass = swf.getDocumentClass();
|
||||
boolean isDocumentClass = documentClass != null && documentClass.equals(pack.getClassPath().toString());
|
||||
|
||||
ScriptInfo si = script_info.get(oldIndex);
|
||||
si.delete(this, true);
|
||||
|
||||
@@ -1492,14 +1492,20 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (AssignableAVM2Item an : subvariables) {
|
||||
if (an instanceof NameAVM2Item) {
|
||||
NameAVM2Item n = (NameAVM2Item) an;
|
||||
if (n.getVariableName() != null) {
|
||||
if (!n.getVariableName().equals("this") && needsActivation) {
|
||||
String variableName = n.getVariableName();
|
||||
if (variableName != null) {
|
||||
boolean isThisOrSuper = variableName.equals("this") || variableName.equals("super");
|
||||
if (!isThisOrSuper && needsActivation) {
|
||||
if (n.getSlotNumber() <= 0) {
|
||||
n.setSlotNumber(slotNames.indexOf(n.getVariableName()));
|
||||
n.setSlotNumber(slotNames.indexOf(variableName));
|
||||
n.setSlotScope(slotScope);
|
||||
}
|
||||
} else {
|
||||
n.setRegNumber(registerNames.indexOf(n.getVariableName()));
|
||||
if (isThisOrSuper) {
|
||||
n.setRegNumber(0);
|
||||
} else {
|
||||
n.setRegNumber(registerNames.indexOf(variableName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1553,7 +1559,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("this".equals(n.getVariableName()) || paramNames.contains(n.getVariableName()) || "argmuments".equals(n.getVariableName())) {
|
||||
String variableName = n.getVariableName();
|
||||
if ("this".equals(variableName) || "super".equals(variableName) || paramNames.contains(variableName) || "argmuments".equals(variableName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,19 @@
|
||||
* 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.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropVoidIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperVoidIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetGlobalScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
@@ -133,8 +137,14 @@ public class CallAVM2Item extends AVM2Item {
|
||||
if (obj == null) {
|
||||
obj = new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{propIndex});
|
||||
}
|
||||
|
||||
boolean isSuper = (obj instanceof NameAVM2Item) && "super".equals(((NameAVM2Item) obj).getVariableName());
|
||||
|
||||
InstructionDefinition insDef = isSuper ?
|
||||
(needsReturn ? new CallSuperIns() : new CallSuperVoidIns()) :
|
||||
(needsReturn ? new CallPropertyIns() : new CallPropVoidIns());
|
||||
return toSourceMerge(localData, generator, obj, arguments,
|
||||
return toSourceMerge(localData, generator, obj, arguments,
|
||||
ins(insDef, propIndex, arguments.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
@@ -22,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
@@ -427,7 +429,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parts.get(0).equals("this") || parts.get(0).equals("super")) {
|
||||
if (thisType == null) {
|
||||
throw new CompilationException("Cannot use this in that context", line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user