diff options
author | jfrijters <jfrijters> | 2013-07-30 22:04:59 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2013-07-30 22:04:59 +0400 |
commit | 543148ee71028a5558c230094e0be9953c64ef4f (patch) | |
tree | aac25973a0b28692aa2fd1221ae7fd803dbf15e2 | |
parent | 5cf1352451813326e4e17927767a966b07f03ffc (diff) |
Moved CLI enum creation to separate method.
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index 12fb2111..8abba386 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -817,24 +817,7 @@ namespace IKVM.Internal // This is primarily to support annotations that take enum parameters. if (f.IsEnum && f.IsPublic) { - CompilerClassLoader ccl = wrapper.classLoader; - string name = "__Enum"; - while (!ccl.ReserveName(f.Name + "$" + name)) - { - name += "_"; - } - enumBuilder = typeBuilder.DefineNestedType(name, TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.NestedPublic | TypeAttributes.Serializable, Types.Enum); - AttributeHelper.HideFromJava(enumBuilder); - enumBuilder.DefineField("value__", Types.Int32, FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); - for (int i = 0; i < f.Fields.Length; i++) - { - if (f.Fields[i].IsEnum) - { - FieldBuilder fieldBuilder = enumBuilder.DefineField(f.Fields[i].Name, enumBuilder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); - fieldBuilder.SetConstant(i); - } - } - wrapper.SetEnumType(enumBuilder); + AddCliEnum(); } TypeWrapper[] interfaces = wrapper.Interfaces; string[] implements = new string[interfaces.Length]; @@ -913,6 +896,30 @@ namespace IKVM.Internal #endif } +#if STATIC_COMPILER + private void AddCliEnum() + { + CompilerClassLoader ccl = wrapper.classLoader; + string name = "__Enum"; + while (!ccl.ReserveName(classFile.Name + "$" + name)) + { + name += "_"; + } + enumBuilder = typeBuilder.DefineNestedType(name, TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.NestedPublic | TypeAttributes.Serializable, Types.Enum); + AttributeHelper.HideFromJava(enumBuilder); + enumBuilder.DefineField("value__", Types.Int32, FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); + for (int i = 0; i < classFile.Fields.Length; i++) + { + if (classFile.Fields[i].IsEnum) + { + FieldBuilder fieldBuilder = enumBuilder.DefineField(classFile.Fields[i].Name, enumBuilder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); + fieldBuilder.SetConstant(i); + } + } + wrapper.SetEnumType(enumBuilder); + } +#endif + private void AddClinitTrigger() { // We create a empty method that we can use to trigger our .cctor |