**** Merged r40732-r40872 from MCS ****
[mono.git] / mcs / gmcs / ecore.cs
index 4fb48ea2434a804d5654c938b07583b720961938..baf528bffae03ddaec3782e7ac4c4bb39085d332 100644 (file)
@@ -299,7 +299,7 @@ namespace Mono.CSharp {
 
                public virtual Expression DoResolveLValue (EmitContext ec, Expression right_side)
                {
-                       return DoResolve (ec);
+                       return null;
                }
 
                //
@@ -451,16 +451,16 @@ namespace Mono.CSharp {
                /// </remarks>
                public Expression ResolveLValue (EmitContext ec, Expression right_side)
                {
+                       int errors = Report.Errors;
                        Expression e = DoResolveLValue (ec, right_side);
 
-                       if (e != null){
-                               if (e is SimpleName){
-                                       SimpleName s = (SimpleName) e;
-                                       MemberLookupFailed (ec, null, ec.ContainerType, s.Name,
-                                                           ec.DeclSpace.Name, loc);
-                                       return null;
-                               }
+                       if (e == null) {
+                               if (errors == Report.Errors)
+                                       Report.Error (131, Location, "The left-hand side of an assignment or mutating operation must be a variable, property or indexer");
+                               return null;
+                       }
 
+                       if (e != null){
                                if (e.eclass == ExprClass.Invalid)
                                        throw new Exception ("Expression " + e +
                                                             " ExprClass is Invalid after resolve");
@@ -815,7 +815,7 @@ namespace Mono.CSharp {
                ///   Returns an expression that can be used to invoke operator true
                ///   on the expression if it exists.
                /// </summary>
-               static public StaticCallExpr GetOperatorTrue (EmitContext ec, Expression e, Location loc)
+               static public Expression GetOperatorTrue (EmitContext ec, Expression e, Location loc)
                {
                        return GetOperatorTrueOrFalse (ec, e, true, loc);
                }
@@ -824,16 +824,19 @@ namespace Mono.CSharp {
                ///   Returns an expression that can be used to invoke operator false
                ///   on the expression if it exists.
                /// </summary>
-               static public StaticCallExpr GetOperatorFalse (EmitContext ec, Expression e, Location loc)
+               static public Expression GetOperatorFalse (EmitContext ec, Expression e, Location loc)
                {
                        return GetOperatorTrueOrFalse (ec, e, false, loc);
                }
 
-               static StaticCallExpr GetOperatorTrueOrFalse (EmitContext ec, Expression e, bool is_true, Location loc)
+               static Expression GetOperatorTrueOrFalse (EmitContext ec, Expression e, bool is_true, Location loc)
                {
                        MethodBase method;
                        Expression operator_group;
 
+                       if (TypeManager.IsNullableType (e.Type))
+                               return new Nullable.OperatorTrueOrFalse (e, is_true, loc).Resolve (ec);
+
                        operator_group = MethodLookup (ec, e.Type, is_true ? "op_True" : "op_False", loc);
                        if (operator_group == null)
                                return null;
@@ -941,7 +944,7 @@ namespace Mono.CSharp {
                                sb.Append (valid [i]);
                        }
 
-                       Error (119, "Expression denotes a `" + ExprClassName () + "' where " +
+                       Report.Error (119, loc, "Expression denotes a `" + ExprClassName () + "' where " +
                               "a `" + sb.ToString () + "' was expected");
                }
                
@@ -1441,6 +1444,7 @@ namespace Mono.CSharp {
                public EmptyCast (Expression child, Type return_type)
                {
                        eclass = child.eclass;
+                       loc = child.Location;
                        type = return_type;
                        this.child = child;
                }
@@ -1496,6 +1500,12 @@ namespace Mono.CSharp {
                        child.Emit (ec);
                }
 
+               public override bool IsDefaultValue {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -1632,7 +1642,13 @@ namespace Mono.CSharp {
                {
                        return Child.ConvertToInt ();
                }
-               
+
+               public override bool IsDefaultValue {
+                       get {
+                               return Child.IsDefaultValue;
+                       }
+               }
+
                public override bool IsZeroInteger {
                        get { return Child.IsZeroInteger; }
                }
@@ -2080,7 +2096,7 @@ namespace Mono.CSharp {
                        int errors = Report.Errors;
                        dt = ec.ResolvingTypeTree 
                                ? ds.FindType (loc, Name)
-                               : ds.LookupType (Name, true, loc);
+                               : ds.LookupType (Name, loc, /*silent=*/ true, /*ignore_cs0104=*/ false);
                        if (Report.Errors != errors)
                                return null;
 
@@ -2275,6 +2291,11 @@ namespace Mono.CSharp {
        ///   section 10.8.1 (Fully Qualified Names).
        /// </summary>
        public abstract class FullNamedExpression : Expression {
+               public override FullNamedExpression ResolveAsTypeStep (EmitContext ec)
+               {
+                       return this;
+               }
+
                public abstract string FullName {
                        get;
                }
@@ -2426,7 +2447,8 @@ namespace Mono.CSharp {
                protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
                {
                        if (type == null) {
-                               FullNamedExpression t = ec.DeclSpace.LookupType (name, false, Location.Null);
+                               FullNamedExpression t = ec.DeclSpace.LookupType (
+                                       name, Location.Null, /*silent=*/ false, /*ignore_cs0104=*/ false);
                                if (t == null)
                                        return null;
                                if (!(t is TypeExpr))
@@ -3025,7 +3047,15 @@ namespace Mono.CSharp {
                                if (is_volatile)
                                        ig.Emit (OpCodes.Volatile);
 
-                               ig.Emit (OpCodes.Ldfld, FieldInfo);
+                               IFixedBuffer ff = AttributeTester.GetFixedBuffer (FieldInfo);
+                               if (ff != null)
+                               {
+                                       ig.Emit (OpCodes.Ldflda, FieldInfo);
+                                       ig.Emit (OpCodes.Ldflda, ff.Element);
+                               }
+                               else {
+                                       ig.Emit (OpCodes.Ldfld, FieldInfo);
+                               }
                        }
 
                        if (leave_copy) {
@@ -3641,6 +3671,11 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               public override Expression DoResolveLValue (EmitContext ec, Expression right_side)
+               {
+                       return DoResolve (ec);
+               }
+
                public override Expression DoResolve (EmitContext ec)
                {
                        if (instance_expr != null) {