#1312 faster colliding usages finder

This commit is contained in:
honfika@gmail.com
2016-12-01 15:09:47 +01:00
parent ce4719fe35
commit 77842de665
11 changed files with 5168 additions and 4795 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,57 +1,84 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ClassNameInTraitMultinameUsage extends MultinameUsage implements DefinitionUsage, InsideClassMultinameUsageInterface {
private int classIndex;
public ClassNameInTraitMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true) + " trait name";
}
@Override
public boolean collides(MultinameUsage other) {
if (other instanceof InsideClassMultinameUsageInterface) {
if (((InsideClassMultinameUsageInterface) other).getClassIndex() == getClassIndex()) {
return false;
}
}
if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) {
return sameMultinameName(other);
}
return false;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ClassNameInTraitMultinameUsage extends MultinameUsage implements DefinitionUsage, InsideClassMultinameUsageInterface {
private final int classIndex;
public ClassNameInTraitMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true) + " trait name";
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 67 * hash + this.classIndex;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final ClassNameInTraitMultinameUsage other = (ClassNameInTraitMultinameUsage) obj;
if (this.classIndex != other.classIndex) {
return false;
}
return true;
}
@Override
public boolean collides(MultinameUsage other) {
if (other instanceof InsideClassMultinameUsageInterface) {
if (((InsideClassMultinameUsageInterface) other).getClassIndex() == getClassIndex()) {
return false;
}
}
if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) {
return sameMultinameName(other);
}
return false;
}
}

View File

@@ -1,57 +1,84 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ClassNameMultinameUsage extends MultinameUsage implements DefinitionUsage, InsideClassMultinameUsageInterface {
private int classIndex;
public ClassNameMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true);
}
@Override
public boolean collides(MultinameUsage other) {
if (other instanceof InsideClassMultinameUsageInterface) {
if (((InsideClassMultinameUsageInterface) other).getClassIndex() == getClassIndex()) {
return false;
}
}
if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) {
return sameMultinameName(other);
}
return false;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ClassNameMultinameUsage extends MultinameUsage implements DefinitionUsage, InsideClassMultinameUsageInterface {
private final int classIndex;
public ClassNameMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true);
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 59 * hash + this.classIndex;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final ClassNameMultinameUsage other = (ClassNameMultinameUsage) obj;
if (this.classIndex != other.classIndex) {
return false;
}
return true;
}
@Override
public boolean collides(MultinameUsage other) {
if (other instanceof InsideClassMultinameUsageInterface) {
if (((InsideClassMultinameUsageInterface) other).getClassIndex() == getClassIndex()) {
return false;
}
}
if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) {
return sameMultinameName(other);
}
return false;
}
}

View File

@@ -1,81 +1,77 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.ConvertData;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import java.util.ArrayList;
/**
*
* @author JPEXS
*/
public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
public ConstVarMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
}
@Override
public String toString() {
NulWriter nulWriter = new NulWriter();
ConvertData convertData = new ConvertData();
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
} else if (traitsType == TRAITS_TYPE_INSTANCE) {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
}
}
try {
((TraitSlotConst) traits.traits.get(traitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS /*?? FIXME*/, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
} catch (InterruptedException ex) {
// ignore
}
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString() + " ");
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
} else if (traitsType == TRAITS_TYPE_INSTANCE) {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
}
}
try {
((TraitSlotConst) traits.traits.get(traitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
} catch (InterruptedException ex) {
// ignore
}
return writer.toString().trim();
}
public int getTraitIndex() {
return traitIndex;
}
public boolean isStatic() {
return traitsType == TRAITS_TYPE_CLASS;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.ConvertData;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import java.util.ArrayList;
/**
*
* @author JPEXS
*/
public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
public ConstVarMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
}
@Override
public String toString() {
NulWriter nulWriter = new NulWriter();
ConvertData convertData = new ConvertData();
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
} else if (traitsType == TRAITS_TYPE_INSTANCE) {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
}
}
try {
((TraitSlotConst) traits.traits.get(traitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS /*?? FIXME*/, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
} catch (InterruptedException ex) {
// ignore
}
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString() + " ");
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
} else if (traitsType == TRAITS_TYPE_INSTANCE) {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
}
}
try {
((TraitSlotConst) traits.traits.get(traitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
} catch (InterruptedException ex) {
// ignore
}
return writer.toString().trim();
}
public boolean isStatic() {
return traitsType == TRAITS_TYPE_CLASS;
}
}

View File

@@ -1,49 +1,76 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ExtendsMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
private int classIndex;
public ExtendsMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return super.toString() + " extends";
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ExtendsMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
private final int classIndex;
public ExtendsMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return super.toString() + " extends";
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 17 * hash + this.classIndex;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final ExtendsMultinameUsage other = (ExtendsMultinameUsage) obj;
if (this.classIndex != other.classIndex) {
return false;
}
return true;
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
}

View File

@@ -1,49 +1,76 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ImplementsMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
private int classIndex;
public ImplementsMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return super.toString() + " implements";
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public class ImplementsMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
private final int classIndex;
public ImplementsMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
super(abc, multinameIndex);
this.classIndex = classIndex;
}
@Override
public int getClassIndex() {
return classIndex;
}
@Override
public String toString() {
return super.toString() + " implements";
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 59 * hash + this.classIndex;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final ImplementsMultinameUsage other = (ImplementsMultinameUsage) obj;
if (this.classIndex != other.classIndex) {
return false;
}
return true;
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
}

View File

@@ -1,99 +1,123 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.ConvertData;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import java.util.ArrayList;
/**
*
* @author JPEXS
*/
public abstract class MethodMultinameUsage extends TraitMultinameUsage {
public boolean isInitializer;
public MethodMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
this.isInitializer = isInitializer;
}
public boolean isInitializer() {
return isInitializer;
}
@Override
public String toString() {
NulWriter nulWriter = new NulWriter();
ConvertData convertData = new ConvertData();
if (!isInitializer) {
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
}
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
}
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString());
writer.appendNoHilight(" ");
if (isInitializer) {
switch (traitsType) {
case TRAITS_TYPE_CLASS:
writer.appendNoHilight("class initializer");
break;
case TRAITS_TYPE_INSTANCE:
writer.appendNoHilight("instance initializer");
break;
case TRAITS_TYPE_SCRIPT:
writer.appendNoHilight("script initializer");
break;
default:
break;
}
} else {
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
}
writer.appendNoHilight(" ");
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
}
return writer.toString().trim();
}
public int getTraitIndex() {
return traitIndex;
}
public boolean isStatic() {
return traitsType == TRAITS_TYPE_CLASS;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.ConvertData;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import java.util.ArrayList;
/**
*
* @author JPEXS
*/
public abstract class MethodMultinameUsage extends TraitMultinameUsage {
private boolean isInitializer;
public MethodMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, boolean isInitializer, Traits traits, int parentTraitIndex) {
super(abc, multinameIndex, scriptIndex, classIndex, traitIndex, traitsType, traits, parentTraitIndex);
this.isInitializer = isInitializer;
}
public boolean isInitializer() {
return isInitializer;
}
@Override
public String toString() {
NulWriter nulWriter = new NulWriter();
ConvertData convertData = new ConvertData();
if (!isInitializer) {
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
}
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).convertHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<>(), false);
}
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString());
writer.appendNoHilight(" ");
if (isInitializer) {
switch (traitsType) {
case TRAITS_TYPE_CLASS:
writer.appendNoHilight("class initializer");
break;
case TRAITS_TYPE_INSTANCE:
writer.appendNoHilight("instance initializer");
break;
case TRAITS_TYPE_SCRIPT:
writer.appendNoHilight("script initializer");
break;
default:
break;
}
} else {
if (parentTraitIndex > -1) {
if (traitsType == TRAITS_TYPE_CLASS) {
((TraitMethodGetterSetter) abc.class_info.get(classIndex).static_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info.get(classIndex).instance_traits.traits.get(parentTraitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
}
writer.appendNoHilight(" ");
}
((TraitMethodGetterSetter) traits.traits.get(traitIndex)).toStringHeader(null, convertData, "", abc, traitsType == TRAITS_TYPE_CLASS, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<>(), false);
}
return writer.toString().trim();
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 61 * hash + (this.isInitializer ? 1 : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final MethodMultinameUsage other = (MethodMultinameUsage) obj;
if (this.isInitializer != other.isInitializer) {
return false;
}
return true;
}
public boolean isStatic() {
return traitsType == TRAITS_TYPE_CLASS;
}
}

View File

@@ -1,89 +1,119 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import java.util.ArrayList;
import java.util.Objects;
/**
*
* @author JPEXS
*/
public abstract class MultinameUsage {
public ABC abc;
public int multinameIndex;
public MultinameUsage(ABC abc, int multinameIndex) {
this.abc = abc;
this.multinameIndex = multinameIndex;
}
public int getMultinameIndex() {
return multinameIndex;
}
public ABC getAbc() {
return abc;
}
protected boolean sameMultinameName(MultinameUsage other) {
Multiname thisM = abc.constants.getMultiname(multinameIndex);
Multiname otherM = other.abc.constants.getMultiname(other.multinameIndex);
if (thisM == null && otherM == null) {
return false;
}
if (thisM == null || otherM == null) {
return false;
}
if ((thisM.kind == Multiname.QNAME || thisM.kind == Multiname.QNAMEA) && otherM.kind == thisM.kind) {
String thisName = thisM.getName(abc.constants, new ArrayList<>(), true, true);
String otherName = otherM.getName(other.abc.constants, new ArrayList<>(), true, true);
Namespace thisNs = thisM.getNamespace(abc.constants);
Namespace otherNs = otherM.getNamespace(other.abc.constants);
if (!Objects.equals(thisName, otherName)) {
return false;
}
//Both are custom namespaced
if (thisNs.kind == Namespace.KIND_NAMESPACE && otherNs.kind == Namespace.KIND_NAMESPACE) {
//compare those custom
return Objects.equals(thisNs.getName(abc.constants), otherNs.getName(other.abc.constants));
}
//One is custom namespaced, other cannot be the same
if (thisNs.kind == Namespace.KIND_NAMESPACE || otherNs.kind == Namespace.KIND_NAMESPACE) {
return false;
}
//public or package internal are colliding when have same package ns
if ((thisNs.kind == Namespace.KIND_PACKAGE || thisNs.kind == Namespace.KIND_PACKAGE_INTERNAL)
&& (otherNs.kind == Namespace.KIND_PACKAGE || otherNs.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
return Objects.equals(thisNs.getName(abc.constants), otherNs.getName(other.abc.constants));
}
//one of them is private/protected
return true;
}
return false;
}
public abstract boolean collides(MultinameUsage other);
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import java.util.ArrayList;
import java.util.Objects;
/**
*
* @author JPEXS
*/
public abstract class MultinameUsage {
protected final ABC abc;
private final int multinameIndex;
public MultinameUsage(ABC abc, int multinameIndex) {
this.abc = abc;
this.multinameIndex = multinameIndex;
}
public int getMultinameIndex() {
return multinameIndex;
}
public ABC getAbc() {
return abc;
}
protected boolean sameMultinameName(MultinameUsage other) {
Multiname thisM = abc.constants.getMultiname(multinameIndex);
Multiname otherM = other.abc.constants.getMultiname(other.multinameIndex);
if (thisM == null && otherM == null) {
return false; // honfika: why false?
}
if (thisM == null || otherM == null) {
return false;
}
if ((thisM.kind == Multiname.QNAME || thisM.kind == Multiname.QNAMEA) && otherM.kind == thisM.kind) {
String thisName = thisM.getName(abc.constants, new ArrayList<>(), true, true);
String otherName = otherM.getName(other.abc.constants, new ArrayList<>(), true, true);
Namespace thisNs = thisM.getNamespace(abc.constants);
Namespace otherNs = otherM.getNamespace(other.abc.constants);
if (!Objects.equals(thisName, otherName)) {
return false;
}
//Both are custom namespaced
if (thisNs.kind == Namespace.KIND_NAMESPACE && otherNs.kind == Namespace.KIND_NAMESPACE) {
//compare those custom
return Objects.equals(thisNs.getName(abc.constants), otherNs.getName(other.abc.constants));
}
//One is custom namespaced, other cannot be the same
if (thisNs.kind == Namespace.KIND_NAMESPACE || otherNs.kind == Namespace.KIND_NAMESPACE) {
return false;
}
//public or package internal are colliding when have same package ns
if ((thisNs.kind == Namespace.KIND_PACKAGE || thisNs.kind == Namespace.KIND_PACKAGE_INTERNAL)
&& (otherNs.kind == Namespace.KIND_PACKAGE || otherNs.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
return Objects.equals(thisNs.getName(abc.constants), otherNs.getName(other.abc.constants));
}
//one of them is private/protected
return true;
}
return false;
}
@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + Objects.hashCode(this.abc);
hash = 97 * hash + this.multinameIndex;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MultinameUsage other = (MultinameUsage) obj;
if (this.multinameIndex != other.multinameIndex) {
return false;
}
if (!Objects.equals(this.abc, other.abc)) {
return false;
}
return true;
}
public abstract boolean collides(MultinameUsage other);
}

View File

@@ -1,67 +1,139 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
/**
*
* @author JPEXS
*/
public abstract class TraitMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
public int traitIndex;
public static final int TRAITS_TYPE_CLASS = 1;
public static final int TRAITS_TYPE_INSTANCE = 2;
public static final int TRAITS_TYPE_SCRIPT = 3;
public int traitsType;
public int classIndex;
public int scriptIndex;
public Traits traits;
public int parentTraitIndex;
public TraitMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
super(abc, multinameIndex);
this.scriptIndex = scriptIndex;
this.classIndex = classIndex;
this.traitIndex = traitIndex;
this.traitsType = traitsType;
this.traits = traits;
this.parentTraitIndex = parentTraitIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true);
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
@Override
public int getClassIndex() {
return classIndex;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import java.util.Objects;
/**
*
* @author JPEXS
*/
public abstract class TraitMultinameUsage extends MultinameUsage implements InsideClassMultinameUsageInterface {
protected final int traitIndex;
public static final int TRAITS_TYPE_CLASS = 1;
public static final int TRAITS_TYPE_INSTANCE = 2;
public static final int TRAITS_TYPE_SCRIPT = 3;
protected final int traitsType;
protected final int classIndex;
protected final int scriptIndex;
protected final Traits traits;
protected final int parentTraitIndex;
public TraitMultinameUsage(ABC abc, int multinameIndex, int scriptIndex, int classIndex, int traitIndex, int traitsType, Traits traits, int parentTraitIndex) {
super(abc, multinameIndex);
this.scriptIndex = scriptIndex;
this.classIndex = classIndex;
this.traitIndex = traitIndex;
this.traitsType = traitsType;
this.traits = traits;
this.parentTraitIndex = parentTraitIndex;
}
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true);
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 23 * hash + this.traitIndex;
hash = 23 * hash + this.traitsType;
hash = 23 * hash + this.classIndex;
hash = 23 * hash + this.scriptIndex;
hash = 23 * hash + Objects.hashCode(this.traits);
hash = 23 * hash + this.parentTraitIndex;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final TraitMultinameUsage other = (TraitMultinameUsage) obj;
if (this.traitIndex != other.traitIndex) {
return false;
}
if (this.traitsType != other.traitsType) {
return false;
}
if (this.classIndex != other.classIndex) {
return false;
}
if (this.scriptIndex != other.scriptIndex) {
return false;
}
if (this.parentTraitIndex != other.parentTraitIndex) {
return false;
}
if (!Objects.equals(this.traits, other.traits)) {
return false;
}
return true;
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
@Override
public int getClassIndex() {
return classIndex;
}
public int getTraitIndex() {
return traitIndex;
}
public int getTraitsType() {
return traitsType;
}
public int getScriptIndex() {
return scriptIndex;
}
public Traits getTraits() {
return traits;
}
public int getParentTraitIndex() {
return parentTraitIndex;
}
}

View File

@@ -1,44 +1,76 @@
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import java.util.ArrayList;
/**
*
* @author JPEXS
*/
public class TypeNameMultinameUsage extends MultinameUsage {
public int typename_index;
public TypeNameMultinameUsage(ABC abc, int multinameIndex, int typename_index) {
super(abc, multinameIndex);
this.typename_index = typename_index;
}
@Override
public String toString() {
return "TypeName " + abc.constants.getMultiname(typename_index).toString(abc.constants, new ArrayList<>());
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
}
/*
* Copyright (C) 2010-2016 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.usages;
import com.jpexs.decompiler.flash.abc.ABC;
import java.util.ArrayList;
/**
*
* @author JPEXS
*/
public class TypeNameMultinameUsage extends MultinameUsage {
protected int typename_index;
public TypeNameMultinameUsage(ABC abc, int multinameIndex, int typename_index) {
super(abc, multinameIndex);
this.typename_index = typename_index;
}
@Override
public String toString() {
return "TypeName " + abc.constants.getMultiname(typename_index).toString(abc.constants, new ArrayList<>());
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 67 * hash + this.typename_index;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final TypeNameMultinameUsage other = (TypeNameMultinameUsage) obj;
if (this.typename_index != other.typename_index) {
return false;
}
return true;
}
@Override
public boolean collides(MultinameUsage other) {
return false;
}
public int getTypenameIndex() {
return typename_index;
}
}