mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 04:11:13 +00:00
AS3 parser: Default xml namespace, get descendants
This commit is contained in:
@@ -47,6 +47,7 @@ public class DXNSIns extends InstructionDefinition {
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
//FIXME!!! - search namespace
|
||||
output.add(new DefaultXMLNamespace(ins, new StringAVM2Item(ins, constants.getString(ins.operands[0]))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,17 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.DXNSLateIns;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -50,4 +56,11 @@ public class DefaultXMLNamespace extends AVM2Item {
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, ns, ins(new DXNSLateIns()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,18 +16,35 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class GetDescendantsAVM2Item extends AVM2Item {
|
||||
|
||||
public GraphTargetItem object;
|
||||
public FullMultinameAVM2Item multiname;
|
||||
public GraphTargetItem multiname;
|
||||
public List<Integer> openedNamespaces;
|
||||
public String nameStr;
|
||||
|
||||
public GetDescendantsAVM2Item(AVM2Instruction instruction, GraphTargetItem object, FullMultinameAVM2Item multiname) {
|
||||
|
||||
//constructor for compiler
|
||||
public GetDescendantsAVM2Item(GraphTargetItem object, String nameStr, List<Integer> openedNamespaces) {
|
||||
super(null, PRECEDENCE_PRIMARY);
|
||||
this.object = object;
|
||||
this.nameStr = nameStr;
|
||||
this.openedNamespaces = openedNamespaces;
|
||||
}
|
||||
|
||||
public GetDescendantsAVM2Item(AVM2Instruction instruction, GraphTargetItem object, GraphTargetItem multiname) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.object = object;
|
||||
this.multiname = multiname;
|
||||
@@ -49,4 +66,11 @@ public class GetDescendantsAVM2Item extends AVM2Item {
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return ((AVM2SourceGenerator)generator).generate(localData, this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.LookupSwitchIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetDescendantsIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetGlobalScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns;
|
||||
@@ -65,6 +66,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.CheckFilterIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
@@ -145,6 +147,18 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return new AVM2Instruction(0, def, operands, new byte[0]);
|
||||
}
|
||||
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, GetDescendantsAVM2Item item) throws CompilationException {
|
||||
int nssa[] = new int[item.openedNamespaces.size()];
|
||||
for (int i = 0; i < item.openedNamespaces.size(); i++) {
|
||||
nssa[i] = item.openedNamespaces.get(i);
|
||||
}
|
||||
int nsset = abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
|
||||
|
||||
return GraphTargetItem.toSourceMerge(localData, this,
|
||||
item.object,
|
||||
ins(new GetDescendantsIns(),abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, abc.constants.getStringId(item.nameStr, true), 0, nsset, 0, new ArrayList<Integer>()), true))
|
||||
);
|
||||
}
|
||||
@Override
|
||||
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, AndItem item) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
|
||||
+298
-294
File diff suppressed because it is too large
Load Diff
+542
-521
File diff suppressed because it is too large
Load Diff
@@ -201,5 +201,6 @@ public enum SymbolType {
|
||||
XML_INSTRATTRNAMEVAR_BEGIN, // {...}=
|
||||
XML_INSTRATTRVALVAR_BEGIN, // aaa={
|
||||
XML_INSTRVARTAG_BEGIN, // <?{
|
||||
FILTER
|
||||
FILTER,
|
||||
DESCENDANTS
|
||||
}
|
||||
|
||||
@@ -314,6 +314,7 @@ SingleCharacter = [^\r\n\'\\]
|
||||
"void" { return new ParsedSymbol(SymbolGroup.OPERATOR,SymbolType.VOID,yytext()); }
|
||||
"@" { return new ParsedSymbol(SymbolGroup.OPERATOR,SymbolType.ATTRIBUTE,yytext()); }
|
||||
".(" { return new ParsedSymbol(SymbolGroup.OPERATOR,SymbolType.FILTER,yytext()); }
|
||||
".." { return new ParsedSymbol(SymbolGroup.OPERATOR,SymbolType.DESCENDANTS,yytext()); }
|
||||
|
||||
/* string literal */
|
||||
\" {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
TODO List for AS3 parser/compiler:
|
||||
------------------------------
|
||||
- default xml namespace
|
||||
- ???
|
||||
|
||||
Reference in New Issue
Block a user