AS3 XML fix

This commit is contained in:
Jindra Pet��k
2013-01-26 20:09:38 +01:00
parent 71d8f7d301
commit bb80f59b71
2 changed files with 35 additions and 10 deletions
@@ -26,6 +26,8 @@ import com.jpexs.asdec.abc.avm2.treemodel.ConstructTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.EscapeXAttrTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.EscapeXElemTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.FindPropertyTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.GetLexTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.GetPropertyTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.StringTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
@@ -56,7 +58,7 @@ public class ConstructIns extends InstructionDefinition {
//push new instance
}
private boolean walkXML(TreeItem item, List<TreeItem> list) {
public static boolean walkXML(TreeItem item, List<TreeItem> list) {
boolean ret = true;
if (item instanceof StringTreeItem) {
list.add(item);
@@ -79,22 +81,33 @@ public class ConstructIns extends InstructionDefinition {
args.add(0, (TreeItem) stack.pop());
}
TreeItem obj = (TreeItem) stack.pop();
FullMultinameTreeItem xmlMult = null;
boolean isXML = false;
if (obj instanceof GetPropertyTreeItem) {
GetPropertyTreeItem gpt = (GetPropertyTreeItem) obj;
if (gpt.object instanceof FindPropertyTreeItem) {
FindPropertyTreeItem fpt = (FindPropertyTreeItem) gpt.object;
if (fpt.propertyName.isXML(constants, localRegNames, fullyQualifiedNames) && gpt.propertyName.isXML(constants, localRegNames, fullyQualifiedNames)) {
if (args.size() == 1) {
TreeItem arg = args.get(0);
List<TreeItem> xmlLines = new ArrayList<TreeItem>();
if (walkXML(arg, xmlLines)) {
stack.push(new XMLTreeItem(ins, xmlLines));
return;
}
}
xmlMult = fpt.propertyName;
isXML = xmlMult.isXML(constants, localRegNames, fullyQualifiedNames) && xmlMult.isXML(constants, localRegNames, fullyQualifiedNames);
}
}
if (obj instanceof GetLexTreeItem) {
GetLexTreeItem glt = (GetLexTreeItem) obj;
isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML");
}
if (isXML) {
if (args.size() == 1) {
TreeItem arg = args.get(0);
List<TreeItem> xmlLines = new ArrayList<TreeItem>();
if (walkXML(arg, xmlLines)) {
stack.push(new XMLTreeItem(ins, xmlLines));
return;
}
}
}
stack.push(new ConstructTreeItem(ins, obj, args));
}
@@ -23,8 +23,10 @@ import com.jpexs.asdec.abc.avm2.LocalDataArea;
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.asdec.abc.avm2.treemodel.ConstructPropTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.ConstructTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.XMLTreeItem;
import com.jpexs.asdec.abc.types.MethodInfo;
import java.util.ArrayList;
import java.util.HashMap;
@@ -63,6 +65,16 @@ public class ConstructPropIns extends InstructionDefinition {
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
TreeItem obj = (TreeItem) stack.pop();
if (multiname.isXML(constants, localRegNames, fullyQualifiedNames)) {
if (args.size() == 1) {
TreeItem arg = args.get(0);
List<TreeItem> xmlLines = new ArrayList<TreeItem>();
if (ConstructIns.walkXML(arg, xmlLines)) {
stack.push(new XMLTreeItem(ins, xmlLines));
return;
}
}
}
stack.push(new ConstructPropTreeItem(ins, obj, multiname, args));
}