Fixed #1888 Resolve properties on script traits

This commit is contained in:
Jindra Petřík
2022-11-27 10:54:51 +01:00
parent 2a68570103
commit 183048bd82
21 changed files with 152 additions and 96 deletions

View File

@@ -1977,7 +1977,7 @@ public class AVM2Code implements Cloneable {
Slot sl = new Slot(new NewActivationAVM2Item(null, null), abc.constants.getMultiname(traits.get(traitName).name_index));
TraitSlotConst tsc = (TraitSlotConst) traits.get(traitName);
GraphTargetItem type = PropertyAVM2Item.multinameToType(tsc.type_index, abc.constants);
DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc.constants, type, false), type);
DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc.constants, type, TypeItem.UNBOUNDED /*?*/, false), type);
declaredSlotsDec.add(d);
declaredSlots.add(sl);

View File

@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
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.other.GetPropertyIns;
import com.jpexs.decompiler.flash.abc.avm2.model.CallAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;

View File

@@ -81,12 +81,14 @@ public class CallPropLexIns extends CallPropertyIns {
}
FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins);
GraphTargetItem receiver = stack.pop();
GraphTargetItem obj = stack.pop();
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true);
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type, isStatic.getVal()));
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, obj, multiname, args, callType.getVal(), isStatic.getVal()));
}
@Override

View File

@@ -82,10 +82,12 @@ public class CallPropVoidIns extends InstructionDefinition {
}
FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins);
GraphTargetItem receiver = stack.pop();
GraphTargetItem obj = stack.pop();
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true);
output.add(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, true, receiver, multiname, args, type, isStatic.getVal()));
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
output.add(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, true, obj, multiname, args, callType.getVal(), isStatic.getVal()));
}
@Override

View File

@@ -82,11 +82,13 @@ public class CallPropertyIns extends InstructionDefinition {
}
FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins);
GraphTargetItem receiver = stack.pop();
GraphTargetItem obj = stack.pop();
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true);
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type, isStatic.getVal()));
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, obj, multiname, args, callType.getVal(), isStatic.getVal()));
}
@Override

View File

@@ -57,7 +57,9 @@ public class DeletePropertyIns extends InstructionDefinition {
FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins);
GraphTargetItem obj = stack.pop();
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, true);
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
stack.add(new DeletePropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, isStatic.getVal()));
}

View File

@@ -24,10 +24,13 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.TypeItem;
@@ -46,12 +49,13 @@ public class GetLexIns extends InstructionDefinition {
super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}, true);
}
public static GraphTargetItem resolveLexType(
public static void resolveLexType(
AVM2LocalData localData,
GraphTargetItem obj,
int multinameIndex,
Reference<Boolean> isStatic, boolean call) {
GraphTargetItem type = null;
Reference<Boolean> isStatic, Reference<GraphTargetItem> type, Reference<GraphTargetItem> callType) {
type.setVal(TypeItem.UNBOUNDED);
callType.setVal(TypeItem.UNBOUNDED);
String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true);
for (Trait t : localData.methodBody.traits.traits) {
if (t instanceof TraitSlotConst) {
@@ -60,41 +64,41 @@ public class GetLexIns extends InstructionDefinition {
tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true),
multinameStr
)) {
type = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants);
break;
GraphTargetItem ty = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants);
type.setVal(ty);
callType.setVal(ty);
return;
}
}
}
if (type == null) {
if (localData.abcIndex != null) {
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
GraphTargetItem thisPropType = TypeItem.UNBOUNDED;
if (currentClassName != null) {
if (call) {
thisPropType = localData.abcIndex.findPropertyCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true);
} else {
thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true);
}
}
if (!thisPropType.equals(TypeItem.UNBOUNDED)) {
type = thisPropType;
}
if (localData.abcIndex != null) {
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
if (currentClassName != null) {
localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true, type, callType);
}
if (type == null) {
TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true));
if (localData.abcIndex.findClass(ti) != null) {
type = ti;
if (type.getVal().equals(TypeItem.UNBOUNDED)) {
TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true));
if (localData.abcIndex.findClass(ti) != null) {
type.setVal(ti);
callType.setVal(TypeItem.UNBOUNDED);
isStatic.setVal(true);
return;
}
Namespace ns = localData.abc.constants.getMultiname(multinameIndex).getNamespace(localData.abc.constants);
if (ns != null) {
String rawNs = ns.getRawName(localData.abc.constants);
AbcIndexing.TraitIndex traitIndex = localData.abcIndex.findScriptProperty(multinameStr, DottedChain.parseWithSuffix(rawNs));
if (traitIndex != null) {
type.setVal(traitIndex.returnType);
callType.setVal(traitIndex.callReturnType);
isStatic.setVal(true);
return;
}
}
}
}
if (type == null) {
type = TypeItem.UNBOUNDED;
}
return type;
}
@Override
@@ -102,8 +106,10 @@ public class GetLexIns extends InstructionDefinition {
int multinameIndex = ins.operands[0];
Multiname multiname = localData.getConstants().getMultiname(multinameIndex);
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, false);
stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type, isStatic.getVal()));
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, type, callType);
stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type.getVal(), callType.getVal(), isStatic.getVal()));
}
@Override

View File

@@ -31,14 +31,17 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.ecma.ArrayType;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.ObjectType;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.TypeItem;
@@ -131,17 +134,20 @@ public class GetPropertyIns extends InstructionDefinition {
}
}
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = resolvePropertyType(localData, obj, multiname, isStatic, false);
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
stack.push(new GetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, type, isStatic.getVal()));
stack.push(new GetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, type.getVal(), callType.getVal(), isStatic.getVal()));
}
public static GraphTargetItem resolvePropertyType(
public static void resolvePropertyType(
AVM2LocalData localData,
GraphTargetItem obj,
FullMultinameAVM2Item multiname,
Reference<Boolean> isStatic, boolean call) {
GraphTargetItem type = null;
Reference<Boolean> isStatic, Reference<GraphTargetItem> type, Reference<GraphTargetItem> callType) {
type.setVal(TypeItem.UNBOUNDED);
callType.setVal(TypeItem.UNBOUNDED);
String multinameStr = localData.abc.constants.getMultiname(multiname.multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true);
if (obj instanceof FindPropertyAVM2Item) {
FindPropertyAVM2Item fprop = (FindPropertyAVM2Item) obj;
@@ -153,32 +159,40 @@ public class GetPropertyIns extends InstructionDefinition {
tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true),
multinameStr
)) {
type = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants);
break;
GraphTargetItem ty = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants);
type.setVal(ty);
callType.setVal(ty);
return;
}
}
}
if (type == null) {
if (type.getVal().equals(TypeItem.UNBOUNDED)) {
if (localData.abcIndex != null) {
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
GraphTargetItem thisPropType = TypeItem.UNBOUNDED;
if (currentClassName != null) {
if (call) {
thisPropType = localData.abcIndex.findPropertyCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true);
} else {
thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true);
}
localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true, type, callType);
}
if (!thisPropType.equals(TypeItem.UNBOUNDED)) {
type = thisPropType;
}
if (type == null) {
if (type.getVal().equals(TypeItem.UNBOUNDED)) {
TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multiname.multinameIndex).getNameWithNamespace(localData.abc.constants, true));
if (localData.abcIndex.findClass(ti) != null) {
type = ti;
type.setVal(ti);
callType.setVal(TypeItem.UNBOUNDED);
isStatic.setVal(true);
return;
}
Namespace ns = localData.abc.constants.getMultiname(multiname.multinameIndex).getNamespace(localData.abc.constants);
if (ns != null) {
String rawNs = ns.getRawName(localData.abc.constants);
AbcIndexing.TraitIndex traitIndex = localData.abcIndex.findScriptProperty(multinameStr, DottedChain.parseWithSuffix(rawNs));
if (traitIndex != null) {
type.setVal(traitIndex.returnType);
callType.setVal(traitIndex.callReturnType);
isStatic.setVal(true); //?
return;
}
}
}
}
@@ -198,22 +212,21 @@ public class GetPropertyIns extends InstructionDefinition {
if (obj instanceof GetPropertyAVM2Item) {
if (((GetPropertyAVM2Item) obj).isStatic) {
parentStatic = true;
}
}
}
if (receiverType instanceof ApplyTypeAVM2Item) {
ApplyTypeAVM2Item ati = (ApplyTypeAVM2Item) receiverType;
ApplyTypeAVM2Item ati = (ApplyTypeAVM2Item) receiverType;
if (localData.abc.constants.getMultiname(multiname.multinameIndex).needsName()) {
if (call) {
type = TypeItem.UNBOUNDED; /*?*/
} else {
type = ati.params.get(0);
}
callType.setVal(TypeItem.UNBOUNDED);
/*?*/
type.setVal(ati.params.get(0));
return;
} else {
receiverType = ati.object;
if (receiverType.equals(new TypeItem("__AS3__.vec.Vector"))) {
String paramStr = ati.params.get(0).toString();
switch(paramStr) {
switch (paramStr) {
case "double":
case "int":
case "uint":
@@ -223,26 +236,14 @@ public class GetPropertyIns extends InstructionDefinition {
receiverType = new TypeItem("__AS3__.vec.Vector$object");
}
}
//TODO: handle method calls to return proper param type results
}
}
if (type == null)
{
if (call) {
type = localData.abcIndex.findPropertyCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false);
} else {
type = localData.abcIndex.findPropertyType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false);
}
}
localData.abcIndex.findPropertyTypeOrCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false, type, callType);
}
}
}
if (type == null) {
type = TypeItem.UNBOUNDED;
}
return type;
}
@Override

View File

@@ -69,9 +69,11 @@ public class InitPropertyIns extends InstructionDefinition {
}*/
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, false);
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
InitPropertyAVM2Item result = new InitPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, val, type, isStatic.getVal());
InitPropertyAVM2Item result = new InitPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, val, type.getVal(), callType.getVal(), isStatic.getVal());
SetPropertyIns.handleCompound(localData, obj, multiname, val, output, result);
output.add(result);
}

View File

@@ -361,9 +361,11 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
}
*/
Reference<Boolean> isStatic = new Reference<>(false);
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, false);
Reference<GraphTargetItem> type = new Reference<>(null);
Reference<GraphTargetItem> callType = new Reference<>(null);
GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType);
SetPropertyAVM2Item result = new SetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, value, type, isStatic.getVal());
SetPropertyAVM2Item result = new SetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, value, type.getVal(), callType.getVal(), isStatic.getVal());
handleCompound(localData, obj, multiname, value, output, result);
SetTypeIns.handleResult(value, stack, output, localData, result, -1);

View File

@@ -226,6 +226,12 @@ public class CallAVM2Item extends AVM2Item {
@Override
public GraphTargetItem returnType() {
if (function instanceof GetPropertyAVM2Item) {
return ((GetPropertyAVM2Item)function).callType;
}
if (function instanceof GetLexAVM2Item) {
return ((GetLexAVM2Item)function).callType;
}
return TypeItem.UNBOUNDED;
}

View File

@@ -37,14 +37,17 @@ public class GetLexAVM2Item extends AVM2Item implements SimpleValue {
public GraphTargetItem type;
public boolean isStatic;
public GraphTargetItem callType;
public boolean isStatic;
private final DottedChain fullPropertyName;
public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants, GraphTargetItem type, boolean isStatic) {
public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) {
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
this.propertyName = propertyName;
this.type = type;
this.callType = callType;
this.fullPropertyName = propertyName.getNameWithNamespace(constants, true);
this.isStatic = isStatic;
}

View File

@@ -49,6 +49,8 @@ public class GetPropertyAVM2Item extends AVM2Item {
public GraphTargetItem type;
public GraphTargetItem callType;
public boolean isStatic;
@Override
@@ -131,11 +133,12 @@ public class GetPropertyAVM2Item extends AVM2Item {
return null;
}
public GetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem type, boolean isStatic) {
public GetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) {
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
this.object = object;
this.propertyName = propertyName;
this.type = type;
this.callType = callType;
this.isStatic = isStatic;
}

View File

@@ -44,6 +44,8 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
public GraphTargetItem type;
public GraphTargetItem callType;
public boolean isStatic;
@Override
@@ -63,11 +65,12 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
this.declaration = declaration;
}
public InitPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, FullMultinameAVM2Item propertyName, GraphTargetItem value, GraphTargetItem type, boolean isStatic) {
public InitPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, FullMultinameAVM2Item propertyName, GraphTargetItem value, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) {
super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT, value);
this.object = object;
this.propertyName = propertyName;
this.type = type;
this.callType = callType;
this.isStatic = isStatic;
}
@@ -87,7 +90,7 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
@Override
public GraphTargetItem getObject() {
return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, isStatic);
return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, callType, isStatic);
}
@Override

View File

@@ -51,6 +51,8 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
public GraphTargetItem type;
public GraphTargetItem callType;
public boolean isStatic;
@Override
@@ -77,12 +79,13 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
}
}
public SetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem value, GraphTargetItem type, boolean isStatic) {
public SetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem value, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) {
super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT);
this.object = object;
this.propertyName = propertyName;
this.value = value;
this.type = type;
this.callType = callType;
this.isStatic = isStatic;
}
@@ -106,7 +109,7 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
@Override
public GraphTargetItem getObject() {
return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, isStatic);
return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, callType, isStatic);
}
@Override

View File

@@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.helpers.Reference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -354,6 +355,18 @@ public final class AbcIndexing {
return classes.get(cls);
}
public void findPropertyTypeOrCallType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected, Reference<GraphTargetItem> type, Reference<GraphTargetItem> callType) {
TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected);
if (traitIndex == null) {
type.setVal(TypeItem.UNBOUNDED);
callType.setVal(TypeItem.UNBOUNDED);
} else {
type.setVal(traitIndex.returnType);
callType.setVal(traitIndex.callReturnType);
}
}
public GraphTargetItem findPropertyType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected) {
TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected);
if (traitIndex == null) {