static public Type intptr_type;
static public Type monitor_type;
static public Type runtime_field_handle_type;
+ static public Type runtime_argument_handle_type;
static public Type attribute_type;
static public Type attribute_usage_type;
static public Type dllimport_type;
static public Type struct_layout_attribute_type;
static public Type field_offset_attribute_type;
+ static public Type generic_ienumerator_type;
+ static public Type generic_ienumerable_type;
+
//
// An empty array of types
//
assemblies = n;
}
+ public static Assembly [] GetAssemblies ()
+ {
+ return assemblies;
+ }
+
/// <summary>
/// Registers a module builder to lookup types from
/// </summary>
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");
struct_layout_attribute_type = CoreLookupType ("System.Runtime.InteropServices.StructLayoutAttribute");
field_offset_attribute_type = CoreLookupType ("System.Runtime.InteropServices.FieldOffsetAttribute");
+ //
+ // Generic types
+ //
+ generic_ienumerator_type = CoreLookupType ("System.Collections.Generic.IEnumerator`1");
+ generic_ienumerable_type = CoreLookupType ("System.Collections.Generic.IEnumerable`1");
+
+
//
// When compiling corlib, store the "real" types here.
//
/// </summary>
static public Type [] GetArgumentTypes (MethodBase mb)
{
- if (method_arguments.Contains (mb))
- return (Type []) method_arguments [mb];
- else {
+ object t = method_arguments [mb];
+ if (t != null)
+ return (Type []) t;
+
ParameterInfo [] pi = mb.GetParameters ();
int c = pi.Length;
- Type [] types = new Type [c];
+ Type [] types;
+ if (c == 0) {
+ types = NoTypes;
+ } else {
+ types = new Type [c];
for (int i = 0; i < c; i++)
types [i] = pi [i].ParameterType;
-
+ }
method_arguments.Add (mb, types);
return types;
}
- }
/// <summary>
/// Returns the argument types for an indexer based on its PropertyInfo
return "Item";
}
- static MethodInfo pinned_method = null;
- public static void MakePinned (LocalBuilder builder)
- {
- if (pinned_method == null) {
- pinned_method = typeof (LocalBuilder).GetMethod ("MakePinned", BindingFlags.Instance | BindingFlags.NonPublic);
- if (pinned_method == null) {
- Report.Warning (-24, new Location (-1), "Microsoft.NET does not support making pinned variables." +
+ static MethodInfo declare_local_method = null;
+
+ public static LocalBuilder DeclareLocalPinned (ILGenerator ig, Type t)
+ {
+ if (declare_local_method == null){
+ declare_local_method = typeof (ILGenerator).GetMethod (
+ "DeclareLocal",
+ BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
+ null,
+ new Type [] { typeof (Type), typeof (bool)},
+ null);
+ if (declare_local_method == null){
+ Report.Warning (-24, new Location (-1),
+ "This version of the runtime does not support making pinned local variables. " +
"This code may cause errors on a runtime with a moving GC");
-
- return;
+ return ig.DeclareLocal (t);
}
}
-
- pinned_method.Invoke (builder, null);
+ return (LocalBuilder) declare_local_method.Invoke (ig, new object [] { t, true });
}
-
//
// Returns whether the array of memberinfos contains the given method
//