This commit is contained in:
Jindra Petřík
2015-07-03 18:34:17 +02:00
parent 62127fe7fb
commit 0cea275073
178 changed files with 37069 additions and 37069 deletions
@@ -1,50 +1,50 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.operations.InstanceOfAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class InstanceOfIns extends InstructionDefinition {
public InstanceOfIns() {
super(0xb1, "instanceof", new int[]{}, true);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem type = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new InstanceOfAVM2Item(ins, value, type));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.operations.InstanceOfAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class InstanceOfIns extends InstructionDefinition {
public InstanceOfIns() {
super(0xb1, "instanceof", new int[]{}, true);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem type = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new InstanceOfAVM2Item(ins, value, type));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1;
}
}
@@ -1,51 +1,51 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.FullMultinameAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class IsTypeIns extends InstructionDefinition {
public IsTypeIns() {
super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}, true);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
int multinameIndex = ins.operands[0];
GraphTargetItem value = stack.pop();
stack.push(new IsTypeAVM2Item(ins, value, new FullMultinameAVM2Item(ins, multinameIndex)));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1; //may not be runtime multiname
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.FullMultinameAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class IsTypeIns extends InstructionDefinition {
public IsTypeIns() {
super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}, true);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
int multinameIndex = ins.operands[0];
GraphTargetItem value = stack.pop();
stack.push(new IsTypeAVM2Item(ins, value, new FullMultinameAVM2Item(ins, multinameIndex)));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1; //may not be runtime multiname
}
}
@@ -1,50 +1,50 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.operations.IsTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class IsTypeLateIns extends InstructionDefinition {
public IsTypeLateIns() {
super(0xb3, "istypelate", new int[]{}, true);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem type = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new IsTypeAVM2Item(ins, value, type));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.operations.IsTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class IsTypeLateIns extends InstructionDefinition {
public IsTypeLateIns() {
super(0xb3, "istypelate", new int[]{}, true);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem type = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new IsTypeAVM2Item(ins, value, type));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1;
}
}
@@ -1,48 +1,48 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.operations.TypeOfAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class TypeOfIns extends InstructionDefinition {
public TypeOfIns() {
super(0x95, "typeof", new int[]{}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
stack.push(new TypeOfAVM2Item(ins, stack.pop()));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
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.operations.TypeOfAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class TypeOfIns extends InstructionDefinition {
public TypeOfIns() {
super(0x95, "typeof", new int[]{}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
stack.push(new TypeOfAVM2Item(ins, stack.pop()));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
@@ -1,55 +1,55 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.FilteredCheckAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class CheckFilterIns extends InstructionDefinition {
public CheckFilterIns() {
super(0x78, "checkfilter", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
//if pop() is not XML|XMLList throw
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem obj = stack.pop();
stack.push(new FilteredCheckAVM2Item(ins, obj));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.FilteredCheckAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class CheckFilterIns extends InstructionDefinition {
public CheckFilterIns() {
super(0x78, "checkfilter", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
//if pop() is not XML|XMLList throw
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem obj = stack.pop();
stack.push(new FilteredCheckAVM2Item(ins, obj));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
@@ -1,54 +1,54 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.DefaultXMLNamespace;
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class DXNSIns extends InstructionDefinition {
public DXNSIns() {
super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
int strIndex = (int) ((Long) arguments.get(0)).longValue();
String s = constants.getString(strIndex);
System.out.println("Set default XML space " + s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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]))));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.DefaultXMLNamespace;
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class DXNSIns extends InstructionDefinition {
public DXNSIns() {
super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
int strIndex = (int) ((Long) arguments.get(0)).longValue();
String s = constants.getString(strIndex);
System.out.println("Set default XML space " + s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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]))));
}
}
@@ -1,57 +1,57 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.DefaultXMLNamespace;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class DXNSLateIns extends InstructionDefinition {
public DXNSLateIns() {
super(0x07, "dxnslate", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
String s = lda.operandStack.pop().toString();
System.out.println("Set default XML space " + s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem xmlns = stack.pop();
output.add(new DefaultXMLNamespace(ins, xmlns));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.DefaultXMLNamespace;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class DXNSLateIns extends InstructionDefinition {
public DXNSLateIns() {
super(0x07, "dxnslate", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
String s = lda.operandStack.pop().toString();
System.out.println("Set default XML space " + s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
GraphTargetItem xmlns = stack.pop();
output.add(new DefaultXMLNamespace(ins, xmlns));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}
@@ -1,56 +1,56 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.EscapeXAttrAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class EscXAttrIns extends InstructionDefinition {
public EscXAttrIns() {
super(0x72, "esc_xattr", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
String s = lda.operandStack.pop().toString();
//escape
lda.operandStack.push(s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
stack.push(new EscapeXAttrAVM2Item(ins, stack.pop()));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.EscapeXAttrAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class EscXAttrIns extends InstructionDefinition {
public EscXAttrIns() {
super(0x72, "esc_xattr", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
String s = lda.operandStack.pop().toString();
//escape
lda.operandStack.push(s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
stack.push(new EscapeXAttrAVM2Item(ins, stack.pop()));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
@@ -1,56 +1,56 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.EscapeXElemAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class EscXElemIns extends InstructionDefinition {
public EscXElemIns() {
super(0x71, "esc_xelem", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
String s = lda.operandStack.pop().toString();
//escape
lda.operandStack.push(s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
stack.push(new EscapeXElemAVM2Item(ins, stack.pop()));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.xml;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
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.model.EscapeXElemAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class EscXElemIns extends InstructionDefinition {
public EscXElemIns() {
super(0x71, "esc_xelem", new int[]{}, true);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
String s = lda.operandStack.pop().toString();
//escape
lda.operandStack.push(s);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool 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) {
stack.push(new EscapeXElemAVM2Item(ins, stack.pop()));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
@@ -1,43 +1,43 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
/**
*
* @author JPEXS
*/
public class ExceptionMarkAVM2Instruction extends AVM2Instruction {
public int markType;
public int exceptionId;
public ExceptionMarkAVM2Instruction(int exceptionId, int markType) {
super(0, null, null);
this.markType = markType;
this.exceptionId = exceptionId;
this.definition = new InstructionDefinition(0, "--mark", new int[0], false /*?*/);
}
@Override
public byte[] getBytes() {
return new byte[0];
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
/**
*
* @author JPEXS
*/
public class ExceptionMarkAVM2Instruction extends AVM2Instruction {
public int markType;
public int exceptionId;
public ExceptionMarkAVM2Instruction(int exceptionId, int markType) {
super(0, null, null);
this.markType = markType;
this.exceptionId = exceptionId;
this.definition = new InstructionDefinition(0, "--mark", new int[0], false /*?*/);
}
@Override
public byte[] getBytes() {
return new byte[0];
}
}
@@ -1,355 +1,355 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertBIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertUIns;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
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 com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
*
* @author JPEXS
*/
public class NameAVM2Item extends AssignableAVM2Item {
private String variableName;
private boolean definition;
private int nsKind = -1;
public List<Integer> openedNamespaces;
public int line;
public GraphTargetItem type;
private GraphTargetItem ns = null;
private int regNumber = -1;
public boolean unresolved = false;
private int slotNumber = -1;
private int slotScope = 0;
public GraphTargetItem redirect;
@Override
public AssignableAVM2Item copy() {
NameAVM2Item c = new NameAVM2Item(type, line, variableName, assignedValue, definition, openedNamespaces);
c.setNs(ns);
c.regNumber = regNumber;
c.unresolved = unresolved;
c.nsKind = nsKind;
return c;
}
public void setSlotScope(int slotScope) {
this.slotScope = slotScope;
}
public int getSlotScope() {
return slotScope;
}
public void setNs(GraphTargetItem ns) {
this.ns = ns;
}
public void setRegNumber(int regNumber) {
this.regNumber = regNumber;
}
public int getSlotNumber() {
return slotNumber;
}
public void setSlotNumber(int slotNumber) {
this.slotNumber = slotNumber;
}
public int getRegNumber() {
return regNumber;
}
public GraphTargetItem getNs() {
return ns;
}
public void appendName(String name) {
this.variableName += "." + name;
}
public void setDefinition(boolean definition) {
this.definition = definition;
}
public void setNsKind(int nsKind) {
this.nsKind = nsKind;
}
public int getNsKind() {
return nsKind;
}
public String getVariableName() {
return variableName;
}
public NameAVM2Item(GraphTargetItem type, int line, String variableName, GraphTargetItem storeValue, boolean definition, List<Integer> openedNamespaces) {
super(storeValue);
this.variableName = variableName;
this.assignedValue = storeValue;
this.definition = definition;
this.line = line;
this.type = type;
this.openedNamespaces = openedNamespaces;
}
public boolean isDefinition() {
return definition;
}
public GraphTargetItem getStoreValue() {
return assignedValue;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
return writer;
}
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
}
public static GraphTargetItem getDefaultValue(String type) {
switch (type) {
case "*":
return new UndefinedAVM2Item(null);
case "int":
return new IntegerValueAVM2Item(null, 0L);
case "Number":
return new NanAVM2Item(null);
default:
return new NullAVM2Item(null);
}
}
public static AVM2Instruction generateCoerce(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem ttype) throws CompilationException {
if (ttype instanceof UnresolvedAVM2Item) {
ttype = ((UnresolvedAVM2Item) ttype).resolved;
}
AVM2Instruction ins;
if (ttype instanceof UnboundedTypeItem) {
ins = ins(new CoerceAIns());
} else {
switch (ttype.toString()) {
case "int":
ins = ins(new ConvertIIns());
break;
case "*":
ins = ins(new CoerceAIns());
break;
case "String":
ins = ins(new CoerceSIns());
break;
case "Boolean":
ins = ins(new ConvertBIns());
break;
case "uint":
ins = ins(new ConvertUIns());
break;
default:
int type_index = AVM2SourceGenerator.resolveType(localData, ttype, ((AVM2SourceGenerator) generator).abc, ((AVM2SourceGenerator) generator).allABCs);
ins = ins(new CoerceIns(), type_index);
break;
}
}
return ins;
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
if (variableName != null && regNumber == -1 && slotNumber == -1 && ns == null) {
throw new CompilationException("No register or slot set for " + variableName, line);
}
if (definition && assignedValue == null) {
return new ArrayList<>();
}
String name = variableName;
boolean attr = false;
if (name != null && name.startsWith("@")) {
name = name.substring(1);
attr = true;
}
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
Reference<Integer> ns_temp = new Reference<>(-1);
Reference<Integer> index_temp = new Reference<>(-1);
Reference<Integer> ret_temp = new Reference<>(-1);
if (assignedValue != null) {
List<String> basicTypes = Arrays.asList("int", "Number");
if (slotNumber > -1) {
return toSourceMerge(localData, generator,
ins(new GetScopeObjectIns(), slotScope),
assignedValue, !(("" + assignedValue.returnType()).equals("" + type) && (basicTypes.contains("" + type))) ? generateCoerce(localData, generator, type) : null, needsReturn
? dupSetTemp(localData, generator, ret_temp) : null, generateSetLoc(regNumber), slotNumber > -1
? ins(new SetSlotIns(), slotNumber)
: null,
needsReturn ? getTemp(localData, generator, ret_temp) : null,
killTemp(localData, generator, Arrays.asList(ret_temp)));
} else {
return toSourceMerge(localData, generator, assignedValue, !(("" + assignedValue.returnType()).equals("" + type) && (basicTypes.contains("" + type))) ? generateCoerce(localData, generator, type) : null, needsReturn
? ins(new DupIns()) : null, generateSetLoc(regNumber));
}
} else {
return toSourceMerge(localData, generator, generateGetLoc(regNumber), generateGetSlot(slotScope, slotNumber),
needsReturn ? null : ins(new PopIns()));
}
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if (redirect != null) {
return redirect.toSource(localData, generator);
}
return toSource(localData, generator, true);
}
@Override
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if (redirect != null) {
return redirect.toSourceIgnoreReturnValue(localData, generator);
}
return toSource(localData, generator, false);
}
@Override
public boolean hasReturnValue() {
if (definition) {
return false;
}
return true;
}
@Override
public boolean needsSemicolon() {
if (definition) {
return true;
}
return false;
}
@Override
public String toString() {
return variableName;
}
@Override
public GraphTargetItem returnType() {
if (type == null) {
return TypeItem.UNBOUNDED;
}
return type;
}
@Override
public List<GraphSourceItem> toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException {
if (redirect != null) {
return ((AssignableAVM2Item) redirect).toSourceChange(localData, generator, post, decrement, needsReturn);
}
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
Reference<Integer> ns_temp = new Reference<>(-1);
Reference<Integer> name_temp = new Reference<>(-1);
Reference<Integer> index_temp = new Reference<>(-1);
Reference<Integer> ret_temp = new Reference<>(-1);
boolean isInteger = returnType().toString().equals("int");
/*
*/
if (!needsReturn) {
if (slotNumber > -1) {
return toSourceMerge(localData, generator,
ins(new GetScopeObjectIns(), slotScope),
generateGetSlot(slotScope, slotNumber),
(decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())),
ins(new SetSlotIns(), slotNumber)
);
} else {
return toSourceMerge(localData, generator,
(decrement ? ins(isInteger ? new DecLocalIIns() : new DecLocalIns(), regNumber) : ins(isInteger ? new IncLocalIIns() : new IncLocalIns(), regNumber)));
}
}
return toSourceMerge(localData, generator,
slotNumber > -1 ? ins(new GetScopeObjectIns(), slotScope) : null,
//Start get original
generateGetLoc(regNumber), generateGetSlot(slotScope, slotNumber),
//End get original
//!isInteger ? ins(new ConvertDIns()) : null,
//End get original
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
needsReturn ? ins(new DupIns()) : null,
(post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
generateCoerce(localData, generator, returnType()),
generateSetLoc(regNumber),
slotNumber > -1 ? ins(new SetSlotIns(), slotNumber) : null
);
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertBIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertUIns;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
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 com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
*
* @author JPEXS
*/
public class NameAVM2Item extends AssignableAVM2Item {
private String variableName;
private boolean definition;
private int nsKind = -1;
public List<Integer> openedNamespaces;
public int line;
public GraphTargetItem type;
private GraphTargetItem ns = null;
private int regNumber = -1;
public boolean unresolved = false;
private int slotNumber = -1;
private int slotScope = 0;
public GraphTargetItem redirect;
@Override
public AssignableAVM2Item copy() {
NameAVM2Item c = new NameAVM2Item(type, line, variableName, assignedValue, definition, openedNamespaces);
c.setNs(ns);
c.regNumber = regNumber;
c.unresolved = unresolved;
c.nsKind = nsKind;
return c;
}
public void setSlotScope(int slotScope) {
this.slotScope = slotScope;
}
public int getSlotScope() {
return slotScope;
}
public void setNs(GraphTargetItem ns) {
this.ns = ns;
}
public void setRegNumber(int regNumber) {
this.regNumber = regNumber;
}
public int getSlotNumber() {
return slotNumber;
}
public void setSlotNumber(int slotNumber) {
this.slotNumber = slotNumber;
}
public int getRegNumber() {
return regNumber;
}
public GraphTargetItem getNs() {
return ns;
}
public void appendName(String name) {
this.variableName += "." + name;
}
public void setDefinition(boolean definition) {
this.definition = definition;
}
public void setNsKind(int nsKind) {
this.nsKind = nsKind;
}
public int getNsKind() {
return nsKind;
}
public String getVariableName() {
return variableName;
}
public NameAVM2Item(GraphTargetItem type, int line, String variableName, GraphTargetItem storeValue, boolean definition, List<Integer> openedNamespaces) {
super(storeValue);
this.variableName = variableName;
this.assignedValue = storeValue;
this.definition = definition;
this.line = line;
this.type = type;
this.openedNamespaces = openedNamespaces;
}
public boolean isDefinition() {
return definition;
}
public GraphTargetItem getStoreValue() {
return assignedValue;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
return writer;
}
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
}
public static GraphTargetItem getDefaultValue(String type) {
switch (type) {
case "*":
return new UndefinedAVM2Item(null);
case "int":
return new IntegerValueAVM2Item(null, 0L);
case "Number":
return new NanAVM2Item(null);
default:
return new NullAVM2Item(null);
}
}
public static AVM2Instruction generateCoerce(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem ttype) throws CompilationException {
if (ttype instanceof UnresolvedAVM2Item) {
ttype = ((UnresolvedAVM2Item) ttype).resolved;
}
AVM2Instruction ins;
if (ttype instanceof UnboundedTypeItem) {
ins = ins(new CoerceAIns());
} else {
switch (ttype.toString()) {
case "int":
ins = ins(new ConvertIIns());
break;
case "*":
ins = ins(new CoerceAIns());
break;
case "String":
ins = ins(new CoerceSIns());
break;
case "Boolean":
ins = ins(new ConvertBIns());
break;
case "uint":
ins = ins(new ConvertUIns());
break;
default:
int type_index = AVM2SourceGenerator.resolveType(localData, ttype, ((AVM2SourceGenerator) generator).abc, ((AVM2SourceGenerator) generator).allABCs);
ins = ins(new CoerceIns(), type_index);
break;
}
}
return ins;
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
if (variableName != null && regNumber == -1 && slotNumber == -1 && ns == null) {
throw new CompilationException("No register or slot set for " + variableName, line);
}
if (definition && assignedValue == null) {
return new ArrayList<>();
}
String name = variableName;
boolean attr = false;
if (name != null && name.startsWith("@")) {
name = name.substring(1);
attr = true;
}
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
Reference<Integer> ns_temp = new Reference<>(-1);
Reference<Integer> index_temp = new Reference<>(-1);
Reference<Integer> ret_temp = new Reference<>(-1);
if (assignedValue != null) {
List<String> basicTypes = Arrays.asList("int", "Number");
if (slotNumber > -1) {
return toSourceMerge(localData, generator,
ins(new GetScopeObjectIns(), slotScope),
assignedValue, !(("" + assignedValue.returnType()).equals("" + type) && (basicTypes.contains("" + type))) ? generateCoerce(localData, generator, type) : null, needsReturn
? dupSetTemp(localData, generator, ret_temp) : null, generateSetLoc(regNumber), slotNumber > -1
? ins(new SetSlotIns(), slotNumber)
: null,
needsReturn ? getTemp(localData, generator, ret_temp) : null,
killTemp(localData, generator, Arrays.asList(ret_temp)));
} else {
return toSourceMerge(localData, generator, assignedValue, !(("" + assignedValue.returnType()).equals("" + type) && (basicTypes.contains("" + type))) ? generateCoerce(localData, generator, type) : null, needsReturn
? ins(new DupIns()) : null, generateSetLoc(regNumber));
}
} else {
return toSourceMerge(localData, generator, generateGetLoc(regNumber), generateGetSlot(slotScope, slotNumber),
needsReturn ? null : ins(new PopIns()));
}
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if (redirect != null) {
return redirect.toSource(localData, generator);
}
return toSource(localData, generator, true);
}
@Override
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if (redirect != null) {
return redirect.toSourceIgnoreReturnValue(localData, generator);
}
return toSource(localData, generator, false);
}
@Override
public boolean hasReturnValue() {
if (definition) {
return false;
}
return true;
}
@Override
public boolean needsSemicolon() {
if (definition) {
return true;
}
return false;
}
@Override
public String toString() {
return variableName;
}
@Override
public GraphTargetItem returnType() {
if (type == null) {
return TypeItem.UNBOUNDED;
}
return type;
}
@Override
public List<GraphSourceItem> toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException {
if (redirect != null) {
return ((AssignableAVM2Item) redirect).toSourceChange(localData, generator, post, decrement, needsReturn);
}
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
Reference<Integer> ns_temp = new Reference<>(-1);
Reference<Integer> name_temp = new Reference<>(-1);
Reference<Integer> index_temp = new Reference<>(-1);
Reference<Integer> ret_temp = new Reference<>(-1);
boolean isInteger = returnType().toString().equals("int");
/*
*/
if (!needsReturn) {
if (slotNumber > -1) {
return toSourceMerge(localData, generator,
ins(new GetScopeObjectIns(), slotScope),
generateGetSlot(slotScope, slotNumber),
(decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())),
ins(new SetSlotIns(), slotNumber)
);
} else {
return toSourceMerge(localData, generator,
(decrement ? ins(isInteger ? new DecLocalIIns() : new DecLocalIns(), regNumber) : ins(isInteger ? new IncLocalIIns() : new IncLocalIns(), regNumber)));
}
}
return toSourceMerge(localData, generator,
slotNumber > -1 ? ins(new GetScopeObjectIns(), slotScope) : null,
//Start get original
generateGetLoc(regNumber), generateGetSlot(slotScope, slotNumber),
//End get original
//!isInteger ? ins(new ConvertDIns()) : null,
//End get original
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
needsReturn ? ins(new DupIns()) : null,
(post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
generateCoerce(localData, generator, returnType()),
generateSetLoc(regNumber),
slotNumber > -1 ? ins(new SetSlotIns(), slotNumber) : null
);
}
}
@@ -1,242 +1,242 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.graph.GraphTargetItem;
/**
*
* @author JPEXS
*/
public enum SymbolType {
//Keywords
BREAK,
CASE,
CONTINUE,
DEFAULT,
DO,
WHILE,
ELSE,
FOR,
EACH,
IN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
IF,
RETURN,
SUPER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
SWITCH,
THROW,
TRY,
CATCH,
FINALLY,
WITH,
DYNAMIC,
INTERNAL,
OVERRIDE,
PRIVATE,
PROTECTED,
PUBLIC,
STATIC,
CLASS,
CONST,
EXTENDS,
FUNCTION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
GET,
IMPLEMENTS,
INTERFACE,
NAMESPACE,
PACKAGE,
SET,
VAR,
IMPORT,
USE,
FALSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NULL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
THIS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TRUE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//Operators
PARENT_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
PARENT_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
CURLY_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
CURLY_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
BRACKET_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
BRACKET_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
SEMICOLON,
COMMA(GraphTargetItem.PRECEDENCE_COMMA, false),
REST,
DOT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
ASSIGN(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
GREATER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
LOWER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
NOT(GraphTargetItem.PRECEDENCE_UNARY, false),
NEGATE(GraphTargetItem.PRECEDENCE_UNARY, false),
TERNAR(GraphTargetItem.PRECEDENCE_CONDITIONAL, true, true), /*!! ternar !!!*/
COLON(GraphTargetItem.PRECEDENCE_CONDITIONAL, false),/*!! ternar !!!*/
EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
STRICT_EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
LOWER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
GREATER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
STRICT_NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
AND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
OR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
INCREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false),//OR Unary
DECREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false), //OR Unary
PLUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true),
MINUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true), //OR Unary
MULTIPLY(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
DIVIDE(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
BITAND(GraphTargetItem.PRECEDENCE_BITWISEAND, true),
BITOR(GraphTargetItem.PRECEDENCE_BITWISEOR, true),
XOR(GraphTargetItem.PRECEDENCE_BITWISEXOR, true),
MODULO(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
SHIFT_LEFT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
ASSIGN_PLUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_MINUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_MULTIPLY(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_DIVIDE(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_BITAND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_BITOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_XOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_MODULO(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_SHIFT_LEFT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
AS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
DELETE(GraphTargetItem.PRECEDENCE_UNARY, false),
INSTANCEOF(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
IS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
NAMESPACE_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NEW(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TYPEOF(GraphTargetItem.PRECEDENCE_UNARY, false),
VOID,
ATTRIBUTE,
//Other
STRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
COMMENT,
//XML,
IDENTIFIER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
INTEGER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
DOUBLE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TYPENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
EOF,
//TRACE,
//GETURL,
//GOTOANDSTOP,
//NEXTFRAME,
//PLAY,
//PREVFRAME,
//TELLTARGET,
//STOP,
//STOPALLSOUNDS,
//TOGGLEHIGHQUALITY,
//ORD,
//CHR,
//DUPLICATEMOVIECLIP,
//STOPDRAG,
//GETTIMER,
//LOADVARIABLES,
//LOADMOVIE,
//GOTOANDPLAY,
//MBORD,
//MBCHR,
//MBLENGTH,
//MBSUBSTRING,
//RANDOM,
//REMOVEMOVIECLIP,
//STARTDRAG,
//SUBSTR,
//LENGTH, //string.length
INT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//TARGETPATH,
NUMBER_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
STRING_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//IFFRAMELOADED,
INFINITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//EVAL,
UNDEFINED(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//NEWLINE,
NAN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//GETVERSION,
//CALL,
//LOADMOVIENUM,
//LOADVARIABLESNUM,
//PRINT,
//PRINTNUM,
//PRINTASBITMAP,
//PRINTASBITMAPNUM,
//UNLOADMOVIE,
//UNLOADMOVIENUM,
FINAL,
XML_STARTTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <xxx
XML_STARTVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <{
XML_STARTTAG_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // >
XML_FINISHVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // </{
XML_FINISHTAG(GraphTargetItem.PRECEDENCE_PRIMARY, false), // </xxx>
XML_STARTFINISHTAG_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // />
XML_COMMENT(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <!-- ... -->
XML_CDATA(GraphTargetItem.PRECEDENCE_PRIMARY, false), //<![CDATA[ ... ]]>
XML_INSTR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?xxx
XML_INSTR_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // ?>
XML_VAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {
XML_ATTRIBUTENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa=
XML_ATTRIBUTEVALUE(GraphTargetItem.PRECEDENCE_PRIMARY, false), // "vvv"
XML_TEXT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
XML_ATTRNAMEVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {...}=
XML_ATTRVALVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa={
XML_INSTRATTRNAMEVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {...}=
XML_INSTRATTRVALVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa={
XML_INSTRVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?{
FILTER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
DESCENDANTS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NATIVE;
private int precedence = GraphTargetItem.NOPRECEDENCE;
private boolean binary = false;
private boolean rightAssociative = false;
public boolean isBinary() {
return binary;
}
public boolean isRightAssociative() {
return rightAssociative;
}
public int getPrecedence() {
return precedence;
}
private SymbolType(int precedence, boolean binary) {
this.precedence = precedence;
this.binary = binary;
}
private SymbolType(int precedence, boolean binary, boolean rightAssociative) {
this.precedence = precedence;
this.binary = binary;
this.rightAssociative = rightAssociative;
}
private SymbolType() {
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.graph.GraphTargetItem;
/**
*
* @author JPEXS
*/
public enum SymbolType {
//Keywords
BREAK,
CASE,
CONTINUE,
DEFAULT,
DO,
WHILE,
ELSE,
FOR,
EACH,
IN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
IF,
RETURN,
SUPER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
SWITCH,
THROW,
TRY,
CATCH,
FINALLY,
WITH,
DYNAMIC,
INTERNAL,
OVERRIDE,
PRIVATE,
PROTECTED,
PUBLIC,
STATIC,
CLASS,
CONST,
EXTENDS,
FUNCTION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
GET,
IMPLEMENTS,
INTERFACE,
NAMESPACE,
PACKAGE,
SET,
VAR,
IMPORT,
USE,
FALSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NULL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
THIS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TRUE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//Operators
PARENT_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
PARENT_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
CURLY_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
CURLY_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
BRACKET_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
BRACKET_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
SEMICOLON,
COMMA(GraphTargetItem.PRECEDENCE_COMMA, false),
REST,
DOT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
ASSIGN(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
GREATER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
LOWER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
NOT(GraphTargetItem.PRECEDENCE_UNARY, false),
NEGATE(GraphTargetItem.PRECEDENCE_UNARY, false),
TERNAR(GraphTargetItem.PRECEDENCE_CONDITIONAL, true, true), /*!! ternar !!!*/
COLON(GraphTargetItem.PRECEDENCE_CONDITIONAL, false),/*!! ternar !!!*/
EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
STRICT_EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
LOWER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
GREATER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
STRICT_NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
AND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
OR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
INCREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false),//OR Unary
DECREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false), //OR Unary
PLUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true),
MINUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true), //OR Unary
MULTIPLY(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
DIVIDE(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
BITAND(GraphTargetItem.PRECEDENCE_BITWISEAND, true),
BITOR(GraphTargetItem.PRECEDENCE_BITWISEOR, true),
XOR(GraphTargetItem.PRECEDENCE_BITWISEXOR, true),
MODULO(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
SHIFT_LEFT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
ASSIGN_PLUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_MINUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_MULTIPLY(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_DIVIDE(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_BITAND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_BITOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_XOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_MODULO(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_SHIFT_LEFT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
AS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
DELETE(GraphTargetItem.PRECEDENCE_UNARY, false),
INSTANCEOF(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
IS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
NAMESPACE_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NEW(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TYPEOF(GraphTargetItem.PRECEDENCE_UNARY, false),
VOID,
ATTRIBUTE,
//Other
STRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
COMMENT,
//XML,
IDENTIFIER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
INTEGER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
DOUBLE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TYPENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
EOF,
//TRACE,
//GETURL,
//GOTOANDSTOP,
//NEXTFRAME,
//PLAY,
//PREVFRAME,
//TELLTARGET,
//STOP,
//STOPALLSOUNDS,
//TOGGLEHIGHQUALITY,
//ORD,
//CHR,
//DUPLICATEMOVIECLIP,
//STOPDRAG,
//GETTIMER,
//LOADVARIABLES,
//LOADMOVIE,
//GOTOANDPLAY,
//MBORD,
//MBCHR,
//MBLENGTH,
//MBSUBSTRING,
//RANDOM,
//REMOVEMOVIECLIP,
//STARTDRAG,
//SUBSTR,
//LENGTH, //string.length
INT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//TARGETPATH,
NUMBER_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
STRING_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//IFFRAMELOADED,
INFINITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//EVAL,
UNDEFINED(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//NEWLINE,
NAN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
//GETVERSION,
//CALL,
//LOADMOVIENUM,
//LOADVARIABLESNUM,
//PRINT,
//PRINTNUM,
//PRINTASBITMAP,
//PRINTASBITMAPNUM,
//UNLOADMOVIE,
//UNLOADMOVIENUM,
FINAL,
XML_STARTTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <xxx
XML_STARTVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <{
XML_STARTTAG_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // >
XML_FINISHVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // </{
XML_FINISHTAG(GraphTargetItem.PRECEDENCE_PRIMARY, false), // </xxx>
XML_STARTFINISHTAG_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // />
XML_COMMENT(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <!-- ... -->
XML_CDATA(GraphTargetItem.PRECEDENCE_PRIMARY, false), //<![CDATA[ ... ]]>
XML_INSTR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?xxx
XML_INSTR_END(GraphTargetItem.PRECEDENCE_PRIMARY, false), // ?>
XML_VAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {
XML_ATTRIBUTENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa=
XML_ATTRIBUTEVALUE(GraphTargetItem.PRECEDENCE_PRIMARY, false), // "vvv"
XML_TEXT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
XML_ATTRNAMEVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {...}=
XML_ATTRVALVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa={
XML_INSTRATTRNAMEVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // {...}=
XML_INSTRATTRVALVAR_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // aaa={
XML_INSTRVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?{
FILTER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
DESCENDANTS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NATIVE;
private int precedence = GraphTargetItem.NOPRECEDENCE;
private boolean binary = false;
private boolean rightAssociative = false;
public boolean isBinary() {
return binary;
}
public boolean isRightAssociative() {
return rightAssociative;
}
public int getPrecedence() {
return precedence;
}
private SymbolType(int precedence, boolean binary) {
this.precedence = precedence;
this.binary = binary;
}
private SymbolType(int precedence, boolean binary, boolean rightAssociative) {
this.precedence = precedence;
this.binary = binary;
this.rightAssociative = rightAssociative;
}
private SymbolType() {
}
}
@@ -1,49 +1,49 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import java.util.List;
public class ClassInfo {
public int cinit_index; //MethodInfo - static initializer
public Traits static_traits;
@Internal
public boolean deleted;
public ClassInfo() {
static_traits = new Traits();
}
public ClassInfo(Traits traits) {
static_traits = traits;
}
@Override
public String toString() {
return "method_index=" + cinit_index + "\r\n" + static_traits.toString();
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc, fullyQualifiedNames);
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import java.util.List;
public class ClassInfo {
public int cinit_index; //MethodInfo - static initializer
public Traits static_traits;
@Internal
public boolean deleted;
public ClassInfo() {
static_traits = new Traits();
}
public ClassInfo(Traits traits) {
static_traits = traits;
}
@Override
public String toString() {
return "method_index=" + cinit_index + "\r\n" + static_traits.toString();
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc, fullyQualifiedNames);
}
}
@@ -1,140 +1,140 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
import java.util.List;
public class InstanceInfo {
public int name_index;
public int super_index;
public int flags; // 1 = sealed, 0 = dynamic, 2 = final, 4 = interface, 8 = ProtectedNs
public int protectedNS; //if flags & 8
public int[] interfaces;
public int iinit_index; // MethodInfo - constructor
public Traits instance_traits;
public static final int CLASS_SEALED = 1; //not dynamic
public static final int CLASS_FINAL = 2;
public static final int CLASS_INTERFACE = 4;
public static final int CLASS_PROTECTEDNS = 8;
@Internal
public boolean deleted;
public InstanceInfo() {
instance_traits = new Traits();
}
public InstanceInfo(Traits traits) {
instance_traits = traits;
}
@Override
public String toString() {
return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString();
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
String supIndexStr = "[nothing]";
if (super_index > 0) {
supIndexStr = abc.constants.getMultiname(super_index).toString(abc.constants, fullyQualifiedNames);
}
return "name_index=" + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames);
}
public GraphTextWriter getClassHeaderStr(GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames, boolean allowPrivate) {
String modifiers;
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
modifiers = ns.getPrefix(abc);
if (!allowPrivate && modifiers.equals("private")) {
modifiers = "";
}
if (!modifiers.isEmpty()) {
modifiers += " ";
}
if (isFinal()) {
modifiers += "final ";
}
if (!isInterface() && isDynamic()) {
modifiers += "dynamic ";
}
String objType = "class ";
if (isInterface()) {
objType = "interface ";
}
writer.appendNoHilight(modifiers + objType);
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<>()/* No full names here*/, false), HighlightSpecialType.CLASS_NAME);
if (super_index > 0) {
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true);
writer.appendNoHilight(" extends ");
writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName);
}
if (interfaces.length > 0) {
if (isInterface()) {
writer.appendNoHilight(" extends ");
} else {
writer.appendNoHilight(" implements ");
}
for (int i = 0; i < interfaces.length; i++) {
if (i > 0) {
writer.append(", ");
}
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true);
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName);
}
}
return writer;
}
public Multiname getName(AVM2ConstantPool constants) {
return constants.getMultiname(name_index);
}
public boolean isInterface() {
return ((flags & CLASS_INTERFACE) == CLASS_INTERFACE);
}
public boolean isDynamic() {
return (flags & CLASS_SEALED) == 0;
}
public boolean isFinal() {
return (flags & CLASS_FINAL) == CLASS_FINAL;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
import java.util.List;
public class InstanceInfo {
public int name_index;
public int super_index;
public int flags; // 1 = sealed, 0 = dynamic, 2 = final, 4 = interface, 8 = ProtectedNs
public int protectedNS; //if flags & 8
public int[] interfaces;
public int iinit_index; // MethodInfo - constructor
public Traits instance_traits;
public static final int CLASS_SEALED = 1; //not dynamic
public static final int CLASS_FINAL = 2;
public static final int CLASS_INTERFACE = 4;
public static final int CLASS_PROTECTEDNS = 8;
@Internal
public boolean deleted;
public InstanceInfo() {
instance_traits = new Traits();
}
public InstanceInfo(Traits traits) {
instance_traits = traits;
}
@Override
public String toString() {
return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString();
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
String supIndexStr = "[nothing]";
if (super_index > 0) {
supIndexStr = abc.constants.getMultiname(super_index).toString(abc.constants, fullyQualifiedNames);
}
return "name_index=" + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames);
}
public GraphTextWriter getClassHeaderStr(GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames, boolean allowPrivate) {
String modifiers;
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
modifiers = ns.getPrefix(abc);
if (!allowPrivate && modifiers.equals("private")) {
modifiers = "";
}
if (!modifiers.isEmpty()) {
modifiers += " ";
}
if (isFinal()) {
modifiers += "final ";
}
if (!isInterface() && isDynamic()) {
modifiers += "dynamic ";
}
String objType = "class ";
if (isInterface()) {
objType = "interface ";
}
writer.appendNoHilight(modifiers + objType);
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<>()/* No full names here*/, false), HighlightSpecialType.CLASS_NAME);
if (super_index > 0) {
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true);
writer.appendNoHilight(" extends ");
writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName);
}
if (interfaces.length > 0) {
if (isInterface()) {
writer.appendNoHilight(" extends ");
} else {
writer.appendNoHilight(" implements ");
}
for (int i = 0; i < interfaces.length; i++) {
if (i > 0) {
writer.append(", ");
}
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true);
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName);
}
}
return writer;
}
public Multiname getName(AVM2ConstantPool constants) {
return constants.getMultiname(name_index);
}
public boolean isInterface() {
return ((flags & CLASS_INTERFACE) == CLASS_INTERFACE);
}
public boolean isDynamic() {
return (flags & CLASS_SEALED) == 0;
}
public boolean isFinal() {
return (flags & CLASS_FINAL) == CLASS_FINAL;
}
}
@@ -1,200 +1,200 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.helpers.Helper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public abstract class Trait implements Serializable {
private static final int[] EMPTY_METADATA_ARRAY = new int[0];
public int name_index;
public int kindType;
public int kindFlags;
public int[] metadata = EMPTY_METADATA_ARRAY;
public long fileOffset;
public byte[] bytes;
public static final int ATTR_Final = 0x1;
public static final int ATTR_Override = 0x2;
public static final int ATTR_Metadata = 0x4;
public static final int TRAIT_SLOT = 0;
public static final int TRAIT_METHOD = 1;
public static final int TRAIT_GETTER = 2;
public static final int TRAIT_SETTER = 3;
public static final int TRAIT_CLASS = 4;
public static final int TRAIT_FUNCTION = 5;
public static final int TRAIT_CONST = 6;
public abstract void delete(ABC abc, boolean d);
public String getModifiers(ABC abc, boolean isStatic) {
String ret = "";
if ((kindFlags & ATTR_Override) > 0) {
ret += "override";
}
Multiname m = getName(abc);
if (m != null) {
String nsname = "";
//if (abc.constants.getNamespace(m.namespace_index).kind == Namespace.KIND_NAMESPACE) {
{
for (ABCContainerTag abcTag : abc.getAbcTags()) {
if (m.namespace_index == -1) {
break;
}
nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants, true));
if (nsname == null) {
break;
}
if (nsname.contains(".")) {
nsname = nsname.substring(nsname.lastIndexOf('.') + 1);
}
if (!nsname.isEmpty()) {
break;
}
}
}
Namespace ns = m.getNamespace(abc.constants);
if (nsname.contains(":")) {
nsname = "";
}
if ((!nsname.isEmpty()) && (!nsname.equals("-"))) {
} else {
if (ns != null) {
if (ns.kind == Namespace.KIND_NAMESPACE) {
nsname = ns.getName(abc.constants, true);
}
}
}
if (nsname != null && (!nsname.contains(":")) && (!nsname.isEmpty())) {
ret += " " + nsname;
}
if (ns != null) {
ret += " " + ns.getPrefix(abc);
}
}
if (isStatic) {
if ((this instanceof TraitSlotConst) && ((TraitSlotConst) this).isNamespace()) {
//static is automatic
} else {
ret += " static";
}
}
if ((kindFlags & ATTR_Final) > 0) {
if (!isStatic) {
ret += " final";
}
}
return ret.trim();
}
@Override
public String toString() {
return "name_index=" + name_index + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
}
public GraphTextWriter toString(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
writer.appendNoHilight(abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata));
return writer;
}
public void convert(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
}
public GraphTextWriter toStringPackaged(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants, false);
writer.appendNoHilight("package");
if (!nsname.isEmpty()) {
writer.appendNoHilight(" " + nsname); //assume not null name
}
writer.startBlock();
toString(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
writer.endBlock();
writer.newLine();
}
return writer;
}
public void convertPackaged(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants, false);
convert(parent, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
}
public GraphTextWriter toStringHeader(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
toString(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
return writer;
}
public void convertHeader(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
convert(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
public Multiname getName(ABC abc) {
if (name_index == 0) {
return null;
} else {
return abc.constants.getMultiname(name_index);
}
}
public abstract int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException;
public ClassPath getPath(ABC abc) {
Multiname name = getName(abc);
Namespace ns = name.getNamespace(abc.constants);
String packageName = ns.getName(abc.constants, false);
String objectName = name.getName(abc.constants, new ArrayList<>(), false);
return new ClassPath(packageName, objectName); //assume not null name
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.helpers.Helper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public abstract class Trait implements Serializable {
private static final int[] EMPTY_METADATA_ARRAY = new int[0];
public int name_index;
public int kindType;
public int kindFlags;
public int[] metadata = EMPTY_METADATA_ARRAY;
public long fileOffset;
public byte[] bytes;
public static final int ATTR_Final = 0x1;
public static final int ATTR_Override = 0x2;
public static final int ATTR_Metadata = 0x4;
public static final int TRAIT_SLOT = 0;
public static final int TRAIT_METHOD = 1;
public static final int TRAIT_GETTER = 2;
public static final int TRAIT_SETTER = 3;
public static final int TRAIT_CLASS = 4;
public static final int TRAIT_FUNCTION = 5;
public static final int TRAIT_CONST = 6;
public abstract void delete(ABC abc, boolean d);
public String getModifiers(ABC abc, boolean isStatic) {
String ret = "";
if ((kindFlags & ATTR_Override) > 0) {
ret += "override";
}
Multiname m = getName(abc);
if (m != null) {
String nsname = "";
//if (abc.constants.getNamespace(m.namespace_index).kind == Namespace.KIND_NAMESPACE) {
{
for (ABCContainerTag abcTag : abc.getAbcTags()) {
if (m.namespace_index == -1) {
break;
}
nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants, true));
if (nsname == null) {
break;
}
if (nsname.contains(".")) {
nsname = nsname.substring(nsname.lastIndexOf('.') + 1);
}
if (!nsname.isEmpty()) {
break;
}
}
}
Namespace ns = m.getNamespace(abc.constants);
if (nsname.contains(":")) {
nsname = "";
}
if ((!nsname.isEmpty()) && (!nsname.equals("-"))) {
} else {
if (ns != null) {
if (ns.kind == Namespace.KIND_NAMESPACE) {
nsname = ns.getName(abc.constants, true);
}
}
}
if (nsname != null && (!nsname.contains(":")) && (!nsname.isEmpty())) {
ret += " " + nsname;
}
if (ns != null) {
ret += " " + ns.getPrefix(abc);
}
}
if (isStatic) {
if ((this instanceof TraitSlotConst) && ((TraitSlotConst) this).isNamespace()) {
//static is automatic
} else {
ret += " static";
}
}
if ((kindFlags & ATTR_Final) > 0) {
if (!isStatic) {
ret += " final";
}
}
return ret.trim();
}
@Override
public String toString() {
return "name_index=" + name_index + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
}
public GraphTextWriter toString(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
writer.appendNoHilight(abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata));
return writer;
}
public void convert(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
}
public GraphTextWriter toStringPackaged(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants, false);
writer.appendNoHilight("package");
if (!nsname.isEmpty()) {
writer.appendNoHilight(" " + nsname); //assume not null name
}
writer.startBlock();
toString(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
writer.endBlock();
writer.newLine();
}
return writer;
}
public void convertPackaged(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants, false);
convert(parent, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
}
public GraphTextWriter toStringHeader(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
toString(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
return writer;
}
public void convertHeader(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
convert(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
public Multiname getName(ABC abc) {
if (name_index == 0) {
return null;
} else {
return abc.constants.getMultiname(name_index);
}
}
public abstract int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException;
public ClassPath getPath(ABC abc) {
Multiname name = getName(abc);
Namespace ns = name.getNamespace(abc.constants);
String packageName = ns.getName(abc.constants, false);
String objectName = name.getName(abc.constants, new ArrayList<>(), false);
return new ClassPath(packageName, objectName); //assume not null name
}
}
@@ -1,216 +1,216 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Traits implements Serializable {
public List<Trait> traits;
public Traits() {
traits = new ArrayList<>();
}
public Traits(int initialCapacity) {
traits = new ArrayList<>(initialCapacity);
}
public void delete(ABC abc, boolean d) {
for (Trait t : traits) {
t.delete(abc, d);
}
}
public int addTrait(Trait t) {
traits.add(t);
return traits.size() - 1;
}
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException {
int ret = 0;
for (Trait t : traits) {
ret += t.removeTraps(scriptIndex, classIndex, isStatic, abc, path);
}
return ret;
}
@Override
public String toString() {
String s = "";
for (int t = 0; t < traits.size(); t++) {
if (t > 0) {
s += "\r\n";
}
s += traits.get(t).toString();
}
return s;
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
String s = "";
for (int t = 0; t < traits.size(); t++) {
if (t > 0) {
s += "\r\n";
}
s += traits.get(t).toString(abc, fullyQualifiedNames);
}
return s;
}
private class TraitConvertTask implements Callable<Void> {
Trait trait;
boolean makePackages;
String path;
ABC abc;
boolean isStatic;
ScriptExportMode exportMode;
int scriptIndex;
int classIndex;
NulWriter writer;
List<String> fullyQualifiedNames;
int traitIndex;
boolean parallel;
Trait parent;
public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, int traitIndex, boolean parallel) {
this.trait = trait;
this.parent = parent;
this.makePackages = makePackages;
this.path = path;
this.abc = abc;
this.isStatic = isStatic;
this.exportMode = exportMode;
this.scriptIndex = scriptIndex;
this.classIndex = classIndex;
this.writer = writer;
this.fullyQualifiedNames = fullyQualifiedNames;
this.traitIndex = traitIndex;
this.parallel = parallel;
}
@Override
public Void call() throws InterruptedException {
if (makePackages) {
trait.convertPackaged(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
} else {
trait.convert(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
return null;
}
}
public GraphTextWriter toString(Class[] traitTypes, Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
for (int t = 0; t < traits.size(); t++) {
Trait trait = traits.get(t);
if (traitTypes != null) {
boolean found = false;
for (Class c : traitTypes) {
if (c.isInstance(trait)) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
writer.newLine();
int h = t;
if (classIndex != -1) {
if (!isStatic) {
h += abc.class_info.get(classIndex).static_traits.traits.size();
}
}
if (trait instanceof TraitClass) {
writer.startClass(((TraitClass) trait).class_info);
} else {
writer.startTrait(h);
}
if (makePackages) {
trait.toStringPackaged(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
} else {
trait.toString(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
if (trait instanceof TraitClass) {
writer.endClass();
} else {
writer.endTrait();
}
}
return writer;
}
public void convert(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
if (!parallel || traits.size() < 2) {
for (int t = 0; t < traits.size(); t++) {
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel);
task.call();
}
} else {
ExecutorService executor = Executors.newFixedThreadPool(Configuration.getParallelThreadCount());
List<Future<Void>> futureResults = null;
futureResults = new ArrayList<>();
for (int t = 0; t < traits.size(); t++) {
// each convert task needs a separate NulWriter, because they are executed parallel
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, new NulWriter(), fullyQualifiedNames, t, parallel);
Future<Void> future = executor.submit(task);
futureResults.add(future);
}
for (int f = 0; f < futureResults.size(); f++) {
try {
futureResults.get(f).get();
} catch (InterruptedException ex) {
executor.shutdownNow();
throw ex;
} catch (ExecutionException ex) {
Logger.getLogger(Traits.class.getName()).log(Level.SEVERE, "Error during traits converting", ex);
}
}
executor.shutdown();
}
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Traits implements Serializable {
public List<Trait> traits;
public Traits() {
traits = new ArrayList<>();
}
public Traits(int initialCapacity) {
traits = new ArrayList<>(initialCapacity);
}
public void delete(ABC abc, boolean d) {
for (Trait t : traits) {
t.delete(abc, d);
}
}
public int addTrait(Trait t) {
traits.add(t);
return traits.size() - 1;
}
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException {
int ret = 0;
for (Trait t : traits) {
ret += t.removeTraps(scriptIndex, classIndex, isStatic, abc, path);
}
return ret;
}
@Override
public String toString() {
String s = "";
for (int t = 0; t < traits.size(); t++) {
if (t > 0) {
s += "\r\n";
}
s += traits.get(t).toString();
}
return s;
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
String s = "";
for (int t = 0; t < traits.size(); t++) {
if (t > 0) {
s += "\r\n";
}
s += traits.get(t).toString(abc, fullyQualifiedNames);
}
return s;
}
private class TraitConvertTask implements Callable<Void> {
Trait trait;
boolean makePackages;
String path;
ABC abc;
boolean isStatic;
ScriptExportMode exportMode;
int scriptIndex;
int classIndex;
NulWriter writer;
List<String> fullyQualifiedNames;
int traitIndex;
boolean parallel;
Trait parent;
public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, int traitIndex, boolean parallel) {
this.trait = trait;
this.parent = parent;
this.makePackages = makePackages;
this.path = path;
this.abc = abc;
this.isStatic = isStatic;
this.exportMode = exportMode;
this.scriptIndex = scriptIndex;
this.classIndex = classIndex;
this.writer = writer;
this.fullyQualifiedNames = fullyQualifiedNames;
this.traitIndex = traitIndex;
this.parallel = parallel;
}
@Override
public Void call() throws InterruptedException {
if (makePackages) {
trait.convertPackaged(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
} else {
trait.convert(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
return null;
}
}
public GraphTextWriter toString(Class[] traitTypes, Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
for (int t = 0; t < traits.size(); t++) {
Trait trait = traits.get(t);
if (traitTypes != null) {
boolean found = false;
for (Class c : traitTypes) {
if (c.isInstance(trait)) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
writer.newLine();
int h = t;
if (classIndex != -1) {
if (!isStatic) {
h += abc.class_info.get(classIndex).static_traits.traits.size();
}
}
if (trait instanceof TraitClass) {
writer.startClass(((TraitClass) trait).class_info);
} else {
writer.startTrait(h);
}
if (makePackages) {
trait.toStringPackaged(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
} else {
trait.toString(parent, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
if (trait instanceof TraitClass) {
writer.endClass();
} else {
writer.endTrait();
}
}
return writer;
}
public void convert(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
if (!parallel || traits.size() < 2) {
for (int t = 0; t < traits.size(); t++) {
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel);
task.call();
}
} else {
ExecutorService executor = Executors.newFixedThreadPool(Configuration.getParallelThreadCount());
List<Future<Void>> futureResults = null;
futureResults = new ArrayList<>();
for (int t = 0; t < traits.size(); t++) {
// each convert task needs a separate NulWriter, because they are executed parallel
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, makePackages, path, abc, isStatic, exportMode, scriptIndex, classIndex, new NulWriter(), fullyQualifiedNames, t, parallel);
Future<Void> future = executor.submit(task);
futureResults.add(future);
}
for (int f = 0; f < futureResults.size(); f++) {
try {
futureResults.get(f).get();
} catch (InterruptedException ex) {
executor.shutdownNow();
throw ex;
} catch (ExecutionException ex) {
Logger.getLogger(Traits.class.getName()).log(Level.SEVERE, "Error during traits converting", ex);
}
}
executor.shutdown();
}
}
}