diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs index 7ef97558f..9eba80628 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs @@ -960,11 +960,16 @@ public ParametersCompiled Parameters { return Block.Parameters; } } - + public bool IsAsync { get; internal set; } + + public ReportPrinter TypeInferenceReportPrinter { + get; set; + } + #endregion // @@ -975,7 +980,13 @@ public bool ImplicitStandardConversionExists (ResolveContext ec, TypeSpec delega { using (ec.With (ResolveContext.Options.InferReturnType, false)) { using (ec.Set (ResolveContext.Options.ProbingMode)) { - return Compatible (ec, delegate_type) != null; + var prev = ec.Report.SetPrinter (TypeInferenceReportPrinter ?? new NullReportPrinter ()); + + var res = Compatible (ec, delegate_type) != null; + + ec.Report.SetPrinter (prev); + + return res; } } } @@ -1109,12 +1120,23 @@ public TypeSpec InferReturnType (ResolveContext ec, TypeInferenceContext tic, Ty } using (ec.Set (ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType)) { + ReportPrinter prev; + if (TypeInferenceReportPrinter != null) { + prev = ec.Report.SetPrinter (TypeInferenceReportPrinter); + } else { + prev = null; + } + var body = CompatibleMethodBody (ec, tic, null, delegate_type); if (body != null) { am = body.Compatible (ec, body); } else { am = null; } + + if (TypeInferenceReportPrinter != null) { + ec.Report.SetPrinter (prev); + } } if (am == null) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs index de601e145..f7c09cc36 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs @@ -70,6 +70,12 @@ public override TypeSpec CurrentType { } } + public Dictionary DefinedNames { + get { + return defined_names; + } + } + public TypeDefinition PartialContainer { get { return main_container; @@ -2403,16 +2409,6 @@ public override void AddNameToContainer (MemberCore symbol, string name) base.AddNameToContainer (symbol, name); } - public override void VerifyMembers () - { - base.VerifyMembers (); - - if (containers != null) { - foreach (var t in containers) - t.VerifyMembers (); - } - } - public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.IsValidSecurityAttribute ()) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs index 77893426d..ca0b7a3f4 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs @@ -2665,7 +2665,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_456(); break; case 457: -#line 3344 "cs-parser.jay" +#line 3345 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } @@ -2707,13 +2707,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_473(); break; case 474: -#line 3441 "cs-parser.jay" +#line 3442 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 476: -#line 3449 "cs-parser.jay" +#line 3450 "cs-parser.jay" { yyVal = new This (GetLocation (yyVals[0+yyTop])); } @@ -2725,13 +2725,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_478(); break; case 479: -#line 3469 "cs-parser.jay" +#line 3470 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; case 480: -#line 3476 "cs-parser.jay" +#line 3477 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } @@ -2758,7 +2758,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_487(); break; case 488: -#line 3543 "cs-parser.jay" +#line 3544 "cs-parser.jay" { ++lexer.parsing_type; } @@ -2770,7 +2770,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_490(); break; case 493: -#line 3570 "cs-parser.jay" +#line 3571 "cs-parser.jay" { yyVal = null; } break; case 495: @@ -2801,25 +2801,25 @@ internal Object yyparse (yyParser.yyInput yyLex) case_506(); break; case 507: -#line 3648 "cs-parser.jay" +#line 3649 "cs-parser.jay" { yyVal = 2; } break; case 508: -#line 3652 "cs-parser.jay" +#line 3653 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; case 509: -#line 3659 "cs-parser.jay" +#line 3660 "cs-parser.jay" { yyVal = null; } break; case 510: -#line 3663 "cs-parser.jay" +#line 3664 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2837,7 +2837,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_514(); break; case 515: -#line 3707 "cs-parser.jay" +#line 3708 "cs-parser.jay" { lexer.TypeOfParsing = true; } @@ -2882,7 +2882,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_530(); break; case 531: -#line 3827 "cs-parser.jay" +#line 3828 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); } @@ -2891,7 +2891,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_532(); break; case 533: -#line 3840 "cs-parser.jay" +#line 3841 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); } @@ -2900,13 +2900,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_534(); break; case 535: -#line 3857 "cs-parser.jay" +#line 3858 "cs-parser.jay" { yyVal = ParametersCompiled.Undefined; } break; case 537: -#line 3865 "cs-parser.jay" +#line 3866 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -2918,13 +2918,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_539(); break; case 541: -#line 3891 "cs-parser.jay" +#line 3892 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 542: -#line 3895 "cs-parser.jay" +#line 3896 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2936,37 +2936,37 @@ internal Object yyparse (yyParser.yyInput yyLex) case_544(); break; case 546: -#line 3931 "cs-parser.jay" +#line 3932 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 547: -#line 3935 "cs-parser.jay" +#line 3936 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 548: -#line 3939 "cs-parser.jay" +#line 3940 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 549: -#line 3943 "cs-parser.jay" +#line 3944 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 550: -#line 3947 "cs-parser.jay" +#line 3948 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 551: -#line 3951 "cs-parser.jay" +#line 3952 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2984,7 +2984,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_557(); break; case 558: -#line 3983 "cs-parser.jay" +#line 3984 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2993,13 +2993,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_559(); break; case 560: -#line 3992 "cs-parser.jay" +#line 3993 "cs-parser.jay" { yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 561: -#line 3996 "cs-parser.jay" +#line 3997 "cs-parser.jay" { yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3053,7 +3053,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_587(); break; case 588: -#line 4125 "cs-parser.jay" +#line 4126 "cs-parser.jay" { yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3104,14 +3104,14 @@ internal Object yyparse (yyParser.yyInput yyLex) case_603(); break; case 604: -#line 4222 "cs-parser.jay" +#line 4223 "cs-parser.jay" { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 605: case_605(); break; case 608: -#line 4238 "cs-parser.jay" +#line 4239 "cs-parser.jay" { start_block (Location.Null); } @@ -3135,7 +3135,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_615(); break; case 616: -#line 4283 "cs-parser.jay" +#line 4284 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3147,7 +3147,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_618(); break; case 619: -#line 4297 "cs-parser.jay" +#line 4298 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3159,7 +3159,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_621(); break; case 627: -#line 4322 "cs-parser.jay" +#line 4323 "cs-parser.jay" { yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); } @@ -3174,13 +3174,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_630(); break; case 632: -#line 4351 "cs-parser.jay" +#line 4352 "cs-parser.jay" { yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); } break; case 633: -#line 4364 "cs-parser.jay" +#line 4365 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -3198,18 +3198,18 @@ internal Object yyparse (yyParser.yyInput yyLex) case_637(); break; case 638: -#line 4409 "cs-parser.jay" +#line 4410 "cs-parser.jay" { yyVal = null; } break; case 639: -#line 4411 "cs-parser.jay" +#line 4412 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } break; case 640: case_640(); break; case 641: -#line 4424 "cs-parser.jay" +#line 4425 "cs-parser.jay" { lexer.parsing_modifiers = false; } @@ -3269,7 +3269,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_661(); break; case 663: -#line 4550 "cs-parser.jay" +#line 4551 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3299,19 +3299,19 @@ internal Object yyparse (yyParser.yyInput yyLex) case_671(); break; case 672: -#line 4643 "cs-parser.jay" +#line 4644 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; case 673: -#line 4647 "cs-parser.jay" +#line 4648 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; case 674: -#line 4654 "cs-parser.jay" +#line 4655 "cs-parser.jay" { yyVal = Variance.None; } @@ -3329,7 +3329,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_678(); break; case 679: -#line 4699 "cs-parser.jay" +#line 4700 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3350,13 +3350,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_684(); break; case 689: -#line 4748 "cs-parser.jay" +#line 4749 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; case 690: -#line 4752 "cs-parser.jay" +#line 4753 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } @@ -3368,13 +3368,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_693(); break; case 696: -#line 4786 "cs-parser.jay" +#line 4787 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; case 697: -#line 4790 "cs-parser.jay" +#line 4791 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } @@ -3407,13 +3407,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_736(); break; case 737: -#line 4934 "cs-parser.jay" +#line 4935 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 738: -#line 4938 "cs-parser.jay" +#line 4939 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -3425,7 +3425,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_741(); break; case 742: -#line 4959 "cs-parser.jay" +#line 4960 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); } @@ -3467,7 +3467,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_762(); break; case 763: -#line 5094 "cs-parser.jay" +#line 5095 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); } @@ -3488,18 +3488,18 @@ internal Object yyparse (yyParser.yyInput yyLex) case_773(); break; case 774: -#line 5144 "cs-parser.jay" +#line 5145 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 775: case_775(); break; case 776: -#line 5154 "cs-parser.jay" +#line 5155 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 777: -#line 5155 "cs-parser.jay" +#line 5156 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 778: @@ -3521,7 +3521,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_785(); break; case 786: -#line 5230 "cs-parser.jay" +#line 5231 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); } @@ -3545,13 +3545,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_793(); break; case 794: -#line 5281 "cs-parser.jay" +#line 5282 "cs-parser.jay" { current_block = current_block.CreateSwitchBlock (lexer.Location); } break; case 795: -#line 5285 "cs-parser.jay" +#line 5286 "cs-parser.jay" { yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); } @@ -3569,7 +3569,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_799(); break; case 800: -#line 5319 "cs-parser.jay" +#line 5320 "cs-parser.jay" { yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } @@ -3593,7 +3593,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_810(); break; case 811: -#line 5380 "cs-parser.jay" +#line 5381 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3602,7 +3602,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_812(); break; case 813: -#line 5395 "cs-parser.jay" +#line 5396 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3614,7 +3614,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_815(); break; case 816: -#line 5416 "cs-parser.jay" +#line 5417 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3629,7 +3629,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_819(); break; case 820: -#line 5449 "cs-parser.jay" +#line 5451 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; case 822: @@ -3639,11 +3639,11 @@ internal Object yyparse (yyParser.yyInput yyLex) case_823(); break; case 825: -#line 5470 "cs-parser.jay" +#line 5472 "cs-parser.jay" { yyVal = null; } break; case 827: -#line 5475 "cs-parser.jay" +#line 5477 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; case 831: @@ -3704,7 +3704,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_855(); break; case 858: -#line 5692 "cs-parser.jay" +#line 5694 "cs-parser.jay" { yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); } @@ -3725,7 +3725,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_863(); break; case 866: -#line 5742 "cs-parser.jay" +#line 5744 "cs-parser.jay" { yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3734,7 +3734,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_867(); break; case 868: -#line 5761 "cs-parser.jay" +#line 5763 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } @@ -3743,13 +3743,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_869(); break; case 870: -#line 5779 "cs-parser.jay" +#line 5781 "cs-parser.jay" { yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 871: -#line 5786 "cs-parser.jay" +#line 5788 "cs-parser.jay" { yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3758,7 +3758,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_872(); break; case 873: -#line 5796 "cs-parser.jay" +#line 5798 "cs-parser.jay" { yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } @@ -3797,7 +3797,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_885(); break; case 886: -#line 5901 "cs-parser.jay" +#line 5903 "cs-parser.jay" { Error_MissingInitializer (lexer.Location); } @@ -3830,7 +3830,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_895(); break; case 896: -#line 6006 "cs-parser.jay" +#line 6008 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3839,7 +3839,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_897(); break; case 898: -#line 6022 "cs-parser.jay" +#line 6024 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3860,7 +3860,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_904(); break; case 905: -#line 6086 "cs-parser.jay" +#line 6088 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3881,7 +3881,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_911(); break; case 917: -#line 6140 "cs-parser.jay" +#line 6142 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3890,7 +3890,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_918(); break; case 919: -#line 6159 "cs-parser.jay" +#line 6161 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3926,7 +3926,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_930(); break; case 931: -#line 6313 "cs-parser.jay" +#line 6315 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3947,7 +3947,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_938(); break; case 939: -#line 6359 "cs-parser.jay" +#line 6361 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } @@ -3959,7 +3959,7 @@ internal Object yyparse (yyParser.yyInput yyLex) case_941(); break; case 942: -#line 6376 "cs-parser.jay" +#line 6378 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } @@ -3983,13 +3983,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_951(); break; case 959: -#line 6498 "cs-parser.jay" +#line 6500 "cs-parser.jay" { module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; } break; case 960: -#line 6505 "cs-parser.jay" +#line 6507 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; } @@ -4001,13 +4001,13 @@ internal Object yyparse (yyParser.yyInput yyLex) case_962(); break; case 963: -#line 6522 "cs-parser.jay" +#line 6524 "cs-parser.jay" { yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], MemberCache.IndexerNameAlias, Location.Null); } break; case 964: -#line 6526 "cs-parser.jay" +#line 6528 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -4025,25 +4025,25 @@ internal Object yyparse (yyParser.yyInput yyLex) case_968(); break; case 970: -#line 6562 "cs-parser.jay" +#line 6564 "cs-parser.jay" { yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); } break; case 972: -#line 6570 "cs-parser.jay" +#line 6572 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; case 973: -#line 6574 "cs-parser.jay" +#line 6576 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 974: -#line 6581 "cs-parser.jay" +#line 6583 "cs-parser.jay" { yyVal = new List (0); } @@ -6435,68 +6435,69 @@ void case_454() void case_455() #line 3329 "cs-parser.jay" { + lexer.putback (')'); /* TODO: Wrong but what can I do*/ Error_SyntaxError (yyToken); yyVal = yyVals[-2+yyTop]; } void case_456() -#line 3334 "cs-parser.jay" +#line 3335 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } void case_461() -#line 3355 "cs-parser.jay" +#line 3356 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_462() -#line 3360 "cs-parser.jay" +#line 3361 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_463() -#line 3365 "cs-parser.jay" +#line 3366 "cs-parser.jay" { yyVal = new Argument (new Arglist ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]))); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_464() -#line 3370 "cs-parser.jay" +#line 3371 "cs-parser.jay" { yyVal = new Argument (new Arglist (GetLocation (yyVals[-2+yyTop]))); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_466() -#line 3382 "cs-parser.jay" +#line 3383 "cs-parser.jay" { yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_467() -#line 3387 "cs-parser.jay" +#line 3388 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); } void case_468() -#line 3392 "cs-parser.jay" +#line 3393 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess ((Expression) yyVals[-2+yyTop], null, GetLocation (yyVals[-1+yyTop])); } void case_469() -#line 3400 "cs-parser.jay" +#line 3401 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); @@ -6504,7 +6505,7 @@ void case_469() } void case_470() -#line 3406 "cs-parser.jay" +#line 3407 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6513,14 +6514,14 @@ void case_470() } void case_471() -#line 3412 "cs-parser.jay" +#line 3413 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } void case_472() -#line 3420 "cs-parser.jay" +#line 3421 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); @@ -6528,7 +6529,7 @@ void case_472() } void case_473() -#line 3426 "cs-parser.jay" +#line 3427 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6540,21 +6541,21 @@ void case_473() } void case_477() -#line 3454 "cs-parser.jay" +#line 3455 "cs-parser.jay" { yyVal = new ElementAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_478() -#line 3459 "cs-parser.jay" +#line 3460 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } void case_481() -#line 3481 "cs-parser.jay" +#line 3482 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) @@ -6569,7 +6570,7 @@ void case_481() } void case_482() -#line 3494 "cs-parser.jay" +#line 3495 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); @@ -6578,7 +6579,7 @@ void case_482() } void case_483() -#line 3506 "cs-parser.jay" +#line 3507 "cs-parser.jay" { yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List) yyVals[-3+yyTop], new ComposedTypeSpecifier (((List) yyVals[-3+yyTop]).Count, GetLocation (yyVals[-4+yyTop])) { @@ -6588,7 +6589,7 @@ void case_483() } void case_484() -#line 3514 "cs-parser.jay" +#line 3515 "cs-parser.jay" { if (yyVals[0+yyTop] == null) report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6597,7 +6598,7 @@ void case_484() } void case_485() -#line 3521 "cs-parser.jay" +#line 3522 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); @@ -6606,14 +6607,14 @@ void case_485() } void case_486() -#line 3528 "cs-parser.jay" +#line 3529 "cs-parser.jay" { report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop])); } void case_487() -#line 3533 "cs-parser.jay" +#line 3534 "cs-parser.jay" { Error_SyntaxError (yyToken); /* It can be any of new expression, create the most common one*/ @@ -6621,14 +6622,14 @@ void case_487() } void case_489() -#line 3545 "cs-parser.jay" +#line 3546 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } void case_490() -#line 3553 "cs-parser.jay" +#line 3554 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); @@ -6640,7 +6641,7 @@ void case_490() } void case_495() -#line 3576 "cs-parser.jay" +#line 3577 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6648,7 +6649,7 @@ void case_495() } void case_496() -#line 3582 "cs-parser.jay" +#line 3583 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6658,7 +6659,7 @@ void case_496() } void case_497() -#line 3593 "cs-parser.jay" +#line 3594 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop]; yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location); @@ -6666,7 +6667,7 @@ void case_497() } void case_498() -#line 3599 "cs-parser.jay" +#line 3600 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location), @@ -6674,14 +6675,14 @@ void case_498() } void case_499() -#line 3605 "cs-parser.jay" +#line 3606 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } void case_500() -#line 3610 "cs-parser.jay" +#line 3611 "cs-parser.jay" { report.Error (746, lexer.Location, "Invalid anonymous type member declarator. Anonymous type members must be a member assignment, simple name or member access expression"); @@ -6689,28 +6690,28 @@ void case_500() } void case_504() -#line 3625 "cs-parser.jay" +#line 3626 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_505() -#line 3633 "cs-parser.jay" +#line 3634 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_506() -#line 3638 "cs-parser.jay" +#line 3639 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_511() -#line 3668 "cs-parser.jay" +#line 3669 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6719,7 +6720,7 @@ void case_511() } void case_512() -#line 3675 "cs-parser.jay" +#line 3676 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6732,7 +6733,7 @@ void case_512() } void case_513() -#line 3689 "cs-parser.jay" +#line 3690 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); @@ -6740,7 +6741,7 @@ void case_513() } void case_514() -#line 3695 "cs-parser.jay" +#line 3696 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6749,7 +6750,7 @@ void case_514() } void case_516() -#line 3709 "cs-parser.jay" +#line 3710 "cs-parser.jay" { lexer.TypeOfParsing = false; yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -6757,14 +6758,14 @@ void case_516() } void case_519() -#line 3720 "cs-parser.jay" +#line 3721 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } void case_520() -#line 3728 "cs-parser.jay" +#line 3729 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6772,7 +6773,7 @@ void case_520() } void case_521() -#line 3734 "cs-parser.jay" +#line 3735 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6782,7 +6783,7 @@ void case_521() } void case_522() -#line 3742 "cs-parser.jay" +#line 3743 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6792,7 +6793,7 @@ void case_522() } void case_523() -#line 3750 "cs-parser.jay" +#line 3751 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6802,7 +6803,7 @@ void case_523() } void case_524() -#line 3758 "cs-parser.jay" +#line 3759 "cs-parser.jay" { var tne = (ATypeNameExpression) yyVals[-3+yyTop]; if (tne.HasTypeArguments) @@ -6815,7 +6816,7 @@ void case_524() } void case_525() -#line 3772 "cs-parser.jay" +#line 3773 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); @@ -6824,7 +6825,7 @@ void case_525() } void case_526() -#line 3782 "cs-parser.jay" +#line 3783 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; if (lang_version == LanguageVersion.ISO_1) @@ -6834,35 +6835,35 @@ void case_526() } void case_527() -#line 3793 "cs-parser.jay" +#line 3794 "cs-parser.jay" { yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_528() -#line 3801 "cs-parser.jay" +#line 3802 "cs-parser.jay" { yyVal = new CheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_529() -#line 3809 "cs-parser.jay" +#line 3810 "cs-parser.jay" { yyVal = new UnCheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_530() -#line 3817 "cs-parser.jay" +#line 3818 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-3+yyTop], GetLocation (yyVals[-2+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); } void case_532() -#line 3829 "cs-parser.jay" +#line 3830 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); if ((ParametersCompiled) yyVals[-2+yyTop] != ParametersCompiled.Undefined) { @@ -6873,7 +6874,7 @@ void case_532() } void case_534() -#line 3842 "cs-parser.jay" +#line 3843 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); @@ -6885,7 +6886,7 @@ void case_534() } void case_538() -#line 3867 "cs-parser.jay" +#line 3868 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; @@ -6894,7 +6895,7 @@ void case_538() } void case_539() -#line 3877 "cs-parser.jay" +#line 3878 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); @@ -6904,14 +6905,14 @@ void case_539() } void case_543() -#line 3897 "cs-parser.jay" +#line 3898 "cs-parser.jay" { yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_544() -#line 3902 "cs-parser.jay" +#line 3903 "cs-parser.jay" { if (!async_block) { if (current_anonymous_method is LambdaExpression) { @@ -6932,133 +6933,133 @@ void case_544() } void case_553() -#line 3957 "cs-parser.jay" +#line 3958 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_554() -#line 3962 "cs-parser.jay" +#line 3963 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_555() -#line 3967 "cs-parser.jay" +#line 3968 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_557() -#line 3976 "cs-parser.jay" +#line 3977 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_559() -#line 3985 "cs-parser.jay" +#line 3986 "cs-parser.jay" { /* Shift/Reduce conflict*/ yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_563() -#line 4002 "cs-parser.jay" +#line 4003 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_564() -#line 4007 "cs-parser.jay" +#line 4008 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_566() -#line 4016 "cs-parser.jay" +#line 4017 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_567() -#line 4021 "cs-parser.jay" +#line 4022 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_568() -#line 4026 "cs-parser.jay" +#line 4027 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_569() -#line 4031 "cs-parser.jay" +#line 4032 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_571() -#line 4040 "cs-parser.jay" +#line 4041 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_572() -#line 4045 "cs-parser.jay" +#line 4046 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_574() -#line 4054 "cs-parser.jay" +#line 4055 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_576() -#line 4063 "cs-parser.jay" +#line 4064 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_578() -#line 4072 "cs-parser.jay" +#line 4073 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_580() -#line 4081 "cs-parser.jay" +#line 4082 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_582() -#line 4090 "cs-parser.jay" +#line 4091 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_584() -#line 4099 "cs-parser.jay" +#line 4100 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); @@ -7067,91 +7068,91 @@ void case_584() } void case_586() -#line 4110 "cs-parser.jay" +#line 4111 "cs-parser.jay" { yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_587() -#line 4115 "cs-parser.jay" +#line 4116 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-3+yyTop]), (Expression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } void case_589() -#line 4127 "cs-parser.jay" +#line 4128 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_590() -#line 4132 "cs-parser.jay" +#line 4133 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_591() -#line 4137 "cs-parser.jay" +#line 4138 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_592() -#line 4142 "cs-parser.jay" +#line 4143 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_593() -#line 4147 "cs-parser.jay" +#line 4148 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_594() -#line 4152 "cs-parser.jay" +#line 4153 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_595() -#line 4157 "cs-parser.jay" +#line 4158 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_596() -#line 4162 "cs-parser.jay" +#line 4163 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_597() -#line 4167 "cs-parser.jay" +#line 4168 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_598() -#line 4172 "cs-parser.jay" +#line 4173 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_599() -#line 4180 "cs-parser.jay" +#line 4181 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -7160,7 +7161,7 @@ void case_599() } void case_600() -#line 4187 "cs-parser.jay" +#line 4188 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -7175,7 +7176,7 @@ void case_600() } void case_601() -#line 4203 "cs-parser.jay" +#line 4204 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -7183,7 +7184,7 @@ void case_601() } void case_602() -#line 4209 "cs-parser.jay" +#line 4210 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -7191,14 +7192,14 @@ void case_602() } void case_603() -#line 4215 "cs-parser.jay" +#line 4216 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } void case_605() -#line 4223 "cs-parser.jay" +#line 4224 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); @@ -7206,7 +7207,7 @@ void case_605() } void case_609() -#line 4240 "cs-parser.jay" +#line 4241 "cs-parser.jay" { Block b = end_block (Location.Null); b.IsCompilerGenerated = true; @@ -7215,14 +7216,14 @@ void case_609() } void case_611() -#line 4251 "cs-parser.jay" +#line 4252 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } void case_612() -#line 4259 "cs-parser.jay" +#line 4260 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); @@ -7230,14 +7231,14 @@ void case_612() } void case_613() -#line 4265 "cs-parser.jay" +#line 4266 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } void case_614() -#line 4270 "cs-parser.jay" +#line 4271 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); @@ -7245,63 +7246,63 @@ void case_614() } void case_615() -#line 4276 "cs-parser.jay" +#line 4277 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_617() -#line 4285 "cs-parser.jay" +#line 4286 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], false, GetLocation (yyVals[-4+yyTop])); } void case_618() -#line 4290 "cs-parser.jay" +#line 4291 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_620() -#line 4299 "cs-parser.jay" +#line 4300 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], true, GetLocation (yyVals[-5+yyTop])); } void case_621() -#line 4304 "cs-parser.jay" +#line 4305 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_628() -#line 4327 "cs-parser.jay" +#line 4328 "cs-parser.jay" { yyVal = new RefValueExpr ((Expression) yyVals[-3+yyTop], (FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_629() -#line 4332 "cs-parser.jay" +#line 4333 "cs-parser.jay" { yyVal = new RefTypeExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_630() -#line 4337 "cs-parser.jay" +#line 4338 "cs-parser.jay" { yyVal = new MakeRefExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_634() -#line 4366 "cs-parser.jay" +#line 4367 "cs-parser.jay" { Class c = new Class (current_container, (MemberName) yyVals[0+yyTop], (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]); if (((c.ModFlags & Modifiers.STATIC) != 0) && lang_version == LanguageVersion.ISO_1) { @@ -7313,7 +7314,7 @@ void case_634() } void case_635() -#line 4377 "cs-parser.jay" +#line 4378 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -7329,7 +7330,7 @@ void case_635() } void case_636() -#line 4391 "cs-parser.jay" +#line 4392 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -7337,7 +7338,7 @@ void case_636() } void case_637() -#line 4397 "cs-parser.jay" +#line 4398 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -7348,7 +7349,7 @@ void case_637() } void case_640() -#line 4416 "cs-parser.jay" +#line 4417 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; @@ -7356,7 +7357,7 @@ void case_640() } void case_643() -#line 4430 "cs-parser.jay" +#line 4431 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -7374,7 +7375,7 @@ void case_643() } void case_644() -#line 4449 "cs-parser.jay" +#line 4450 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7384,91 +7385,91 @@ void case_644() } void case_645() -#line 4457 "cs-parser.jay" +#line 4458 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_646() -#line 4462 "cs-parser.jay" +#line 4463 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_647() -#line 4467 "cs-parser.jay" +#line 4468 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_648() -#line 4472 "cs-parser.jay" +#line 4473 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_649() -#line 4477 "cs-parser.jay" +#line 4478 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_650() -#line 4482 "cs-parser.jay" +#line 4483 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_651() -#line 4487 "cs-parser.jay" +#line 4488 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_652() -#line 4492 "cs-parser.jay" +#line 4493 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_653() -#line 4497 "cs-parser.jay" +#line 4498 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_654() -#line 4502 "cs-parser.jay" +#line 4503 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_655() -#line 4507 "cs-parser.jay" +#line 4508 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_656() -#line 4512 "cs-parser.jay" +#line 4513 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_657() -#line 4517 "cs-parser.jay" +#line 4518 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7477,21 +7478,21 @@ void case_657() } void case_658() -#line 4524 "cs-parser.jay" +#line 4525 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_660() -#line 4533 "cs-parser.jay" +#line 4534 "cs-parser.jay" { current_type.AddBasesForPart ((List) yyVals[0+yyTop]); lbag.AppendToMember (current_type, GetLocation (yyVals[-1+yyTop])); } void case_661() -#line 4538 "cs-parser.jay" +#line 4539 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7499,7 +7500,7 @@ void case_661() } void case_664() -#line 4555 "cs-parser.jay" +#line 4556 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); @@ -7507,7 +7508,7 @@ void case_664() } void case_665() -#line 4561 "cs-parser.jay" +#line 4562 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7525,7 +7526,7 @@ void case_665() } void case_666() -#line 4580 "cs-parser.jay" +#line 4581 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -7533,7 +7534,7 @@ void case_666() } void case_667() -#line 4586 "cs-parser.jay" +#line 4587 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7542,7 +7543,7 @@ void case_667() } void case_668() -#line 4596 "cs-parser.jay" +#line 4597 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -7550,7 +7551,7 @@ void case_668() } void case_669() -#line 4602 "cs-parser.jay" +#line 4603 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7576,7 +7577,7 @@ void case_669() } void case_670() -#line 4629 "cs-parser.jay" +#line 4630 "cs-parser.jay" { if (yyVals[0+yyTop] is ComposedCast) report.Error (706, GetLocation (yyVals[0+yyTop]), "Invalid constraint type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ()); @@ -7585,14 +7586,14 @@ void case_670() } void case_671() -#line 4636 "cs-parser.jay" +#line 4637 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Constructor, GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_675() -#line 4656 "cs-parser.jay" +#line 4657 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); @@ -7601,56 +7602,56 @@ void case_675() } void case_676() -#line 4666 "cs-parser.jay" +#line 4667 "cs-parser.jay" { yyVal = Variance.Covariant; savedLocation = GetLocation (yyVals[0+yyTop]); } void case_677() -#line 4671 "cs-parser.jay" +#line 4672 "cs-parser.jay" { yyVal = Variance.Contravariant; savedLocation = GetLocation (yyVals[0+yyTop]); } void case_678() -#line 4692 "cs-parser.jay" +#line 4693 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } void case_680() -#line 4704 "cs-parser.jay" +#line 4705 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } void case_681() -#line 4709 "cs-parser.jay" +#line 4710 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } void case_682() -#line 4718 "cs-parser.jay" +#line 4719 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } void case_683() -#line 4723 "cs-parser.jay" +#line 4724 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } void case_684() -#line 4727 "cs-parser.jay" +#line 4728 "cs-parser.jay" { report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol '}', expected '{'"); lexer.putback ('}'); @@ -7658,7 +7659,7 @@ void case_684() } void case_692() -#line 4756 "cs-parser.jay" +#line 4757 "cs-parser.jay" { Error_SyntaxError (yyToken); var lt =(Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -7668,42 +7669,42 @@ void case_692() } void case_693() -#line 4765 "cs-parser.jay" +#line 4766 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_726() -#line 4829 "cs-parser.jay" +#line 4830 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } void case_727() -#line 4834 "cs-parser.jay" +#line 4835 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } void case_728() -#line 4839 "cs-parser.jay" +#line 4840 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } void case_729() -#line 4847 "cs-parser.jay" +#line 4848 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } void case_730() -#line 4855 "cs-parser.jay" +#line 4856 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7713,7 +7714,7 @@ void case_730() } void case_733() -#line 4868 "cs-parser.jay" +#line 4869 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7722,7 +7723,7 @@ void case_733() } void case_734() -#line 4884 "cs-parser.jay" +#line 4885 "cs-parser.jay" { /* Ok, the above "primary_expression" is there to get rid of*/ /* both reduce/reduce and shift/reduces in the grammar, it should*/ @@ -7754,7 +7755,7 @@ void case_734() } void case_735() -#line 4914 "cs-parser.jay" +#line 4915 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7767,7 +7768,7 @@ void case_735() } void case_736() -#line 4925 "cs-parser.jay" +#line 4926 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7776,21 +7777,21 @@ void case_736() } void case_739() -#line 4940 "cs-parser.jay" +#line 4941 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_741() -#line 4949 "cs-parser.jay" +#line 4950 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_744() -#line 4965 "cs-parser.jay" +#line 4966 "cs-parser.jay" { if (async_block) { report.Error (4003, GetLocation (yyVals[0+yyTop]), "`await' cannot be used as an identifier within an async method or lambda expression"); @@ -7799,7 +7800,7 @@ void case_744() } void case_745() -#line 4975 "cs-parser.jay" +#line 4976 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7808,7 +7809,7 @@ void case_745() } void case_746() -#line 4982 "cs-parser.jay" +#line 4983 "cs-parser.jay" { yyVal = current_variable; current_variable = null; @@ -7816,7 +7817,7 @@ void case_746() } void case_747() -#line 4988 "cs-parser.jay" +#line 4989 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7825,7 +7826,7 @@ void case_747() } void case_748() -#line 4995 "cs-parser.jay" +#line 4996 "cs-parser.jay" { if (current_variable.Initializer != null) { lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); @@ -7837,7 +7838,7 @@ void case_748() } void case_750() -#line 5008 "cs-parser.jay" +#line 5009 "cs-parser.jay" { /* Redundant, but wont regress*/ report.Error (1525, lexer.Location, "Unexpected symbol }"); @@ -7846,14 +7847,14 @@ void case_750() } void case_752() -#line 5019 "cs-parser.jay" +#line 5020 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } void case_753() -#line 5024 "cs-parser.jay" +#line 5025 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7869,7 +7870,7 @@ void case_753() } void case_754() -#line 5038 "cs-parser.jay" +#line 5039 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7880,7 +7881,7 @@ void case_754() } void case_758() -#line 5056 "cs-parser.jay" +#line 5057 "cs-parser.jay" { foreach (var d in current_variable.Declarators) { if (d.Initializer == null) @@ -7889,7 +7890,7 @@ void case_758() } void case_761() -#line 5071 "cs-parser.jay" +#line 5072 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7900,7 +7901,7 @@ void case_761() } void case_762() -#line 5080 "cs-parser.jay" +#line 5081 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7911,14 +7912,14 @@ void case_762() } void case_764() -#line 5096 "cs-parser.jay" +#line 5097 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); current_variable.Initializer = (Expression) yyVals[0+yyTop]; } void case_769() -#line 5114 "cs-parser.jay" +#line 5115 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7929,28 +7930,28 @@ void case_769() } void case_771() -#line 5127 "cs-parser.jay" +#line 5128 "cs-parser.jay" { yyVal = new StackAlloc ((Expression) yyVals[-3+yyTop], (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_772() -#line 5132 "cs-parser.jay" +#line 5133 "cs-parser.jay" { report.Error (1575, GetLocation (yyVals[-1+yyTop]), "A stackalloc expression requires [] after type"); yyVal = new StackAlloc ((Expression) yyVals[0+yyTop], null, GetLocation (yyVals[-1+yyTop])); } void case_773() -#line 5140 "cs-parser.jay" +#line 5141 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_775() -#line 5146 "cs-parser.jay" +#line 5147 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; report.Error (1002, GetLocation (yyVals[0+yyTop]), "; expected"); @@ -7958,7 +7959,7 @@ void case_775() } void case_778() -#line 5164 "cs-parser.jay" +#line 5165 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { @@ -7970,7 +7971,7 @@ void case_778() } void case_779() -#line 5177 "cs-parser.jay" +#line 5178 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7980,14 +7981,14 @@ void case_779() } void case_780() -#line 5185 "cs-parser.jay" +#line 5186 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } void case_783() -#line 5199 "cs-parser.jay" +#line 5200 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7997,7 +7998,7 @@ void case_783() } void case_784() -#line 5208 "cs-parser.jay" +#line 5209 "cs-parser.jay" { yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); @@ -8009,7 +8010,7 @@ void case_784() } void case_785() -#line 5218 "cs-parser.jay" +#line 5219 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8018,7 +8019,7 @@ void case_785() } void case_787() -#line 5232 "cs-parser.jay" +#line 5233 "cs-parser.jay" { yyVal = new Switch ((Expression) yyVals[-5+yyTop], (ExplicitBlock) current_block.Explicit, (List) yyVals[-1+yyTop], GetLocation (yyVals[-7+yyTop])); end_block (GetLocation (yyVals[0+yyTop])); @@ -8026,7 +8027,7 @@ void case_787() } void case_788() -#line 5238 "cs-parser.jay" +#line 5239 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8035,14 +8036,14 @@ void case_788() } void case_789() -#line 5248 "cs-parser.jay" +#line 5249 "cs-parser.jay" { report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } void case_791() -#line 5257 "cs-parser.jay" +#line 5258 "cs-parser.jay" { var sections = new List (4); @@ -8051,7 +8052,7 @@ void case_791() } void case_792() -#line 5264 "cs-parser.jay" +#line 5265 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -8060,14 +8061,14 @@ void case_792() } void case_793() -#line 5271 "cs-parser.jay" +#line 5272 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } void case_796() -#line 5290 "cs-parser.jay" +#line 5291 "cs-parser.jay" { var labels = new List (2); @@ -8076,7 +8077,7 @@ void case_796() } void case_797() -#line 5297 "cs-parser.jay" +#line 5298 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -8085,21 +8086,21 @@ void case_797() } void case_798() -#line 5307 "cs-parser.jay" +#line 5308 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_799() -#line 5312 "cs-parser.jay" +#line 5313 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); } void case_805() -#line 5331 "cs-parser.jay" +#line 5332 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8109,7 +8110,7 @@ void case_805() } void case_806() -#line 5339 "cs-parser.jay" +#line 5340 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8118,21 +8119,21 @@ void case_806() } void case_807() -#line 5349 "cs-parser.jay" +#line 5350 "cs-parser.jay" { yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], GetLocation (yyVals[-6+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_808() -#line 5354 "cs-parser.jay" +#line 5355 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Do ((Statement) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } void case_809() -#line 5359 "cs-parser.jay" +#line 5360 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8141,7 +8142,7 @@ void case_809() } void case_810() -#line 5369 "cs-parser.jay" +#line 5370 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; @@ -8152,7 +8153,7 @@ void case_810() } void case_812() -#line 5386 "cs-parser.jay" +#line 5387 "cs-parser.jay" { For f = (For) yyVals[-2+yyTop]; f.Initializer = (Statement) yyVals[-1+yyTop]; @@ -8161,7 +8162,7 @@ void case_812() } void case_814() -#line 5396 "cs-parser.jay" +#line 5397 "cs-parser.jay" { report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol ')', expected ';'"); For f = (For) yyVals[-2+yyTop]; @@ -8171,7 +8172,7 @@ void case_814() } void case_815() -#line 5407 "cs-parser.jay" +#line 5408 "cs-parser.jay" { For f = (For) yyVals[-2+yyTop]; f.Condition = (BooleanExpression) yyVals[-1+yyTop]; @@ -8180,7 +8181,7 @@ void case_815() } void case_817() -#line 5417 "cs-parser.jay" +#line 5419 "cs-parser.jay" { report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol ')', expected ';'"); For f = (For) yyVals[-2+yyTop]; @@ -8190,7 +8191,7 @@ void case_817() } void case_818() -#line 5429 "cs-parser.jay" +#line 5431 "cs-parser.jay" { For f = (For) yyVals[-3+yyTop]; f.Iterator = (Statement) yyVals[-2+yyTop]; @@ -8205,14 +8206,14 @@ void case_818() } void case_819() -#line 5442 "cs-parser.jay" +#line 5444 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } void case_822() -#line 5455 "cs-parser.jay" +#line 5457 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -8221,14 +8222,14 @@ void case_822() } void case_823() -#line 5462 "cs-parser.jay" +#line 5464 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_831() -#line 5486 "cs-parser.jay" +#line 5488 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -8244,7 +8245,7 @@ void case_831() } void case_832() -#line 5503 "cs-parser.jay" +#line 5505 "cs-parser.jay" { report.Error (230, GetLocation (yyVals[-3+yyTop]), "Type and identifier are both required in a foreach statement"); @@ -8259,7 +8260,7 @@ void case_832() } void case_833() -#line 5516 "cs-parser.jay" +#line 5518 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8278,7 +8279,7 @@ void case_833() } void case_834() -#line 5533 "cs-parser.jay" +#line 5535 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -8289,7 +8290,7 @@ void case_834() } void case_835() -#line 5542 "cs-parser.jay" +#line 5544 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8302,7 +8303,7 @@ void case_835() } void case_836() -#line 5553 "cs-parser.jay" +#line 5555 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); current_block.IsCompilerGenerated = true; @@ -8317,7 +8318,7 @@ void case_836() } void case_837() -#line 5566 "cs-parser.jay" +#line 5568 "cs-parser.jay" { Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, null, GetLocation (yyVals[-3+yyTop])); current_block.AddStatement (f); @@ -8327,28 +8328,28 @@ void case_837() } void case_844() -#line 5586 "cs-parser.jay" +#line 5588 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_845() -#line 5594 "cs-parser.jay" +#line 5596 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_846() -#line 5599 "cs-parser.jay" +#line 5601 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); } void case_847() -#line 5607 "cs-parser.jay" +#line 5609 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new Goto (lt.Value, GetLocation (yyVals[-2+yyTop])); @@ -8356,49 +8357,49 @@ void case_847() } void case_848() -#line 5613 "cs-parser.jay" +#line 5615 "cs-parser.jay" { yyVal = new GotoCase ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_849() -#line 5618 "cs-parser.jay" +#line 5620 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_850() -#line 5626 "cs-parser.jay" +#line 5628 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_851() -#line 5631 "cs-parser.jay" +#line 5633 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Return (null, GetLocation (yyVals[-1+yyTop])); } void case_852() -#line 5639 "cs-parser.jay" +#line 5641 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_853() -#line 5644 "cs-parser.jay" +#line 5646 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Throw (null, GetLocation (yyVals[-1+yyTop])); } void case_854() -#line 5652 "cs-parser.jay" +#line 5654 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -8416,7 +8417,7 @@ void case_854() } void case_855() -#line 5668 "cs-parser.jay" +#line 5670 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -8432,14 +8433,14 @@ void case_855() } void case_859() -#line 5694 "cs-parser.jay" +#line 5696 "cs-parser.jay" { yyVal = new TryFinally ((Statement) yyVals[-2+yyTop], (Block) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_860() -#line 5699 "cs-parser.jay" +#line 5701 "cs-parser.jay" { var loc = GetLocation (yyVals[-4+yyTop]); yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List) yyVals[-2+yyTop], loc, true), (Block) yyVals[0+yyTop], loc); @@ -8447,14 +8448,14 @@ void case_860() } void case_861() -#line 5705 "cs-parser.jay" +#line 5707 "cs-parser.jay" { Error_SyntaxError (1524, yyToken); yyVal = new TryCatch ((Block) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]), false); } void case_862() -#line 5713 "cs-parser.jay" +#line 5715 "cs-parser.jay" { var l = new List (2); @@ -8463,7 +8464,7 @@ void case_862() } void case_863() -#line 5720 "cs-parser.jay" +#line 5722 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -8477,7 +8478,7 @@ void case_863() } void case_867() -#line 5744 "cs-parser.jay" +#line 5746 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -8494,7 +8495,7 @@ void case_867() } void case_869() -#line 5763 "cs-parser.jay" +#line 5765 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { report.Error (1015, lexer.Location, @@ -8507,14 +8508,14 @@ void case_869() } void case_872() -#line 5791 "cs-parser.jay" +#line 5793 "cs-parser.jay" { if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } void case_874() -#line 5801 "cs-parser.jay" +#line 5803 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8524,7 +8525,7 @@ void case_874() } void case_875() -#line 5809 "cs-parser.jay" +#line 5811 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8533,7 +8534,7 @@ void case_875() } void case_876() -#line 5819 "cs-parser.jay" +#line 5821 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8545,14 +8546,14 @@ void case_876() } void case_877() -#line 5829 "cs-parser.jay" +#line 5831 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_878() -#line 5834 "cs-parser.jay" +#line 5836 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8564,7 +8565,7 @@ void case_878() } void case_879() -#line 5847 "cs-parser.jay" +#line 5849 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8576,14 +8577,14 @@ void case_879() } void case_880() -#line 5857 "cs-parser.jay" +#line 5859 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_881() -#line 5862 "cs-parser.jay" +#line 5864 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8595,7 +8596,7 @@ void case_881() } void case_882() -#line 5872 "cs-parser.jay" +#line 5874 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8605,7 +8606,7 @@ void case_882() } void case_883() -#line 5880 "cs-parser.jay" +#line 5882 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8614,14 +8615,14 @@ void case_883() } void case_885() -#line 5891 "cs-parser.jay" +#line 5893 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); } void case_887() -#line 5903 "cs-parser.jay" +#line 5905 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); @@ -8629,7 +8630,7 @@ void case_887() } void case_888() -#line 5915 "cs-parser.jay" +#line 5917 "cs-parser.jay" { lexer.query_parsing = false; @@ -8643,7 +8644,7 @@ void case_888() } void case_889() -#line 5927 "cs-parser.jay" +#line 5929 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -8655,7 +8656,7 @@ void case_889() } void case_890() -#line 5938 "cs-parser.jay" +#line 5940 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -8665,7 +8666,7 @@ void case_890() } void case_891() -#line 5945 "cs-parser.jay" +#line 5947 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); @@ -8673,7 +8674,7 @@ void case_891() } void case_892() -#line 5954 "cs-parser.jay" +#line 5956 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8685,7 +8686,7 @@ void case_892() } void case_893() -#line 5964 "cs-parser.jay" +#line 5966 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8699,7 +8700,7 @@ void case_893() } void case_894() -#line 5979 "cs-parser.jay" +#line 5981 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8711,7 +8712,7 @@ void case_894() } void case_895() -#line 5989 "cs-parser.jay" +#line 5991 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8725,7 +8726,7 @@ void case_895() } void case_897() -#line 6008 "cs-parser.jay" +#line 6010 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8739,7 +8740,7 @@ void case_897() } void case_899() -#line 6024 "cs-parser.jay" +#line 6026 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8757,7 +8758,7 @@ void case_899() } void case_900() -#line 6043 "cs-parser.jay" +#line 6045 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -8774,7 +8775,7 @@ void case_900() } void case_901() -#line 6058 "cs-parser.jay" +#line 6060 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[0+yyTop]; @@ -8788,21 +8789,21 @@ void case_901() } void case_903() -#line 6071 "cs-parser.jay" +#line 6073 "cs-parser.jay" { report.Error (742, GetLocation (yyVals[0+yyTop]), "Unexpected symbol `{0}'. A query body must end with select or group clause", GetSymbolName (yyToken)); yyVal = yyVals[-1+yyTop]; } void case_904() -#line 6076 "cs-parser.jay" +#line 6078 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_906() -#line 6088 "cs-parser.jay" +#line 6090 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8811,7 +8812,7 @@ void case_906() } void case_907() -#line 6095 "cs-parser.jay" +#line 6097 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8821,7 +8822,7 @@ void case_907() } void case_908() -#line 6103 "cs-parser.jay" +#line 6105 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8830,7 +8831,7 @@ void case_908() } void case_909() -#line 6110 "cs-parser.jay" +#line 6112 "cs-parser.jay" { yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-3+yyTop], linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); @@ -8840,14 +8841,14 @@ void case_909() } void case_911() -#line 6122 "cs-parser.jay" +#line 6124 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_918() -#line 6142 "cs-parser.jay" +#line 6144 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8861,7 +8862,7 @@ void case_918() } void case_920() -#line 6161 "cs-parser.jay" +#line 6163 "cs-parser.jay" { yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8870,7 +8871,7 @@ void case_920() } void case_921() -#line 6171 "cs-parser.jay" +#line 6173 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8880,7 +8881,7 @@ void case_921() } void case_922() -#line 6179 "cs-parser.jay" +#line 6181 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8890,7 +8891,7 @@ void case_922() } void case_923() -#line 6187 "cs-parser.jay" +#line 6189 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8900,7 +8901,7 @@ void case_923() } void case_924() -#line 6195 "cs-parser.jay" +#line 6197 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8940,7 +8941,7 @@ void case_924() } void case_925() -#line 6233 "cs-parser.jay" +#line 6235 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8950,7 +8951,7 @@ void case_925() } void case_926() -#line 6241 "cs-parser.jay" +#line 6243 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8960,7 +8961,7 @@ void case_926() } void case_927() -#line 6249 "cs-parser.jay" +#line 6251 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8970,7 +8971,7 @@ void case_927() } void case_928() -#line 6257 "cs-parser.jay" +#line 6259 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -9014,14 +9015,14 @@ void case_928() } void case_930() -#line 6303 "cs-parser.jay" +#line 6305 "cs-parser.jay" { opt_intoStack.Push (GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } void case_932() -#line 6315 "cs-parser.jay" +#line 6317 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -9030,7 +9031,7 @@ void case_932() } void case_934() -#line 6326 "cs-parser.jay" +#line 6328 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -9039,14 +9040,14 @@ void case_934() } void case_935() -#line 6333 "cs-parser.jay" +#line 6335 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } void case_937() -#line 6342 "cs-parser.jay" +#line 6344 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -9055,42 +9056,42 @@ void case_937() } void case_938() -#line 6349 "cs-parser.jay" +#line 6351 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } void case_940() -#line 6361 "cs-parser.jay" +#line 6363 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_941() -#line 6366 "cs-parser.jay" +#line 6368 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_943() -#line 6378 "cs-parser.jay" +#line 6380 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_944() -#line 6383 "cs-parser.jay" +#line 6385 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_946() -#line 6393 "cs-parser.jay" +#line 6395 "cs-parser.jay" { /* query continuation block is not linked with query block but with block*/ /* before. This means each query can use same range variable names for*/ @@ -9108,7 +9109,7 @@ void case_946() } void case_947() -#line 6409 "cs-parser.jay" +#line 6411 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -9119,7 +9120,7 @@ void case_947() } void case_950() -#line 6436 "cs-parser.jay" +#line 6438 "cs-parser.jay" { current_container = current_type = new Class (current_container, new MemberName (""), Modifiers.PUBLIC, null); @@ -9149,7 +9150,7 @@ void case_950() } void case_951() -#line 6464 "cs-parser.jay" +#line 6466 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); @@ -9161,7 +9162,7 @@ void case_951() } void case_961() -#line 6507 "cs-parser.jay" +#line 6509 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -9169,7 +9170,7 @@ void case_961() } void case_962() -#line 6513 "cs-parser.jay" +#line 6515 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -9178,14 +9179,14 @@ void case_962() } void case_965() -#line 6528 "cs-parser.jay" +#line 6530 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], MemberCache.IndexerNameAlias, Location.Null); } void case_966() -#line 6533 "cs-parser.jay" +#line 6535 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -9195,7 +9196,7 @@ void case_966() } void case_967() -#line 6541 "cs-parser.jay" +#line 6543 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -9205,7 +9206,7 @@ void case_967() } void case_968() -#line 6549 "cs-parser.jay" +#line 6551 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); module.DocumentationBuilder.ParsedParameters = p; @@ -9214,7 +9215,7 @@ void case_968() } void case_976() -#line 6587 "cs-parser.jay" +#line 6589 "cs-parser.jay" { var parameters = new List (); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); @@ -9222,7 +9223,7 @@ void case_976() } void case_977() -#line 6593 "cs-parser.jay" +#line 6595 "cs-parser.jay" { var parameters = yyVals[-2+yyTop] as List; parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); @@ -9230,7 +9231,7 @@ void case_977() } void case_978() -#line 6602 "cs-parser.jay" +#line 6604 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); @@ -12715,7 +12716,7 @@ void case_978() -1, -1, -1, -1, -1, 362, }; -#line 6611 "cs-parser.jay" +#line 6613 "cs-parser.jay" // // A class used to hold info about an operator declarator diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay index 6e2e26750..fe728c9b7 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay @@ -3327,6 +3327,7 @@ argument_list } | argument_list COMMA error { + lexer.putback (')'); // TODO: Wrong but what can I do Error_SyntaxError (yyToken); $$ = $1; } @@ -5414,6 +5415,7 @@ for_statement_condition { $$ = $4; } + | boolean_expression CLOSE_PARENS { report.Error (1525, GetLocation ($2), "Unexpected symbol ')', expected ';'"); For f = (For) $0; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs index 2d2dcf8ff..19c79512f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs @@ -945,6 +945,15 @@ public enum StateFlags GenericTask = 1 << 22 } + // + // Some flags can be copied directly from other member + // + protected const StateFlags SharedStateFlags = + StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected | + StateFlags.Obsolete | StateFlags.Obsolete_Undetected | + StateFlags.MissingDependency | StateFlags.MissingDependency_Undetected | + StateFlags.HasDynamicElement; + protected Modifiers modifiers; public StateFlags state; protected IMemberDefinition definition; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs index 4ccc3c3e9..210a5fbb5 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs @@ -2777,8 +2777,14 @@ protected MethodSpec CandidateToBaseOverride (ResolveContext rc, MethodSpec meth } } - // TODO: For now we do it for any hoisted call even if it's needed for - // hoisted stories only but that requires a new expression wrapper + // + // When base access is used inside anonymous method/iterator/etc we need to + // get back to the context of original type. We do it by emiting proxy + // method in original class and rewriting base call to this compiler + // generated method call which does the actual base invocation. This may + // introduce redundant storey but with `this' only but it's tricky to avoid + // at this stage as we don't know what expressions follow base + // if (rc.CurrentAnonymousMethod != null) { if (targs == null && method.IsGeneric) { targs = method.TypeArguments; @@ -2792,8 +2798,9 @@ protected MethodSpec CandidateToBaseOverride (ResolveContext rc, MethodSpec meth // Ideally this should apply to any proxy rewrite but in the case of unary mutators on // get/set member expressions second call would fail to proxy because left expression - // would be of 'this' and not 'base' - if (rc.CurrentType.IsStruct) + // would be of 'this' and not 'base' because we share InstanceExpression for get/set + // FIXME: The async check is another hack but will probably fail with mutators + if (rc.CurrentType.IsStruct || rc.CurrentAnonymousMethod.Storey is AsyncTaskStorey) InstanceExpression = new This (loc).Resolve (rc); } @@ -2993,12 +3000,15 @@ public bool ResolveInstanceExpression (ResolveContext rc, Expression rhs) if (me != null) { me.ResolveInstanceExpression (rc, rhs); - var fe = me as FieldExpr; - if (fe != null && fe.IsMarshalByRefAccess (rc)) { - rc.Report.SymbolRelatedToPreviousError (me.DeclaringType); - rc.Report.Warning (1690, 1, loc, - "Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class", - me.GetSignatureForError ()); + // Using this check to detect probing instance expression resolve + if (!rc.OmitStructFlowAnalysis) { + var fe = me as FieldExpr; + if (fe != null && fe.IsMarshalByRefAccess (rc)) { + rc.Report.SymbolRelatedToPreviousError (me.DeclaringType); + rc.Report.Warning (1690, 1, loc, + "Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class", + me.GetSignatureForError ()); + } } return true; @@ -3587,7 +3597,6 @@ public AmbiguousCandidate (MemberSpec member, AParametersCollection parameters, TypeSpec best_candidate_return_type; SessionReportPrinter lambda_conv_msgs; - ReportPrinter prev_recorder; public OverloadResolver (IList members, Restrictions restrictions, Location loc) : this (members, null, restrictions, loc) @@ -4045,6 +4054,7 @@ public static void Error_ConstructorMismatch (ResolveContext rc, TypeSpec type, // // A return value rates candidate method compatibility, // 0 = the best, int.MaxValue = the worst + // -1 = fatal error // int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref MemberSpec candidate, IParametersMember pm, ref bool params_expanded_form, ref bool dynamicArgument, ref TypeSpec returnType) { @@ -4166,6 +4176,18 @@ int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref arg_count = arguments.Count; } + // + // Don't do any expensive checks when the candidate cannot succeed + // + if (arg_count != param_count && !cpd.HasParams) + return (param_count - arg_count) * 2 + 1; + + var dep = candidate.GetMissingDependencies (); + if (dep != null) { + ImportedTypeDefinition.Error_MissingDependency (ec, dep, loc); + return -1; + } + // // 1. Handle generic method using type arguments when specified or type inference // @@ -4182,20 +4204,41 @@ int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref 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 + // + // Deploy custom error reporting for infered anonymous expression or lambda methods. When + // probing lambda methods keep all errors reported in separate set and once we are done and no best + // candidate was found use the set to report more details about what was wrong with lambda body. + // The general idea is to distinguish between code errors and errors caused by + // trial-and-error type inference + // if (lambda_conv_msgs == null) { - lambda_conv_msgs = new SessionReportPrinter (); - prev_recorder = ec.Report.SetPrinter (lambda_conv_msgs); + for (int i = 0; i < arg_count; i++) { + Argument a = arguments[i]; + if (a == null) + continue; + + var am = a.Expr as AnonymousMethodExpression; + if (am != null) { + if (lambda_conv_msgs == null) + lambda_conv_msgs = new SessionReportPrinter (); + + am.TypeInferenceReportPrinter = lambda_conv_msgs; + } + } } var ti = new TypeInference (arguments); TypeSpec[] i_args = ti.InferMethodArguments (ec, ms); - lambda_conv_msgs.EndSession (); if (i_args == null) return ti.InferenceScore - 20000; + // + // Clear any error messages when the result was success + // + if (lambda_conv_msgs != null) + lambda_conv_msgs.ClearSession (); + if (i_args.Length != 0) { ms = ms.MakeGenericMethod (ec, i_args); } @@ -4403,28 +4446,11 @@ int IsArgumentCompatible (ResolveContext ec, Argument argument, Parameter.Modifi if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; - // - // Deploy custom error reporting for lambda methods. When probing lambda methods - // keep all errors reported in separate set and once we are done and no best - // candidate was found, this set is used to report more details about what was wrong - // with lambda body - // - if (argument.Expr.Type == InternalType.AnonymousMethod) { - if (lambda_conv_msgs == null) { - lambda_conv_msgs = new SessionReportPrinter (); - prev_recorder = ec.Report.SetPrinter (lambda_conv_msgs); - } - } - // // Use implicit conversion in all modes to return same candidates when the expression // is used as argument or delegate conversion // if (!Convert.ImplicitConversionExists (ec, argument.Expr, parameter)) { - if (lambda_conv_msgs != null) { - lambda_conv_msgs.EndSession (); - } - return 2; } } @@ -4494,147 +4520,148 @@ public T ResolveMember (ResolveContext rc, ref Arguments args) where T : Memb bool error_mode = false; MemberSpec invocable_member = null; - // Be careful, cannot return until error reporter is restored while (true) { best_candidate = null; best_candidate_rate = int.MaxValue; var type_members = members; - try { + do { + for (int i = 0; i < type_members.Count; ++i) { + var member = type_members[i]; + + // + // Methods in a base class are not candidates if any method in a derived + // class is applicable + // + if ((member.Modifiers & Modifiers.OVERRIDE) != 0) + continue; + + if (!error_mode) { + if (!member.IsAccessible (rc)) + continue; - do { - for (int i = 0; i < type_members.Count; ++i) { - var member = type_members[i]; + if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc)) + continue; + if ((member.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED && + instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess (rc, member)) { + continue; + } + } + + IParametersMember pm = member as IParametersMember; + if (pm == null) { // - // Methods in a base class are not candidates if any method in a derived - // class is applicable + // Will use it later to report ambiguity between best method and invocable member // - if ((member.Modifiers & Modifiers.OVERRIDE) != 0) - continue; + if (Invocation.IsMemberInvocable (member)) + invocable_member = member; - if (!error_mode) { - if (!member.IsAccessible (rc)) - continue; + continue; + } - if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc)) - continue; + // + // Overload resolution is looking for base member but using parameter names + // and default values from the closest member. That means to do expensive lookup + // for the closest override for virtual or abstract members + // + if ((member.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) { + var override_params = base_provider.GetOverrideMemberParameters (member); + if (override_params != null) + pm = override_params; + } - if ((member.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED && - instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess (rc, member)) { + // + // Check if the member candidate is applicable + // + bool params_expanded_form = false; + bool dynamic_argument = false; + TypeSpec rt = pm.MemberType; + int candidate_rate = IsApplicable (rc, ref candidate_args, args_count, ref member, pm, ref params_expanded_form, ref dynamic_argument, ref rt); + + if (lambda_conv_msgs != null) + lambda_conv_msgs.EndSession (); + + // + // How does it score compare to others + // + if (candidate_rate < best_candidate_rate) { + + // Fatal error (missing dependency), cannot continue + if (candidate_rate < 0) + return null; + + best_candidate_rate = candidate_rate; + best_candidate = member; + best_candidate_args = candidate_args; + best_candidate_params = params_expanded_form; + best_candidate_dynamic = dynamic_argument; + best_parameter_member = pm; + best_candidate_return_type = rt; + } else if (candidate_rate == 0) { + // + // The member look is done per type for most operations but sometimes + // it's not possible like for binary operators overload because they + // are unioned between 2 sides + // + if ((restrictions & Restrictions.BaseMembersIncluded) != 0) { + if (TypeSpec.IsBaseClass (best_candidate.DeclaringType, member.DeclaringType, true)) continue; - } } - IParametersMember pm = member as IParametersMember; - if (pm == null) { + bool is_better; + if (best_candidate.DeclaringType.IsInterface && member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { // - // Will use it later to report ambiguity between best method and invocable member + // We pack all interface members into top level type which makes the overload resolution + // more complicated for interfaces. We compensate it by removing methods with same + // signature when building the cache hence this path should not really be hit often // - if (Invocation.IsMemberInvocable (member)) - invocable_member = member; + // Example: + // interface IA { void Foo (int arg); } + // interface IB : IA { void Foo (params int[] args); } + // + // IB::Foo is the best overload when calling IB.Foo (1) + // + is_better = true; + if (ambiguous_candidates != null) { + foreach (var amb_cand in ambiguous_candidates) { + if (member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { + continue; + } - continue; - } + is_better = false; + break; + } - // - // Overload resolution is looking for base member but using parameter names - // and default values from the closest member. That means to do expensive lookup - // for the closest override for virtual or abstract members - // - if ((member.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) { - var override_params = base_provider.GetOverrideMemberParameters (member); - if (override_params != null) - pm = override_params; + if (is_better) + ambiguous_candidates = null; + } + } else { + // Is the new candidate better + is_better = BetterFunction (rc, candidate_args, member, pm.Parameters, params_expanded_form, best_candidate, best_parameter_member.Parameters, best_candidate_params); } - // - // Check if the member candidate is applicable - // - bool params_expanded_form = false; - bool dynamic_argument = false; - TypeSpec rt = pm.MemberType; - int candidate_rate = IsApplicable (rc, ref candidate_args, args_count, ref member, pm, ref params_expanded_form, ref dynamic_argument, ref rt); - - // - // How does it score compare to others - // - if (candidate_rate < best_candidate_rate) { - best_candidate_rate = candidate_rate; + if (is_better) { best_candidate = member; best_candidate_args = candidate_args; best_candidate_params = params_expanded_form; best_candidate_dynamic = dynamic_argument; best_parameter_member = pm; best_candidate_return_type = rt; - } else if (candidate_rate == 0) { - // - // The member look is done per type for most operations but sometimes - // it's not possible like for binary operators overload because they - // are unioned between 2 sides - // - if ((restrictions & Restrictions.BaseMembersIncluded) != 0) { - if (TypeSpec.IsBaseClass (best_candidate.DeclaringType, member.DeclaringType, true)) - continue; - } - - bool is_better; - if (best_candidate.DeclaringType.IsInterface && member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { - // - // We pack all interface members into top level type which makes the overload resolution - // more complicated for interfaces. We compensate it by removing methods with same - // signature when building the cache hence this path should not really be hit often - // - // Example: - // interface IA { void Foo (int arg); } - // interface IB : IA { void Foo (params int[] args); } - // - // IB::Foo is the best overload when calling IB.Foo (1) - // - is_better = true; - if (ambiguous_candidates != null) { - foreach (var amb_cand in ambiguous_candidates) { - if (member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { - continue; - } - - is_better = false; - break; - } - - if (is_better) - ambiguous_candidates = null; - } - } else { - // Is the new candidate better - is_better = BetterFunction (rc, candidate_args, member, pm.Parameters, params_expanded_form, best_candidate, best_parameter_member.Parameters, best_candidate_params); - } + } else { + // It's not better but any other found later could be but we are not sure yet + if (ambiguous_candidates == null) + ambiguous_candidates = new List (); - if (is_better) { - best_candidate = member; - best_candidate_args = candidate_args; - best_candidate_params = params_expanded_form; - best_candidate_dynamic = dynamic_argument; - best_parameter_member = pm; - best_candidate_return_type = rt; - } else { - // It's not better but any other found later could be but we are not sure yet - if (ambiguous_candidates == null) - ambiguous_candidates = new List (); - - ambiguous_candidates.Add (new AmbiguousCandidate (member, pm.Parameters, params_expanded_form)); - } + ambiguous_candidates.Add (new AmbiguousCandidate (member, pm.Parameters, params_expanded_form)); } - - // Restore expanded arguments - if (candidate_args != args) - candidate_args = args; } - } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null); - } finally { - if (prev_recorder != null) - rc.Report.SetPrinter (prev_recorder); - } + + // Restore expanded arguments + if (candidate_args != args) + candidate_args = args; + } + } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null); // // We've found exact match @@ -4744,11 +4771,6 @@ public T ResolveMember (ResolveContext rc, ref Arguments args) where T : Memb if (oa != null && !rc.IsObsolete) AttributeTester.Report_ObsoleteMessage (oa, best_candidate.GetSignatureForError (), loc, rc.Report); - var dep = best_candidate.GetMissingDependencies (); - if (dep != null) { - ImportedTypeDefinition.Error_MissingDependency (rc, dep, loc); - } - best_candidate.MemberDefinition.SetIsUsed (); args = best_candidate_args; @@ -4825,9 +4847,8 @@ void ReportOverloadError (ResolveContext rc, MemberSpec best_candidate, IParamet return; } - if (lambda_conv_msgs != null) { - if (lambda_conv_msgs.Merge (rc.Report.Printer)) - return; + if (lambda_conv_msgs != null && lambda_conv_msgs.Merge (rc.Report.Printer)) { + return; } @@ -5279,7 +5300,7 @@ Expression DoResolve (ResolveContext ec, Expression rhs) if (lvalue_instance && var != null && var.VariableInfo != null) { var.VariableInfo.SetStructFieldAssigned (ec, Name); } - + if (fb != null) { IFixedExpression fe = InstanceExpression as IFixedExpression; if (!ec.HasSet (ResolveContext.Options.FixedInitializerScope) && (fe == null || !fe.IsFixed)) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs index 3091426b4..ead10fc33 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs @@ -6987,7 +6987,7 @@ public void CheckStructThisDefiniteAssignment (ResolveContext rc) if (variable_info == null) return; - if (rc.HasSet (ResolveContext.Options.OmitStructFlowAnalysis)) + if (rc.OmitStructFlowAnalysis) return; if (!variable_info.IsAssigned (rc)) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs index 6f1b92cbe..2922ff589 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs @@ -1488,7 +1488,9 @@ public InflatedTypeSpec (IModuleContext context, TypeSpec openType, TypeSpec dec if (targs == null) throw new ArgumentNullException ("targs"); -// this.state = openType.state; + this.state &= ~SharedStateFlags; + this.state |= (openType.state & SharedStateFlags); + this.context = context; this.open_type = openType; this.targs = targs; @@ -2289,7 +2291,7 @@ public static bool Check (IMemberContext mc, TypeSpec type, Location loc) // // Checks all type arguments againts type parameters constraints - // NOTE: It can run in probing mode when `mc' is null + // NOTE: It can run in probing mode when `this.mc' is null // public bool CheckAll (MemberSpec context, TypeSpec[] targs, TypeParameterSpec[] tparams, Location loc) { @@ -2342,15 +2344,6 @@ bool CheckConstraint (MemberSpec context, TypeSpec atype, TypeParameterSpec tpar // Check the class constraint // if (tparam.HasTypeConstraint) { - var dep = tparam.BaseType.GetMissingDependencies (); - if (dep != null) { - if (mc == null) - return false; - - ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc); - ok = false; - } - if (!CheckConversion (mc, context, atype, tparam, tparam.BaseType, loc)) { if (mc == null) return false; @@ -2364,19 +2357,6 @@ bool CheckConstraint (MemberSpec context, TypeSpec atype, TypeParameterSpec tpar // if (tparam.Interfaces != null) { foreach (TypeSpec iface in tparam.Interfaces) { - var dep = iface.GetMissingDependencies (); - if (dep != null) { - if (mc == null) - return false; - - ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc); - ok = false; - - // return immediately to avoid duplicate errors because we are scanning - // expanded interface list - return false; - } - if (!CheckConversion (mc, context, atype, tparam, iface, loc)) { if (mc == null) return false; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs index 541a407fa..da3e3d7c7 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs @@ -835,6 +835,13 @@ TypeSpec CreateType (MetaType type, TypeSpec declaringType, DynamicTypeReader dt import_cache.Add (type, spec); + if (kind == MemberKind.TypeParameter) { + if (canImportBaseType) + ImportTypeParameterTypeConstraints ((TypeParameterSpec) spec, type); + + return spec; + } + // // Two stage setup as the base type can be inflated declaring type or // another nested type inside same declaring type which has not been @@ -992,7 +999,6 @@ void ImportTypeBase (TypeSpec spec, MetaType type) ImportTypeParameterTypeConstraints (tp, tp.GetMetaInfo ()); } } - } protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool hasExtensionTypes) @@ -1796,7 +1802,15 @@ public static void Error_MissingDependency (IMemberContext ctx, List t // or referenced from the user core in which case compilation error has to // be reported because compiler cannot continue anyway // - foreach (var t in types) { + for (int i = 0; i < types.Count; ++i) { + var t = types [i]; + + // + // Report missing types only once per type + // + if (i > 0 && types.IndexOf (t) < i) + continue; + string name = t.GetSignatureForError (); if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs index 5f15beb0b..f3c847e1f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs @@ -496,6 +496,20 @@ public override List ResolveMissingDependencies () missing.AddRange (m); } + if (Arity > 0) { + foreach (var tp in GenericDefinition.TypeParameters) { + var m = tp.GetMissingDependencies (); + + if (m == null) + continue; + + if (missing == null) + missing = new List (); + + missing.AddRange (m); + } + } + return missing; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs index c2d4f3040..1da253c40 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs @@ -801,8 +801,10 @@ public override void AddTypeContainer (TypeContainer tc) name = mn.Name; } + var names_container = Parent == null ? Module : (TypeContainer) this; + MemberCore mc; - if (defined_names.TryGetValue (name, out mc)) { + if (names_container.DefinedNames.TryGetValue (name, out mc)) { if (tc is NamespaceContainer && mc is NamespaceContainer) { containers.Add (tc); return; @@ -816,7 +818,7 @@ public override void AddTypeContainer (TypeContainer tc) GetSignatureForError (), mn.GetSignatureForError ()); } } else { - defined_names.Add (name, tc); + names_container.DefinedNames.Add (name, tc); } base.AddTypeContainer (tc); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs index c72840cce..d53d724fb 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs @@ -1440,7 +1440,14 @@ public GetIndexerMethod (PropertyBase property, Modifiers modifiers, ParametersC public override MethodBuilder Define (TypeContainer parent) { - parameters.Resolve (this); + // Disable reporting, parameters are resolved twice + Report.DisableReporting (); + try { + parameters.Resolve (this); + } finally { + Report.EnableReporting (); + } + return base.Define (parent); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs index 50d78f007..f1b5ec65f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs @@ -644,6 +644,11 @@ class SessionReportPrinter : ReportPrinter bool showFullPaths; + public void ClearSession () + { + session_messages = null; + } + public override void Print (AbstractMessage msg, bool showFullPath) { // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs index 679a3ab1f..1de9b4e98 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs @@ -1565,7 +1565,7 @@ void Usage () " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + " -sdk:VERSION Specifies SDK version of referenced assemblies\n" + - " VERSION can be one of: 2, 4 (default) or custom value\n" + + " VERSION can be one of: 2, 4, 4.5 (default) or a custom value\n" + " -target:KIND Specifies the format of the output assembly (short: -t)\n" + " KIND can be one of: exe, winexe, library, module\n" + " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" + diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs index 4a71f027d..c6503a694 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs @@ -784,12 +784,10 @@ public virtual void Error_FinallyClause (Report Report) public sealed override bool Resolve (BlockContext ec) { - if (!DoResolve (ec)) - return false; - + var res = DoResolve (ec); unwind_protect = ec.CurrentBranching.AddReturnOrigin (ec.CurrentBranching.CurrentUsageVector, this); ec.CurrentBranching.CurrentUsageVector.Goto (); - return true; + return res; } } @@ -1438,6 +1436,7 @@ public Expression Initializer { protected FullNamedExpression type_expr; protected LocalVariable li; protected List declarators; + TypeSpec type; public BlockVariableDeclaration (FullNamedExpression type, LocalVariable li) { @@ -1514,8 +1513,7 @@ public override bool Resolve (BlockContext bc) public bool Resolve (BlockContext bc, bool resolveDeclaratorInitializers) { - if (li.Type == null) { - TypeSpec type = null; + if (type == null && !li.IsCompilerGenerated) { var vexpr = type_expr as VarExpr; // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs index 7ad55a4be..5df85f770 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs @@ -721,6 +721,18 @@ public override List ResolveMissingDependencies () } } + if (MemberDefinition.TypeParametersCount > 0) { + foreach (var tp in MemberDefinition.TypeParameters) { + var tp_missing = tp.GetMissingDependencies (); + if (tp_missing != null) { + if (missing == null) + missing = new List (); + + missing.AddRange (tp_missing); + } + } + } + if (missing != null || BaseType == null) return missing; @@ -1333,7 +1345,7 @@ class InternalType : TypeSpec, ITypeDefinition cache = MemberCache.Empty; // Make all internal types CLS-compliant, non-obsolete - state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected)) | StateFlags.CLSCompliant; + state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant; } #region Properties @@ -1454,11 +1466,8 @@ protected ElementTypeSpec (MemberKind kind, TypeSpec element, MetaType info) { this.Element = element; - // Some flags can be copied directly from the element - const StateFlags shared_flags = StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected - | StateFlags.Obsolete | StateFlags.Obsolete_Undetected | StateFlags.HasDynamicElement; - state &= ~shared_flags; - state |= (element.state & shared_flags); + state &= ~SharedStateFlags; + state |= (element.state & SharedStateFlags); if (element.BuiltinType == BuiltinTypeSpec.Type.Dynamic) state |= StateFlags.HasDynamicElement;