Fixed #1938 AS3 Direct editation - implied this instead of findprop

This commit is contained in:
Jindra Petřík
2023-01-15 18:30:53 +01:00
parent 671ebf08a3
commit 0377a876e3
9 changed files with 72 additions and 8 deletions

View File

@@ -97,11 +97,12 @@ public class CallAVM2Item extends AVM2Item {
otherNs.add(on.getCpoolIndex(g.abcIndex));
}
}
if (cname != null && AVM2SourceGenerator.searchPrototypeChain(null, otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC, isType)) {
//For using this when appropriate: (Non ASC2 approach)
/*if (cname != null && AVM2SourceGenerator.searchPrototypeChain(null, otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC, isType)) {
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), n.line, false, "this", "", null, false, n.openedNamespaces, abcIndex);
nobj.setRegNumber(0);
obj = nobj;
}
}*/
PropertyAVM2Item p = new PropertyAVM2Item(obj, n.isAttribute(), n.getVariableName(), n.getNamespaceSuffix(), g.abcIndex, n.openedNamespaces, new ArrayList<>());
p.setAssignedValue(n.getAssignedValue());
callable = p;
@@ -118,7 +119,8 @@ public class CallAVM2Item extends AVM2Item {
if (callable instanceof PropertyAVM2Item) {
PropertyAVM2Item prop = (PropertyAVM2Item) callable;
obj = prop.object;
if (obj == null) {
//For using this when appropriate: (Non ASC2 approach)
/*if (obj == null) {
String cname = localData.currentClass;
DottedChain pkgName = localData.pkg;
Reference<String> outName = new Reference<>("");
@@ -142,7 +144,7 @@ public class CallAVM2Item extends AVM2Item {
nobj.setRegNumber(0);
obj = nobj;
}
}
}*/
propIndex = prop.resolveProperty(localData);
}
@@ -168,7 +170,7 @@ public class CallAVM2Item extends AVM2Item {
return ((NamespacedAVM2Item) callable).toSource(localData, generator, needsReturn, true, arguments, false, false);
}
return toSourceMerge(localData, generator, callable, ins(AVM2Instructions.GetGlobalScope), arguments, ins(AVM2Instructions.Call, arguments.size()), needsReturn ? null : ins(AVM2Instructions.Pop));
return toSourceMerge(localData, generator, callable, ins(AVM2Instructions.GetGlobalScope) /*ASC2 uses getlocal0 here*/, arguments, ins(AVM2Instructions.Call, arguments.size()), needsReturn ? null : ins(AVM2Instructions.Pop));
}
@Override

View File

@@ -482,11 +482,12 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
namespaceSuffixInt = Integer.parseInt(namespaceSuffix.substring(1));
}
if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) {
//For using this when appropriate (Non ASC2 approach):
/*if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) {
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, false, "this", "", null, false, openedNamespaces, abcIndex);
nobj.setRegNumber(0);
obj = nobj;
} else {
} else {*/
Reference<GraphTargetItem> objType = new Reference<>(null);
Reference<GraphTargetItem> propType = new Reference<>(null);
Reference<Integer> propIndex = new Reference<>(0);
@@ -495,7 +496,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
resolve(false, localData, isType, objType, propType, propIndex, outPropValue, propValueAbc);
obj = ins(AVM2Instructions.FindPropertyStrict, propIndex.getVal());
}
//}
}
return obj;
}