[xbuild] Add new reserved properties $(MSBuildThisFile*).
[mono.git] / mcs / mcs / ecore.cs
index caed688b31d3ac71f3f16905a1a967ab152893bf..e0edcc0a7843027da1619faca9481a42d1e648ae 100644 (file)
@@ -202,7 +202,8 @@ namespace Mono.CSharp {
                //
                public virtual TypeExpr ResolveAsTypeTerminal (IMemberContext ec , bool silent)
                {
-                       int errors = ec.Compiler.Report.Errors;
+                       // FIXME: THIS IS TOO SLOW and it should not be needed either
+                       int errors = ec.Module.Compiler.Report.Errors;
 
                        FullNamedExpression fne = ResolveAsTypeStep (ec, silent);
 
@@ -211,13 +212,13 @@ namespace Mono.CSharp {
                                
                        TypeExpr te = fne as TypeExpr;                          
                        if (te == null) {
-                               if (!silent && errors == ec.Compiler.Report.Errors)
-                                       fne.Error_UnexpectedKind (ec.Compiler.Report, null, "type", loc);
+                               if (!silent && errors == ec.Module.Compiler.Report.Errors)
+                                       fne.Error_UnexpectedKind (ec.Module.Compiler.Report, null, "type", loc);
                                return null;
                        }
 
                        if (!te.type.IsAccessible (ec.CurrentType)) {
-                               ec.Compiler.Report.SymbolRelatedToPreviousError (te.Type);
+                               ec.Module.Compiler.Report.SymbolRelatedToPreviousError (te.Type);
                                ErrorIsInaccesible (ec, te.Type.GetSignatureForError (), loc);
                        }
 
@@ -235,7 +236,7 @@ namespace Mono.CSharp {
                        if (!silent && !(ec is TypeContainer.BaseContext)) {
                                ObsoleteAttribute obsolete_attr = te.Type.GetAttributeObsolete ();
                                if (obsolete_attr != null && !ec.IsObsolete) {
-                                       AttributeTester.Report_ObsoleteMessage (obsolete_attr, te.GetSignatureForError (), Location, ec.Compiler.Report);
+                                       AttributeTester.Report_ObsoleteMessage (obsolete_attr, te.GetSignatureForError (), Location, ec.Module.Compiler.Report);
                                }
                        }
 
@@ -244,7 +245,7 @@ namespace Mono.CSharp {
        
                public static void ErrorIsInaccesible (IMemberContext rc, string member, Location loc)
                {
-                       rc.Compiler.Report.Error (122, loc, "`{0}' is inaccessible due to its protection level", member);
+                       rc.Module.Compiler.Report.Error (122, loc, "`{0}' is inaccessible due to its protection level", member);
                }
 
                public void Error_ExpressionMustBeConstant (ResolveContext rc, Location loc, string e_name)
@@ -480,7 +481,7 @@ namespace Mono.CSharp {
 
                public virtual void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
                {
-                       rc.Compiler.Report.Error (182, loc,
+                       rc.Module.Compiler.Report.Error (182, loc,
                                "An attribute argument must be a constant expression, typeof expression or array creation expression");
                }
 
@@ -614,7 +615,7 @@ namespace Mono.CSharp {
                                                //              }
                                                //      }
                                                //
-                                               if (rc.Compiler.IsRuntimeBinder && !member.DeclaringType.IsAccessible (currentType))
+                                               if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (currentType))
                                                        continue;
                                        }
 
@@ -2187,7 +2188,7 @@ namespace Mono.CSharp {
                                if (ec.CurrentMemberDefinition != null) {
                                        MemberCore mc = ec.CurrentMemberDefinition.Parent.GetDefinition (Name);
                                        if (mc != null) {
-                                               Error_UnexpectedKind (ec.Compiler.Report, mc, "type", GetMemberType (mc), loc);
+                                               Error_UnexpectedKind (ec.Module.Compiler.Report, mc, "type", GetMemberType (mc), loc);
                                                return;
                                        }
                                }
@@ -2218,7 +2219,7 @@ namespace Mono.CSharp {
 
                        FullNamedExpression retval = ec.LookupNamespaceOrType (Name, -System.Math.Max (1, Arity), loc, true);
                        if (retval != null) {
-                               Error_TypeArgumentsCannotBeUsed (ec.Compiler.Report, loc, retval.Type, Arity);
+                               Error_TypeArgumentsCannotBeUsed (ec.Module.Compiler.Report, loc, retval.Type, Arity);
 /*
                                var te = retval as TypeExpr;
                                if (HasTypeArguments && te != null && !te.Type.IsGeneric)
@@ -2229,7 +2230,7 @@ namespace Mono.CSharp {
                                return;
                        }
 
-                       NamespaceEntry.Error_NamespaceNotFound (loc, Name, ec.Compiler.Report);
+                       NamespaceEntry.Error_NamespaceNotFound (loc, Name, ec.Module.Compiler.Report);
                }
 
                protected override Expression DoResolve (ResolveContext ec)
@@ -2244,7 +2245,7 @@ namespace Mono.CSharp {
 
                public override FullNamedExpression ResolveAsTypeStep (IMemberContext ec, bool silent)
                {
-                       int errors = ec.Compiler.Report.Errors;
+                       int errors = ec.Module.Compiler.Report.Errors;
                        FullNamedExpression fne = ec.LookupNamespaceOrType (Name, Arity, loc, /*ignore_cs0104=*/ false);
 
                        if (fne != null) {
@@ -2264,9 +2265,9 @@ namespace Mono.CSharp {
                                        return fne;
                        }
 
-                       if (Arity == 0 && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) {
+                       if (Arity == 0 && Name == "dynamic" && ec.Module.Compiler.Settings.Version > LanguageVersion.V_3) {
                                if (!ec.Module.PredefinedAttributes.Dynamic.IsDefined) {
-                                       ec.Compiler.Report.Error (1980, Location,
+                                       ec.Module.Compiler.Report.Error (1980, Location,
                                                "Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?",
                                                ec.Module.PredefinedAttributes.Dynamic.GetSignatureForError ());
                                }
@@ -2277,7 +2278,7 @@ namespace Mono.CSharp {
                        if (fne != null)
                                return fne;
 
-                       if (silent || errors != ec.Compiler.Report.Errors)
+                       if (silent || errors != ec.Module.Compiler.Report.Errors)
                                return null;
 
                        Error_TypeOrNamespaceNotFound (ec);
@@ -2417,8 +2418,8 @@ namespace Mono.CSharp {
                                        return null;
                                }
 
-                               if (RootContext.EvalMode) {
-                                       var fi = Evaluator.LookupField (Name);
+                               if (rc.Module.Evaluator != null) {
+                                       var fi = rc.Module.Evaluator.LookupField (Name);
                                        if (fi != null)
                                                return new FieldExpr (fi.Item1, loc);
                                }
@@ -2635,7 +2636,7 @@ namespace Mono.CSharp {
                                }
 
                                if (targs != null)
-                                       method = method.MakeGenericMethod (targs);
+                                       method = method.MakeGenericMethod (rc, targs);
                        }
 
                        //
@@ -3419,7 +3420,7 @@ namespace Mono.CSharp {
                        //
                        // If argument is an anonymous function
                        //
-                       if (argument_type == InternalType.AnonymousMethod && RootContext.Version > LanguageVersion.ISO_2) {
+                       if (argument_type == InternalType.AnonymousMethod && ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2) {
                                //
                                // p and q are delegate types or expression tree types
                                //
@@ -3435,8 +3436,8 @@ namespace Mono.CSharp {
                                        p = TypeManager.GetTypeArguments (p)[0];
                                }
 
-                               var p_m = Delegate.GetInvokeMethod (ec.Compiler, p);
-                               var q_m = Delegate.GetInvokeMethod (ec.Compiler, q);
+                               var p_m = Delegate.GetInvokeMethod (p);
+                               var q_m = Delegate.GetInvokeMethod (q);
 
                                //
                                // With identical parameter lists
@@ -3853,7 +3854,7 @@ namespace Mono.CSharp {
                                        if (g_args_count != type_arguments.Count)
                                                return int.MaxValue - 20000 + System.Math.Abs (type_arguments.Count - g_args_count);
 
-                                       ms = ms.MakeGenericMethod (type_arguments.Arguments);
+                                       ms = ms.MakeGenericMethod (ec, type_arguments.Arguments);
                                } else {
                                        // TODO: It should not be here (we don't know yet whether any argument is lambda) but
                                        // for now it simplifies things. I should probably add a callback to ResolveContext
@@ -3870,7 +3871,7 @@ namespace Mono.CSharp {
                                                return ti.InferenceScore - 20000;
 
                                        if (i_args.Length != 0) {
-                                               ms = ms.MakeGenericMethod (i_args);
+                                               ms = ms.MakeGenericMethod (ec, i_args);
                                        }
 
                                        cc.IgnoreInferredDynamic = true;
@@ -3893,7 +3894,7 @@ namespace Mono.CSharp {
                                //
                                if (candidate != pm) {
                                        MethodSpec override_ms = (MethodSpec) pm;
-                                       var inflator = new TypeParameterInflator (ms.DeclaringType, override_ms.GenericDefinition.TypeParameters, ms.TypeArguments);
+                                       var inflator = new TypeParameterInflator (ec, ms.DeclaringType, override_ms.GenericDefinition.TypeParameters, ms.TypeArguments);
                                        returnType = inflator.Inflate (returnType);
                                } else {
                                        returnType = ms.ReturnType;
@@ -4168,7 +4169,7 @@ namespace Mono.CSharp {
                                                                if (!member.IsAccessible (current_type))
                                                                        continue;
 
-                                                               if (rc.Compiler.IsRuntimeBinder && !member.DeclaringType.IsAccessible (current_type))
+                                                               if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (current_type))
                                                                        continue;
                                                        }
 
@@ -4595,7 +4596,7 @@ namespace Mono.CSharp {
                                if (a.Expr.Type == InternalType.Dynamic)
                                        continue;
 
-                               if ((restrictions & Restrictions.CovariantDelegate) != 0 && !Delegate.IsTypeCovariant (a.Expr, pt)) {
+                               if ((restrictions & Restrictions.CovariantDelegate) != 0 && !Delegate.IsTypeCovariant (ec, a.Expr, pt)) {
                                        custom_errors.NoArgumentMatch (ec, member);
                                        return false;
                                }
@@ -5065,7 +5066,7 @@ namespace Mono.CSharp {
                                        EmitInstance (ec, false);
 
                                // Optimization for build-in types
-                               if (TypeManager.IsStruct (type) && type == ec.MemberContext.CurrentType && InstanceExpression.Type == type) {
+                               if (TypeManager.IsStruct (type) && type == ec.CurrentType && InstanceExpression.Type == type) {
                                        ec.EmitLoadFromPtr (type);
                                } else {
                                        var ff = spec as FixedFieldSpec;
@@ -5883,10 +5884,10 @@ namespace Mono.CSharp {
 
                protected override void Error_TypeOrNamespaceNotFound (IMemberContext ec)
                {
-                       if (RootContext.Version < LanguageVersion.V_3)
+                       if (ec.Module.Compiler.Settings.Version < LanguageVersion.V_3)
                                base.Error_TypeOrNamespaceNotFound (ec);
                        else
-                               ec.Compiler.Report.Error (825, loc, "The contextual keyword `var' may only appear within a local variable declaration");
+                               ec.Module.Compiler.Report.Error (825, loc, "The contextual keyword `var' may only appear within a local variable declaration");
                }
        }
 }