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
// 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
// <remarks>
static Hashtable method_internal_params;
- // <remarks>
- // Keeps track of attribute types
- // </remarks>
-
- static Hashtable builder_to_attr;
-
// <remarks>
// Keeps track of methods
// </remarks>
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 ();
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)
{
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>
/// <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);
modules = n;
}
-
private class StandardModule {
public readonly string Namespace;
public readonly string Name;
- public StandardModule(string _namespace, string name) { Namespace = _namespace; Name = name; }
- public override string ToString() { return ((Namespace != null && Namespace.Length > 0)?(Namespace + "."):"") + 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;
return t;
}
- foreach (ModuleBuilder mb in modules) {
+ foreach (System.Reflection.Module mb in modules) {
t = mb.GetType (name, false, true);
if (t != null){
return t;
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.
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;
}
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.
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){
}
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;
}
}
}
- foreach (ModuleBuilder mb in modules) {
+ foreach (System.Reflection.Module mb in modules) {
foreach (Type t in mb.GetTypes ()) {
string ns = t.Namespace;
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;
{
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
// 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)
indexer_arguments.Add (indexer, types);
return types;
- }
+ }*/
}
// <remarks>
/// 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>
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;
}
}