diff options
author | jfrijters <jfrijters> | 2013-07-31 01:54:58 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2013-07-31 01:54:58 +0400 |
commit | 47f221a0d1bee0a50ef9b2b095a5c8dba52de17c (patch) | |
tree | dd31f11b59cae40408b1efcdddf4b7d03b8809fb | |
parent | a9edb3e3e1c9bd8e03a5a6294419600ee358810b (diff) |
Moved adding InnerClassAttribute to separate method.
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index a6d26377..c91a409a 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -798,11 +798,6 @@ namespace IKVM.Internal } } } - if (outer == null && mangledTypeName != wrapper.Name) - { - // HACK we abuse the InnerClassAttribute to record to real name - AttributeHelper.SetInnerClass(typeBuilder, wrapper.Name, wrapper.Modifiers); - } if (typeBuilder.FullName != wrapper.Name && wrapper.Name.Replace('$', '+') != typeBuilder.FullName) { @@ -820,19 +815,7 @@ namespace IKVM.Internal AddCliEnum(); } AddImplementsAttribute(); - if (outer != null) - { - string innerClassName = classFile.Name; - if (innerClassName == outerClassWrapper.Name + "$" + typeBuilder.Name) - { - innerClassName = null; - } - AttributeHelper.SetInnerClass(typeBuilder, innerClassName, outerClass.accessFlags); - } - else if (outerClass.innerClass != 0) - { - AttributeHelper.SetInnerClass(typeBuilder, null, outerClass.accessFlags); - } + AddInnerClassAttribute(outer != null, outerClass.innerClass != 0, mangledTypeName, outerClass.accessFlags); if (classFile.DeprecatedAttribute && !Annotation.HasObsoleteAttribute(classFile.Annotations)) { AttributeHelper.SetDeprecatedAttribute(typeBuilder); @@ -901,6 +884,29 @@ namespace IKVM.Internal AttributeHelper.SetImplementsAttribute(typeBuilder, interfaces); } + private void AddInnerClassAttribute(bool isNestedType, bool isInnerClass, string mangledTypeName, Modifiers innerClassFlags) + { + string name = classFile.Name; + + if (isNestedType) + { + if (name == outerClassWrapper.Name + "$" + typeBuilder.Name) + { + name = null; + } + } + else if (name == mangledTypeName) + { + name = null; + } + + if (isInnerClass || name != null) + { + // HACK we abuse the InnerClassAttribute to record to real name for non-inner classes as well + AttributeHelper.SetInnerClass(typeBuilder, name, isInnerClass ? innerClassFlags : wrapper.Modifiers); + } + } + private void AddCliEnum() { CompilerClassLoader ccl = wrapper.classLoader; |