mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-15 09:48:26 +00:00
Fixed #1763 AS3 - function with activation - param assignment is not a declaration
This commit is contained in:
@@ -248,6 +248,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.DXNSIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.DXNSLateIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.EscXAttrIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.EscXElemIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
@@ -1862,7 +1863,7 @@ public class AVM2Code implements Cloneable {
|
||||
return assignment;
|
||||
}
|
||||
|
||||
private void injectDeclarations(List<GraphTargetItem> items, int minreg, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, List<String> declaredProperties, List<DeclarationAVM2Item> declaredPropsDec, ABC abc, MethodBody body) {
|
||||
private void injectDeclarations(List<String> paramNames, List<GraphTargetItem> items, int minreg, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, List<String> declaredProperties, List<DeclarationAVM2Item> declaredPropsDec, ABC abc, MethodBody body) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
GraphTargetItem currentItem = items.get(i);
|
||||
List<GraphTargetItem> itemsOnLine = new ArrayList<>();
|
||||
@@ -1911,29 +1912,31 @@ public class AVM2Code implements Cloneable {
|
||||
if (sp.object instanceof FindPropertyAVM2Item) {
|
||||
if (sp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
FullMultinameAVM2Item propName = (FullMultinameAVM2Item) sp.propertyName;
|
||||
if (!declaredProperties.contains(propName.resolvedMultinameName)) {
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc).getName(abc.constants, new ArrayList<DottedChain>(), true, false)
|
||||
.equals(propName.resolvedMultinameName)) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
GraphTargetItem type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
sp.setDeclaration(d);
|
||||
declaredPropsDec.add(d);
|
||||
declaredProperties.add(propName.resolvedMultinameName);
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
if (!paramNames.contains(propName.resolvedMultinameName)) {
|
||||
if (!declaredProperties.contains(propName.resolvedMultinameName)) {
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc).getName(abc.constants, new ArrayList<DottedChain>(), true, false)
|
||||
.equals(propName.resolvedMultinameName)) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
GraphTargetItem type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
sp.setDeclaration(d);
|
||||
declaredPropsDec.add(d);
|
||||
declaredProperties.add(propName.resolvedMultinameName);
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int idx = declaredProperties.indexOf(propName.resolvedMultinameName);
|
||||
sp.setDeclaration(declaredPropsDec.get(idx));
|
||||
}
|
||||
} else {
|
||||
int idx = declaredProperties.indexOf(propName.resolvedMultinameName);
|
||||
sp.setDeclaration(declaredPropsDec.get(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1942,31 +1945,34 @@ public class AVM2Code implements Cloneable {
|
||||
SetSlotAVM2Item ssti = (SetSlotAVM2Item) subItem;
|
||||
if (ssti.scope instanceof NewActivationAVM2Item) {
|
||||
Slot sl = new Slot(ssti.scope, ssti.slotName);
|
||||
if (!declaredSlots.contains(sl)) {
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc) == sl.multiname) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
if (!paramNames.contains(sl.multiname.getName(abc.constants, new ArrayList<>(), true, false))) {
|
||||
|
||||
if (!declaredSlots.contains(sl)) {
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc) == sl.multiname) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
ssti.setDeclaration(d);
|
||||
declaredSlotsDec.add(d);
|
||||
declaredSlots.add(sl);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
ssti.setDeclaration(d);
|
||||
declaredSlotsDec.add(d);
|
||||
declaredSlots.add(sl);
|
||||
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
int idx = declaredSlots.indexOf(sl);
|
||||
ssti.setDeclaration(declaredSlotsDec.get(idx));
|
||||
}
|
||||
|
||||
} else {
|
||||
int idx = declaredSlots.indexOf(sl);
|
||||
ssti.setDeclaration(declaredSlotsDec.get(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1975,7 +1981,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (currentItem instanceof Block) {
|
||||
Block blk = (Block) currentItem;
|
||||
for (List<GraphTargetItem> sub : blk.getSubs()) {
|
||||
injectDeclarations(sub, minreg, declaredRegisters, declaredSlots, declaredSlotsDec, declaredProperties, declaredPropsDec, abc, body);
|
||||
injectDeclarations(paramNames, sub, minreg, declaredRegisters, declaredSlots, declaredSlotsDec, declaredProperties, declaredPropsDec, abc, body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2121,7 +2127,12 @@ public class AVM2Code implements Cloneable {
|
||||
//
|
||||
|
||||
//int minreg = abc.method_info.get(body.method_info).getMaxReservedReg() + 1;
|
||||
injectDeclarations(list, 1, d, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), abc, body);
|
||||
HashMap<Integer, String> registerNames = body.getLocalRegNames(abc);
|
||||
List<String> paramNamesList = new ArrayList<>();
|
||||
for (int ir = 0; ir < r; ir++) {
|
||||
paramNamesList.add(AVM2Item.localRegName(localRegNames, ir));
|
||||
}
|
||||
injectDeclarations(paramNamesList, list, 1, d, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), abc, body);
|
||||
|
||||
int lastPos = list.size() - 1;
|
||||
if (lastPos < 0) {
|
||||
|
||||
Reference in New Issue
Block a user