From 0fcf330866e1635c2eb62af1a453ffce1526c9e3 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 15 Jun 2012 10:30:18 +0100 Subject: [PATCH] Fix column info for binary expressions --- .../CSharpBinaryOperationBinder.cs | 2 +- mcs/mcs/anonymous.cs | 35 ++++----- mcs/mcs/argument.cs | 16 ++-- mcs/mcs/assign.cs | 2 +- mcs/mcs/cfold.cs | 40 +++++----- mcs/mcs/cs-parser.jay | 77 ++++++++++--------- mcs/mcs/dynamic.cs | 2 +- mcs/mcs/expression.cs | 20 ++--- mcs/mcs/nullable.cs | 8 +- mcs/mcs/property.cs | 3 +- mcs/mcs/statement.cs | 16 ++-- mcs/tests/test-debug-11-ref.xml | 2 +- mcs/tests/test-debug-24-ref.xml | 52 +++++++++++++ mcs/tests/test-debug-24.cs | 18 +++++ mcs/tests/ver-il-net_4_5.xml | 16 ++++ 15 files changed, 197 insertions(+), 112 deletions(-) create mode 100644 mcs/tests/test-debug-24-ref.xml create mode 100644 mcs/tests/test-debug-24.cs diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinaryOperationBinder.cs b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinaryOperationBinder.cs index 9ebae70b1bc..374eb0d961f 100644 --- a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinaryOperationBinder.cs +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinaryOperationBinder.cs @@ -142,7 +142,7 @@ namespace Microsoft.CSharp.RuntimeBinder var target_expr = new Compiler.RuntimeValueExpression (target, ctx.ImportType (target.LimitType)); expr = new Compiler.CompoundAssign (oper, target_expr, right, left); } else { - expr = new Compiler.Binary (oper, left, right, Compiler.Location.Null); + expr = new Compiler.Binary (oper, left, right); } expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null); diff --git a/mcs/mcs/anonymous.cs b/mcs/mcs/anonymous.cs index 0b2e4532e8a..9bc786205a2 100644 --- a/mcs/mcs/anonymous.cs +++ b/mcs/mcs/anonymous.cs @@ -2007,11 +2007,11 @@ namespace Mono.CSharp { IntConstant FNV_prime = new IntConstant (Compiler.BuiltinTypes, 16777619, loc); rs_hashcode = new Binary (Binary.Operator.Multiply, - new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode, loc), - FNV_prime, loc); + new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode), + FNV_prime); Expression field_to_string = new Conditional (new BooleanExpression (new Binary (Binary.Operator.Inequality, - new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc), loc)), + new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc))), new Invocation (new MemberAccess ( new MemberAccess (new This (f.Location), f.Name), "ToString"), null), new StringConstant (Compiler.BuiltinTypes, string.Empty, loc), loc); @@ -2022,9 +2022,7 @@ namespace Mono.CSharp { string_concat, new Binary (Binary.Operator.Addition, new StringConstant (Compiler.BuiltinTypes, " " + p.Name + " = ", loc), - field_to_string, - loc), - loc); + field_to_string)); continue; } @@ -2034,18 +2032,15 @@ namespace Mono.CSharp { string_concat = new Binary (Binary.Operator.Addition, new Binary (Binary.Operator.Addition, string_concat, - new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc), - loc), - field_to_string, - loc); + new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc)), + field_to_string); - rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal, loc); + rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal); } string_concat = new Binary (Binary.Operator.Addition, string_concat, - new StringConstant (Compiler.BuiltinTypes, " }", loc), - loc); + new StringConstant (Compiler.BuiltinTypes, " }", loc)); // // Equals (object obj) override @@ -2056,9 +2051,9 @@ namespace Mono.CSharp { new As (equals_block.GetParameterReference (0, loc), current_type, loc), loc))); - Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc), loc); + Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc)); if (rs_equals != null) - equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals, loc); + equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals); equals_block.AddStatement (new Return (equals_test, loc)); equals.Block = equals_block; @@ -2100,19 +2095,19 @@ namespace Mono.CSharp { var hash_variable = new LocalVariableReference (li_hash, loc); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 13, loc), loc)))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 13, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable, - new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 7, loc), loc)))); + new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 7, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 3, loc), loc)))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 3, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable, - new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 17, loc), loc)))); + new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 17, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 5, loc), loc)))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 5, loc))))); hashcode_block.AddStatement (new Return (hash_variable, loc)); hashcode.Block = hashcode_top; diff --git a/mcs/mcs/argument.cs b/mcs/mcs/argument.cs index 9da98b8a80c..22e28eaf729 100644 --- a/mcs/mcs/argument.cs +++ b/mcs/mcs/argument.cs @@ -320,20 +320,20 @@ namespace Mono.CSharp if (a.Expr is Constant) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "Constant", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "Constant", loc)); } else if (a.ArgType == Argument.AType.Ref) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsRef", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsRef", loc)); info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc)); } else if (a.ArgType == Argument.AType.Out) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsOut", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsOut", loc)); info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc)); } else if (a.ArgType == Argument.AType.DynamicTypeName) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsStaticType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsStaticType", loc)); } var arg_type = a.Expr.Type; @@ -354,14 +354,14 @@ namespace Mono.CSharp } info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc)); } string named_value; NamedArgument na = a as NamedArgument; if (na != null) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "NamedArgument", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "NamedArgument", loc)); named_value = na.Name; } else { diff --git a/mcs/mcs/assign.cs b/mcs/mcs/assign.cs index e91479ffd92..fdb24f20fc2 100644 --- a/mcs/mcs/assign.cs +++ b/mcs/mcs/assign.cs @@ -720,7 +720,7 @@ namespace Mono.CSharp { if (left == null) left = new TargetExpression (target); - source = new Binary (op, left, right, true, loc); + source = new Binary (op, left, right, true); if (target is DynamicMemberAssignable) { Arguments targs = ((DynamicMemberAssignable) target).Arguments; diff --git a/mcs/mcs/cfold.cs b/mcs/mcs/cfold.cs index 9e2cfc8b96c..8724e48b52d 100644 --- a/mcs/mcs/cfold.cs +++ b/mcs/mcs/cfold.cs @@ -187,7 +187,7 @@ namespace Mono.CSharp { // if ((lt.BuiltinType == BuiltinTypeSpec.Type.Bool && right is NullLiteral) || (rt.BuiltinType == BuiltinTypeSpec.Type.Bool && left is NullLiteral)) { - var b = new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + var b = new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); // false | null => null // null | false => null @@ -231,7 +231,7 @@ namespace Mono.CSharp { // if ((lt.BuiltinType == BuiltinTypeSpec.Type.Bool && right is NullLiteral) || (rt.BuiltinType == BuiltinTypeSpec.Type.Bool && left is NullLiteral)) { - var b = new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + var b = new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); // false & null => false // null & false => false @@ -469,7 +469,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -566,7 +566,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -662,7 +662,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -762,7 +762,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -852,7 +852,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } IntConstant ic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant; @@ -873,7 +873,7 @@ namespace Mono.CSharp { // null << value => null if (left is NullLiteral) - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); left = left.ConvertImplicitly (ec.BuiltinTypes.Int); if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) @@ -889,7 +889,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } IntConstant sic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant; @@ -909,7 +909,7 @@ namespace Mono.CSharp { // null >> value => null if (left is NullLiteral) - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); left = left.ConvertImplicitly (ec.BuiltinTypes.Int); if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) @@ -925,7 +925,7 @@ namespace Mono.CSharp { if (left.IsNull || right.IsNull) { return ReducedExpression.Create ( new BoolConstant (ec.BuiltinTypes, left.IsNull == right.IsNull, left.Location), - new Binary (oper, left, right, loc)); + new Binary (oper, left, right)); } if (left is StringConstant && right is StringConstant) @@ -969,7 +969,7 @@ namespace Mono.CSharp { if (left.IsNull || right.IsNull) { return ReducedExpression.Create ( new BoolConstant (ec.BuiltinTypes, left.IsNull != right.IsNull, left.Location), - new Binary (oper, left, right, loc)); + new Binary (oper, left, right)); } if (left is StringConstant && right is StringConstant) @@ -1011,11 +1011,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } @@ -1051,11 +1051,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } @@ -1091,11 +1091,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } @@ -1131,11 +1131,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 8c5d3b26dec..ce7fc3ec298 100644 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -3840,18 +3840,18 @@ multiplicative_expression : prefixed_unary_expression | multiplicative_expression STAR prefixed_unary_expression { - $$ = new Binary (Binary.Operator.Multiply, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Multiply, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | multiplicative_expression DIV prefixed_unary_expression { - $$ = new Binary (Binary.Operator.Division, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Division, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | multiplicative_expression PERCENT prefixed_unary_expression { - $$ = new Binary (Binary.Operator.Modulus, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Modulus, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3859,17 +3859,19 @@ additive_expression : multiplicative_expression | additive_expression PLUS multiplicative_expression { - $$ = new Binary (Binary.Operator.Addition, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Addition, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | additive_expression MINUS multiplicative_expression { - $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | parenthesized_expression MINUS multiplicative_expression { // Shift/Reduce conflict - $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | additive_expression AS type { @@ -3885,13 +3887,13 @@ shift_expression : additive_expression | shift_expression OP_SHIFT_LEFT additive_expression { - $$ = new Binary (Binary.Operator.LeftShift, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LeftShift, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | shift_expression OP_SHIFT_RIGHT additive_expression { - $$ = new Binary (Binary.Operator.RightShift, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.RightShift, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3899,23 +3901,23 @@ relational_expression : shift_expression | relational_expression OP_LT shift_expression { - $$ = new Binary (Binary.Operator.LessThan, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LessThan, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | relational_expression OP_GT shift_expression { - $$ = new Binary (Binary.Operator.GreaterThan, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.GreaterThan, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | relational_expression OP_LE shift_expression { - $$ = new Binary (Binary.Operator.LessThanOrEqual, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LessThanOrEqual, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | relational_expression OP_GE shift_expression { - $$ = new Binary (Binary.Operator.GreaterThanOrEqual, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3923,13 +3925,13 @@ equality_expression : relational_expression | equality_expression OP_EQ relational_expression { - $$ = new Binary (Binary.Operator.Equality, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Equality, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | equality_expression OP_NE relational_expression { - $$ = new Binary (Binary.Operator.Inequality, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Inequality, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3937,8 +3939,8 @@ and_expression : equality_expression | and_expression BITWISE_AND equality_expression { - $$ = new Binary (Binary.Operator.BitwiseAnd, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.BitwiseAnd, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3946,8 +3948,8 @@ exclusive_or_expression : and_expression | exclusive_or_expression CARRET and_expression { - $$ = new Binary (Binary.Operator.ExclusiveOr, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3955,8 +3957,8 @@ inclusive_or_expression : exclusive_or_expression | inclusive_or_expression BITWISE_OR exclusive_or_expression { - $$ = new Binary (Binary.Operator.BitwiseOr, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.BitwiseOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3964,8 +3966,8 @@ conditional_and_expression : inclusive_or_expression | conditional_and_expression OP_AND inclusive_or_expression { - $$ = new Binary (Binary.Operator.LogicalAnd, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LogicalAnd, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3973,8 +3975,8 @@ conditional_or_expression : conditional_and_expression | conditional_or_expression OP_OR conditional_and_expression { - $$ = new Binary (Binary.Operator.LogicalOr, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LogicalOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3985,7 +3987,8 @@ null_coalescing_expression if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation ($2), "null coalescing operator"); - $$ = new Nullable.NullCoalescingOperator ((Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Nullable.NullCoalescingOperator ((Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; diff --git a/mcs/mcs/dynamic.cs b/mcs/mcs/dynamic.cs index c9cea6927cd..b9d6967dccf 100644 --- a/mcs/mcs/dynamic.cs +++ b/mcs/mcs/dynamic.cs @@ -502,7 +502,7 @@ namespace Mono.CSharp using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { if (s.Resolve (bc)) { - Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc); + Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc); init.Emit (ec); } diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs index 4df85131429..b4f68f05c3b 100644 --- a/mcs/mcs/expression.cs +++ b/mcs/mcs/expression.cs @@ -1211,7 +1211,7 @@ namespace Mono.CSharp var one = new IntConstant (ec.BuiltinTypes, 1, loc); var op = IsDecrement ? Binary.Operator.Subtraction : Binary.Operator.Addition; - operation = new Binary (op, source, one, loc); + operation = new Binary (op, source, one); operation = operation.Resolve (ec); if (operation == null) throw new NotImplementedException ("should not be reached"); @@ -1527,7 +1527,7 @@ namespace Mono.CSharp // Turn is check into simple null check for implicitly convertible reference types // return ReducedExpression.Create ( - new Binary (Binary.Operator.Inequality, expr, new NullLiteral (loc), loc).Resolve (ec), + new Binary (Binary.Operator.Inequality, expr, new NullLiteral (loc)).Resolve (ec), this).Resolve (ec); } @@ -2014,7 +2014,7 @@ namespace Mono.CSharp // b = b.left >> b.right & (0x1f|0x3f) // b.right = new Binary (Operator.BitwiseAnd, - b.right, new IntConstant (ec.BuiltinTypes, right_mask, b.right.Location), b.loc).Resolve (ec); + b.right, new IntConstant (ec.BuiltinTypes, right_mask, b.right.Location)).Resolve (ec); // // Expression tree representation does not use & mask @@ -2202,19 +2202,19 @@ namespace Mono.CSharp protected State state; Expression enum_conversion; - public Binary (Operator oper, Expression left, Expression right, bool isCompound, Location loc) - : this (oper, left, right, loc) + public Binary (Operator oper, Expression left, Expression right, bool isCompound) + : this (oper, left, right) { if (isCompound) state |= State.Compound; } - public Binary (Operator oper, Expression left, Expression right, Location loc) + public Binary (Operator oper, Expression left, Expression right) { this.oper = oper; this.left = left; this.right = right; - this.loc = loc; + this.loc = left.Location; } #region Properties @@ -2319,7 +2319,7 @@ namespace Mono.CSharp public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, Operator oper, Location loc) { - new Binary (oper, left, right, loc).Error_OperatorCannotBeApplied (ec, left, right); + new Binary (oper, left, right).Error_OperatorCannotBeApplied (ec, left, right); } public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, string oper, Location loc) @@ -3031,7 +3031,7 @@ namespace Mono.CSharp (TypeSpec.IsValueType (left.Type) && right is NullLiteral) || (right.Type.IsNullableType && (left is NullLiteral || left.Type.IsNullableType || TypeSpec.IsValueType (left.Type))) || (TypeSpec.IsValueType (right.Type) && left is NullLiteral))) { - var lifted = new Nullable.LiftedBinaryOperator (oper, left, right, loc); + var lifted = new Nullable.LiftedBinaryOperator (oper, left, right); lifted.state = state; return lifted.Resolve (ec); } @@ -4409,7 +4409,7 @@ namespace Mono.CSharp // TODO: Should be the checks resolve context sensitive? ResolveContext rc = new ResolveContext (ec.MemberContext, ResolveContext.Options.UnsafeScope); - right = new Binary (Binary.Operator.Multiply, right, right_const, loc).Resolve (rc); + right = new Binary (Binary.Operator.Multiply, right, right_const).Resolve (rc); if (right == null) return; } diff --git a/mcs/mcs/nullable.cs b/mcs/mcs/nullable.cs index 9397486a336..0c370b1f3a4 100644 --- a/mcs/mcs/nullable.cs +++ b/mcs/mcs/nullable.cs @@ -539,8 +539,8 @@ namespace Mono.CSharp.Nullable Expression user_operator; MethodSpec wrap_ctor; - public LiftedBinaryOperator (Binary.Operator op, Expression left, Expression right, Location loc) - : base (op, left, right, loc) + public LiftedBinaryOperator (Binary.Operator op, Expression left, Expression right) + : base (op, left, right) { } @@ -1001,11 +1001,11 @@ namespace Mono.CSharp.Nullable Expression left, right; Unwrap unwrap; - public NullCoalescingOperator (Expression left, Expression right, Location loc) + public NullCoalescingOperator (Expression left, Expression right) { this.left = left; this.right = right; - this.loc = loc; + this.loc = left.Location; } public Expression LeftExpression { diff --git a/mcs/mcs/property.cs b/mcs/mcs/property.cs index 863f5556e88..325b8f118f4 100644 --- a/mcs/mcs/property.cs +++ b/mcs/mcs/property.cs @@ -943,8 +943,7 @@ namespace Mono.CSharp var cond = new BooleanExpression (new Binary (Binary.Operator.Inequality, new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj1, Location), Location), - new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj2, Location), Location), - Location)); + new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj2, Location), Location))); var body = new ExplicitBlock (block, Location, Location); block.AddStatement (new Do (body, cond, Location, Location)); diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index e918b3f2d2b..7dcde8d8be3 100644 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -1633,8 +1633,10 @@ namespace Mono.CSharp { if (declarators != null) { foreach (var d in declarators) { d.Variable.CreateBuilder (ec); - if (d.Initializer != null) + if (d.Initializer != null) { + ec.Mark (d.Variable.Location); ((ExpressionStatement) d.Initializer).EmitStatement (ec); + } } } } @@ -4249,10 +4251,10 @@ namespace Mono.CSharp { Expression cond = null; for (int ci = 0; ci < s.Labels.Count; ++ci) { - var e = new Binary (Binary.Operator.Equality, value, s.Labels[ci].Converted, loc); + var e = new Binary (Binary.Operator.Equality, value, s.Labels[ci].Converted); if (ci > 0) { - cond = new Binary (Binary.Operator.LogicalOr, cond, e, loc); + cond = new Binary (Binary.Operator.LogicalOr, cond, e); } else { cond = e; } @@ -5142,8 +5144,8 @@ namespace Mono.CSharp { // fixed (T* e_ptr = (e == null || e.Length == 0) ? null : converted [0]) // converted = new Conditional (new BooleanExpression (new Binary (Binary.Operator.LogicalOr, - new Binary (Binary.Operator.Equality, initializer, new NullLiteral (loc), loc), - new Binary (Binary.Operator.Equality, new MemberAccess (initializer, "Length"), new IntConstant (bc.BuiltinTypes, 0, loc), loc), loc)), + new Binary (Binary.Operator.Equality, initializer, new NullLiteral (loc)), + new Binary (Binary.Operator.Equality, new MemberAccess (initializer, "Length"), new IntConstant (bc.BuiltinTypes, 0, loc)))), new NullLiteral (loc), converted, loc); @@ -5701,7 +5703,7 @@ namespace Mono.CSharp { // Add conditional call when disposing possible null variable if (!type.IsStruct || type.IsNullableType) - dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, dispose.loc); + dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc)), dispose, dispose.loc); return dispose; } @@ -6047,7 +6049,7 @@ namespace Mono.CSharp { var idisaposable_test = new Binary (Binary.Operator.Inequality, new CompilerAssign ( dispose_variable.CreateReferenceExpression (bc, loc), new As (lv.CreateReferenceExpression (bc, loc), new TypeExpression (dispose_variable.Type, loc), loc), - loc), new NullLiteral (loc), loc); + loc), new NullLiteral (loc)); var m = bc.Module.PredefinedMembers.IDisposableDispose.Resolve (loc); diff --git a/mcs/tests/test-debug-11-ref.xml b/mcs/tests/test-debug-11-ref.xml index e4f3be31dc7..9a6c2dcacd7 100644 --- a/mcs/tests/test-debug-11-ref.xml +++ b/mcs/tests/test-debug-11-ref.xml @@ -315,7 +315,7 @@