X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fmodule.cs;h=e7e02a0bf14d7f0a1fe29840919fcb06dac0f745;hb=f37e86ff58d7b5a47484e60aded45bf8b98ae918;hp=6fabc733356421f5338d9856b1a9db4a167844ef;hpb=d0baa99bcb8ef12231e24432d0b5710b3a0a4380;p=mono.git diff --git a/mcs/mcs/module.cs b/mcs/mcs/module.cs index 6fabc733356..e7e02a0bf14 100644 --- a/mcs/mcs/module.cs +++ b/mcs/mcs/module.cs @@ -113,6 +113,7 @@ namespace Mono.CSharp readonly Dictionary pointer_types; readonly Dictionary reference_types; readonly Dictionary attrs_cache; + readonly Dictionary awaiters; AssemblyDefinition assembly; readonly CompilerContext context; @@ -127,6 +128,9 @@ namespace Mono.CSharp PredefinedTypes predefined_types; PredefinedMembers predefined_members; + public Binary.PredefinedOperator[] OperatorsBinaryEqualityLifted; + public Binary.PredefinedOperator[] OperatorsBinaryLifted; + static readonly string[] attribute_targets = new string[] { "assembly", "module" }; public ModuleContainer (CompilerContext context) @@ -144,6 +148,7 @@ namespace Mono.CSharp pointer_types = new Dictionary (); reference_types = new Dictionary (); attrs_cache = new Dictionary (); + awaiters = new Dictionary (); } #region Properties @@ -182,9 +187,6 @@ namespace Mono.CSharp } public int CounterAnonymousTypes { get; set; } - public int CounterAnonymousMethods { get; set; } - public int CounterAnonymousContainers { get; set; } - public int CounterSwitchTypes { get; set; } public AssemblyDefinition DeclaringAssembly { get { @@ -309,7 +311,7 @@ namespace Mono.CSharp public override void AddTypeContainer (TypeContainer tc) { - containers.Add (tc); + AddTypeContainerMember (tc); } public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) @@ -398,6 +400,8 @@ namespace Mono.CSharp { DefineContainer (); + ExpandBaseInterfaces (); + base.Define (); HasTypesFullyDefined = true; @@ -422,7 +426,7 @@ namespace Mono.CSharp if (OptAttributes != null) OptAttributes.Emit (); - if (Compiler.Settings.Unsafe) { + if (Compiler.Settings.Unsafe && !assembly.IsSatelliteAssembly) { var pa = PredefinedAttributes.UnverifiableCode; if (pa.IsDefined) pa.EmitAttribute (builder); @@ -470,6 +474,43 @@ namespace Mono.CSharp return null; } + // + // Return container with awaiter definition. It never returns null + // but all container member can be null for easier error reporting + // + public AwaiterDefinition GetAwaiter (TypeSpec type) + { + AwaiterDefinition awaiter; + if (awaiters.TryGetValue (type, out awaiter)) + return awaiter; + + awaiter = new AwaiterDefinition (); + + // + // Predefined: bool IsCompleted { get; } + // + awaiter.IsCompleted = MemberCache.FindMember (type, MemberFilter.Property ("IsCompleted", Compiler.BuiltinTypes.Bool), + BindingRestriction.InstanceOnly) as PropertySpec; + + // + // Predefined: GetResult () + // + // The method return type is also result type of await expression + // + awaiter.GetResult = MemberCache.FindMember (type, MemberFilter.Method ("GetResult", 0, + ParametersCompiled.EmptyReadOnlyParameters, null), + BindingRestriction.InstanceOnly) as MethodSpec; + + // + // Predefined: INotifyCompletion.OnCompleted (System.Action) + // + var nc = PredefinedTypes.INotifyCompletion; + awaiter.INotifyCompletion = !nc.Define () || type.ImplementsInterface (nc.TypeSpec, false); + + awaiters.Add (type, awaiter); + return awaiter; + } + public override void GetCompletionStartingWith (string prefix, List results) { var names = Evaluator.GetVarNames (); @@ -488,11 +529,37 @@ namespace Mono.CSharp return ""; } + public Binary.PredefinedOperator[] GetPredefinedEnumAritmeticOperators (TypeSpec enumType, bool nullable) + { + TypeSpec underlying; + Binary.Operator mask = 0; + + if (nullable) { + underlying = Nullable.NullableInfo.GetEnumUnderlyingType (this, enumType); + mask = Binary.Operator.NullableMask; + } else { + underlying = EnumSpec.GetUnderlyingType (enumType); + } + + var operators = new[] { + new Binary.PredefinedOperator (enumType, underlying, + mask | Binary.Operator.AdditionMask | Binary.Operator.SubtractionMask | Binary.Operator.DecomposedMask, enumType), + new Binary.PredefinedOperator (underlying, enumType, + mask | Binary.Operator.AdditionMask | Binary.Operator.SubtractionMask | Binary.Operator.DecomposedMask, enumType), + new Binary.PredefinedOperator (enumType, mask | Binary.Operator.SubtractionMask, underlying) + }; + + return operators; + } + public void InitializePredefinedTypes () { predefined_attributes = new PredefinedAttributes (this); predefined_types = new PredefinedTypes (this); predefined_members = new PredefinedMembers (this); + + OperatorsBinaryEqualityLifted = Binary.CreateEqualityLiftedOperatorsTable (this); + OperatorsBinaryLifted = Binary.CreateStandardLiftedOperatorsTable (this); } public override bool IsClsComplianceRequired ()