ecore.cs : Added support for Implicit numeric conversions
[mono.git] / mcs / mbas / typemanager.cs
index 9332c1718fc92c76f6ee1b0cf65db022906fc2b0..608ee89dfee433cef07a380b7c1808b59821cd9c 100644 (file)
@@ -18,7 +18,7 @@ using System.Text.RegularExpressions;
 using System.Runtime.CompilerServices;
 using System.Diagnostics;
 
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
 
 public class TypeManager {
        //
@@ -37,6 +37,7 @@ public class TypeManager {
        static public Type char_ptr_type;
        static public Type short_type;
        static public Type decimal_type;
+       static public Type date_type;
        static public Type bool_type;
        static public Type sbyte_type;
        static public Type byte_type;
@@ -89,6 +90,7 @@ public class TypeManager {
        static public Expression system_int32_expr, system_uint32_expr;
        static public Expression system_int64_expr, system_uint64_expr;
        static public Expression system_char_expr, system_void_expr;
+       static public Expression system_date_expr;
        static public Expression system_asynccallback_expr;
        static public Expression system_iasyncresult_expr;
 
@@ -144,7 +146,9 @@ public class TypeManager {
        //
        static public ConstructorInfo cons_param_array_attribute;
        static public ConstructorInfo void_decimal_ctor_five_args;
+       static public ConstructorInfo void_datetime_ctor_ticks_arg;
        static public ConstructorInfo unverifiable_code_ctor;
+       static public ConstructorInfo default_member_ctor;
        
        // <remarks>
        //   Holds the Array of Assemblies that have been loaded
@@ -157,7 +161,13 @@ public class TypeManager {
        //  Keeps a list of module builders. We used this to do lookups
        //  on the modulebuilder using GetType -- needed for arrays
        // </remarks>
-       static ModuleBuilder [] modules;
+       
+       // This is changed from list of ModuleBuilders 
+       // to list of Modules for getting addmodule 
+       // compiler option working
+       // Anirban - 13.07.2004
+
+       static System.Reflection.Module [] modules;
 
        // <remarks>
        //   This is the type_cache from the assemblies to avoid
@@ -198,17 +208,11 @@ public class TypeManager {
        static Hashtable indexer_arguments;
 
        // <remarks>
-       //   Maybe `method_arguments' should be replaced and only
+       //   Maybe 'method_arguments' should be replaced and only
        //   method_internal_params should be kept?
        // <remarks>
        static Hashtable method_internal_params;
 
-       // <remarks>
-       //  Keeps track of attribute types
-       // </remarks>
-
-       static Hashtable builder_to_attr;
-
        // <remarks>
        //  Keeps track of methods
        // </remarks>
@@ -285,6 +289,7 @@ public class TypeManager {
                system_uint64_expr  = new TypeLookupExpression ("System.UInt64");
                system_char_expr    = new TypeLookupExpression ("System.Char");
                system_void_expr    = new TypeLookupExpression ("System.Void");
+               system_date_expr    = new TypeLookupExpression ("System.DateTime");
                system_asynccallback_expr = new TypeLookupExpression ("System.AsyncCallback");
                system_iasyncresult_expr = new TypeLookupExpression ("System.IAsyncResult");
        }
@@ -296,10 +301,10 @@ public class TypeManager {
                user_types = new ArrayList ();
                
                types = new CaseInsensitiveHashtable ();
+               negative_hits = new CaseInsensitiveHashtable ();
                typecontainers = new CaseInsensitiveHashtable ();
                
                builder_to_declspace = new PtrHashtable ();
-               builder_to_attr = new PtrHashtable ();
                builder_to_method = new PtrHashtable ();
                method_arguments = new PtrHashtable ();
                method_internal_params = new PtrHashtable ();
@@ -324,14 +329,14 @@ public class TypeManager {
                                //
                                // This probably never happens, as we catch this before
                                //
-                               Report.Error (-17, "The type `" + name + "' has already been defined.");
+                               Report.Error (-17, "The type '" + name + "' has already been defined.");
                                return;
                        }
 
                        tc = builder_to_declspace [t] as TypeContainer;
                        
                        Report.Warning (
-                               1595, "The type `" + name + "' is defined in an existing assembly;"+
+                               1595, "The type '" + name + "' is defined in an existing assembly;"+
                                " Using the new definition from: " + tc.Location);
                        Report.Warning (1595, "Previously defined in: " + prev.Assembly.FullName);
                        
@@ -383,14 +388,9 @@ public class TypeManager {
                builder_to_method.Add (builder, method);
        }
 
-       public static void RegisterAttrType (Type t, TypeContainer tc)
-       {
-               builder_to_attr.Add (t, tc);
-       }
-
        /// <summary>
-       ///   Returns the TypeContainer whose Type is `t' or null if there is no
-       ///   TypeContainer for `t' (ie, the Type comes from a library)
+       ///   Returns the TypeContainer whose Type is 't' or null if there is no
+       ///   TypeContainer for 't' (ie, the Type comes from a library)
        /// </summary>
        public static TypeContainer LookupTypeContainer (Type t)
        {
@@ -422,10 +422,10 @@ public class TypeManager {
        {
                return builder_to_declspace [t] as Enum;
        }
-       
-       public static TypeContainer LookupAttr (Type t)
+
+       public static TypeContainer LookupClass (Type t)
        {
-               return (TypeContainer) builder_to_attr [t];
+               return builder_to_declspace [t] as TypeContainer;
        }
        
        /// <summary>
@@ -440,15 +440,20 @@ public class TypeManager {
                
                n [top] = a;
                assemblies = n;
+
+               foreach(Type type in a.GetTypes()) {
+                       if (type.IsPublic ) // && type. attributed as standard module
+                               AddStandardModule(type);
+               }
        }
 
        /// <summary>
        ///  Registers a module builder to lookup types from
        /// </summary>
-       public static void AddModule (ModuleBuilder mb)
+       public static void AddModule (System.Reflection.Module mb)
        {
                int top = modules != null ? modules.Length : 0;
-               ModuleBuilder [] n = new ModuleBuilder [top + 1];
+               System.Reflection.Module [] n = new System.Reflection.Module [top + 1];
 
                if (modules != null)
                        modules.CopyTo (n, 0);
@@ -456,6 +461,83 @@ public class TypeManager {
                modules = n;
        }
 
+       private class StandardModule {
+               public readonly string Namespace;
+               public readonly string Name;
+               private readonly string asString;
+               public StandardModule(string _namespace, string name) { 
+                       Namespace = _namespace; 
+                       Name = name; 
+                       asString = ((Namespace != null && Namespace.Length > 0)?(Namespace + "."):"") + Name;
+               }
+               public override string ToString() { return asString; }
+       }
+
+       private static StandardModule[] standardModules;
+
+       /// <summary>
+       ///  Registers a new 'standard module' to lookup short-qualified or unqualified members
+       /// </summary>
+       internal static void AddStandardModule(Module module)
+       {
+               int top = standardModules != null ? standardModules.Length : 0;
+               StandardModule [] n = new StandardModule [top + 1];
+
+               if (standardModules != null)
+                       standardModules.CopyTo (n, 0);
+               string name = module.Name;
+               int split = name.LastIndexOf('.'); 
+               if (split > 0)
+                       name = name.Substring(split+1);
+               n [top] = new StandardModule(module.Namespace.Name, name); 
+               // Console.WriteLine("Standard Module added: " + n [top]);
+               standardModules = n;
+       }
+
+       /// 
+       ///  Registers a existing 'standard module' to lookup short-qualified or unqualified members
+       /// 
+       private static void AddStandardModule(Type type)
+       {
+           object[] attributes = type.GetCustomAttributes(false);
+           for (int i = 0; i < attributes.Length; i ++) {
+                       if (attributes[i].ToString() == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute") {
+                               int top = standardModules != null ? standardModules.Length : 0;
+                               StandardModule [] n = new StandardModule [top + 1];
+
+                               if (standardModules != null)
+                                       standardModules.CopyTo (n, 0);
+                               n [top] = new StandardModule(type.Namespace, type.Name) ;
+                               standardModules = n;
+                               return;
+                       }
+        }
+       }
+
+       //
+       // 
+       //
+       public static Type[] GetPertinentStandardModules(params string[] namespaces)
+       {
+               ArrayList list = new ArrayList();
+               foreach(string Namespace in namespaces)
+               { 
+                       for(int i = 0; i < standardModules.Length; i++) {
+                               if (standardModules[i].Namespace == Namespace) {
+                                       string name = standardModules[i].ToString();
+                                       Type t = LookupType(name);
+                                       if (t == null) {
+                                               System.Console.WriteLine("Could not find standard module '" + name + "'"); 
+                                       }
+                                       else {
+                                               list.Add(t);
+                                       }
+                               }
+                       }
+               }
+               return (Type[])list.ToArray(typeof(Type));
+       }
+
        //
        // Low-level lookup, cache-less
        //
@@ -463,21 +545,26 @@ public class TypeManager {
        {
                Type t;
 
-               foreach (Assembly a in assemblies){
-                       t = a.GetType (name);
-                       if (t != null)
-                               return t;
-               }
+               try {
+                       foreach (Assembly a in assemblies){
+                               t = a.GetType (name, false, true);
+                               if (t != null)
+                                       return t;
+                       }
 
-               foreach (ModuleBuilder mb in modules) {
-                       t = mb.GetType (name);
-                       if (t != null){
-                               return t;
+                       foreach (System.Reflection.Module mb in modules) {
+                               t = mb.GetType (name, false, true);
+                               if (t != null){
+                                       return t;
+                               }
                        }
+               } catch (Exception e) {
+                       System.Console.WriteLine("\nERROR: " + e.ToString() + "WHILE EXECUTING LookupTypeReflection(\"" + name + "\")\n");
                }
                return null;
        }
 
+       static CaseInsensitiveHashtable negative_hits;
        //
        // This function is used when you want to avoid the lookups, and want to go
        // directly to the source.  This will use the cache.
@@ -492,11 +579,13 @@ public class TypeManager {
                if (t != null)
                        return t;
 
+               if (negative_hits.Contains (name))
+                       return null;
                t = LookupTypeReflection (name);
                if (t == null)
-                       return null;
-
-               types [name] = t;
+                       negative_hits [name] = null;
+               else
+                       types [name] = t;
                return t;
        }
        
@@ -517,6 +606,9 @@ public class TypeManager {
                if (t != null)
                        return t;
 
+               if (negative_hits.Contains (name))
+                       return null;
+
                //
                // Optimization: ComposedCast will work with an existing type, and might already have the
                // full name of the type, so the full system lookup can probably be avoided.
@@ -528,11 +620,16 @@ public class TypeManager {
                for (int n = 1; n <= count; n++){
                        string top_level_type = String.Join (".", elements, 0, n);
 
+                       if (negative_hits.Contains (top_level_type))
+                               continue;
+
                        t = (Type) types [top_level_type];
                        if (t == null){
                                t = LookupTypeReflection (top_level_type);
-                               if (t == null)
+                               if (t == null){
+                                       negative_hits [top_level_type] = null;
                                        continue;
+                               }
                        }
                        
                        if (count == n){
@@ -541,11 +638,14 @@ public class TypeManager {
                        } 
                        
                        string newt = top_level_type + "+" + String.Join ("+", elements, n, count - n);
-                       t = LookupTypeDirect (newt);
-                       if (t != null)
-                               types [newt] = t;
+                       t = LookupTypeReflection (newt);
+                       if (t == null)
+                               negative_hits [name] = null;
+                       else
+                               types [name] = t;
                        return t;
                }
+               negative_hits [name] = null;
                return null;
        }
 
@@ -556,8 +656,8 @@ public class TypeManager {
        {
                CaseInsensitiveHashtable namespaces = new CaseInsensitiveHashtable ();
 
-               foreach (Assembly a in assemblies){
-                       foreach (Type t in a.GetTypes ()){
+               foreach (Assembly a in assemblies) {
+                       foreach (Type t in a.GetTypes ()) {
                                string ns = t.Namespace;
 
                                if (namespaces.Contains (ns))
@@ -566,8 +666,8 @@ public class TypeManager {
                        }
                }
 
-               foreach (ModuleBuilder mb in modules){
-                       foreach (Type t in mb.GetTypes ()){
+               foreach (System.Reflection.Module mb in modules) {
+                       foreach (Type t in mb.GetTypes ()) {
                                string ns = t.Namespace;
 
                                if (namespaces.Contains (ns))
@@ -575,42 +675,37 @@ public class TypeManager {
                                namespaces [ns] = ns;
                        }
                }
+
                return namespaces;
        }
        
        /// <summary>
        ///   Returns the C# name of a type if possible, or the full type name otherwise
        /// </summary>
-       static public string CSharpName (Type t)
+       static public string MonoBASIC_Name (Type t)
        {
                return Regex.Replace (t.FullName, 
                        @"^System\." +
-                       @"(Int32|UInt32|Int16|Uint16|Int64|UInt64|" +
-                       @"Single|Double|Char|Decimal|Byte|SByte|Object|" +
-                       @"Boolean|String|Void)" +
+                       @"(Int32|Int16|Int64|Single|Double|Char|Decimal|Byte|Object|Boolean|String|DateTime)" +
                        @"(\W+|\b)", 
-                       new MatchEvaluator (CSharpNameMatch));
+                       new MatchEvaluator (MonoBASIC_NameMatch));
        }       
        
-       static String CSharpNameMatch (Match match) 
+       static String MonoBASIC_NameMatch (Match match) 
        {
                string s = match.Groups [1].Captures [0].Value;
                return s.ToLower ().
-               Replace ("int32", "int").
-               Replace ("uint32", "uint").
+               Replace ("int32", "integer").
                Replace ("int16", "short").
-               Replace ("uint16", "ushort").
                Replace ("int64", "long").
-               Replace ("uint64", "ulong").
-               Replace ("single", "float").
-               Replace ("boolean", "bool")
+               Replace ("datetime", "date")
                + match.Groups [2].Captures [0].Value;
        }
 
         /// <summary>
         ///   Returns the signature of the method
         /// </summary>
-        static public string CSharpSignature (MethodBase mb)
+        static public string MonoBASIC_Signature (MethodBase mb)
         {
                 string sig = "(";
 
@@ -645,7 +740,7 @@ public class TypeManager {
                Type t = LookupType (name);
 
                if (t == null){
-                       Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
+                       Report.Error (518, "The predefined type '" + name + "' is not defined or imported");
                        Environment.Exit (0);
                }
 
@@ -653,8 +748,8 @@ public class TypeManager {
        }
 
        /// <summary>
-       ///   Returns the MethodInfo for a method named `name' defined
-       ///   in type `t' which takes arguments of types `args'
+       ///   Returns the MethodInfo for a method named 'name' defined
+       ///   in type 't' which takes arguments of types 'args'
        /// </summary>
        static MethodInfo GetMethod (Type t, string name, Type [] args)
        {
@@ -664,16 +759,16 @@ public class TypeManager {
                sig.name = name;
                sig.args = args;
                
-               list = FindMembers (t, MemberTypes.Method, instance_and_static | BindingFlags.Public,
+               list = FindMembers (t, MemberTypes.Method, instance_and_static | BindingFlags.Public| BindingFlags.IgnoreCase,
                                    signature_filter, sig);
                if (list.Count == 0) {
-                       Report.Error (-19, "Can not find the core function `" + name + "'");
+                       Report.Error (-19, "Can not find the core function '" + name + "'");
                        return null;
                }
 
                MethodInfo mi = list [0] as MethodInfo;
                if (mi == null) {
-                       Report.Error (-19, "Can not find the core function `" + name + "'");
+                       Report.Error (-19, "Can not find the core function '" + name + "'");
                        return null;
                }
 
@@ -692,16 +787,16 @@ public class TypeManager {
                sig.args = args;
                
                list = FindMembers (t, MemberTypes.Constructor,
-                                   instance_and_static | BindingFlags.Public | BindingFlags.DeclaredOnly,
+                                   instance_and_static | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase,
                                    signature_filter, sig);
                if (list.Count == 0){
-                       Report.Error (-19, "Can not find the core constructor for type `" + t.Name + "'");
+                       Report.Error (-19, "Can not find the core constructor for type '" + t.Name + "'");
                        return null;
                }
 
                ConstructorInfo ci = list [0] as ConstructorInfo;
                if (ci == null){
-                       Report.Error (-19, "Can not find the core constructor for type `" + t.Name + "'");
+                       Report.Error (-19, "Can not find the core constructor for type '" + t.Name + "'");
                        return null;
                }
 
@@ -747,6 +842,7 @@ public class TypeManager {
 
                array_type    = CoreLookupType ("System.Array");
                void_type     = CoreLookupType ("System.Void");
+               date_type         = CoreLookupType ("System.DateTime");
                type_type     = CoreLookupType ("System.Type");
 
                runtime_field_handle_type = CoreLookupType ("System.RuntimeFieldHandle");
@@ -925,6 +1021,10 @@ public class TypeManager {
                void_decimal_ctor_five_args = GetConstructor (
                        decimal_type, dec_arg);
                
+               // DateTime constructor
+               Type [] ticks_arg = { int64_type };
+               void_datetime_ctor_ticks_arg = GetConstructor ( date_type, ticks_arg);
+               
                //
                // Attributes
                //
@@ -934,6 +1034,8 @@ public class TypeManager {
                unverifiable_code_ctor = GetConstructor (
                        unverifiable_code_type, void_arg);
                
+               default_member_ctor = GetConstructor (
+                       default_member_type, string_);
        }
 
        const BindingFlags instance_and_static = BindingFlags.Static | BindingFlags.Instance;
@@ -948,9 +1050,9 @@ public class TypeManager {
                                              MemberFilter filter, object criteria)
        {
                DeclSpace decl = (DeclSpace) builder_to_declspace [t];
-bf |= BindingFlags.IgnoreCase;
+               bf |= BindingFlags.IgnoreCase;
                //
-               // `builder_to_declspace' contains all dynamic types.
+               // 'builder_to_declspace' contains all dynamic types.
                //
                if (decl != null) {
                        MemberList list;
@@ -974,7 +1076,7 @@ bf |= BindingFlags.IgnoreCase;
                //
                if ((bf & instance_and_static) == instance_and_static){
                        MemberInfo [] i_members = t.FindMembers (
-                               mt, bf & ~BindingFlags.Static, filter, criteria);
+                               mt, (bf & ~BindingFlags.Static) | BindingFlags.IgnoreCase, filter, criteria);
 
                        int i_len = i_members.Length;
                        if (i_len == 1){
@@ -988,7 +1090,7 @@ bf |= BindingFlags.IgnoreCase;
                        }
                                
                        MemberInfo [] s_members = t.FindMembers (
-                               mt, bf & ~BindingFlags.Instance, filter, criteria);
+                               mt, (bf & ~BindingFlags.Instance) | BindingFlags.IgnoreCase, filter, criteria);
 
                        int s_len = s_members.Length;
                        if (i_len > 0 || s_len > 0)
@@ -1007,7 +1109,7 @@ bf |= BindingFlags.IgnoreCase;
 
        /// <summary>
        ///   This method is only called from within MemberLookup.  It tries to use the member
-       ///   cache if possible and falls back to the normal FindMembers if not.  The `used_cache'
+       ///   cache if possible and falls back to the normal FindMembers if not.  The 'used_cache'
        ///   flag tells the caller whether we used the cache or not.  If we used the cache, then
        ///   our return value will already contain all inherited members and the caller don't need
        ///   to check base classes and interfaces anymore.
@@ -1027,7 +1129,7 @@ bf |= BindingFlags.IgnoreCase;
                }
 
                //
-               // If this is a dynamic type, it's always in the `builder_to_declspace' hash table
+               // If this is a dynamic type, it's always in the 'builder_to_declspace' hash table
                // and we can ask the DeclSpace for the MemberCache.
                //
                if (t is TypeBuilder) {
@@ -1048,7 +1150,7 @@ bf |= BindingFlags.IgnoreCase;
 
                        MemberList list;
                        Timer.StartTimer (TimerType.FindMembers);
-                       list = decl.FindMembers (mt, bf | BindingFlags.DeclaredOnly,
+                       list = decl.FindMembers (mt, bf | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase,
                                                 FilterWithClosure_delegate, name);
                        Timer.StopTimer (TimerType.FindMembers);
                        used_cache = false;
@@ -1071,7 +1173,8 @@ bf |= BindingFlags.IgnoreCase;
                if (t == object_type || t == string_type || t == int32_type || t == uint32_type ||
                    t == int64_type || t == uint64_type || t == float_type || t == double_type ||
                    t == char_type || t == short_type || t == decimal_type || t == bool_type ||
-                   t == sbyte_type || t == byte_type || t == ushort_type || t == void_type)
+                   t == sbyte_type || t == byte_type || t == ushort_type || t == void_type ||
+                       t == date_type)
                        return true;
                else
                        return false;
@@ -1152,7 +1255,7 @@ bf |= BindingFlags.IgnoreCase;
        }
 
        //
-       // Checks whether `type' is a subclass or nested child of `parent'.
+       // Checks whether 'type' is a subclass or nested child of 'parent'.
        //
        public static bool IsSubclassOrNestedChildOf (Type type, Type parent)
        {
@@ -1168,7 +1271,7 @@ bf |= BindingFlags.IgnoreCase;
        }
 
        //
-       // Checks whether `type' is a nested child of `parent'.
+       // Checks whether 'type' is a nested child of 'parent'.
        //
        public static bool IsNestedChildOf (Type type, Type parent)
        {
@@ -1280,12 +1383,33 @@ bf |= BindingFlags.IgnoreCase;
        {
                if (indexer_arguments.Contains (indexer))
                        return (Type []) indexer_arguments [indexer];
-               else if (indexer is PropertyBuilder)
+               else {
                        // If we're a PropertyBuilder and not in the
-                       // `indexer_arguments' hash, then we're a property and
+                       // 'indexer_arguments' hash, then we're a property and
                        // not an indexer.
-                       return NoTypes;
-               else {
+
+                       MethodInfo mi = indexer.GetSetMethod (true);
+                       if (mi == null) {
+                               mi = indexer.GetGetMethod (true);
+                               if (mi == null)
+                                       return NoTypes;
+                       }
+
+                       ParameterInfo [] pi = mi.GetParameters ();
+                       if (pi == null)
+                               return NoTypes;
+
+                       int c = pi.Length;
+                       Type [] types = new Type [c];
+                       
+                       for (int i = 0; i < c; i++)
+                               types [i] = pi [i].ParameterType;
+
+                       indexer_arguments.Add (indexer, types);
+                       return types;
+               }
+               /*else 
+               {
                        ParameterInfo [] pi = indexer.GetIndexParameters ();
                        // Property, not an indexer.
                        if (pi == null)
@@ -1298,7 +1422,7 @@ bf |= BindingFlags.IgnoreCase;
 
                        indexer_arguments.Add (indexer, types);
                        return types;
-               }
+               }*/
        }
        
        // <remarks>
@@ -1423,7 +1547,7 @@ bf |= BindingFlags.IgnoreCase;
 
                        return (MethodInfo) de.Second;
                } else
-                       return pi.GetSetMethod ();
+                       return pi.GetSetMethod (true);
        }
 
        static public MethodInfo GetPropertySetter (PropertyInfo pi)
@@ -1433,7 +1557,7 @@ bf |= BindingFlags.IgnoreCase;
 
                        return (MethodInfo) de.First;
                } else
-                       return pi.GetGetMethod ();
+                       return pi.GetGetMethod (true);
        }
 
        /// <summary>
@@ -1445,28 +1569,39 @@ bf |= BindingFlags.IgnoreCase;
        ///   This expands in context like: IA; IB : IA; IC : IA, IB; the interface "IC" to
        ///   be IA, IB, IC.
        /// </remarks>
+
        public static Type [] ExpandInterfaces (Type [] base_interfaces)
-       {
-               ArrayList new_ifaces = new ArrayList ();
+       {       
+               ArrayList new_ifaces = new ArrayList();
+               ExpandAllInterfaces (base_interfaces, ref new_ifaces);
+               Type [] ret = new Type [new_ifaces.Count];
+               new_ifaces.CopyTo (ret, 0);
                
-               foreach (Type iface in base_interfaces){
+               return ret;
+       }
+
+       /// <summary>
+       ///   Recursively finds out each base interface in case  
+       ///   of multiple inheritance
+       /// </summary>
+       public static void ExpandAllInterfaces 
+                       (Type [] base_interfaces, ref ArrayList new_ifaces)
+       {
+               foreach (Type iface in base_interfaces) {
                        if (!new_ifaces.Contains (iface))
                                new_ifaces.Add (iface);
                        
                        Type [] implementing = TypeManager.GetInterfaces (iface);
-                       
-                       foreach (Type imp in implementing){
-                               if (!new_ifaces.Contains (imp))
-                                       new_ifaces.Add (imp);
-                       }
+                       //
+                       // Incase any base interface is present call this function again
+                       //
+                       if (implementing.Length != 0)
+                               ExpandAllInterfaces (implementing, ref new_ifaces);
                }
-               Type [] ret = new Type [new_ifaces.Count];
-               new_ifaces.CopyTo (ret, 0);
-               return ret;
        }
                
        /// <summary>
-       ///   This function returns the interfaces in the type `t'.  Works with
+       ///   This function returns the interfaces in the type 't'.  Works with
        ///   both types and TypeBuilders.
        /// </summary>
        public static Type [] GetInterfaces (Type t)
@@ -1516,7 +1651,7 @@ bf |= BindingFlags.IgnoreCase;
                //
                // FIXME OPTIMIZATION:
                // as soon as we hit a non-TypeBuiler in the interface
-               // chain, we could return, as the `Type.GetInterfaces'
+               // chain, we could return, as the 'Type.GetInterfaces'
                // will return all the interfaces implement by the type
                // or its parents.
                //
@@ -1548,7 +1683,7 @@ bf |= BindingFlags.IgnoreCase;
                NumberFormatInfo provider = ci.NumberFormat;
 
                //
-               // We must use Type.Equals() here since `conversionType' is
+               // We must use Type.Equals() here since 'conversionType' is
                // the TypeBuilder created version of a system type and not
                // the system type itself.  You cannot use Type.GetTypeCode()
                // on such a type - it'd always return TypeCode.Object.
@@ -1679,6 +1814,8 @@ bf |= BindingFlags.IgnoreCase;
                        return TypeManager.uint64_type;
                case TypeCode.String:
                        return TypeManager.string_type;
+               case TypeCode.DateTime:
+                       return TypeManager.date_type;
                default:
                        if (t == typeof (void))
                                return TypeManager.void_type;
@@ -1713,7 +1850,7 @@ bf |= BindingFlags.IgnoreCase;
                Report.Error (
                        208, loc,
                        "Cannot take the address or size of a variable of a managed type ('" +
-                       CSharpName (t) + "')");
+                       MonoBASIC_Name (t) + "')");
                return false;   
        }
        
@@ -1721,10 +1858,10 @@ bf |= BindingFlags.IgnoreCase;
        ///   Returns the name of the indexer in a given type.
        /// </summary>
        /// <remarks>
-       ///   The default is not always `Item'.  The user can change this behaviour by
+       ///   The default is not always 'Item'.  The user can change this behaviour by
        ///   using the DefaultMemberAttribute in the class.
        ///
-       ///   For example, the String class indexer is named `Chars' not `Item' 
+       ///   For example, the String class indexer is named 'Chars' not 'Item' 
        /// </remarks>
        public static string IndexerPropertyName (Type t)
        {
@@ -1732,17 +1869,17 @@ bf |= BindingFlags.IgnoreCase;
                        if (t.IsInterface) {
                                Interface i = LookupInterface (t);
 
-                               if ((i == null) || (i.IndexerName == null))
+                               if ((i == null) || (i.DefaultPropName == null))
                                        return "Item";
 
-                               return i.IndexerName;
+                               return i.DefaultPropName;
                        } else {
                                TypeContainer tc = LookupTypeContainer (t);
 
-                               if ((tc == null) || (tc.IndexerName == null))
+                               if ((tc == null) || (tc.DefaultPropName == null))
                                        return "Item";
 
-                               return tc.IndexerName;
+                               return tc.DefaultPropName;
                        }
                }
                
@@ -1796,7 +1933,7 @@ bf |= BindingFlags.IgnoreCase;
        }
        
        //
-       // We copy methods from `new_members' into `target_list' if the signature
+       // We copy methods from 'new_members' into 'target_list' if the signature
        // for the method from in the new list does not exist in the target_list
        //
        // The name is assumed to be the same.
@@ -1862,15 +1999,15 @@ bf |= BindingFlags.IgnoreCase;
                        if (a.TypeId == TypeManager.obsolete_attribute_type){
                                ObsoleteAttribute oa = (ObsoleteAttribute) a;
 
-                               string method_desc = TypeManager.CSharpSignature (mb);
+                               string method_desc = TypeManager.MonoBASIC_Signature (mb);
 
                                if (oa.IsError) {
-                                       Report.Error (619, loc, "Method `" + method_desc +
-                                                     "' is obsolete: `" + oa.Message + "'");
+                                       Report.Error (619, loc, "Method '" + method_desc +
+                                                     "' is obsolete: '" + oa.Message + "'");
                                        return MethodFlags.IsObsoleteError;
                                } else
-                                       Report.Warning (618, loc, "Method `" + method_desc +
-                                                       "' is obsolete: `" + oa.Message + "'");
+                                       Report.Warning (618, loc, "Method '" + method_desc +
+                                                       "' is obsolete: '" + oa.Message + "'");
 
                                flags |= MethodFlags.IsObsolete;
 
@@ -1923,7 +2060,7 @@ bf |= BindingFlags.IgnoreCase;
        static internal bool FilterWithClosure (MemberInfo m, object filter_criteria)
        {
                //
-               // Hack: we know that the filter criteria will always be in the `closure'
+               // Hack: we know that the filter criteria will always be in the 'closure'
                // fields. 
                //
 
@@ -1935,7 +2072,7 @@ bf |= BindingFlags.IgnoreCase;
                        return true;
 
                //
-               // Ugly: we need to find out the type of `m', and depending
+               // Ugly: we need to find out the type of 'm', and depending
                // on this, tell whether we accept or not
                //
                if (m is MethodBase){
@@ -2035,10 +2172,10 @@ bf |= BindingFlags.IgnoreCase;
        static MemberFilter FilterWithClosure_delegate = new MemberFilter (FilterWithClosure);
 
        //
-       // Looks up a member called `name' in the `queried_type'.  This lookup
-       // is done by code that is contained in the definition for `invocation_type'.
+       // Looks up a member called 'name' in the 'queried_type'.  This lookup
+       // is done by code that is contained in the definition for 'invocation_type'.
        //
-       // The binding flags are `bf' and the kind of members being looked up are `mt'
+       // The binding flags are 'bf' and the kind of members being looked up are 'mt'
        //
        // Returns an array of a single element for everything but Methods/Constructors
        // that might return multiple matches.
@@ -2063,6 +2200,8 @@ bf |= BindingFlags.IgnoreCase;
                
                ArrayList method_list = null;
                Type current_type = queried_type;
+               if (queried_type == null)
+                       throw new ArgumentNullException("queried_type");
                bool searching = (original_bf & BindingFlags.DeclaredOnly) == 0;
                bool private_ok;
                bool always_ok_flag = false;
@@ -2096,7 +2235,7 @@ bf |= BindingFlags.IgnoreCase;
                        MemberList list;
 
                        //
-                       // `NonPublic' is lame, because it includes both protected and
+                       // 'NonPublic' is lame, because it includes both protected and
                        // private methods, so we need to control this behavior by
                        // explicitly tracking if a private method is ok or not.
                        //
@@ -2124,7 +2263,7 @@ bf |= BindingFlags.IgnoreCase;
                        closure_queried_type = current_type;
 
                        Timer.StopTimer (TimerType.MemberLookup);
-
+                       bf |= BindingFlags.IgnoreCase;
                        list = MemberLookup_FindMembers (current_type, mt, bf, name, out used_cache);
 
                        Timer.StartTimer (TimerType.MemberLookup);
@@ -2160,7 +2299,7 @@ bf |= BindingFlags.IgnoreCase;
                                continue;
                                
                        //
-                       // Events and types are returned by both `static' and `instance'
+                       // Events and types are returned by both 'static' and 'instance'
                        // searches, which means that our above FindMembers will
                        // return two copies of the same.
                        //
@@ -2325,7 +2464,7 @@ public sealed class TypeHandle : IMemberContainer {
                if (mt == MemberTypes.Event)
                        return new MemberList (type.GetEvents (bf | BindingFlags.DeclaredOnly));
                else
-                       return new MemberList (type.FindMembers (mt, bf | BindingFlags.DeclaredOnly,
+                       return new MemberList (type.FindMembers (mt, bf | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase,
                                                                 null, null));
        }