Issue #557 AS3 null namespace names fix => p-code not working

This commit is contained in:
Jindra Pet��k
2014-04-05 09:15:38 +02:00
parent a94c5a277f
commit 412c1cc3fa
12 changed files with 36 additions and 20 deletions
@@ -748,7 +748,7 @@ public class ABC {
if (t instanceof TraitSlotConst) {
TraitSlotConst s = ((TraitSlotConst) t);
if (s.isNamespace()) {
String key = constants.getNamespace(s.value_index).getName(constants);
String key = constants.getNamespace(s.value_index).getName(constants); //assume not null
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants);
namespaceMap.put(key, val);
}
@@ -75,7 +75,7 @@ public class ScriptPack implements TreeElementItem {
Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
packageName = ns.getName(abc.constants);
packageName = ns.getName(abc.constants); //assume not null
}
}
return packageName;
@@ -34,7 +34,7 @@ public class FindDefAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2));
return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2)); //assume not null name
}
@Override
@@ -38,7 +38,7 @@ public class NameSpaceAVM2Item extends AVM2Item {
return writer.append("*");
}
ConstantPool constants = localData.constantsAvm2;
return writer.append(constants.getNamespace(namespaceIndex).toString(constants));
return writer.append(constants.getNamespace(namespaceIndex).toString(constants)); //assume not null name
}
@Override
@@ -158,7 +158,7 @@ public class Multiname {
String name = name_index == 0 ? null : constants.getNamespace(index).getName(constants);
int sub = -1;
for (int n = 1; n < constants.getNamespaceCount(); n++) {
if (constants.getNamespace(n).kind == type && constants.getNamespace(n).getName(constants).equals(constants.getNamespace(index).getName(constants))) {
if (constants.getNamespace(n).kind == type && constants.getNamespace(n).hasName(constants.getNamespace(index).getName(constants),constants)) {
sub++;
}
if (n == index) {
@@ -94,11 +94,24 @@ public class Namespace {
}
return kindStr;
}
public String getName(ConstantPool constants) {
if (name_index == 0) {
return null;
}
return constants.getString(name_index);
}
public boolean hasName(String name, ConstantPool constants){
if(name == null && name_index==0){
return true;
}
if(name == null){
return false;
}
if(name_index == 0){
return false;
}
return constants.getString(name_index).equals(name);
}
}
@@ -49,7 +49,7 @@ public class ScriptInfo {
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE_INTERNAL)
|| (ns.kind == Namespace.KIND_PACKAGE)) {
String packageName = ns.getName(abc.constants);
String packageName = ns.getName(abc.constants); //assume not null package
String objectName = name.getName(abc.constants, new ArrayList<String>());
List<Integer> traitIndices = new ArrayList<>();
@@ -135,7 +135,7 @@ public class ValueKind {
case CONSTANT_ExplicitNamespace:
case CONSTANT_StaticProtectedNs:
case CONSTANT_PrivateNs:
ret = "\"" + constants.getNamespace(value_index).getName(constants) + "\"";
ret = "\"" + constants.getNamespace(value_index).getName(constants) + "\""; //assume not null name
break;
}
return ret;
@@ -177,7 +177,7 @@ public class ValueKind {
case CONSTANT_ExplicitNamespace:
case CONSTANT_StaticProtectedNs:
case CONSTANT_PrivateNs:
ret = constants.getNamespace(value_index).getKindStr() + "(\"" + constants.getNamespace(value_index).getName(constants) + "\")";
ret = constants.getNamespace(value_index).getKindStr() + "(\"" + constants.getNamespace(value_index).getName(constants) + "\")"; //assume not null name
break;
}
return ret;
@@ -62,7 +62,7 @@ public abstract class Trait implements Serializable {
break;
}
nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants));
if (nsname.equals("-")) {
if (nsname == null) {
break;
}
if (nsname.contains(".")) {
@@ -88,7 +88,7 @@ public abstract class Trait implements Serializable {
}
}
if ((!nsname.contains(":")) && (!nsname.isEmpty())) {
if (nsname!=null && (!nsname.contains(":")) && (!nsname.isEmpty())) {
ret += " " + nsname;
}
if (ns != null) {
@@ -127,7 +127,7 @@ public abstract class Trait implements Serializable {
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants);
writer.appendNoHilight("package " + nsname).newLine();
writer.appendNoHilight("package " + nsname).newLine(); //assume not null name
writer.appendNoHilight("{").newLine();
writer.indent();
toString(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
@@ -141,7 +141,6 @@ public abstract class Trait implements Serializable {
public void convertPackaged(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants);
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
}
@@ -170,6 +169,6 @@ public abstract class Trait implements Serializable {
Namespace ns = name.getNamespace(abc.constants);
String packageName = ns.getName(abc.constants);
String objectName = name.getName(abc.constants, new ArrayList<String>());
return packageName + "." + objectName;
return packageName + "." + objectName; //assume not null name
}
}
@@ -96,7 +96,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
newimport = oldimport;
newimport += "." + name;
}
if (newimport.isEmpty()) {
if (newimport!=null && newimport.isEmpty()) {
newimport = null;
}
if (newimport != null) {
@@ -149,7 +149,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
} else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) {
return;
}
if (newimport.equals("-")) {
if (newimport == null) {
newimport = "";
}
//if (!newimport.equals("")) {
@@ -298,7 +298,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
private List<String> getImportsUsages(List<ABCContainerTag> abcTags, ABC abc, List<String> imports, List<String> uses, List<String> fullyQualifiedNames) {
//constructor
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); //assume not null name
parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.getMultiname(abc.instance_info.get(class_info).name_index), packageName, fullyQualifiedNames);
@@ -337,7 +337,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
writer.startClass(class_info);
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); //assume not null name
List<String> namesInThisPackage = new ArrayList<>();
for (ABCContainerTag tag : abcTags) {
for (ScriptInfo si : tag.getABC().script_info) {
@@ -122,7 +122,11 @@ public class NamespaceTableModel implements TableModel {
if (rowIndex == 0) {
return "-";
}
return abc.constants.getNamespace(rowIndex).getName(abc.constants);
String val = abc.constants.getNamespace(rowIndex).getName(abc.constants);
if(val == null){
val = "-";
}
return val;
default:
return null;
}
@@ -103,7 +103,7 @@ public class TypeItem extends GraphTargetItem{
for(InstanceInfo ii:abc.instance_info){
Multiname mname=abc.constants.constant_multiname.get(ii.name_index);
if(mname.getName(abc.constants, new ArrayList<String>()).equals(name)){
if(mname.getNamespace(abc.constants).getName(abc.constants).equals(pkg)){
if(mname.getNamespace(abc.constants).hasName(pkg,abc.constants)){
return ii.name_index;
}
}