mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-12 19:58:25 +00:00
resolving properties and methods on Vector
This commit is contained in:
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2ExecutionException;
|
||||
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.model.ApplyTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
@@ -166,7 +167,7 @@ public class GetPropertyIns extends InstructionDefinition {
|
||||
if (call) {
|
||||
thisPropType = localData.abcIndex.findPropertyCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true);
|
||||
} else {
|
||||
thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true);
|
||||
thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true);
|
||||
}
|
||||
}
|
||||
if (!thisPropType.equals(TypeItem.UNBOUNDED)) {
|
||||
@@ -197,13 +198,42 @@ public class GetPropertyIns extends InstructionDefinition {
|
||||
if (obj instanceof GetPropertyAVM2Item) {
|
||||
if (((GetPropertyAVM2Item) obj).isStatic) {
|
||||
parentStatic = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (call) {
|
||||
type = localData.abcIndex.findPropertyCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic);
|
||||
} else {
|
||||
type = localData.abcIndex.findPropertyType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic);
|
||||
if (receiverType instanceof ApplyTypeAVM2Item) {
|
||||
ApplyTypeAVM2Item ati = (ApplyTypeAVM2Item) receiverType;
|
||||
if (localData.abc.constants.getMultiname(multiname.multinameIndex).needsName()) {
|
||||
if (call) {
|
||||
type = TypeItem.UNBOUNDED; /*?*/
|
||||
} else {
|
||||
type = ati.params.get(0);
|
||||
}
|
||||
} else {
|
||||
receiverType = ati.object;
|
||||
|
||||
if (receiverType.equals(new TypeItem("__AS3__.vec.Vector"))) {
|
||||
String paramStr = ati.params.get(0).toString();
|
||||
switch(paramStr) {
|
||||
case "double":
|
||||
case "int":
|
||||
case "uint":
|
||||
receiverType = new TypeItem("__AS3__.vec.Vector$" + paramStr);
|
||||
break;
|
||||
default:
|
||||
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);
|
||||
} else {
|
||||
type = localData.abcIndex.findPropertyType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,14 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
HighlightData data = new HighlightData();
|
||||
int multinameIndex = ((FullMultinameAVM2Item) propertyName).multinameIndex;
|
||||
int namespaceIndex = localData.constantsAvm2.getMultiname(multinameIndex).namespace_index;
|
||||
data.propertyType = object.returnType().toString();
|
||||
GraphTargetItem returnType = object.returnType();
|
||||
if (returnType instanceof ApplyTypeAVM2Item) {
|
||||
ApplyTypeAVM2Item ati = (ApplyTypeAVM2Item)returnType;
|
||||
data.propertyType = ati.object.toString();
|
||||
data.propertySubType = ati.params.get(0).toString();
|
||||
} else {
|
||||
data.propertyType = returnType.toString();
|
||||
}
|
||||
data.namespaceIndex = namespaceIndex;
|
||||
data.isStatic = isStatic;
|
||||
|
||||
|
||||
@@ -123,4 +123,24 @@ public class ApplyTypeAVM2Item extends AVM2Item {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String ret = object.toString();
|
||||
if (!params.isEmpty()) {
|
||||
ret += ".<";
|
||||
boolean first = true;
|
||||
for (GraphTargetItem param : params) {
|
||||
if (!first) {
|
||||
ret += ", ";
|
||||
}
|
||||
ret += param.toString();
|
||||
first = false;
|
||||
}
|
||||
ret += ">";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -105,6 +105,9 @@ public class CoerceAVM2Item extends AVM2Item {
|
||||
if (typeObj instanceof UnboundedTypeItem) {
|
||||
return typeObj;
|
||||
}
|
||||
if (typeObj instanceof ApplyTypeAVM2Item) {
|
||||
return typeObj;
|
||||
}
|
||||
return new TypeItem(typeObj.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ public final class AbcIndexing {
|
||||
public TraitIndex findProperty(PropertyDef prop, boolean findStatic, boolean findInstance) {
|
||||
/*System.out.println("searching " + prop);
|
||||
for (PropertyDef p : instanceProperties.keySet()) {
|
||||
if (p.parent.equals(new TypeItem("String"))) {
|
||||
if (p.parent.equals(new TypeItem("__AS3__.vec.Vector"))) {
|
||||
System.out.println("- " + p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public class HighlightData implements Cloneable, Serializable {
|
||||
public boolean isStatic = false;
|
||||
|
||||
public String propertyType;
|
||||
|
||||
public String propertySubType;
|
||||
|
||||
public boolean isEmpty() {
|
||||
return !declaration && declaredType == null && localName == null
|
||||
@@ -57,7 +59,8 @@ public class HighlightData implements Cloneable, Serializable {
|
||||
&& index == 0 && offset == 0 && regIndex == -1 && firstLineOffset == -1
|
||||
&& fileOffset == -1
|
||||
&& namespaceIndex == -1
|
||||
&& propertyType == null;
|
||||
&& propertyType == null
|
||||
&& propertySubType == null;
|
||||
}
|
||||
|
||||
public void merge(HighlightData data) {
|
||||
@@ -103,6 +106,9 @@ public class HighlightData implements Cloneable, Serializable {
|
||||
if (data.propertyType != null) {
|
||||
propertyType = data.propertyType;
|
||||
}
|
||||
if (data.propertySubType != null) {
|
||||
propertySubType = data.propertySubType;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user