static public Type conditional_attribute_type;
static public Type in_attribute_type;
static public Type out_attribute_type;
+ static public Type default_parameter_value_attribute_type;
+
static public Type anonymous_method_type;
static public Type cls_compliant_attribute_type;
static public Type typed_reference_type;
static internal Type default_charset_type;
#endif
- //
- // An empty array of types
- //
- static public Type [] NoTypes;
- static public TypeExpr [] NoTypeExprs;
-
-
//
// Expressions representing the internal types. Used during declaration
// definition.
// The attribute constructors.
//
static public ConstructorInfo object_ctor;
- static public ConstructorInfo cons_param_array_attribute;
+ static private ConstructorInfo cons_param_array_attribute;
static public ConstructorInfo void_decimal_ctor_five_args;
static public ConstructorInfo void_decimal_ctor_int_arg;
static public ConstructorInfo unverifiable_code_ctor;
public static Hashtable AllClsTopLevelTypes;
static Hashtable fieldbuilders_to_fields;
+ static Hashtable propertybuilder_to_property;
static Hashtable fields;
+ static Hashtable events;
struct Signature {
public string name;
events = null;
priv_fields_events = null;
type_hash = null;
+ propertybuilder_to_property = null;
TypeHandle.CleanUp ();
}
indexer_arguments = new PtrHashtable ();
builder_to_ifaces = new PtrHashtable ();
- NoTypes = new Type [0];
- NoTypeExprs = new TypeExpr [0];
-
fieldbuilders_to_fields = new Hashtable ();
+ propertybuilder_to_property = new Hashtable ();
fields = new Hashtable ();
type_hash = new DoubleHash ();
+
+ // to uncover regressions
+ cons_param_array_attribute = null;
}
public static void AddUserType (DeclSpace ds)
{
PropertyInfo pi = mi as PropertyInfo;
if (pi != null) {
- MethodBase pmi = pi.GetGetMethod ();
+ MethodBase pmi = pi.GetGetMethod (true);
if (pmi == null)
- pmi = pi.GetSetMethod ();
+ pmi = pi.GetSetMethod (true);
if (GetParameterData (pmi).Count > 0)
mi = pmi;
}
/// <summary>
/// Returns the ConstructorInfo for "args"
/// </summary>
- public static ConstructorInfo GetConstructor (Type t, Type [] args)
+ private static ConstructorInfo GetConstructor (Type t, Type [] args)
{
MemberList list;
Signature sig;
sig.name = ".ctor";
sig.args = args;
+
+ if (t == null)
+ throw new InternalErrorException ("Core types haven't been initialized yet?");
list = FindMembers (t, MemberTypes.Constructor,
instance_and_static | BindingFlags.Public | BindingFlags.DeclaredOnly,
param_array_type = CoreLookupType ("System", "ParamArrayAttribute");
in_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "InAttribute");
out_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "OutAttribute");
+#if NET_2_0
+ default_parameter_value_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "DefaultParameterValueAttribute");
+#endif
typed_reference_type = CoreLookupType ("System", "TypedReference");
arg_iterator_type = CoreLookupType ("System", "ArgIterator");
mbr_type = CoreLookupType ("System", "MarshalByRefObject");
system_type_type = typeof (System.Type);
system_assemblybuilder_type = typeof (System.Reflection.Emit.AssemblyBuilder);
- Type [] void_arg = { };
system_int_array_get_length = GetMethod (
- system_array_type, "get_Length", void_arg);
+ system_array_type, "get_Length", Type.EmptyTypes);
system_int_array_get_rank = GetMethod (
- system_array_type, "get_Rank", void_arg);
+ system_array_type, "get_Rank", Type.EmptyTypes);
system_object_array_clone = GetMethod (
- system_array_type, "Clone", void_arg);
+ system_array_type, "Clone", Type.EmptyTypes);
Type [] system_int_arg = { system_int32_type };
system_int_array_get_length_int = GetMethod (
//
// Void arguments
//
- Type [] void_arg = { };
ienumerator_getcurrent = GetProperty (
ienumerator_type, "Current");
bool_movenext_void = GetMethod (
- ienumerator_type, "MoveNext", void_arg);
+ ienumerator_type, "MoveNext", Type.EmptyTypes);
void_reset_void = GetMethod (
- ienumerator_type, "Reset", void_arg);
+ ienumerator_type, "Reset", Type.EmptyTypes);
void_dispose_void = GetMethod (
- idisposable_type, "Dispose", void_arg);
+ idisposable_type, "Dispose", Type.EmptyTypes);
int_get_offset_to_string_data = GetMethod (
- runtime_helpers_type, "get_OffsetToStringData", void_arg);
+ runtime_helpers_type, "get_OffsetToStringData", Type.EmptyTypes);
int_array_get_length = GetMethod (
- array_type, "get_Length", void_arg);
+ array_type, "get_Length", Type.EmptyTypes);
int_array_get_rank = GetMethod (
- array_type, "get_Rank", void_arg);
+ array_type, "get_Rank", Type.EmptyTypes);
ienumerable_getenumerator_void = GetMethod (
- ienumerable_type, "GetEnumerator", void_arg);
+ ienumerable_type, "GetEnumerator", Type.EmptyTypes);
//
// Int32 arguments
// System.Array methods
//
object_array_clone = GetMethod (
- array_type, "Clone", void_arg);
+ array_type, "Clone", Type.EmptyTypes);
Type [] array_int_arg = { array_type, int32_type };
void_array_copyto_array_int = GetMethod (
array_type, "CopyTo", array_int_arg);
//
// Attributes
//
- cons_param_array_attribute = GetConstructor (param_array_type, void_arg);
- unverifiable_code_ctor = GetConstructor (unverifiable_code_type, void_arg);
+ unverifiable_code_ctor = GetConstructor (unverifiable_code_type, Type.EmptyTypes);
default_member_ctor = GetConstructor (default_member_type, string_);
Type[] short_arg = { short_type };
//
#if NET_2_0
compiler_generated_attr = new CustomAttributeBuilder (
- GetConstructor (compiler_generated_attr_type, void_arg), new object[0]);
+ GetConstructor (compiler_generated_attr_type, Type.EmptyTypes), new object[0]);
Type[] type_int_arg = { type_type, int32_type };
fixed_buffer_attr_ctor = GetConstructor (fixed_buffer_attr_type, type_int_arg);
#endif
// Object
- object_ctor = GetConstructor (object_type, void_arg);
+ object_ctor = GetConstructor (object_type, Type.EmptyTypes);
+
+ }
+ static public ConstructorInfo ConsParamArrayAttribute {
+ get {
+ if (cons_param_array_attribute == null)
+ cons_param_array_attribute = GetConstructor (param_array_type, Type.EmptyTypes);
+ return cons_param_array_attribute;
+ }
}
const BindingFlags instance_and_static = BindingFlags.Static | BindingFlags.Instance;
static public void RegisterOverride (MethodBase override_method, MethodBase base_method)
{
- if (method_overrides.Contains (override_method)) {
- if (method_overrides [override_method] != base_method)
- throw new InternalErrorException ("Override mismatch: " + override_method);
- return;
- }
- method_overrides [override_method] = base_method;
+ if (!method_overrides.Contains (override_method))
+ method_overrides [override_method] = base_method;
+ if (method_overrides [override_method] != base_method)
+ throw new InternalErrorException ("Override mismatch: " + override_method);
}
static public bool IsOverride (MethodBase m)
(m is MethodBuilder || method_overrides.Contains (m));
}
+ static public MethodBase TryGetBaseDefinition (MethodBase m)
+ {
+ return (MethodBase) method_overrides [m];
+ }
+
/// <summary>
/// Returns the argument types for an indexer based on its PropertyInfo
///
// If we're a PropertyBuilder and not in the
// `indexer_arguments' hash, then we're a property and
// not an indexer.
- return NoTypes;
+ return Type.EmptyTypes;
else {
ParameterInfo [] pi = indexer.GetIndexParameters ();
// Property, not an indexer.
if (pi == null)
- return NoTypes;
+ return Type.EmptyTypes;
int c = pi.Length;
Type [] types = new Type [c];
return (IConstant)fields [fb];
}
+ public static void RegisterProperty (PropertyInfo pi, PropertyBase pb)
+ {
+ propertybuilder_to_property.Add (pi, pb);
+ }
+
+ public static PropertyBase GetProperty (PropertyInfo pi)
+ {
+ return (PropertyBase)propertybuilder_to_property [pi];
+ }
+
static public bool RegisterFieldBase (FieldBuilder fb, FieldBase f)
{
if (fieldbuilders_to_fields.Contains (fb))
return (FieldBase) fieldbuilders_to_fields [fb];
}
- static Hashtable events;
-
static public void RegisterEvent (MyEventBuilder eb, MethodBase add, MethodBase remove)
{
if (events == null)
/// This expands in context like: IA; IB : IA; IC : IA, IB; the interface "IC" to
/// be IA, IB, IC.
/// </remarks>
- public static Type[] ExpandInterfaces (EmitContext ec, TypeExpr [] base_interfaces)
+ public static Type[] ExpandInterfaces (TypeExpr [] base_interfaces)
{
ArrayList new_ifaces = new ArrayList ();
foreach (TypeExpr iface in base_interfaces){
- Type itype = iface.ResolveType (ec);
- if (itype == null)
- return null;
+ Type itype = iface.Type;
if (!new_ifaces.Contains (itype))
new_ifaces.Add (itype);
/// </summary>
public static Type [] GetInterfaces (Type t)
{
-
Type [] cached = iface_cache [t] as Type [];
if (cached != null)
return cached;
Type [] base_ifaces;
if (t.BaseType == null)
- base_ifaces = NoTypes;
+ base_ifaces = Type.EmptyTypes;
else
base_ifaces = GetInterfaces (t.BaseType);
Type [] type_ifaces = (Type []) builder_to_ifaces [t];
- if (type_ifaces == null)
- type_ifaces = NoTypes;
-
+ if (type_ifaces == null || type_ifaces.Length == 0)
+ type_ifaces = Type.EmptyTypes;
+
int base_count = base_ifaces.Length;
Type [] result = new Type [base_count + type_ifaces.Length];
base_ifaces.CopyTo (result, 0);
}
+ // This method always return false for non-generic compiler,
+ // while Type.IsGenericParameter is returned if it is supported.
+ public static bool IsGenericParameter (Type type)
+ {
+ return false;
+ }
+
+ public static int GenericParameterPosition (Type type)
+ {
+ throw new InternalErrorException ("should not be called");
+ }
+
#region MemberLookup implementation
//
// uses NonPublic for both protected and private), we need to distinguish.
//
- static internal bool FilterNone (MemberInfo m, object filter_criteria)
- {
- return true;
- }
-
internal class Closure {
internal bool private_ok;
return (MemberInfo []) first_members_list;
}
- if (method_list != null && method_list.Count > 0)
+ if (method_list != null && method_list.Count > 0) {
return (MemberInfo []) method_list.ToArray (typeof (MemberInfo));
-
+ }
//
// This happens if we already used the cache in the first iteration, in this case
// the cache already looked in all interfaces.