Issue #715 namespace resolving fix

This commit is contained in:
Jindra Petřík
2014-11-23 13:21:57 +01:00
parent 9cc4fd5a52
commit 767dfd8278
4 changed files with 5 additions and 16 deletions

View File

@@ -1839,7 +1839,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
if (fullCustom.equals(m.getNameWithNamespace(a.constants, true))) {
if (t instanceof TraitSlotConst) {
if (((TraitSlotConst) t).isNamespace()) {
return ((TraitSlotConst) t).value_index;
Namespace ns = a.constants.getNamespace(((TraitSlotConst) t).value_index);
return abc.constants.getNamespaceId(new Namespace(ns.kind, abc.constants.getStringId(ns.getName(a.constants, true),true)), 0, true);
}
}
}

View File

@@ -258,7 +258,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
for (int i = 0; i < openedNamespaces.size(); i++) {
int nsindex = openedNamespaces.get(i);
int nsKind = abc.constants.constant_namespace.get(openedNamespaces.get(i)).kind;
String nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants, true);
String nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants, true);
int name_index = 0;
for (int m = 1; m < abc.constants.constant_multiname.size(); m++) {
Multiname mname = abc.constants.constant_multiname.get(m);

View File

@@ -326,19 +326,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
impName = impName.substring(impName.lastIndexOf('.') + 1);
}
if (impName.equals(parts.get(0))) {
TypeItem ret = new TypeItem(imp);
/*for (GraphTargetItem s : subtypes) {
if (!subtypes.isEmpty() && parts.size() > 1) {
continue;
}
UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<String>(), importedClasses, true, null, line, s, null, openedNamespaces);
su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables);
if (!(su.resolved instanceof TypeItem)) {
throw new CompilationException("Not a type", line);
}
TypeItem st = (TypeItem) su.resolved;
ret.subtypes.add(st.fullTypeName);
}*/
TypeItem ret = new TypeItem(imp);
resolved = ret;
for (int i = 1; i < parts.size(); i++) {
resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<MethodBody>());

View File

@@ -91,7 +91,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
if (name.isEmpty()) {
name = "*";
}
String newimport = ns.getName(abc.constants, false);
String newimport = ns.getName(abc.constants, ns.kind == Namespace.KIND_NAMESPACE);
/*if ((ns.kind != Namespace.KIND_PACKAGE)
&& (ns.kind != Namespace.KIND_NAMESPACE)
&& (ns.kind != Namespace.KIND_STATIC_PROTECTED)) {