mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 01:30:43 +00:00
Fixed: Incorrectly colliding class names detection on script private classes
This commit is contained in:
@@ -1112,13 +1112,25 @@ public class ABC {
|
||||
|
||||
private void findMultinameUsageInTraits(Traits traits, int multinameIndex, int traitsType, int scriptIndex, int classIndex, List<MultinameUsage> ret, int parentTraitIndex) {
|
||||
for (int t = 0; t < traits.traits.size(); t++) {
|
||||
//Assuming instance_info.name_index has same multiname as in the class trait
|
||||
/*if (traits.traits.get(t) instanceof TraitClass) {
|
||||
if (traits.traits.get(t) instanceof TraitClass) {
|
||||
TraitClass tc = (TraitClass) traits.traits.get(t);
|
||||
if (tc.name_index == multinameIndex) {
|
||||
ret.add(new ClassNameInTraitMultinameUsage(this, multinameIndex, tc.class_info));
|
||||
ret.add(new ClassNameMultinameUsage(this, multinameIndex, tc.class_info, scriptIndex));
|
||||
}
|
||||
}*/
|
||||
int c = tc.class_info;
|
||||
if (instance_info.get(c).super_index == multinameIndex) {
|
||||
ret.add(new ExtendsMultinameUsage(this, multinameIndex, c, scriptIndex));
|
||||
}
|
||||
for (int i = 0; i < instance_info.get(c).interfaces.length; i++) {
|
||||
if (instance_info.get(c).interfaces[i] == multinameIndex) {
|
||||
ret.add(new ImplementsMultinameUsage(this, multinameIndex, c, scriptIndex));
|
||||
}
|
||||
}
|
||||
checkMultinameUsedInMethod(multinameIndex, instance_info.get(c).iinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, true, null, -1);
|
||||
checkMultinameUsedInMethod(multinameIndex, class_info.get(c).cinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_CLASS, true, null, -1);
|
||||
findMultinameUsageInTraits(instance_info.get(c).instance_traits, multinameIndex, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, -1/*FIXME*/, c, ret, -1);
|
||||
findMultinameUsageInTraits(class_info.get(c).static_traits, multinameIndex, TraitMultinameUsage.TRAITS_TYPE_CLASS, -1/*FIXME*/, c, ret, -1);
|
||||
}
|
||||
if (traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) traits.traits.get(t);
|
||||
if (tsc.name_index == multinameIndex) {
|
||||
@@ -1140,13 +1152,25 @@ public class ABC {
|
||||
|
||||
private void findAllMultinameUsageInTraits(Traits traits, int traitsType, int scriptIndex, int classIndex, List<List<MultinameUsage>> ret, int parentTraitIndex) {
|
||||
for (int t = 0; t < traits.traits.size(); t++) {
|
||||
//Assuming instance_info.name_index has same multiname as in the class trait
|
||||
/*if (traits.traits.get(t) instanceof TraitClass) {
|
||||
if (traits.traits.get(t) instanceof TraitClass) {
|
||||
TraitClass tc = (TraitClass) traits.traits.get(t);
|
||||
if (tc.name_index == multinameIndex) {
|
||||
ret.add(new ClassNameInTraitMultinameUsage(this, multinameIndex, tc.class_info));
|
||||
ret.get(tc.name_index).add(new ClassNameMultinameUsage(this, tc.name_index, tc.class_info, scriptIndex));
|
||||
|
||||
int c = tc.class_info;
|
||||
|
||||
int classNameMultinameIndex = instance_info.get(c).name_index;
|
||||
ret.get(classNameMultinameIndex).add(new ClassNameMultinameUsage(this, classNameMultinameIndex, c, scriptIndex));
|
||||
int extendsMultinameIndex = instance_info.get(c).super_index;
|
||||
ret.get(extendsMultinameIndex).add(new ExtendsMultinameUsage(this, extendsMultinameIndex, c, scriptIndex));
|
||||
for (int i = 0; i < instance_info.get(c).interfaces.length; i++) {
|
||||
int implementsMultinameIndex = instance_info.get(c).interfaces[i];
|
||||
ret.get(implementsMultinameIndex).add(new ImplementsMultinameUsage(this, implementsMultinameIndex, c, scriptIndex));
|
||||
}
|
||||
}*/
|
||||
checkAllMultinameUsedInMethod(instance_info.get(c).iinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, true, null, -1);
|
||||
checkAllMultinameUsedInMethod(class_info.get(c).cinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_CLASS, true, null, -1);
|
||||
findAllMultinameUsageInTraits(instance_info.get(c).instance_traits, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, -1/*FIXME*/, c, ret, -1);
|
||||
findAllMultinameUsageInTraits(class_info.get(c).static_traits, TraitMultinameUsage.TRAITS_TYPE_CLASS, -1/*FIXME*/, c, ret, -1);
|
||||
}
|
||||
if (traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) traits.traits.get(t);
|
||||
ret.get(tsc.name_index).add(new ConstVarNameMultinameUsage(this, tsc.name_index, scriptIndex, classIndex, t, traitsType, traits, parentTraitIndex));
|
||||
@@ -1261,34 +1285,17 @@ public class ABC {
|
||||
for (int s = 0; s < script_info.size(); s++) {
|
||||
findMultinameUsageInTraits(script_info.get(s).traits, multinameIndex, TraitMultinameUsage.TRAITS_TYPE_SCRIPT, s, -1, ret, -1);
|
||||
}
|
||||
for (int c = 0; c < instance_info.size(); c++) {
|
||||
if (instance_info.get(c).name_index == multinameIndex) {
|
||||
ret.add(new ClassNameMultinameUsage(this, multinameIndex, c));
|
||||
}
|
||||
if (instance_info.get(c).super_index == multinameIndex) {
|
||||
ret.add(new ExtendsMultinameUsage(this, multinameIndex, c));
|
||||
}
|
||||
for (int i = 0; i < instance_info.get(c).interfaces.length; i++) {
|
||||
if (instance_info.get(c).interfaces[i] == multinameIndex) {
|
||||
ret.add(new ImplementsMultinameUsage(this, multinameIndex, c));
|
||||
}
|
||||
}
|
||||
checkMultinameUsedInMethod(multinameIndex, instance_info.get(c).iinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, true, null, -1);
|
||||
checkMultinameUsedInMethod(multinameIndex, class_info.get(c).cinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_CLASS, true, null, -1);
|
||||
findMultinameUsageInTraits(instance_info.get(c).instance_traits, multinameIndex, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, -1/*FIXME*/, c, ret, -1);
|
||||
findMultinameUsageInTraits(class_info.get(c).static_traits, multinameIndex, TraitMultinameUsage.TRAITS_TYPE_CLASS, -1/*FIXME*/, c, ret, -1);
|
||||
}
|
||||
loopm:
|
||||
for (int t = 1; t < constants.getMultinameCount(); t++) {
|
||||
Multiname multiname = constants.getMultiname(t);
|
||||
if (multiname.kind == Multiname.TYPENAME) {
|
||||
if (multiname.qname_index == multinameIndex) {
|
||||
ret.add(new TypeNameMultinameUsage(this, multinameIndex, t));
|
||||
ret.add(new TypeNameMultinameUsage(this, multinameIndex, t, -1));
|
||||
continue;
|
||||
}
|
||||
for (int mp : multiname.params) {
|
||||
if (mp == multinameIndex) {
|
||||
ret.add(new TypeNameMultinameUsage(this, multinameIndex, t));
|
||||
ret.add(new TypeNameMultinameUsage(this, multinameIndex, t, -1));
|
||||
continue loopm;
|
||||
}
|
||||
}
|
||||
@@ -1306,32 +1313,18 @@ public class ABC {
|
||||
for (int s = 0; s < script_info.size(); s++) {
|
||||
findAllMultinameUsageInTraits(script_info.get(s).traits, TraitMultinameUsage.TRAITS_TYPE_SCRIPT, s, -1, ret, -1);
|
||||
}
|
||||
for (int c = 0; c < instance_info.size(); c++) {
|
||||
int classNameMultinameIndex = instance_info.get(c).name_index;
|
||||
ret.get(classNameMultinameIndex).add(new ClassNameMultinameUsage(this, classNameMultinameIndex, c));
|
||||
int extendsMultinameIndex = instance_info.get(c).super_index;
|
||||
ret.get(extendsMultinameIndex).add(new ExtendsMultinameUsage(this, extendsMultinameIndex, c));
|
||||
for (int i = 0; i < instance_info.get(c).interfaces.length; i++) {
|
||||
int implementsMultinameIndex = instance_info.get(c).interfaces[i];
|
||||
ret.get(implementsMultinameIndex).add(new ImplementsMultinameUsage(this, implementsMultinameIndex, c));
|
||||
}
|
||||
checkAllMultinameUsedInMethod(instance_info.get(c).iinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, true, null, -1);
|
||||
checkAllMultinameUsedInMethod(class_info.get(c).cinit_index, ret, -1/*FIXME*/, c, 0, TraitMultinameUsage.TRAITS_TYPE_CLASS, true, null, -1);
|
||||
findAllMultinameUsageInTraits(instance_info.get(c).instance_traits, TraitMultinameUsage.TRAITS_TYPE_INSTANCE, -1/*FIXME*/, c, ret, -1);
|
||||
findAllMultinameUsageInTraits(class_info.get(c).static_traits, TraitMultinameUsage.TRAITS_TYPE_CLASS, -1/*FIXME*/, c, ret, -1);
|
||||
}
|
||||
|
||||
boolean[] foundMultinames = new boolean[constants.getMultinameCount()];
|
||||
for (int t = 1; t < constants.getMultinameCount(); t++) {
|
||||
Multiname multiname = constants.getMultiname(t);
|
||||
if (multiname.kind == Multiname.TYPENAME) {
|
||||
if (!foundMultinames[multiname.qname_index]) {
|
||||
ret.get(multiname.qname_index).add(new TypeNameMultinameUsage(this, multiname.qname_index, t));
|
||||
ret.get(multiname.qname_index).add(new TypeNameMultinameUsage(this, multiname.qname_index, t, -1));
|
||||
foundMultinames[multiname.qname_index] = true;
|
||||
}
|
||||
for (int mp : multiname.params) {
|
||||
if (!foundMultinames[mp]) {
|
||||
ret.get(mp).add(new TypeNameMultinameUsage(this, mp, t));
|
||||
ret.get(mp).add(new TypeNameMultinameUsage(this, mp, t, -1));
|
||||
foundMultinames[mp] = true;
|
||||
}
|
||||
}
|
||||
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2021 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;
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -25,8 +26,8 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
public ClassNameMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
|
||||
super(abc, multinameIndex);
|
||||
public ClassNameMultinameUsage(ABC abc, int multinameIndex, int classIndex, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
@@ -37,13 +38,13 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true);
|
||||
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 = 59 * hash + this.classIndex;
|
||||
hash = 67 * hash + this.classIndex;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) {
|
||||
if (other instanceof ClassNameMultinameUsage) {
|
||||
return sameMultinameName(other);
|
||||
}
|
||||
return false;
|
||||
|
||||
+4
-3
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -25,8 +26,8 @@ public class ExtendsMultinameUsage extends MultinameUsage implements InsideClass
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
public ExtendsMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
|
||||
super(abc, multinameIndex);
|
||||
public ExtendsMultinameUsage(ABC abc, int multinameIndex, int classIndex, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -25,8 +26,8 @@ public class ImplementsMultinameUsage extends MultinameUsage implements InsideCl
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
public ImplementsMultinameUsage(ABC abc, int multinameIndex, int classIndex) {
|
||||
super(abc, multinameIndex);
|
||||
public ImplementsMultinameUsage(ABC abc, int multinameIndex, int classIndex, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -31,9 +32,13 @@ public abstract class MultinameUsage {
|
||||
|
||||
private final int multinameIndex;
|
||||
|
||||
public MultinameUsage(ABC abc, int multinameIndex) {
|
||||
protected int scriptIndex;
|
||||
|
||||
public MultinameUsage(ABC abc, int multinameIndex, int scriptIndex) {
|
||||
this.abc = abc;
|
||||
this.multinameIndex = multinameIndex;
|
||||
this.scriptIndex = scriptIndex;
|
||||
|
||||
}
|
||||
|
||||
public int getMultinameIndex() {
|
||||
@@ -78,6 +83,10 @@ public abstract class MultinameUsage {
|
||||
return Objects.equals(thisNs.getName(abc.constants), otherNs.getName(other.abc.constants));
|
||||
}
|
||||
|
||||
if (other.scriptIndex != scriptIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//one of them is private/protected
|
||||
return true;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -44,7 +45,7 @@ public abstract class TraitMultinameUsage extends MultinameUsage implements Insi
|
||||
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);
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.scriptIndex = scriptIndex;
|
||||
this.classIndex = classIndex;
|
||||
this.traitIndex = traitIndex;
|
||||
|
||||
+4
-3
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -26,8 +27,8 @@ public class TypeNameMultinameUsage extends MultinameUsage {
|
||||
|
||||
protected int typename_index;
|
||||
|
||||
public TypeNameMultinameUsage(ABC abc, int multinameIndex, int typename_index) {
|
||||
super(abc, multinameIndex);
|
||||
public TypeNameMultinameUsage(ABC abc, int multinameIndex, int typename_index, int scriptIndex) {
|
||||
super(abc, multinameIndex, scriptIndex);
|
||||
this.typename_index = typename_index;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user