AS3: Better usage detection for multinames

This commit is contained in:
Jindra Pet��k
2011-07-31 17:18:07 +02:00
parent f05a39e854
commit e3905865cf
18 changed files with 745 additions and 214 deletions
+93 -96
View File
@@ -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<Usage> findMultinameUsage(int multinameIndex) {
List<Usage> ret = new ArrayList<Usage>();
List<Integer> bodyIndices = new ArrayList<Integer>();
List<Integer> subTraitBodyIndices = new ArrayList<Integer>();
List<Integer> subTraitIndexIndices = new ArrayList<Integer>();
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<MultinameUsage> 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<MultinameUsage> 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<MultinameUsage> findMultinameUsage(int multinameIndex) {
List<MultinameUsage> ret = new ArrayList<MultinameUsage>();
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<bodies.length;i++){
public void autoFillAllBodyParams() {
for (int i = 0; i < bodies.length; i++) {
bodies[i].autoFillStats(this);
}
}
-112
View File
@@ -1,112 +0,0 @@
/*
* Copyright (C) 2010-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;
import com.jpexs.asdec.abc.types.traits.Trait;
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
/**
*
* @author JPEXS
*/
public class Usage {
public int classIndex;
public int traitIndex;
public int subTraitIndex;
public boolean isStatic;
public static final int TYPE_CLASS_NAME=0;
public static final int TYPE_TRAIT_NAME=1;
public static final int TYPE_SUBTRAIT_NAME=4;
public static final int TYPE_INITIALIZER_SUBTRAIT_NAME=5;
public static final int TYPE_INITIALIZER=2;
public static final int TYPE_TRAIT_BODY=3;
public int type;
public ABC abc;
public int bodyIndex;
public Usage(ABC abc,int bodyIndex,int classIndex, int traitIndex, int subTraitIndex, boolean isStatic, int type) {
this.abc = abc;
this.classIndex = classIndex;
this.traitIndex = traitIndex;
this.isStatic = isStatic;
this.type = type;
this.subTraitIndex = subTraitIndex;
this.bodyIndex = bodyIndex;
}
@Override
public String toString() {
String ret="";
String className=abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants);
Trait tr=null;
String staticStr="";
String traitName="";
String subTraitName="";
switch(type){
case TYPE_CLASS_NAME:
return "Class "+className;
case TYPE_TRAIT_NAME:
if(isStatic){
tr=abc.class_info[classIndex].static_traits.traits[traitIndex];
}else{
tr=abc.instance_info[classIndex].instance_traits.traits[traitIndex];
}
traitName=tr.getMultiName(abc.constants).getName(abc.constants);
staticStr=isStatic?"static ":"";
String typeStr="";
if(tr instanceof TraitMethodGetterSetter) typeStr="method ";
if(tr instanceof TraitSlotConst) {
if(((TraitSlotConst)tr).isConst()) typeStr="const ";
if(((TraitSlotConst)tr).isVar()) typeStr="var ";
}
return staticStr+typeStr+className+"."+traitName;
case TYPE_INITIALIZER_SUBTRAIT_NAME:
case TYPE_INITIALIZER:
if(type==TYPE_SUBTRAIT_NAME){
subTraitName="."+abc.bodies[bodyIndex].traits.traits[subTraitIndex].getMultiName(abc.constants).getName(abc.constants);
}
if(isStatic){
return "static initializer "+className+subTraitName;
}else{
return "instance initializer "+className+subTraitName;
}
case TYPE_SUBTRAIT_NAME:
case TYPE_TRAIT_BODY:
if(isStatic){
tr=abc.class_info[classIndex].static_traits.traits[traitIndex];
}else{
tr=abc.instance_info[classIndex].instance_traits.traits[traitIndex];
}
traitName=tr.getMultiName(abc.constants).getName(abc.constants);
if(type==TYPE_SUBTRAIT_NAME){
subTraitName="."+abc.bodies[bodyIndex].traits.traits[subTraitIndex].getMultiName(abc.constants).getName(abc.constants);
}
staticStr=isStatic?"static ":"";
return staticStr+"method body "+className+"."+traitName+subTraitName;
}
return ret;
}
}
@@ -19,9 +19,8 @@
package com.jpexs.asdec.abc.gui;
import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.Usage;
import com.jpexs.asdec.abc.types.traits.Trait;
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.asdec.abc.usages.InsideClassMultinameUsage;
import com.jpexs.asdec.abc.usages.MultinameUsage;
import com.jpexs.asdec.gui.View;
import java.awt.BorderLayout;
import java.awt.Container;
@@ -44,10 +43,11 @@ public class UsageFrame extends JFrame implements ActionListener {
private JButton gotoButton=new JButton("Go to");
private JButton cancelButton=new JButton("Cancel");
private JList usageList;
private DefaultListModel usageListModel=new DefaultListModel();
private UsageListModel usageListModel;
public UsageFrame(ABC abc,int multinameIndex){
List<Usage> usages=abc.findMultinameUsage(multinameIndex);
for(Usage u:usages){
List<MultinameUsage> usages=abc.findMultinameUsage(multinameIndex);
usageListModel=new UsageListModel(abc);
for(MultinameUsage u:usages){
usageListModel.addElement(u);
}
usageList=new JList(usageListModel);
@@ -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);
}
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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";
}
}
@@ -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";
}
}
@@ -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";
}
}
@@ -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";
}
}
@@ -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;
}
}
@@ -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";
}
}
@@ -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;
}
}
@@ -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";
}
}
@@ -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";
}
}
@@ -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";
}
}
@@ -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);
}
@@ -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);
}
}