Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert Driesen <drieseng@users.sourceforge.net>2008-05-12 00:03:52 +0400
committerGert Driesen <drieseng@users.sourceforge.net>2008-05-12 00:03:52 +0400
commit419d317434367e122a6c5030e881fbf2c2203494 (patch)
treeeca33d1dd79e58c20c190daec702d41a0a09217d /mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
parentaf5e5adc962d4b05a71ec5e762915e71b036dc22 (diff)
* FieldBuilder.cs: Added null check for type.
* TypeBuilder.cs: For enums, construct UnderlyingSystemType when first instance field is defined instead of having to lookup it up on demand. Avoid cast in IsCompilerContext. * TypeBuilderTest.cs: Added test for type null check in DefineField. svn path=/trunk/mcs/; revision=102973
Diffstat (limited to 'mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs')
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs18
1 files changed, 10 insertions, 8 deletions
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
index 1884c82432d..2e2c69be704 100644
--- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
@@ -83,6 +83,7 @@ namespace System.Reflection.Emit
#endregion
string fullname;
bool createTypeCalled;
+ private Type underlying_type;
public const int UnspecifiedTypeSize = 0;
@@ -194,13 +195,8 @@ namespace System.Reflection.Emit
return created.UnderlyingSystemType;
if (IsEnum && !IsCompilerContext) {
- for (int i = 0; i < num_fields; i++) {
- FieldBuilder field = fields [i];
- if ((field.Attributes & FieldAttributes.Static) == 0) {
- return field.FieldType;
- }
- }
-
+ if (underlying_type != null)
+ return underlying_type;
throw new InvalidOperationException (
"Enumeration type is not defined.");
}
@@ -686,6 +682,12 @@ namespace System.Reflection.Emit
num_fields ++;
create_internal_class (this);
}
+
+ if (IsEnum && !IsCompilerContext) {
+ if (underlying_type == null && (attributes & FieldAttributes.Static) == 0)
+ underlying_type = type;
+ }
+
return res;
}
@@ -1618,7 +1620,7 @@ namespace System.Reflection.Emit
internal bool IsCompilerContext {
get {
- return ((AssemblyBuilder) Assembly).IsCompilerContext;
+ return pmodule.assemblyb.IsCompilerContext;
}
}