// Ravi Pratap (ravi@ximian.com)
// Marek Safar (marek.safar@seznam.cz)
//
-// Licensed under the terms of the GNU GPL
-//
-// (C) 2001 Ximian, Inc (http://www.ximian.com)
+// Dual licensed under the terms of the MIT X11 or GNU GPL
//
+// Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
+// Copyright 2003-2008 Novell, Inc.
//
//
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
-using System.Text.RegularExpressions;
using System.Runtime.CompilerServices;
using System.Diagnostics;
static internal Type fixed_buffer_attr_type;
static internal Type default_charset_type;
static internal Type type_forwarder_attr_type;
+ static internal Type isvolatile_type;
static public Type activator_type;
static public Type generic_ilist_type;
static public Type generic_icollection_type;
static public MethodInfo int_interlocked_compare_exchange;
static public PropertyInfo ienumerator_getcurrent;
public static MethodInfo methodbase_get_type_from_handle;
+ public static MethodInfo methodbase_get_type_from_handle_generic;
+ public static MethodInfo fieldinfo_get_field_from_handle;
static public MethodInfo activator_create_instance;
//
int_get_offset_to_string_data =
int_interlocked_compare_exchange =
methodbase_get_type_from_handle =
+ methodbase_get_type_from_handle_generic =
+ fieldinfo_get_field_from_handle =
activator_create_instance = null;
ienumerator_getcurrent = null;
param_array_attr =
compiler_generated_attr =
extension_attribute_attr = null;
+
+ isvolatile_type = null;
// to uncover regressions
AllClsTopLevelTypes = null;
return CSharpName (GetFullName (t));
}
+ static readonly char [] elements = new char [] { '*', '[' };
+
public static string CSharpName (string name)
{
- if (name.StartsWith (AnonymousTypeClass.ClassNamePrefix))
- return AnonymousTypeClass.SignatureForError;
-
- return Regex.Replace (name,
- @"^System\." +
- @"(Int32|UInt32|Int16|UInt16|Int64|UInt64|" +
- @"Single|Double|Char|Decimal|Byte|SByte|Object|" +
- @"Boolean|String|Void|Null)" +
- @"(\W+|\b)",
- new MatchEvaluator (CSharpNameMatch)).Replace ('+', '.');
+ if (name.Length > 10) {
+ switch (name) {
+ case "System.Int32": return "int";
+ case "System.Int64": return "long";
+ case "System.String": return "string";
+ case "System.Boolean": return "bool";
+ case "System.Void": return "void";
+ case "System.Object": return "object";
+ case "System.UInt32": return "uint";
+ case "System.Int16": return "short";
+ case "System.UInt16": return "ushort";
+ case "System.UInt64": return "ulong";
+ case "System.Single": return "float";
+ case "System.Double": return "double";
+ case "System.Decimal": return "decimal";
+ case "System.Char": return "char";
+ case "System.Byte": return "byte";
+ case "System.SByte": return "sbyte";
+ }
+
+ int idx = name.IndexOfAny (elements, 10);
+ if (idx > 0)
+ return CSharpName (name.Substring (0, idx)) + name.Substring (idx);
+ }
+
+ if (name [0] == AnonymousTypeClass.ClassNamePrefix [0] && name.StartsWith (AnonymousTypeClass.ClassNamePrefix))
+ return AnonymousTypeClass.SignatureForError;
+
+ return name.Replace ('+', '.');
}
static public string CSharpName (Type[] types)
return sb.ToString ();
}
- static String CSharpNameMatch (Match match)
- {
- string s = match.Groups [1].Captures [0].Value;
- return s.ToLower ().
- Replace ("int32", "int").
- Replace ("uint32", "uint").
- Replace ("int16", "short").
- Replace ("uint16", "ushort").
- Replace ("int64", "long").
- Replace ("uint64", "ulong").
- Replace ("single", "float").
- Replace ("boolean", "bool")
- + match.Groups [2].Captures [0].Value;
- }
-
// Used for error reporting to show symbolic name instead of underlying value
public static string CSharpEnumValue (Type t, object value)
{
void_ptr_type = GetPointerType (void_type);
char_ptr_type = GetPointerType (char_type);
+ //
+ // Initialize InternalsVisibleTo as the very first optional type. Otherwise we would populate
+ // types cache with incorrect accessiblity when any of optional types is internal.
+ //
+ internals_visible_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "InternalsVisibleToAttribute", Kind.Class, false);
+
runtime_argument_handle_type = CoreLookupType ("System", "RuntimeArgumentHandle", Kind.Struct, false);
asynccallback_type = CoreLookupType ("System", "AsyncCallback", Kind.Delegate, false);
iasyncresult_type = CoreLookupType ("System", "IAsyncResult", Kind.Interface, false);
comimport_attr_type = CoreLookupType ("System.Runtime.InteropServices", "ComImportAttribute", Kind.Class, false);
coclass_attr_type = CoreLookupType ("System.Runtime.InteropServices", "CoClassAttribute", Kind.Class, false);
attribute_usage_type = CoreLookupType ("System", "AttributeUsageAttribute", Kind.Class, false);
- internals_visible_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "InternalsVisibleToAttribute", Kind.Class, false);
default_parameter_value_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "DefaultParameterValueAttribute", Kind.Class, false);
// New in .NET 2.0
return is_friend;
}
+#if GMCS_SOURCE
static bool CompareKeyTokens (byte [] token1, byte [] token2)
{
for (int i = 0; i < token1.Length; i++)
return true;
}
-#if GMCS_SOURCE
static void Error_FriendAccessNameNotMatching (string other_name)
{
Report.Error (281, "Friend access was granted to `" + other_name +