X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Ftypemanager.cs;h=d5060cbf04d9696e2cb71c1cb88a6af10e57798d;hb=a2f7036e7364141983f41ad7b523450fa0539527;hp=8d8b4df7f7a91d5b6ee4fd213767195b252371ec;hpb=9711837418e07615f89ea85129897186efd0cda9;p=mono.git
diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs
index 8d8b4df7f7a..d5060cbf04d 100644
--- a/mcs/mcs/typemanager.cs
+++ b/mcs/mcs/typemanager.cs
@@ -99,6 +99,7 @@ public class TypeManager {
static public Type security_attr_type;
static public Type required_attr_type;
static public Type guid_attr_type;
+ static public Type assembly_culture_attribute_type;
///
/// .NET 2.0
@@ -166,7 +167,6 @@ public class TypeManager {
static public MethodInfo string_concat_object_dot_dot_dot;
static public MethodInfo string_isinterneted_string;
static public MethodInfo system_type_get_type_from_handle;
- static public MethodInfo object_getcurrent_void;
static public MethodInfo bool_movenext_void;
static public MethodInfo ienumerable_getenumerator_void;
static public MethodInfo void_reset_void;
@@ -185,6 +185,7 @@ public class TypeManager {
static public MethodInfo int_array_get_lower_bound_int;
static public MethodInfo int_array_get_upper_bound_int;
static public MethodInfo void_array_copyto_array_int;
+ static public PropertyInfo ienumerator_getcurrent;
//
// The attribute constructors.
@@ -220,24 +221,6 @@ public class TypeManager {
//
static Module [] modules;
- //
- // This is the type_cache from the assemblies to avoid
- // hitting System.Reflection on every lookup.
- //
- static Hashtable types;
-
- //
- // This is used to hotld the corresponding TypeContainer objects
- // since we need this in FindMembers
- //
- static Hashtable typecontainers;
-
- //
- // Keeps track of those types that are defined by the
- // user's program
- //
- static ArrayList user_types;
-
static PtrHashtable builder_to_declspace;
static PtrHashtable builder_to_member_cache;
@@ -280,7 +263,7 @@ public class TypeManager {
// Contains all public types from referenced assemblies.
// This member is used only if CLS Compliance verification is required.
//
- public static Hashtable all_imported_types;
+ public static Hashtable AllClsTopLevelTypes;
static Hashtable fieldbuilders_to_fields;
static Hashtable fields;
@@ -295,9 +278,6 @@ public class TypeManager {
// Lets get everything clean so that we can collect before generating code
assemblies = null;
modules = null;
- types = null;
- typecontainers = null;
- user_types = null;
builder_to_declspace = null;
builder_to_member_cache = null;
builder_to_ifaces = null;
@@ -307,11 +287,9 @@ public class TypeManager {
builder_to_method = null;
fields = null;
- builder_to_constant = null;
fieldbuilders_to_fields = null;
events = null;
priv_fields_events = null;
- properties = null;
type_hash = null;
TypeHandle.CleanUp ();
@@ -400,10 +378,6 @@ public class TypeManager {
{
assemblies = new Assembly [0];
modules = null;
- user_types = new ArrayList ();
-
- types = new Hashtable ();
- typecontainers = new Hashtable ();
builder_to_declspace = new PtrHashtable ();
builder_to_member_cache = new PtrHashtable ();
@@ -422,44 +396,9 @@ public class TypeManager {
type_hash = new DoubleHash ();
}
- public static void HandleDuplicate (string name, Type t)
- {
- Type prev = (Type) types [name];
- TypeContainer tc = builder_to_declspace [prev] as TypeContainer;
-
- if (tc != null){
- //
- // This probably never happens, as we catch this before
- //
- Report.Error (-17, "The type `" + name + "' has already been defined.");
- return;
- }
-
- tc = builder_to_declspace [t] as TypeContainer;
- if (tc != null){
- Report.Warning (
- 1595, "The type `" + name + "' is defined in an existing assembly;"+
- " Using the new definition from: " + tc.Location);
- } else {
- Report.Warning (
- 1595, "The type `" + name + "' is defined in an existing assembly;");
- }
-
- Report.Warning (1595, "Previously defined in: " + prev.Assembly.FullName);
-
- types.Remove (name);
- types.Add (name, t);
- }
-
- public static void AddUserType (string name, TypeBuilder t)
+ public static void AddUserType (string name, DeclSpace ds)
{
- try {
- types.Add (name, t);
- } catch {
- HandleDuplicate (name, t);
- }
-
- user_types.Add (t);
+ builder_to_declspace.Add (ds.TypeBuilder, ds);
}
//
@@ -469,35 +408,7 @@ public class TypeManager {
{
if (ifaces != null)
builder_to_ifaces [tb] = ifaces;
- }
-
- public static void AddUserType (string name, TypeBuilder t, TypeContainer tc)
- {
- builder_to_declspace.Add (t, tc);
- typecontainers.Add (name, tc);
- AddUserType (name, t);
- }
-
- public static void AddDelegateType (string name, TypeBuilder t, Delegate del)
- {
- try {
- types.Add (name, t);
- } catch {
- HandleDuplicate (name, t);
- }
-
- builder_to_declspace.Add (t, del);
- }
-
- public static void AddEnumType (string name, TypeBuilder t, Enum en)
- {
- try {
- types.Add (name, t);
- } catch {
- HandleDuplicate (name, t);
- }
- builder_to_declspace.Add (t, en);
- }
+ }
public static void AddMethod (MethodBase builder, IMethodData method)
{
@@ -569,11 +480,6 @@ public class TypeManager {
return builder_to_declspace [t] as Delegate;
}
- public static Enum LookupEnum (Type t)
- {
- return builder_to_declspace [t] as Enum;
- }
-
public static Class LookupClass (Type t)
{
return (Class) builder_to_declspace [t];
@@ -665,54 +571,58 @@ public class TypeManager {
{
object ret = null;
if (!type_hash.Lookup (t, name, out ret)) {
- string lookup = t.ToString () + "+" + name;
- ret = t.Module.GetType (lookup);
+ ret = t.GetNestedType (name,
+ BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
type_hash.Insert (t, name, ret);
}
return (Type) ret;
}
-
- //
- // Low-level lookup, cache-less
- //
- public static Type LookupTypeReflection (string name)
+
+ public static Type LookupTypeReflection (string name, Location loc)
{
- Type t;
+ Type found_type = null;
- foreach (Assembly a in assemblies){
- t = a.GetType (name);
+ foreach (Assembly a in assemblies) {
+ Type t = a.GetType (name);
if (t == null)
continue;
- do {
- TypeAttributes ta = t.Attributes & TypeAttributes.VisibilityMask;
- if (ta == TypeAttributes.NotPublic ||
- ta == TypeAttributes.NestedPrivate ||
- ta == TypeAttributes.NestedAssembly ||
- ta == TypeAttributes.NestedFamANDAssem){
-
- //
- // In .NET pointers turn out to be private, even if their
- // element type is not
- //
- if (t.IsPointer){
- t = t.GetElementType ();
- continue;
- } else
- t = null;
- } else {
- return t;
+ if (t.IsPointer)
+ throw new InternalErrorException ("Use GetPointerType() to get a pointer");
+
+ TypeAttributes ta = t.Attributes & TypeAttributes.VisibilityMask;
+ if (ta != TypeAttributes.NotPublic && ta != TypeAttributes.NestedPrivate &&
+ ta != TypeAttributes.NestedAssembly && ta != TypeAttributes.NestedFamANDAssem) {
+ if (found_type == null) {
+ found_type = t;
+ continue;
}
- } while (t != null);
+
+ Report.SymbolRelatedToPreviousError (found_type);
+ Report.SymbolRelatedToPreviousError (t);
+ Report.Error (433, loc, "The imported type `{0}' is defined multiple times", name);
+ return found_type;
+ }
}
foreach (Module mb in modules) {
- t = mb.GetType (name);
- if (t != null)
- return t;
+ Type t = mb.GetType (name);
+ if (t == null)
+ continue;
+
+ if (found_type == null) {
+ found_type = t;
+ continue;
+ }
+
+ Report.SymbolRelatedToPreviousError (t);
+ Report.SymbolRelatedToPreviousError (found_type);
+ Report.Warning (436, 2, loc, "Ignoring imported type `{0}' since the current assembly already has a declaration with the same name",
+ TypeManager.CSharpName (t));
+ return t;
}
-
- return null;
+
+ return found_type;
}
///
@@ -734,7 +644,7 @@ public class TypeManager {
Assembly a = assemblies [i];
string [] namespaces = (string []) assembly_get_namespaces.Invoke (a, null);
foreach (string ns in namespaces){
- if (ns == "")
+ if (ns.Length == 0)
continue;
Namespace.LookupNamespace (ns, true);
}
@@ -780,10 +690,10 @@ public class TypeManager {
///
public static void LoadAllImportedTypes ()
{
- all_imported_types = new Hashtable ();
+ AllClsTopLevelTypes = new Hashtable (1500);
foreach (Assembly a in assemblies) {
foreach (Type t in a.GetExportedTypes ()) {
- all_imported_types [t.FullName] = t;
+ AllClsTopLevelTypes [t.FullName.ToLower (System.Globalization.CultureInfo.InvariantCulture)] = null;
}
}
}
@@ -842,91 +752,94 @@ public class TypeManager {
///
static public string GetFullNameSignature (MemberInfo mi)
{
- // Unfortunately, there's no dynamic dispatch on the arguments of a function.
return (mi is MethodBase)
- ? GetFullNameSignature (mi as MethodBase)
- : mi.DeclaringType.FullName.Replace ('+', '.') + '.' + mi.Name;
- }
-
- static public string GetFullNameSignature (MethodBase mb)
- {
- string name = mb.Name;
- if (name == ".ctor")
- name = mb.DeclaringType.Name;
-
- if (mb.IsSpecialName) {
- if (name.StartsWith ("get_") || name.StartsWith ("set_")) {
- name = name.Remove (0, 4);
- }
-
- if (name == "Item")
- name = "this";
- }
-
- return mb.DeclaringType.FullName.Replace ('+', '.') + '.' + name;
+ ? CSharpSignature (mi as MethodBase)
+ : CSharpName (mi.DeclaringType) + '.' + mi.Name;
}
///
- /// Returns the signature of the property and indexer
+ /// When we need to report accessors as well
///
- static public string CSharpSignature (PropertyBuilder pb, bool is_indexer)
+ static public string CSharpSignature (MethodBase mb)
{
- if (!is_indexer) {
- return GetFullNameSignature (pb);
- }
-
- MethodBase mb = pb.GetSetMethod (true) != null ? pb.GetSetMethod (true) : pb.GetGetMethod (true);
- string signature = GetFullNameSignature (mb);
- string arg = GetParameterData (mb).ParameterDesc (0);
- return String.Format ("{0}.this[{1}]", signature.Substring (0, signature.LastIndexOf ('.')), arg);
+ return CSharpSignature (mb, false);
}
///
/// Returns the signature of the method
///
- static public string CSharpSignature (MethodBase mb)
+ static public string CSharpSignature (MethodBase mb, bool show_accessor)
{
- StringBuilder sig = new StringBuilder ("(");
+ StringBuilder sig = new StringBuilder (CSharpName (mb.DeclaringType));
+ sig.Append ('.');
ParameterData iparams = GetParameterData (mb);
+ string parameters = iparams.GetSignatureForError ();
+ string accessor = "";
// Is property
- if (mb.IsSpecialName && iparams.Count == 0 && !mb.IsConstructor)
- return GetFullNameSignature (mb);
-
- for (int i = 0; i < iparams.Count; i++) {
- if (i > 0) {
- sig.Append (", ");
+ if (mb.IsSpecialName) {
+ Operator.OpType ot = Operator.GetOperatorType (mb.Name);
+ if (ot != Operator.OpType.TOP) {
+ sig.Append ("operator ");
+ sig.Append (Operator.GetName (ot));
+ sig.Append (parameters);
+ return sig.ToString ();
+ }
+
+ if (mb.Name.StartsWith ("get_") || mb.Name.StartsWith ("set_")) {
+ accessor = mb.Name.Substring (0, 3);
}
- sig.Append (iparams.ParameterDesc (i));
}
- sig.Append (")");
// Is indexer
- if (mb.IsSpecialName && iparams.Count == 1 && !mb.IsConstructor) {
- sig.Replace ('(', '[');
- sig.Replace (')', ']');
+ if (mb.IsSpecialName && !mb.IsConstructor) {
+ if (iparams.Count > 1) {
+ sig.Append ("this[");
+ if (show_accessor) {
+ sig.Append (parameters.Substring (1, parameters.Length - 2));
+ }
+ else {
+ int before_ret_val = parameters.LastIndexOf (',');
+ sig.Append (parameters.Substring (1, before_ret_val - 1));
+ }
+ sig.Append (']');
+ } else {
+ sig.Append (mb.Name.Substring (4));
+ }
+ } else {
+ if (mb.Name == ".ctor")
+ sig.Append (mb.DeclaringType.Name);
+ else
+ sig.Append (mb.Name);
+
+ sig.Append (parameters);
}
- return GetFullNameSignature (mb) + sig.ToString ();
+ if (show_accessor && accessor.Length > 0) {
+ sig.Append ('.');
+ sig.Append (accessor);
+ }
+
+ return sig.ToString ();
+ }
+
+ static public string CSharpSignature (EventInfo ei)
+ {
+ return CSharpName (ei.DeclaringType) + '.' + ei.Name;
}
///
/// Looks up a type, and aborts if it is not found. This is used
/// by types required by the compiler
///
- static Type CoreLookupType (string name)
+ static Type CoreLookupType (string ns_name, string name)
{
- Type t = null;
- if (types.Contains (name))
- t = (Type) types [name];
- else
- t = LookupTypeReflection (name);
-
+ Namespace ns = Namespace.LookupNamespace (ns_name, true);
+ FullNamedExpression fne = ns.Lookup (RootContext.Tree.Types, name, Location.Null);
+ Type t = fne == null ? null : fne.Type;
if (t == null)
Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
-
- types [name] = t;
return t;
}
@@ -973,6 +886,27 @@ public class TypeManager {
return GetMethod (t, name, args, true);
}
+ ///
+ /// Returns the PropertyInfo for a property named `name' defined
+ /// in type `t'
+ ///
+ static PropertyInfo GetProperty (Type t, string name)
+ {
+ MemberList list = FindMembers (t, MemberTypes.Property, BindingFlags.Public |
+ BindingFlags.Instance, Type.FilterName, name);
+ if (list.Count == 0) {
+ Report.Error (-19, "Can not find the core property `" + name + "'");
+ return null;
+ }
+
+ PropertyInfo pi = list [0] as PropertyInfo;
+ if (pi == null) {
+ Report.Error (-19, "Can not find the core function `" + name + "'");
+ return null;
+ }
+
+ return pi;
+ }
///
/// Returns the ConstructorInfo for "args"
@@ -1005,14 +939,14 @@ public class TypeManager {
public static void InitEnumUnderlyingTypes ()
{
- int32_type = CoreLookupType ("System.Int32");
- int64_type = CoreLookupType ("System.Int64");
- uint32_type = CoreLookupType ("System.UInt32");
- uint64_type = CoreLookupType ("System.UInt64");
- byte_type = CoreLookupType ("System.Byte");
- sbyte_type = CoreLookupType ("System.SByte");
- short_type = CoreLookupType ("System.Int16");
- ushort_type = CoreLookupType ("System.UInt16");
+ int32_type = CoreLookupType ("System", "Int32");
+ int64_type = CoreLookupType ("System", "Int64");
+ uint32_type = CoreLookupType ("System", "UInt32");
+ uint64_type = CoreLookupType ("System", "UInt64");
+ byte_type = CoreLookupType ("System", "Byte");
+ sbyte_type = CoreLookupType ("System", "SByte");
+ short_type = CoreLookupType ("System", "Int16");
+ ushort_type = CoreLookupType ("System", "UInt16");
}
///
@@ -1022,84 +956,85 @@ public class TypeManager {
///
public static void InitCoreTypes ()
{
- object_type = CoreLookupType ("System.Object");
- value_type = CoreLookupType ("System.ValueType");
+ object_type = CoreLookupType ("System", "Object");
+ value_type = CoreLookupType ("System", "ValueType");
InitEnumUnderlyingTypes ();
- char_type = CoreLookupType ("System.Char");
- string_type = CoreLookupType ("System.String");
- float_type = CoreLookupType ("System.Single");
- double_type = CoreLookupType ("System.Double");
- char_ptr_type = CoreLookupType ("System.Char*");
- decimal_type = CoreLookupType ("System.Decimal");
- bool_type = CoreLookupType ("System.Boolean");
- enum_type = CoreLookupType ("System.Enum");
-
- multicast_delegate_type = CoreLookupType ("System.MulticastDelegate");
- delegate_type = CoreLookupType ("System.Delegate");
-
- array_type = CoreLookupType ("System.Array");
- void_type = CoreLookupType ("System.Void");
- type_type = CoreLookupType ("System.Type");
-
- runtime_field_handle_type = CoreLookupType ("System.RuntimeFieldHandle");
- runtime_argument_handle_type = CoreLookupType ("System.RuntimeArgumentHandle");
- runtime_helpers_type = CoreLookupType ("System.Runtime.CompilerServices.RuntimeHelpers");
- default_member_type = CoreLookupType ("System.Reflection.DefaultMemberAttribute");
- runtime_handle_type = CoreLookupType ("System.RuntimeTypeHandle");
- asynccallback_type = CoreLookupType ("System.AsyncCallback");
- iasyncresult_type = CoreLookupType ("System.IAsyncResult");
- ienumerator_type = CoreLookupType ("System.Collections.IEnumerator");
- ienumerable_type = CoreLookupType ("System.Collections.IEnumerable");
- idisposable_type = CoreLookupType ("System.IDisposable");
- icloneable_type = CoreLookupType ("System.ICloneable");
- iconvertible_type = CoreLookupType ("System.IConvertible");
- monitor_type = CoreLookupType ("System.Threading.Monitor");
- intptr_type = CoreLookupType ("System.IntPtr");
-
- attribute_type = CoreLookupType ("System.Attribute");
- attribute_usage_type = CoreLookupType ("System.AttributeUsageAttribute");
- dllimport_type = CoreLookupType ("System.Runtime.InteropServices.DllImportAttribute");
- methodimpl_attr_type = CoreLookupType ("System.Runtime.CompilerServices.MethodImplAttribute");
- marshal_as_attr_type = CoreLookupType ("System.Runtime.InteropServices.MarshalAsAttribute");
- param_array_type = CoreLookupType ("System.ParamArrayAttribute");
- in_attribute_type = CoreLookupType ("System.Runtime.InteropServices.InAttribute");
- out_attribute_type = CoreLookupType ("System.Runtime.InteropServices.OutAttribute");
- typed_reference_type = CoreLookupType ("System.TypedReference");
- arg_iterator_type = CoreLookupType ("System.ArgIterator");
- mbr_type = CoreLookupType ("System.MarshalByRefObject");
- decimal_constant_attribute_type = CoreLookupType ("System.Runtime.CompilerServices.DecimalConstantAttribute");
-
- unverifiable_code_type= CoreLookupType ("System.Security.UnverifiableCodeAttribute");
-
- void_ptr_type = CoreLookupType ("System.Void*");
-
- indexer_name_type = CoreLookupType ("System.Runtime.CompilerServices.IndexerNameAttribute");
-
- exception_type = CoreLookupType ("System.Exception");
- invalid_operation_exception_type = CoreLookupType ("System.InvalidOperationException");
- not_supported_exception_type = CoreLookupType ("System.NotSupportedException");
+ char_type = CoreLookupType ("System", "Char");
+ string_type = CoreLookupType ("System", "String");
+ float_type = CoreLookupType ("System", "Single");
+ double_type = CoreLookupType ("System", "Double");
+ char_ptr_type = GetPointerType (char_type);
+ decimal_type = CoreLookupType ("System", "Decimal");
+ bool_type = CoreLookupType ("System", "Boolean");
+ enum_type = CoreLookupType ("System", "Enum");
+
+ multicast_delegate_type = CoreLookupType ("System", "MulticastDelegate");
+ delegate_type = CoreLookupType ("System", "Delegate");
+
+ array_type = CoreLookupType ("System", "Array");
+ void_type = CoreLookupType ("System", "Void");
+ type_type = CoreLookupType ("System", "Type");
+
+ runtime_field_handle_type = CoreLookupType ("System", "RuntimeFieldHandle");
+ runtime_argument_handle_type = CoreLookupType ("System", "RuntimeArgumentHandle");
+ runtime_helpers_type = CoreLookupType ("System.Runtime.CompilerServices", "RuntimeHelpers");
+ default_member_type = CoreLookupType ("System.Reflection", "DefaultMemberAttribute");
+ runtime_handle_type = CoreLookupType ("System", "RuntimeTypeHandle");
+ asynccallback_type = CoreLookupType ("System", "AsyncCallback");
+ iasyncresult_type = CoreLookupType ("System", "IAsyncResult");
+ ienumerator_type = CoreLookupType ("System.Collections", "IEnumerator");
+ ienumerable_type = CoreLookupType ("System.Collections", "IEnumerable");
+ idisposable_type = CoreLookupType ("System", "IDisposable");
+ icloneable_type = CoreLookupType ("System", "ICloneable");
+ iconvertible_type = CoreLookupType ("System", "IConvertible");
+ monitor_type = CoreLookupType ("System.Threading", "Monitor");
+ intptr_type = CoreLookupType ("System", "IntPtr");
+
+ attribute_type = CoreLookupType ("System", "Attribute");
+ attribute_usage_type = CoreLookupType ("System", "AttributeUsageAttribute");
+ dllimport_type = CoreLookupType ("System.Runtime.InteropServices", "DllImportAttribute");
+ methodimpl_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "MethodImplAttribute");
+ marshal_as_attr_type = CoreLookupType ("System.Runtime.InteropServices", "MarshalAsAttribute");
+ param_array_type = CoreLookupType ("System", "ParamArrayAttribute");
+ in_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "InAttribute");
+ out_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "OutAttribute");
+ typed_reference_type = CoreLookupType ("System", "TypedReference");
+ arg_iterator_type = CoreLookupType ("System", "ArgIterator");
+ mbr_type = CoreLookupType ("System", "MarshalByRefObject");
+ decimal_constant_attribute_type = CoreLookupType ("System.Runtime.CompilerServices", "DecimalConstantAttribute");
+
+ unverifiable_code_type= CoreLookupType ("System.Security", "UnverifiableCodeAttribute");
+
+ void_ptr_type = GetPointerType (void_type);
+
+ indexer_name_type = CoreLookupType ("System.Runtime.CompilerServices", "IndexerNameAttribute");
+
+ exception_type = CoreLookupType ("System", "Exception");
+ invalid_operation_exception_type = CoreLookupType ("System", "InvalidOperationException");
+ not_supported_exception_type = CoreLookupType ("System", "NotSupportedException");
//
// Attribute types
//
- obsolete_attribute_type = CoreLookupType ("System.ObsoleteAttribute");
- conditional_attribute_type = CoreLookupType ("System.Diagnostics.ConditionalAttribute");
- cls_compliant_attribute_type = CoreLookupType ("System.CLSCompliantAttribute");
- struct_layout_attribute_type = CoreLookupType ("System.Runtime.InteropServices.StructLayoutAttribute");
- field_offset_attribute_type = CoreLookupType ("System.Runtime.InteropServices.FieldOffsetAttribute");
- security_attr_type = CoreLookupType ("System.Security.Permissions.SecurityAttribute");
- required_attr_type = CoreLookupType ("System.Runtime.CompilerServices.RequiredAttributeAttribute");
- guid_attr_type = CoreLookupType ("System.Runtime.InteropServices.GuidAttribute");
+ obsolete_attribute_type = CoreLookupType ("System", "ObsoleteAttribute");
+ conditional_attribute_type = CoreLookupType ("System.Diagnostics", "ConditionalAttribute");
+ cls_compliant_attribute_type = CoreLookupType ("System", "CLSCompliantAttribute");
+ struct_layout_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "StructLayoutAttribute");
+ field_offset_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "FieldOffsetAttribute");
+ security_attr_type = CoreLookupType ("System.Security.Permissions", "SecurityAttribute");
+ required_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "RequiredAttributeAttribute");
+ guid_attr_type = CoreLookupType ("System.Runtime.InteropServices", "GuidAttribute");
+ assembly_culture_attribute_type = CoreLookupType ("System.Reflection", "AssemblyCultureAttribute");
//
// .NET 2.0
//
#if NET_2_0
- compiler_generated_attr_type = CoreLookupType ("System.Runtime.CompilerServices.CompilerGeneratedAttribute");
- fixed_buffer_attr_type = CoreLookupType ("System.Runtime.CompilerServices.FixedBufferAttribute");
- default_charset_type = CoreLookupType ("System.Runtime.InteropServices.DefaultCharSetAttribute");
+ compiler_generated_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "CompilerGeneratedAttribute");
+ fixed_buffer_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "FixedBufferAttribute");
+ default_charset_type = CoreLookupType ("System.Runtime.InteropServices", "DefaultCharSetAttribute");
#endif
//
// When compiling corlib, store the "real" types here.
@@ -1244,8 +1179,8 @@ public class TypeManager {
// Void arguments
//
Type [] void_arg = { };
- object_getcurrent_void = GetMethod (
- ienumerator_type, "get_Current", void_arg);
+ ienumerator_getcurrent = GetProperty (
+ ienumerator_type, "Current");
bool_movenext_void = GetMethod (
ienumerator_type, "MoveNext", void_arg);
void_reset_void = GetMethod (
@@ -1512,11 +1447,12 @@ public class TypeManager {
public static bool IsEnumType (Type t)
{
- if (t.IsSubclassOf (TypeManager.enum_type))
+ if (builder_to_declspace [t] is Enum)
return true;
- else
- return false;
+
+ return t.IsEnum;
}
+
public static bool IsBuiltinOrEnum (Type t)
{
if (IsBuiltinType (t))
@@ -1680,42 +1616,6 @@ public class TypeManager {
{
return t.IsArray || t.IsPointer || t.IsByRef;
}
-
- ///
- /// Returns the User Defined Types
- ///
- public static ArrayList UserTypes {
- get {
- return user_types;
- }
- }
-
- public static Hashtable TypeContainers {
- get {
- return typecontainers;
- }
- }
-
- static Hashtable builder_to_constant;
-
- public static void RegisterConstant (FieldBuilder fb, Const c)
- {
- if (builder_to_constant == null)
- builder_to_constant = new PtrHashtable ();
-
- if (builder_to_constant.Contains (fb))
- return;
-
- builder_to_constant.Add (fb, c);
- }
-
- public static Const LookupConstant (FieldBuilder fb)
- {
- if (builder_to_constant == null)
- return null;
-
- return (Const) builder_to_constant [fb];
- }
///
/// Gigantic work around for missing features in System.Reflection.Emit follows.
@@ -1825,23 +1725,17 @@ public class TypeManager {
}
}
- //
- // This is a workaround the fact that GetValue is not
- // supported for dynamic types
- //
- static public bool RegisterFieldValue (FieldBuilder fb, object value)
+ public static void RegisterConstant (FieldInfo fb, IConstant ic)
{
- if (fields.Contains (fb))
- return false;
-
- fields.Add (fb, value);
-
- return true;
+ fields.Add (fb, ic);
}
- static public object GetValue (FieldBuilder fb)
+ public static IConstant GetConstant (FieldInfo fb)
{
- return fields [fb];
+ if (fb == null)
+ return null;
+
+ return (IConstant)fields [fb];
}
static public bool RegisterFieldBase (FieldBuilder fb, FieldBase f)
@@ -1918,27 +1812,9 @@ public class TypeManager {
return (MemberInfo) priv_fields_events [ei];
}
- static Hashtable properties;
-
- static public bool RegisterProperty (PropertyBuilder pb, MethodBase get, MethodBase set)
- {
- if (properties == null)
- properties = new Hashtable ();
-
- if (properties.Contains (pb))
- return false;
-
- properties.Add (pb, new Pair (get, set));
-
- return true;
- }
-
static public bool RegisterIndexer (PropertyBuilder pb, MethodBase get,
MethodBase set, Type[] args)
{
- if (!RegisterProperty (pb, get,set))
- return false;
-
indexer_arguments.Add (pb, args);
return true;
@@ -2213,7 +2089,6 @@ public class TypeManager {
t == TypeManager.int64_type ||
t == TypeManager.uint64_type)
return t;
- throw new Exception ("Unhandled typecode in enum " + " from " + t.AssemblyQualifiedName);
}
TypeCode tc = Type.GetTypeCode (t);
@@ -2304,10 +2179,9 @@ public class TypeManager {
if (IsUnmanagedType (t))
return true;
- Report.Error (
- 208, loc,
- "Cannot take the address or size of a variable of a managed type ('" +
- CSharpName (t) + "')");
+ Report.Error (208, loc, "Cannot take the address of, get the size of, or declare a pointer to a managed type `{0}'",
+ CSharpName (t));
+
return false;
}
@@ -2471,7 +2345,7 @@ public class TypeManager {
return true;
}
- if (!is_static && almost_match != null)
+ if (almost_match != null)
almost_match.Add (m);
return false;
@@ -2614,31 +2488,12 @@ public class TypeManager {
Type current_type = queried_type;
bool searching = (original_bf & BindingFlags.DeclaredOnly) == 0;
bool skip_iface_check = true, used_cache = false;
- bool always_ok_flag = false;
+ bool always_ok_flag = invocation_type != null && IsNestedChildOf (invocation_type, queried_type);
closure.invocation_type = invocation_type;
closure.invocation_assembly = invocation_type != null ? invocation_type.Assembly : null;
closure.qualifier_type = qualifier_type;
closure.almost_match = almost_match;
-
- //
- // If we are a nested class, we always have access to our container
- // type names
- //
- if (invocation_type != null){
- string invocation_name = invocation_type.FullName;
- if (invocation_name.IndexOf ('+') != -1){
- string container = queried_type.FullName + "+";
- int container_length = container.Length;
-
- if (invocation_name.Length > container_length){
- string shared = invocation_name.Substring (0, container_length);
-
- if (shared == container)
- always_ok_flag = true;
- }
- }
- }
// This is from the first time we find a method
// in most cases, we do not actually find a method in the base class