diff --git a/trunk/src/com/jpexs/asdec/abc/ABC.java b/trunk/src/com/jpexs/asdec/abc/ABC.java index 9bef56415..99e33a9a8 100644 --- a/trunk/src/com/jpexs/asdec/abc/ABC.java +++ b/trunk/src/com/jpexs/asdec/abc/ABC.java @@ -29,6 +29,19 @@ import com.jpexs.asdec.abc.types.*; import com.jpexs.asdec.abc.types.traits.Trait; import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.asdec.abc.types.traits.TraitSlotConst; +import com.jpexs.asdec.abc.types.traits.Traits; +import com.jpexs.asdec.abc.usages.ClassNameMultinameUsage; +import com.jpexs.asdec.abc.usages.ConstVarNameMultinameUsage; +import com.jpexs.asdec.abc.usages.ConstVarTypeMultinameUsage; +import com.jpexs.asdec.abc.usages.ExtendsMultinameUsage; +import com.jpexs.asdec.abc.usages.ImplementsMultinameUsage; +import com.jpexs.asdec.abc.usages.MethodBodyMultinameUsage; +import com.jpexs.asdec.abc.usages.MethodNameMultinameUsage; +import com.jpexs.asdec.abc.usages.MethodParamsMultinameUsage; +import com.jpexs.asdec.abc.usages.MethodReturnTypeMultinameUsage; +import com.jpexs.asdec.abc.usages.InsideClassMultinameUsage; +import com.jpexs.asdec.abc.usages.MultinameUsage; +import com.jpexs.asdec.abc.usages.TypeNameMultinameUsage; import com.jpexs.asdec.helpers.Highlighting; import java.io.*; @@ -519,8 +532,7 @@ public class ABC { return ret; } - public Trait findTraitByTraitId(int classIndex, int traitId) - { + public Trait findTraitByTraitId(int classIndex, int traitId) { if (traitId < class_info[classIndex].static_traits.traits.length) { return class_info[classIndex].static_traits.traits[traitId]; } else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) { @@ -580,7 +592,7 @@ public class ABC { out.println(IDENT_STRING + classHeader); out.println(IDENT_STRING + "{"); - String toPrint=""; + String toPrint = ""; //if (class_info[i].cinit_index != 0) { if (AUTOINIT_STATIC_VARIABLES) { @@ -614,14 +626,14 @@ public class ABC { String bodyStr = ""; int bodyIndex = findBodyIndex(class_info[i].cinit_index); if (bodyIndex != -1) { - bodyStr = addTabs(bodies[bodyIndex].toString(pcode,true,i,this, constants, method_info, highlight), 3); + bodyStr = addTabs(bodies[bodyIndex].toString(pcode, true, i, this, constants, method_info, highlight), 3); } - // if (!bodyStr.equals("")) { - toPrint = IDENT_STRING + IDENT_STRING + "{\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}"; - if (highlight) { - toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + instance_info[i].instance_traits.traits.length + 1); - } - out.println(toPrint); + // if (!bodyStr.equals("")) { + toPrint = IDENT_STRING + IDENT_STRING + "{\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}"; + if (highlight) { + toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + instance_info[i].instance_traits.traits.length + 1); + } + out.println(toPrint); //} //} @@ -796,105 +808,90 @@ public class ABC { return isValid; } - public List findMultinameUsage(int multinameIndex) { - List ret = new ArrayList(); - List bodyIndices = new ArrayList(); - List subTraitBodyIndices = new ArrayList(); - List subTraitIndexIndices = new ArrayList(); - for (int i = 0; i < bodies.length; i++) { - for (int t = 0; t < bodies[i].traits.traits.length; t++) { - Trait tr = bodies[i].traits.traits[t]; - if (tr.name_index == multinameIndex) { - subTraitBodyIndices.add(i); - subTraitIndexIndices.add(t); + private void checkMultinameUsedInMethod(int multinameIndex, int methodInfo, List ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer) { + for (int p = 0; p < method_info[methodInfo].param_types.length; p++) { + if (method_info[methodInfo].param_types[p] == multinameIndex) { + ret.add(new MethodParamsMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer)); + } + } + if (method_info[methodInfo].ret_type == multinameIndex) { + ret.add(new MethodReturnTypeMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer)); + } + MethodBody body = findBody(methodInfo); + if (body != null) { + for(ABCException e:body.exceptions){ + if((e.name_index==multinameIndex)||(e.type_index==multinameIndex)){ + ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer)); + return; } } - loopbody: - for (AVM2Instruction ins : bodies[i].code.code) { - for (int op = 0; op < ins.definition.operands.length; op++) { - if (ins.definition.operands[op] == AVM2Code.DAT_MULTINAME_INDEX) { - if (ins.operands[op] == multinameIndex) { - bodyIndices.add(i); - break loopbody; + for (AVM2Instruction ins : body.code.code) { + for (int o = 0; o < ins.definition.operands.length; o++) { + if (ins.definition.operands[o] == AVM2Code.DAT_MULTINAME_INDEX) { + if (ins.operands[o] == multinameIndex) { + ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer)); + return; } } } } } + } + private void findMultinameUsageInTraits(Traits traits, int multinameIndex, boolean isStatic, int classIndex, List ret) { + for (int t = 0; t < traits.traits.length; t++) { + if (traits.traits[t] instanceof TraitSlotConst) { + TraitSlotConst tsc = (TraitSlotConst) traits.traits[t]; + if (tsc.name_index == multinameIndex) { + ret.add(new ConstVarNameMultinameUsage(multinameIndex, classIndex, t, isStatic)); + } + if (tsc.type_index == multinameIndex) { + ret.add(new ConstVarTypeMultinameUsage(multinameIndex, classIndex, t, isStatic)); + } + } + if (traits.traits[t] instanceof TraitMethodGetterSetter) { + TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) traits.traits[t]; + if (tmgs.name_index == multinameIndex) { + ret.add(new MethodNameMultinameUsage(multinameIndex, classIndex, t, isStatic, false)); + } + checkMultinameUsedInMethod(multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false); + } + } + } - for (int c = 0; c < class_info.length; c++) { + public List findMultinameUsage(int multinameIndex) { + List ret = new ArrayList(); + if (multinameIndex == 0) { + return ret; + } + for (int c = 0; c < instance_info.length; c++) { if (instance_info[c].name_index == multinameIndex) { - ret.add(new Usage(this, -1, c, -1, -1, false, Usage.TYPE_CLASS_NAME)); + ret.add(new ClassNameMultinameUsage(multinameIndex, c)); } - for (int t = 0; t < class_info[c].static_traits.traits.length; t++) { - Trait tr = class_info[c].static_traits.traits[t]; - if (tr.name_index == multinameIndex) { - ret.add(new Usage(this, -1, c, t, -1, true, Usage.TYPE_TRAIT_NAME)); - } - } - for (int t = 0; t < instance_info[c].instance_traits.traits.length; t++) { - Trait tr = instance_info[c].instance_traits.traits[t]; - if (tr.name_index == multinameIndex) { - ret.add(new Usage(this, -1, c, t, -1, false, Usage.TYPE_TRAIT_NAME)); + if (instance_info[c].super_index == multinameIndex) { + ret.add(new ExtendsMultinameUsage(multinameIndex, c)); + } + for (int i = 0; i < instance_info[c].interfaces.length; i++) { + if (instance_info[c].interfaces[i] == multinameIndex) { + ret.add(new ImplementsMultinameUsage(multinameIndex, c)); } } + checkMultinameUsedInMethod(multinameIndex, instance_info[c].iinit_index, ret, c, 0, false, true); + checkMultinameUsedInMethod(multinameIndex, class_info[c].cinit_index, ret, c, 0, true, true); + findMultinameUsageInTraits(instance_info[c].instance_traits, multinameIndex, false, c, ret); + findMultinameUsageInTraits(class_info[c].static_traits, multinameIndex, true, c, ret); } - for (int bodyIndex : bodyIndices) { - for (int c = 0; c < class_info.length; c++) { - if (class_info[c].cinit_index == bodyIndex) { - ret.add(new Usage(this, bodyIndex, c, -1, -1, true, Usage.TYPE_INITIALIZER)); + loopm: + for (int m = 1; m < constants.constant_multiname.length; m++) { + if (constants.constant_multiname[m].kind == Multiname.TYPENAME) { + if (constants.constant_multiname[m].qname_index == multinameIndex) { + ret.add(new TypeNameMultinameUsage(m)); + continue; } - if (instance_info[c].iinit_index == bodyIndex) { - ret.add(new Usage(this, bodyIndex, c, -1, -1, false, Usage.TYPE_INITIALIZER)); - } - for (int t = 0; t < class_info[c].static_traits.traits.length; t++) { - Trait tr = class_info[c].static_traits.traits[t]; - if (tr instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) tr; - if (tmgs.method_info == bodies[bodyIndex].method_info) { - ret.add(new Usage(this, bodyIndex, c, t, -1, true, Usage.TYPE_TRAIT_BODY)); - } - } - } - for (int t = 0; t < instance_info[c].instance_traits.traits.length; t++) { - Trait tr = instance_info[c].instance_traits.traits[t]; - if (tr instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) tr; - if (tmgs.method_info == bodies[bodyIndex].method_info) { - ret.add(new Usage(this, bodyIndex, c, t, -1, false, Usage.TYPE_TRAIT_BODY)); - } - } - } - } - } - - - for (int b = 0; b < subTraitBodyIndices.size(); b++) { - int bodyIndex = subTraitBodyIndices.get(b); - for (int c = 0; c < class_info.length; c++) { - if (class_info[c].cinit_index == bodyIndex) { - ret.add(new Usage(this, bodyIndex, c, -1, subTraitIndexIndices.get(b), true, Usage.TYPE_INITIALIZER_SUBTRAIT_NAME)); - } - if (instance_info[c].iinit_index == bodyIndex) { - ret.add(new Usage(this, bodyIndex, c, -1, subTraitIndexIndices.get(b), false, Usage.TYPE_INITIALIZER_SUBTRAIT_NAME)); - } - for (int t = 0; t < class_info[c].static_traits.traits.length; t++) { - Trait tr = class_info[c].static_traits.traits[t]; - if (tr instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) tr; - if (tmgs.method_info == bodies[bodyIndex].method_info) { - ret.add(new Usage(this, bodyIndex, c, t, subTraitIndexIndices.get(b), true, Usage.TYPE_SUBTRAIT_NAME)); - } - } - } - for (int t = 0; t < instance_info[c].instance_traits.traits.length; t++) { - Trait tr = instance_info[c].instance_traits.traits[t]; - if (tr instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) tr; - if (tmgs.method_info == bodies[bodyIndex].method_info) { - ret.add(new Usage(this, bodyIndex, c, t, subTraitIndexIndices.get(b), false, Usage.TYPE_SUBTRAIT_NAME)); - } + for (int mp : constants.constant_multiname[m].params) { + if (mp == multinameIndex) { + ret.add(new TypeNameMultinameUsage(m)); + continue loopm; } } } @@ -902,8 +899,8 @@ public class ABC { return ret; } - public void autoFillAllBodyParams(){ - for(int i=0;i usages=abc.findMultinameUsage(multinameIndex); - for(Usage u:usages){ + List usages=abc.findMultinameUsage(multinameIndex); + usageListModel=new UsageListModel(abc); + for(MultinameUsage u:usages){ usageListModel.addElement(u); } usageList=new JList(usageListModel); diff --git a/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java b/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java new file mode 100644 index 000000000..f8d063cae --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.gui; + +import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.usages.MultinameUsage; +import javax.swing.DefaultListModel; + +/** + * + * @author JPEXS + */ +public class UsageListModel extends DefaultListModel{ + + private ABC abc; + public UsageListModel(ABC abc){ + this.abc=abc; + } + @Override + public Object get(int index) { + return ((MultinameUsage)super.get(index)).toString(abc); + } + + @Override + public Object getElementAt(int index) { + return ((MultinameUsage)super.getElementAt(index)).toString(abc); + } + + + + + +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java new file mode 100644 index 000000000..9d15599f8 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class ClassNameMultinameUsage extends InsideClassMultinameUsage +{ + + public ClassNameMultinameUsage(int multinameIndex,int classIndex) + { + super(multinameIndex,classIndex); + } + + @Override + public String toString(ABC abc) { + return "class "+abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java new file mode 100644 index 000000000..2425099a5 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter; +import com.jpexs.asdec.abc.types.traits.TraitSlotConst; + +/** + * + * @author JPEXS + */ +public abstract class ConstVarMultinameUsage extends InsideClassMultinameUsage { + + public int traitIndex ; + public boolean isStatic; + public ConstVarMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic) + { + super(multinameIndex,classIndex); + this.traitIndex=traitIndex; + this.isStatic=isStatic; + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" "+(isStatic? + ((TraitSlotConst)abc.class_info[classIndex].static_traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc,true) + : + ((TraitSlotConst)abc.instance_info[classIndex].instance_traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc,false) + ); + } + + public int getTraitIndex() { + return traitIndex; + } + + public boolean isStatic() { + return isStatic; + } + + + + +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java new file mode 100644 index 000000000..c700bc9cb --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage{ + + public ConstVarNameMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic) + { + super(multinameIndex,classIndex,traitIndex,isStatic); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" name"; + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java new file mode 100644 index 000000000..89bc713dd --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage{ + + public ConstVarTypeMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic) + { + super(multinameIndex,classIndex,traitIndex,isStatic); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" type"; + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java new file mode 100644 index 000000000..8973556f1 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class ExtendsMultinameUsage extends InsideClassMultinameUsage { + + + public ExtendsMultinameUsage(int multinameIndex,int classIndex) + { + super(multinameIndex,classIndex); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" extends"; + } + +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java new file mode 100644 index 000000000..705491c35 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class ImplementsMultinameUsage extends InsideClassMultinameUsage { + + + public ImplementsMultinameUsage(int multinameIndex,int classIndex) + { + super(multinameIndex,classIndex); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" implements"; + } + +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java new file mode 100644 index 000000000..c513ddaff --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public abstract class InsideClassMultinameUsage extends MultinameUsage { + public int multinameIndex; + public int classIndex; + + public InsideClassMultinameUsage(int multinameIndex,int classIndex){ + this.multinameIndex=multinameIndex; + this.classIndex=classIndex; + } + + public String toString(ABC abc){ + return "class "+abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); + } + + public int getMultinameIndex(){ + return multinameIndex; + } + + public int getClassIndex() { + return classIndex; + } + + +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java new file mode 100644 index 000000000..a64510707 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class MethodBodyMultinameUsage extends MethodMultinameUsage { + + public MethodBodyMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer) + { + super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" body"; + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java new file mode 100644 index 000000000..1b39be19d --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter; + +/** + * + * @author JPEXS + */ +public abstract class MethodMultinameUsage extends InsideClassMultinameUsage { + + public int traitIndex ; + public boolean isStatic; + public boolean isInitializer; + public MethodMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer) + { + super(multinameIndex,classIndex); + this.traitIndex=traitIndex; + this.isStatic=isStatic; + this.isInitializer=isInitializer; + } + + public boolean isInitializer() { + return isInitializer; + } + + + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" "+( + isInitializer? + (isStatic? + "class initializer": + "instance initializer") + : + (isStatic? + ((TraitMethodGetterSetter)abc.class_info[classIndex].static_traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc,true) + : + ((TraitMethodGetterSetter)abc.instance_info[classIndex].instance_traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc,false) + )); + } + + public int getTraitIndex() { + return traitIndex; + } + + public boolean isStatic() { + return isStatic; + } + + + + +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java new file mode 100644 index 000000000..f0403f3e2 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class MethodNameMultinameUsage extends MethodMultinameUsage { + + public MethodNameMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer) + { + super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" name"; + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java new file mode 100644 index 000000000..db0773262 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class MethodParamsMultinameUsage extends MethodMultinameUsage { + + public MethodParamsMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer) + { + super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" return type"; + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java new file mode 100644 index 000000000..0c49a7e6a --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage { + + public MethodReturnTypeMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer) + { + super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer); + } + + @Override + public String toString(ABC abc) { + return super.toString(abc)+" params"; + } +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java new file mode 100644 index 000000000..812944999 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public abstract class MultinameUsage { + public abstract String toString(ABC abc); +} diff --git a/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java new file mode 100644 index 000000000..cb527c235 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.abc.usages; + +import com.jpexs.asdec.abc.ABC; + +/** + * + * @author JPEXS + */ +public class TypeNameMultinameUsage extends MultinameUsage { + public int typename_index; + + public TypeNameMultinameUsage(int typename_index){ + this.typename_index=typename_index; + } + + @Override + public String toString(ABC abc) { + return "TypeName "+abc.constants.constant_multiname[typename_index].toString(abc.constants); + } + +}