X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Ftypemanager.cs;h=b53915f6eb1c030c749d98c239553e8a7c46c76d;hb=08a728d237965feb2bbd485f909998b17c0bbb11;hp=6eb7648ce537b162b61e8a9727d995a32d49d8d7;hpb=9cc8fdfc5b5f1ba7bc73722281cb72edf3e086b1;p=mono.git diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs index 6eb7648ce53..b53915f6eb1 100644 --- a/mcs/mcs/typemanager.cs +++ b/mcs/mcs/typemanager.cs @@ -73,7 +73,6 @@ namespace Mono.CSharp public readonly TypeSpec[] OperatorsUnaryMutator; public readonly TypeSpec[] BinaryPromotionsTypes; - public readonly TypeSpec[] SwitchUserTypes; readonly BuiltinTypeSpec[] types; @@ -125,7 +124,6 @@ namespace Mono.CSharp OperatorsUnaryMutator = UnaryMutator.CreatePredefinedOperatorsTable (this); BinaryPromotionsTypes = ConstantFold.CreateBinaryPromotionsTypes (this); - SwitchUserTypes = Switch.CreateSwitchUserTypes (this); types = new BuiltinTypeSpec[] { Object, ValueType, Attribute, @@ -186,7 +184,9 @@ namespace Mono.CSharp public readonly PredefinedType IsVolatile; public readonly PredefinedType IEnumeratorGeneric; public readonly PredefinedType IListGeneric; + public readonly PredefinedType IReadOnlyListGeneric; public readonly PredefinedType ICollectionGeneric; + public readonly PredefinedType IReadOnlyCollectionGeneric; public readonly PredefinedType IEnumerableGeneric; public readonly PredefinedType Nullable; public readonly PredefinedType Activator; @@ -198,6 +198,9 @@ namespace Mono.CSharp public readonly PredefinedType SecurityAction; public readonly PredefinedType Dictionary; public readonly PredefinedType Hashtable; + public readonly PredefinedType Array; + + public readonly TypeSpec[] SwitchUserTypes; // // C# 3.0 @@ -232,6 +235,11 @@ namespace Mono.CSharp public readonly PredefinedType INotifyCompletion; public readonly PredefinedType ICriticalNotifyCompletion; + // C# 6.0 + public readonly PredefinedType IFormattable; + public readonly PredefinedType FormattableString; + public readonly PredefinedType FormattableStringFactory; + public PredefinedTypes (ModuleContainer module) { TypedReference = new PredefinedType (module, MemberKind.Struct, "System", "TypedReference"); @@ -246,7 +254,9 @@ namespace Mono.CSharp IsVolatile = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "IsVolatile"); IEnumeratorGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IEnumerator", 1); IListGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IList", 1); + IReadOnlyListGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IReadOnlyList", 1); ICollectionGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "ICollection", 1); + IReadOnlyCollectionGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IReadOnlyCollection", 1); IEnumerableGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IEnumerable", 1); Nullable = new PredefinedType (module, MemberKind.Struct, "System", "Nullable", 1); Activator = new PredefinedType (module, MemberKind.Class, "System", "Activator"); @@ -258,6 +268,7 @@ namespace Mono.CSharp SecurityAction = new PredefinedType (module, MemberKind.Enum, "System.Security.Permissions", "SecurityAction"); Dictionary = new PredefinedType (module, MemberKind.Class, "System.Collections.Generic", "Dictionary", 2); Hashtable = new PredefinedType (module, MemberKind.Class, "System.Collections", "Hashtable"); + Array = new PredefinedType (module, MemberKind.Class, "System", "Array"); Expression = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression"); ExpressionGeneric = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression", 1); @@ -283,6 +294,10 @@ namespace Mono.CSharp INotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "INotifyCompletion"); ICriticalNotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "ICriticalNotifyCompletion"); + IFormattable = new PredefinedType (module, MemberKind.Interface, "System", "IFormattable"); + FormattableString = new PredefinedType (module, MemberKind.Class, "System", "FormattableString"); + FormattableStringFactory = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "FormattableStringFactory"); + // // Define types which are used for comparison. It does not matter // if they don't exist as no error report is needed @@ -294,13 +309,19 @@ namespace Mono.CSharp ArgIterator.TypeSpec.IsSpecialRuntimeType = true; if (IEnumerableGeneric.Define ()) - IEnumerableGeneric.TypeSpec.IsGenericIterateInterface = true; + IEnumerableGeneric.TypeSpec.IsArrayGenericInterface = true; if (IListGeneric.Define ()) - IListGeneric.TypeSpec.IsGenericIterateInterface = true; + IListGeneric.TypeSpec.IsArrayGenericInterface = true; + + if (IReadOnlyListGeneric.Define ()) + IReadOnlyListGeneric.TypeSpec.IsArrayGenericInterface = true; if (ICollectionGeneric.Define ()) - ICollectionGeneric.TypeSpec.IsGenericIterateInterface = true; + ICollectionGeneric.TypeSpec.IsArrayGenericInterface = true; + + if (IReadOnlyCollectionGeneric.Define ()) + IReadOnlyCollectionGeneric.TypeSpec.IsArrayGenericInterface = true; if (Nullable.Define ()) Nullable.TypeSpec.IsNullableType = true; @@ -311,12 +332,18 @@ namespace Mono.CSharp Task.Define (); if (TaskGeneric.Define ()) TaskGeneric.TypeSpec.IsGenericTask = true; + + SwitchUserTypes = Switch.CreateSwitchUserTypes (module, Nullable.TypeSpec); + + IFormattable.Define (); + FormattableString.Define (); } } class PredefinedMembers { public readonly PredefinedMember ActivatorCreateInstance; + public readonly PredefinedMember ArrayEmpty; public readonly PredefinedMember AsyncTaskMethodBuilderCreate; public readonly PredefinedMember AsyncTaskMethodBuilderStart; public readonly PredefinedMember AsyncTaskMethodBuilderSetResult; @@ -361,6 +388,7 @@ namespace Mono.CSharp public readonly PredefinedMember FixedBufferAttributeCtor; public readonly PredefinedMember MethodInfoGetMethodFromHandle; public readonly PredefinedMember MethodInfoGetMethodFromHandle2; + public readonly PredefinedMember MethodInfoCreateDelegate; public readonly PredefinedMember MonitorEnter; public readonly PredefinedMember MonitorEnter_v4; public readonly PredefinedMember MonitorExit; @@ -387,6 +415,9 @@ namespace Mono.CSharp ActivatorCreateInstance = new PredefinedMember (module, types.Activator, MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); + ArrayEmpty = new PredefinedMember (module, types.Array, + MemberFilter.Method ("Empty", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); + AsyncTaskMethodBuilderCreate = new PredefinedMember (module, types.AsyncTaskMethodBuilder, MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncTaskMethodBuilder.TypeSpec)); @@ -636,6 +667,10 @@ namespace Mono.CSharp MethodInfoGetMethodFromHandle2 = new PredefinedMember (module, types.MethodBase, "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType (btypes.RuntimeTypeHandle)); + MethodInfoCreateDelegate = new PredefinedMember (module, types.MethodInfo, + "CreateDelegate", MemberKind.Method, + new PredefinedType (btypes.Type), new PredefinedType (btypes.Object)); + MonitorEnter = new PredefinedMember (module, types.Monitor, "Enter", btypes.Object); MonitorEnter_v4 = new PredefinedMember (module, types.Monitor, @@ -835,15 +870,22 @@ namespace Mono.CSharp } if (best_match == null && reportErrors) { - Location loc; - if (found[0].MemberDefinition is MemberCore) { - loc = ((MemberCore) found[0].MemberDefinition).Location; + var found_member = found[0]; + + if (found_member.Kind == MemberKind.MissingType) { + // CSC: should be different error number + module.Compiler.Report.Error (518, "The predefined type `{0}.{1}' is defined in an assembly that is not referenced.", ns, name); } else { - loc = Location.Null; - module.Compiler.Report.SymbolRelatedToPreviousError (found[0]); - } + Location loc; + if (found_member.MemberDefinition is MemberCore) { + loc = ((MemberCore) found_member.MemberDefinition).Location; + } else { + loc = Location.Null; + module.Compiler.Report.SymbolRelatedToPreviousError (found_member); + } - module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name); + module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name); + } } return best_match;