diff --git a/data/resources/image/BitmapResources/BitmapResources.res b/data/resources/image/BitmapResources/BitmapResources.res index be7a7add3e..5f527ec42b 100644 --- a/data/resources/image/BitmapResources/BitmapResources.res +++ b/data/resources/image/BitmapResources/BitmapResources.res @@ -267,6 +267,7 @@ Icons.16x16.SharpQuery.Remove = SharpQueryIcons\Icons.16x16.Sh Icons.16x16.NameSpace = ClassBrowserIcons\Icons.16x16.NameSpace.png Icons.16x16.Literal = ClassBrowserIcons\Icons.16x16.Literal.png Icons.16x16.Reference = ClassBrowserIcons\Icons.16x16.Reference.png +Icons.16x16.Keyword = ClassBrowserIcons\Icons.16x16.Keyword.png Icons.16x16.Class = ClassBrowserIcons\Icons.16x16.Class.png @@ -275,6 +276,7 @@ Icons.16x16.Enum = ClassBrowserIcons\Icons.16x1 Icons.16x16.Interface = ClassBrowserIcons\Icons.16x16.Interface.png Icons.16x16.Delegate = ClassBrowserIcons\Icons.16x16.Delegate.png Icons.16x16.Method = ClassBrowserIcons\Icons.16x16.Method.png +Icons.16x16.Operator = ClassBrowserIcons\Icons.16x16.Operator.png Icons.16x16.Property = ClassBrowserIcons\Icons.16x16.Property.png Icons.16x16.Indexer = ClassBrowserIcons\Icons.16x16.Indexer.png Icons.16x16.Field = ClassBrowserIcons\Icons.16x16.Field.png diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Keyword.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Keyword.png new file mode 100644 index 0000000000..c69cca8415 Binary files /dev/null and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Keyword.png differ diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Operator.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Operator.png new file mode 100644 index 0000000000..fda73d0895 Binary files /dev/null and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Operator.png differ diff --git a/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs b/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs index 4c126df80c..10d48da607 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs @@ -310,6 +310,9 @@ namespace ICSharpCode.NRefactory.Ast Modulus, Concat, + UnaryPlus, + UnaryMinus, + Not, BitNot, diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs index 81d47d05ce..a71c1c4d62 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -610,5 +610,70 @@ namespace ICSharpCode.NRefactory.Parser.CSharp item.Parent = parent; } } + + internal static string GetReflectionNameForOperator(OverloadableOperatorType op) + { + switch (op) { + case OverloadableOperatorType.Add: + return "op_Addition"; + case OverloadableOperatorType.BitNot: + return "op_OnesComplement"; + case OverloadableOperatorType.BitwiseAnd: + return "op_BitwiseAnd"; + case OverloadableOperatorType.BitwiseOr: + return "op_BitwiseOr"; + case OverloadableOperatorType.Concat: + case OverloadableOperatorType.CType: + return "op_unknown"; + case OverloadableOperatorType.Decrement: + return "op_Decrement"; + case OverloadableOperatorType.Divide: + return "op_Division"; + case OverloadableOperatorType.DivideInteger: + return "op_unknown"; + case OverloadableOperatorType.Equality: + return "op_Equality"; + case OverloadableOperatorType.ExclusiveOr: + return "op_ExclusiveOr"; + case OverloadableOperatorType.GreaterThan: + return "op_GreaterThan"; + case OverloadableOperatorType.GreaterThanOrEqual: + return "op_GreaterThanOrEqual"; + case OverloadableOperatorType.Increment: + return "op_Increment"; + case OverloadableOperatorType.InEquality: + return "op_Inequality"; + case OverloadableOperatorType.IsFalse: + return "op_False"; + case OverloadableOperatorType.IsTrue: + return "op_True"; + case OverloadableOperatorType.LessThan: + return "op_LessThan"; + case OverloadableOperatorType.LessThanOrEqual: + return "op_LessThanOrEqual"; + case OverloadableOperatorType.Like: + return "op_unknown"; + case OverloadableOperatorType.Modulus: + return "op_Modulus"; + case OverloadableOperatorType.Multiply: + return "op_Multiply"; + case OverloadableOperatorType.Not: + return "op_LogicalNot"; + case OverloadableOperatorType.Power: + return "op_unknown"; + case OverloadableOperatorType.ShiftLeft: + return "op_LeftShift"; + case OverloadableOperatorType.ShiftRight: + return "op_RightShift"; + case OverloadableOperatorType.Subtract: + return "op_Subtraction"; + case OverloadableOperatorType.UnaryMinus: + return "op_UnaryNegation"; + case OverloadableOperatorType.UnaryPlus: + return "op_UnaryPlus"; + default: + throw new NotSupportedException(); + } + } } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 6b8bcd688f..59627eabb5 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -487,68 +487,68 @@ out expr); } void Expr( -#line 1780 "cs.ATG" +#line 1786 "cs.ATG" out Expression expr) { -#line 1781 "cs.ATG" +#line 1787 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; -#line 1783 "cs.ATG" +#line 1789 "cs.ATG" Location startLocation = la.Location; UnaryExpr( -#line 1784 "cs.ATG" +#line 1790 "cs.ATG" out expr); if (StartOf(7)) { AssignmentOperator( -#line 1787 "cs.ATG" +#line 1793 "cs.ATG" out op); Expr( -#line 1787 "cs.ATG" +#line 1793 "cs.ATG" out expr1); -#line 1787 "cs.ATG" +#line 1793 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1788 "cs.ATG" +#line 1794 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1789 "cs.ATG" +#line 1795 "cs.ATG" out op); Expr( -#line 1789 "cs.ATG" +#line 1795 "cs.ATG" out expr1); -#line 1789 "cs.ATG" +#line 1795 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(8)) { ConditionalOrExpr( -#line 1791 "cs.ATG" +#line 1797 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1792 "cs.ATG" +#line 1798 "cs.ATG" out expr1); -#line 1792 "cs.ATG" +#line 1798 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1793 "cs.ATG" +#line 1799 "cs.ATG" out expr1); Expect(9); Expr( -#line 1793 "cs.ATG" +#line 1799 "cs.ATG" out expr2); -#line 1793 "cs.ATG" +#line 1799 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(150); -#line 1796 "cs.ATG" +#line 1802 "cs.ATG" if (expr != null) { expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; @@ -955,39 +955,39 @@ templates); } void TypeParameterList( -#line 2357 "cs.ATG" +#line 2363 "cs.ATG" List templates) { -#line 2359 "cs.ATG" +#line 2365 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2363 "cs.ATG" +#line 2369 "cs.ATG" out section); -#line 2363 "cs.ATG" +#line 2369 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2364 "cs.ATG" +#line 2370 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2365 "cs.ATG" +#line 2371 "cs.ATG" out section); -#line 2365 "cs.ATG" +#line 2371 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2366 "cs.ATG" +#line 2372 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -1020,22 +1020,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2370 "cs.ATG" +#line 2376 "cs.ATG" List templates) { -#line 2371 "cs.ATG" +#line 2377 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2374 "cs.ATG" +#line 2380 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2376 "cs.ATG" +#line 2382 "cs.ATG" out type); -#line 2377 "cs.ATG" +#line 2383 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1048,10 +1048,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2386 "cs.ATG" +#line 2392 "cs.ATG" out type); -#line 2387 "cs.ATG" +#line 2393 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1387,34 +1387,34 @@ out r, canBeUnbound); } void TypeName( -#line 2298 "cs.ATG" +#line 2304 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2299 "cs.ATG" +#line 2305 "cs.ATG" List typeArguments = null; string alias = null; string qualident; Location startLocation = la.Location; if ( -#line 2305 "cs.ATG" +#line 2311 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2306 "cs.ATG" +#line 2312 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2309 "cs.ATG" +#line 2315 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2310 "cs.ATG" +#line 2316 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2312 "cs.ATG" +#line 2318 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1425,26 +1425,26 @@ out typeArguments, canBeUnbound); } while ( -#line 2321 "cs.ATG" +#line 2327 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2322 "cs.ATG" +#line 2328 "cs.ATG" typeArguments = null; Qualident( -#line 2323 "cs.ATG" +#line 2329 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2324 "cs.ATG" +#line 2330 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2325 "cs.ATG" +#line 2331 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } -#line 2327 "cs.ATG" +#line 2333 "cs.ATG" typeRef.StartLocation = startLocation; } @@ -1570,23 +1570,23 @@ ModifierList m) { } void ClassMemberDecl( -#line 1054 "cs.ATG" +#line 1060 "cs.ATG" ModifierList m, List attributes) { -#line 1055 "cs.ATG" +#line 1061 "cs.ATG" Statement stmt = null; if (StartOf(21)) { StructMemberDecl( -#line 1057 "cs.ATG" +#line 1063 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 1058 "cs.ATG" +#line 1064 "cs.ATG" m.Check(Modifiers.Destructors); Location startPos = la.Location; lexer.NextToken(); Identifier(); -#line 1059 "cs.ATG" +#line 1065 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1594,17 +1594,17 @@ m, attributes); Expect(20); Expect(21); -#line 1063 "cs.ATG" +#line 1069 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1063 "cs.ATG" +#line 1069 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(160); -#line 1064 "cs.ATG" +#line 1070 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1930,6 +1930,7 @@ out stmt); List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Name = (isImplicit ? "op_Implicit" : "op_Explicit"), Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, @@ -1943,69 +1944,74 @@ out stmt); } else if (StartOf(22)) { TypeDecl( -#line 897 "cs.ATG" +#line 898 "cs.ATG" m, attributes); } else if (StartOf(10)) { Type( -#line 899 "cs.ATG" +#line 900 "cs.ATG" out type); -#line 899 "cs.ATG" +#line 900 "cs.ATG" Location startPos = t.Location; if (la.kind == 92) { -#line 901 "cs.ATG" +#line 902 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 905 "cs.ATG" +#line 906 "cs.ATG" out op); -#line 905 "cs.ATG" +#line 906 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( -#line 906 "cs.ATG" +#line 907 "cs.ATG" out firstType); Identifier(); -#line 906 "cs.ATG" +#line 907 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( -#line 907 "cs.ATG" +#line 908 "cs.ATG" out secondType); Identifier(); -#line 907 "cs.ATG" +#line 908 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(167); -#line 915 "cs.ATG" +#line 916 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 916 "cs.ATG" +#line 917 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(168); -#line 918 "cs.ATG" +#line 919 "cs.ATG" + if (op == OverloadableOperatorType.Add && secondType == null) + op = OverloadableOperatorType.UnaryPlus; + if (op == OverloadableOperatorType.Subtract && secondType == null) + op = OverloadableOperatorType.UnaryMinus; OperatorDeclaration operatorDeclaration = new OperatorDeclaration { - Modifier = m.Modifier, - Attributes = attributes, - TypeReference = type, - OverloadableOperator = op, - Body = (BlockStatement)stmt, - StartLocation = m.GetDeclarationLocation(startPos), - EndLocation = endPos + Modifier = m.Modifier, + Attributes = attributes, + TypeReference = type, + OverloadableOperator = op, + Name = GetReflectionNameForOperator(op), + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos }; SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2014,75 +2020,75 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 935 "cs.ATG" +#line 941 "cs.ATG" IsVarDecl()) { -#line 936 "cs.ATG" +#line 942 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( -#line 940 "cs.ATG" +#line 946 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( -#line 941 "cs.ATG" +#line 947 "cs.ATG" fd); Expect(18); Expr( -#line 943 "cs.ATG" +#line 949 "cs.ATG" out expr); -#line 943 "cs.ATG" +#line 949 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 947 "cs.ATG" +#line 953 "cs.ATG" fd); Expect(18); Expr( -#line 949 "cs.ATG" +#line 955 "cs.ATG" out expr); -#line 949 "cs.ATG" +#line 955 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (StartOf(19)) { VariableDeclarator( -#line 954 "cs.ATG" +#line 960 "cs.ATG" fd); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 955 "cs.ATG" +#line 961 "cs.ATG" fd); } } else SynErr(169); Expect(11); -#line 957 "cs.ATG" +#line 963 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if (la.kind == 111) { -#line 960 "cs.ATG" +#line 966 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 961 "cs.ATG" +#line 967 "cs.ATG" p); Expect(19); -#line 961 "cs.ATG" +#line 967 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); -#line 962 "cs.ATG" +#line 968 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2091,64 +2097,64 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 969 "cs.ATG" +#line 975 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 970 "cs.ATG" +#line 976 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( -#line 975 "cs.ATG" +#line 981 "cs.ATG" IsIdentifierToken(la)) { if ( -#line 976 "cs.ATG" +#line 982 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 977 "cs.ATG" +#line 983 "cs.ATG" out explicitInterface, false); -#line 978 "cs.ATG" +#line 984 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(19)) { Identifier(); -#line 981 "cs.ATG" +#line 987 "cs.ATG" qualident = t.val; } else SynErr(170); -#line 983 "cs.ATG" +#line 989 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { -#line 987 "cs.ATG" +#line 993 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 989 "cs.ATG" +#line 995 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); -#line 991 "cs.ATG" +#line 997 "cs.ATG" isExtensionMethod = true; } if (StartOf(11)) { FormalParameterList( -#line 992 "cs.ATG" +#line 998 "cs.ATG" p); } Expect(21); -#line 994 "cs.ATG" +#line 1000 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, @@ -2166,23 +2172,23 @@ p); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1009 "cs.ATG" +#line 1015 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 1010 "cs.ATG" +#line 1016 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(171); -#line 1010 "cs.ATG" +#line 1016 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1013 "cs.ATG" +#line 1019 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -2193,11 +2199,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1022 "cs.ATG" +#line 1028 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1024 "cs.ATG" +#line 1030 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2206,17 +2212,17 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 1032 "cs.ATG" +#line 1038 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(111); Expect(18); FormalParameterList( -#line 1033 "cs.ATG" +#line 1039 "cs.ATG" p); Expect(19); -#line 1034 "cs.ATG" +#line 1040 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2227,14 +2233,14 @@ p); Expect(16); -#line 1042 "cs.ATG" +#line 1048 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( -#line 1043 "cs.ATG" +#line 1049 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1044 "cs.ATG" +#line 1050 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2248,7 +2254,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1071 "cs.ATG" +#line 1077 "cs.ATG" TypeReference type; AttributeSection section; @@ -2263,49 +2269,49 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1084 "cs.ATG" +#line 1090 "cs.ATG" out section); -#line 1084 "cs.ATG" +#line 1090 "cs.ATG" attributes.Add(section); } if (la.kind == 89) { lexer.NextToken(); -#line 1085 "cs.ATG" +#line 1091 "cs.ATG" mod = Modifiers.New; startLocation = t.Location; } if ( -#line 1088 "cs.ATG" +#line 1094 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1088 "cs.ATG" +#line 1094 "cs.ATG" if (startLocation.IsEmpty) startLocation = t.Location; Identifier(); -#line 1089 "cs.ATG" +#line 1095 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1090 "cs.ATG" +#line 1096 "cs.ATG" templates); } Expect(20); if (StartOf(11)) { FormalParameterList( -#line 1091 "cs.ATG" +#line 1097 "cs.ATG" parameters); } Expect(21); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1092 "cs.ATG" +#line 1098 "cs.ATG" templates); } Expect(11); -#line 1094 "cs.ATG" +#line 1100 "cs.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true), Parameters = parameters, Attributes = attributes, Templates = templates, @@ -2316,37 +2322,37 @@ templates); } else if (StartOf(23)) { if (StartOf(10)) { Type( -#line 1102 "cs.ATG" +#line 1108 "cs.ATG" out type); -#line 1102 "cs.ATG" +#line 1108 "cs.ATG" if (startLocation.IsEmpty) startLocation = t.Location; if (StartOf(19)) { Identifier(); -#line 1104 "cs.ATG" +#line 1110 "cs.ATG" name = t.val; Location qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1108 "cs.ATG" +#line 1114 "cs.ATG" templates); } Expect(20); if (StartOf(11)) { FormalParameterList( -#line 1109 "cs.ATG" +#line 1115 "cs.ATG" parameters); } Expect(21); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1111 "cs.ATG" +#line 1117 "cs.ATG" templates); } Expect(11); -#line 1112 "cs.ATG" +#line 1118 "cs.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod, TypeReference = type, Parameters = parameters, Attributes = attributes, Templates = templates, @@ -2356,58 +2362,58 @@ templates); } else if (la.kind == 16) { -#line 1121 "cs.ATG" +#line 1127 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1124 "cs.ATG" +#line 1130 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1125 "cs.ATG" +#line 1131 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1126 "cs.ATG" +#line 1132 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(175); } else if (la.kind == 111) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1129 "cs.ATG" +#line 1135 "cs.ATG" parameters); Expect(19); -#line 1130 "cs.ATG" +#line 1136 "cs.ATG" Location bracketEndLocation = t.EndLocation; -#line 1131 "cs.ATG" +#line 1137 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(16); -#line 1133 "cs.ATG" +#line 1139 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1134 "cs.ATG" +#line 1140 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1136 "cs.ATG" +#line 1142 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(176); } else { lexer.NextToken(); -#line 1139 "cs.ATG" +#line 1145 "cs.ATG" if (startLocation.IsEmpty) startLocation = t.Location; Type( -#line 1140 "cs.ATG" +#line 1146 "cs.ATG" out type); Identifier(); -#line 1141 "cs.ATG" +#line 1147 "cs.ATG" EventDeclaration ed = new EventDeclaration { TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes }; @@ -2415,17 +2421,17 @@ out type); Expect(11); -#line 1147 "cs.ATG" +#line 1153 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(177); } void EnumMemberDecl( -#line 1152 "cs.ATG" +#line 1158 "cs.ATG" out FieldDeclaration f) { -#line 1154 "cs.ATG" +#line 1160 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2433,15 +2439,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1160 "cs.ATG" +#line 1166 "cs.ATG" out section); -#line 1160 "cs.ATG" +#line 1166 "cs.ATG" attributes.Add(section); } Identifier(); -#line 1161 "cs.ATG" +#line 1167 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2451,10 +2457,10 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1167 "cs.ATG" +#line 1173 "cs.ATG" out expr); -#line 1167 "cs.ATG" +#line 1173 "cs.ATG" varDecl.Initializer = expr; } } @@ -2567,14 +2573,14 @@ out name); } void NullableQuestionMark( -#line 2331 "cs.ATG" +#line 2337 "cs.ATG" ref TypeReference typeRef) { -#line 2332 "cs.ATG" +#line 2338 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2336 "cs.ATG" +#line 2342 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -2664,11 +2670,11 @@ out ModifierList m) { } void Block( -#line 1287 "cs.ATG" +#line 1293 "cs.ATG" out Statement stmt) { Expect(16); -#line 1289 "cs.ATG" +#line 1295 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.Location; compilationUnit.BlockStart(blockStmt); @@ -2680,7 +2686,7 @@ out Statement stmt) { while (!(la.kind == 0 || la.kind == 17)) {SynErr(182); lexer.NextToken(); } Expect(17); -#line 1297 "cs.ATG" +#line 1303 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2688,10 +2694,10 @@ out Statement stmt) { } void EventAccessorDecls( -#line 1224 "cs.ATG" +#line 1230 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1225 "cs.ATG" +#line 1231 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2700,93 +2706,93 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1232 "cs.ATG" +#line 1238 "cs.ATG" out section); -#line 1232 "cs.ATG" +#line 1238 "cs.ATG" attributes.Add(section); } if (la.kind == 130) { -#line 1234 "cs.ATG" +#line 1240 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1235 "cs.ATG" +#line 1241 "cs.ATG" out stmt); -#line 1235 "cs.ATG" +#line 1241 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 18) { AttributeSection( -#line 1236 "cs.ATG" +#line 1242 "cs.ATG" out section); -#line 1236 "cs.ATG" +#line 1242 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1237 "cs.ATG" +#line 1243 "cs.ATG" out stmt); -#line 1237 "cs.ATG" +#line 1243 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if (la.kind == 131) { RemoveAccessorDecl( -#line 1239 "cs.ATG" +#line 1245 "cs.ATG" out stmt); -#line 1239 "cs.ATG" +#line 1245 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1240 "cs.ATG" +#line 1246 "cs.ATG" out section); -#line 1240 "cs.ATG" +#line 1246 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1241 "cs.ATG" +#line 1247 "cs.ATG" out stmt); -#line 1241 "cs.ATG" +#line 1247 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else SynErr(183); } void ConstructorInitializer( -#line 1317 "cs.ATG" +#line 1323 "cs.ATG" out ConstructorInitializer ci) { -#line 1318 "cs.ATG" +#line 1324 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 51) { lexer.NextToken(); -#line 1322 "cs.ATG" +#line 1328 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 111) { lexer.NextToken(); -#line 1323 "cs.ATG" +#line 1329 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(184); Expect(20); if (StartOf(26)) { Argument( -#line 1326 "cs.ATG" +#line 1332 "cs.ATG" out expr); -#line 1326 "cs.ATG" +#line 1332 "cs.ATG" SafeAdd(ci, ci.Arguments, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1327 "cs.ATG" +#line 1333 "cs.ATG" out expr); -#line 1327 "cs.ATG" +#line 1333 "cs.ATG" SafeAdd(ci, ci.Arguments, expr); } } @@ -2794,161 +2800,161 @@ out expr); } void OverloadableOperator( -#line 1340 "cs.ATG" +#line 1346 "cs.ATG" out OverloadableOperatorType op) { -#line 1341 "cs.ATG" +#line 1347 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1343 "cs.ATG" +#line 1349 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1344 "cs.ATG" +#line 1350 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1346 "cs.ATG" +#line 1352 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1347 "cs.ATG" +#line 1353 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1349 "cs.ATG" +#line 1355 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1350 "cs.ATG" +#line 1356 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 113: { lexer.NextToken(); -#line 1352 "cs.ATG" +#line 1358 "cs.ATG" op = OverloadableOperatorType.IsTrue; break; } case 72: { lexer.NextToken(); -#line 1353 "cs.ATG" +#line 1359 "cs.ATG" op = OverloadableOperatorType.IsFalse; break; } case 6: { lexer.NextToken(); -#line 1355 "cs.ATG" +#line 1361 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1356 "cs.ATG" +#line 1362 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1357 "cs.ATG" +#line 1363 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1359 "cs.ATG" +#line 1365 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1360 "cs.ATG" +#line 1366 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1361 "cs.ATG" +#line 1367 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1363 "cs.ATG" +#line 1369 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1364 "cs.ATG" +#line 1370 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1365 "cs.ATG" +#line 1371 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1366 "cs.ATG" +#line 1372 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1367 "cs.ATG" +#line 1373 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1368 "cs.ATG" +#line 1374 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1369 "cs.ATG" +#line 1375 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1369 "cs.ATG" +#line 1375 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2958,34 +2964,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1279 "cs.ATG" +#line 1285 "cs.ATG" FieldDeclaration parentFieldDeclaration) { -#line 1280 "cs.ATG" +#line 1286 "cs.ATG" Expression expr = null; Identifier(); -#line 1282 "cs.ATG" +#line 1288 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1283 "cs.ATG" +#line 1289 "cs.ATG" out expr); -#line 1283 "cs.ATG" +#line 1289 "cs.ATG" f.Initializer = expr; } -#line 1284 "cs.ATG" +#line 1290 "cs.ATG" f.EndLocation = t.EndLocation; SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f); } void AccessorDecls( -#line 1171 "cs.ATG" +#line 1177 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1173 "cs.ATG" +#line 1179 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2994,92 +3000,92 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1180 "cs.ATG" +#line 1186 "cs.ATG" out section); -#line 1180 "cs.ATG" +#line 1186 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1181 "cs.ATG" +#line 1187 "cs.ATG" out modifiers); } if (la.kind == 128) { GetAccessorDecl( -#line 1183 "cs.ATG" +#line 1189 "cs.ATG" out getBlock, attributes); -#line 1184 "cs.ATG" +#line 1190 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } if (StartOf(27)) { -#line 1185 "cs.ATG" +#line 1191 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1186 "cs.ATG" +#line 1192 "cs.ATG" out section); -#line 1186 "cs.ATG" +#line 1192 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1187 "cs.ATG" +#line 1193 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1188 "cs.ATG" +#line 1194 "cs.ATG" out setBlock, attributes); -#line 1189 "cs.ATG" +#line 1195 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 129) { SetAccessorDecl( -#line 1192 "cs.ATG" +#line 1198 "cs.ATG" out setBlock, attributes); -#line 1193 "cs.ATG" +#line 1199 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } if (StartOf(28)) { -#line 1194 "cs.ATG" +#line 1200 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1195 "cs.ATG" +#line 1201 "cs.ATG" out section); -#line 1195 "cs.ATG" +#line 1201 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1196 "cs.ATG" +#line 1202 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1197 "cs.ATG" +#line 1203 "cs.ATG" out getBlock, attributes); -#line 1198 "cs.ATG" +#line 1204 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (StartOf(19)) { Identifier(); -#line 1200 "cs.ATG" +#line 1206 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(186); } void InterfaceAccessors( -#line 1245 "cs.ATG" +#line 1251 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1247 "cs.ATG" +#line 1253 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -3087,173 +3093,173 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1253 "cs.ATG" +#line 1259 "cs.ATG" out section); -#line 1253 "cs.ATG" +#line 1259 "cs.ATG" attributes.Add(section); } -#line 1254 "cs.ATG" +#line 1260 "cs.ATG" Location startLocation = la.Location; if (la.kind == 128) { lexer.NextToken(); -#line 1256 "cs.ATG" +#line 1262 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if (la.kind == 129) { lexer.NextToken(); -#line 1257 "cs.ATG" +#line 1263 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else SynErr(187); Expect(11); -#line 1260 "cs.ATG" +#line 1266 "cs.ATG" if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } attributes = new List(); if (la.kind == 18 || la.kind == 128 || la.kind == 129) { while (la.kind == 18) { AttributeSection( -#line 1264 "cs.ATG" +#line 1270 "cs.ATG" out section); -#line 1264 "cs.ATG" +#line 1270 "cs.ATG" attributes.Add(section); } -#line 1265 "cs.ATG" +#line 1271 "cs.ATG" startLocation = la.Location; if (la.kind == 128) { lexer.NextToken(); -#line 1267 "cs.ATG" +#line 1273 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if (la.kind == 129) { lexer.NextToken(); -#line 1270 "cs.ATG" +#line 1276 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else SynErr(188); Expect(11); -#line 1275 "cs.ATG" +#line 1281 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1204 "cs.ATG" +#line 1210 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1205 "cs.ATG" +#line 1211 "cs.ATG" Statement stmt = null; Expect(128); -#line 1208 "cs.ATG" +#line 1214 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1209 "cs.ATG" +#line 1215 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(189); -#line 1210 "cs.ATG" +#line 1216 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); -#line 1211 "cs.ATG" +#line 1217 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1214 "cs.ATG" +#line 1220 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1215 "cs.ATG" +#line 1221 "cs.ATG" Statement stmt = null; Expect(129); -#line 1218 "cs.ATG" +#line 1224 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1219 "cs.ATG" +#line 1225 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(190); -#line 1220 "cs.ATG" +#line 1226 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); -#line 1221 "cs.ATG" +#line 1227 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1303 "cs.ATG" +#line 1309 "cs.ATG" out Statement stmt) { -#line 1304 "cs.ATG" +#line 1310 "cs.ATG" stmt = null; Expect(130); Block( -#line 1307 "cs.ATG" +#line 1313 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1310 "cs.ATG" +#line 1316 "cs.ATG" out Statement stmt) { -#line 1311 "cs.ATG" +#line 1317 "cs.ATG" stmt = null; Expect(131); Block( -#line 1314 "cs.ATG" +#line 1320 "cs.ATG" out stmt); } void VariableInitializer( -#line 1332 "cs.ATG" +#line 1338 "cs.ATG" out Expression initializerExpression) { -#line 1333 "cs.ATG" +#line 1339 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(6)) { Expr( -#line 1335 "cs.ATG" +#line 1341 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { CollectionInitializer( -#line 1336 "cs.ATG" +#line 1342 "cs.ATG" out initializerExpression); } else if (la.kind == 106) { lexer.NextToken(); Type( -#line 1337 "cs.ATG" +#line 1343 "cs.ATG" out type); Expect(18); Expr( -#line 1337 "cs.ATG" +#line 1343 "cs.ATG" out expr); Expect(19); -#line 1337 "cs.ATG" +#line 1343 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(191); } void Statement() { -#line 1480 "cs.ATG" +#line 1486 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; @@ -3261,32 +3267,32 @@ out expr); while (!(StartOf(29))) {SynErr(192); lexer.NextToken(); } if ( -#line 1489 "cs.ATG" +#line 1495 "cs.ATG" IsLabel()) { Identifier(); -#line 1489 "cs.ATG" +#line 1495 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 60) { lexer.NextToken(); Type( -#line 1492 "cs.ATG" +#line 1498 "cs.ATG" out type); -#line 1492 "cs.ATG" +#line 1498 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; Identifier(); -#line 1493 "cs.ATG" +#line 1499 "cs.ATG" ident = t.val; Location varStart = t.Location; Expect(3); Expr( -#line 1494 "cs.ATG" +#line 1500 "cs.ATG" out expr); -#line 1496 "cs.ATG" +#line 1502 "cs.ATG" SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) { StartLocation = varStart, EndLocation = t.EndLocation, @@ -3297,14 +3303,14 @@ out expr); lexer.NextToken(); Identifier(); -#line 1502 "cs.ATG" +#line 1508 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1502 "cs.ATG" +#line 1508 "cs.ATG" out expr); -#line 1504 "cs.ATG" +#line 1510 "cs.ATG" SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) { StartLocation = varStart, EndLocation = t.EndLocation, @@ -3314,28 +3320,28 @@ out expr); } Expect(11); -#line 1510 "cs.ATG" +#line 1516 "cs.ATG" var.EndLocation = t.EndLocation; compilationUnit.AddChild(var); } else if ( -#line 1513 "cs.ATG" +#line 1519 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1513 "cs.ATG" +#line 1519 "cs.ATG" out stmt); Expect(11); -#line 1513 "cs.ATG" +#line 1519 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(30)) { EmbeddedStatement( -#line 1515 "cs.ATG" +#line 1521 "cs.ATG" out stmt); -#line 1515 "cs.ATG" +#line 1521 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(193); -#line 1521 "cs.ATG" +#line 1527 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3344,10 +3350,10 @@ out stmt); } void Argument( -#line 1372 "cs.ATG" +#line 1378 "cs.ATG" out Expression argumentexpr) { -#line 1374 "cs.ATG" +#line 1380 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3355,51 +3361,51 @@ out Expression argumentexpr) { if (la.kind == 100) { lexer.NextToken(); -#line 1379 "cs.ATG" +#line 1385 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1380 "cs.ATG" +#line 1386 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1382 "cs.ATG" +#line 1388 "cs.ATG" out expr); -#line 1383 "cs.ATG" +#line 1389 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void CollectionInitializer( -#line 1403 "cs.ATG" +#line 1409 "cs.ATG" out Expression outExpr) { -#line 1405 "cs.ATG" +#line 1411 "cs.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(16); -#line 1409 "cs.ATG" +#line 1415 "cs.ATG" initializer.StartLocation = t.Location; if (StartOf(31)) { VariableInitializer( -#line 1410 "cs.ATG" +#line 1416 "cs.ATG" out expr); -#line 1411 "cs.ATG" +#line 1417 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); while ( -#line 1412 "cs.ATG" +#line 1418 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1413 "cs.ATG" +#line 1419 "cs.ATG" out expr); -#line 1414 "cs.ATG" +#line 1420 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); } if (la.kind == 14) { @@ -3408,105 +3414,105 @@ out expr); } Expect(17); -#line 1418 "cs.ATG" +#line 1424 "cs.ATG" initializer.EndLocation = t.Location; outExpr = initializer; } void AssignmentOperator( -#line 1386 "cs.ATG" +#line 1392 "cs.ATG" out AssignmentOperatorType op) { -#line 1387 "cs.ATG" +#line 1393 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1389 "cs.ATG" +#line 1395 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1390 "cs.ATG" +#line 1396 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1391 "cs.ATG" +#line 1397 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1392 "cs.ATG" +#line 1398 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1393 "cs.ATG" +#line 1399 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1394 "cs.ATG" +#line 1400 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1395 "cs.ATG" +#line 1401 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1396 "cs.ATG" +#line 1402 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1397 "cs.ATG" +#line 1403 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1398 "cs.ATG" +#line 1404 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1399 "cs.ATG" +#line 1405 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1400 "cs.ATG" +#line 1406 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(194); } void CollectionOrObjectInitializer( -#line 1421 "cs.ATG" +#line 1427 "cs.ATG" out Expression outExpr) { -#line 1423 "cs.ATG" +#line 1429 "cs.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(16); -#line 1427 "cs.ATG" +#line 1433 "cs.ATG" initializer.StartLocation = t.Location; if (StartOf(31)) { ObjectPropertyInitializerOrVariableInitializer( -#line 1428 "cs.ATG" +#line 1434 "cs.ATG" out expr); -#line 1429 "cs.ATG" +#line 1435 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); while ( -#line 1430 "cs.ATG" +#line 1436 "cs.ATG" NotFinalComma()) { Expect(14); ObjectPropertyInitializerOrVariableInitializer( -#line 1431 "cs.ATG" +#line 1437 "cs.ATG" out expr); -#line 1432 "cs.ATG" +#line 1438 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); } if (la.kind == 14) { @@ -3515,280 +3521,280 @@ out expr); } Expect(17); -#line 1436 "cs.ATG" +#line 1442 "cs.ATG" initializer.EndLocation = t.Location; outExpr = initializer; } void ObjectPropertyInitializerOrVariableInitializer( -#line 1439 "cs.ATG" +#line 1445 "cs.ATG" out Expression expr) { -#line 1440 "cs.ATG" +#line 1446 "cs.ATG" expr = null; if ( -#line 1442 "cs.ATG" +#line 1448 "cs.ATG" IdentAndAsgn()) { Identifier(); -#line 1444 "cs.ATG" +#line 1450 "cs.ATG" NamedArgumentExpression nae = new NamedArgumentExpression(t.val, null); nae.StartLocation = t.Location; Expression r = null; Expect(3); if (la.kind == 16) { CollectionOrObjectInitializer( -#line 1448 "cs.ATG" +#line 1454 "cs.ATG" out r); } else if (StartOf(31)) { VariableInitializer( -#line 1449 "cs.ATG" +#line 1455 "cs.ATG" out r); } else SynErr(195); -#line 1450 "cs.ATG" +#line 1456 "cs.ATG" nae.Expression = r; nae.EndLocation = t.EndLocation; expr = nae; } else if (StartOf(31)) { VariableInitializer( -#line 1452 "cs.ATG" +#line 1458 "cs.ATG" out expr); } else SynErr(196); } void LocalVariableDecl( -#line 1456 "cs.ATG" +#line 1462 "cs.ATG" out Statement stmt) { -#line 1458 "cs.ATG" +#line 1464 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Location startPos = la.Location; Type( -#line 1464 "cs.ATG" +#line 1470 "cs.ATG" out type); -#line 1464 "cs.ATG" +#line 1470 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = startPos; LocalVariableDeclarator( -#line 1465 "cs.ATG" +#line 1471 "cs.ATG" out var); -#line 1465 "cs.ATG" +#line 1471 "cs.ATG" SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1466 "cs.ATG" +#line 1472 "cs.ATG" out var); -#line 1466 "cs.ATG" +#line 1472 "cs.ATG" SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); } -#line 1467 "cs.ATG" +#line 1473 "cs.ATG" stmt = localVariableDeclaration; stmt.EndLocation = t.EndLocation; } void LocalVariableDeclarator( -#line 1470 "cs.ATG" +#line 1476 "cs.ATG" out VariableDeclaration var) { -#line 1471 "cs.ATG" +#line 1477 "cs.ATG" Expression expr = null; Identifier(); -#line 1473 "cs.ATG" +#line 1479 "cs.ATG" var = new VariableDeclaration(t.val); var.StartLocation = t.Location; if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1474 "cs.ATG" +#line 1480 "cs.ATG" out expr); -#line 1474 "cs.ATG" +#line 1480 "cs.ATG" var.Initializer = expr; } -#line 1475 "cs.ATG" +#line 1481 "cs.ATG" var.EndLocation = t.EndLocation; } void EmbeddedStatement( -#line 1528 "cs.ATG" +#line 1534 "cs.ATG" out Statement statement) { -#line 1530 "cs.ATG" +#line 1536 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; statement = null; -#line 1536 "cs.ATG" +#line 1542 "cs.ATG" Location startLocation = la.Location; if (la.kind == 16) { Block( -#line 1538 "cs.ATG" +#line 1544 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1541 "cs.ATG" +#line 1547 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1544 "cs.ATG" +#line 1550 "cs.ATG" UnCheckedAndLBrace()) { -#line 1544 "cs.ATG" +#line 1550 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 58) { lexer.NextToken(); } else if (la.kind == 118) { lexer.NextToken(); -#line 1545 "cs.ATG" +#line 1551 "cs.ATG" isChecked = false; } else SynErr(197); Block( -#line 1546 "cs.ATG" +#line 1552 "cs.ATG" out block); -#line 1546 "cs.ATG" +#line 1552 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 79) { IfStatement( -#line 1549 "cs.ATG" +#line 1555 "cs.ATG" out statement); } else if (la.kind == 110) { lexer.NextToken(); -#line 1551 "cs.ATG" +#line 1557 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1552 "cs.ATG" +#line 1558 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1553 "cs.ATG" +#line 1559 "cs.ATG" switchSections); Expect(17); -#line 1555 "cs.ATG" +#line 1561 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 125) { lexer.NextToken(); Expect(20); Expr( -#line 1558 "cs.ATG" +#line 1564 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1559 "cs.ATG" +#line 1565 "cs.ATG" out embeddedStatement); -#line 1560 "cs.ATG" +#line 1566 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1562 "cs.ATG" +#line 1568 "cs.ATG" out embeddedStatement); Expect(125); Expect(20); Expr( -#line 1563 "cs.ATG" +#line 1569 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1564 "cs.ATG" +#line 1570 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 76) { lexer.NextToken(); -#line 1566 "cs.ATG" +#line 1572 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(6)) { ForInitializer( -#line 1567 "cs.ATG" +#line 1573 "cs.ATG" out initializer); } Expect(11); if (StartOf(6)) { Expr( -#line 1568 "cs.ATG" +#line 1574 "cs.ATG" out expr); } Expect(11); if (StartOf(6)) { ForIterator( -#line 1569 "cs.ATG" +#line 1575 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1570 "cs.ATG" +#line 1576 "cs.ATG" out embeddedStatement); -#line 1571 "cs.ATG" +#line 1577 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 77) { lexer.NextToken(); Expect(20); Type( -#line 1573 "cs.ATG" +#line 1579 "cs.ATG" out type); Identifier(); -#line 1573 "cs.ATG" +#line 1579 "cs.ATG" string varName = t.val; Expect(81); Expr( -#line 1574 "cs.ATG" +#line 1580 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1575 "cs.ATG" +#line 1581 "cs.ATG" out embeddedStatement); -#line 1576 "cs.ATG" +#line 1582 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); } else if (la.kind == 53) { lexer.NextToken(); Expect(11); -#line 1579 "cs.ATG" +#line 1585 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1580 "cs.ATG" +#line 1586 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 78) { GotoStatement( -#line 1581 "cs.ATG" +#line 1587 "cs.ATG" out statement); } else if ( -#line 1583 "cs.ATG" +#line 1589 "cs.ATG" IsYieldStatement()) { Expect(132); if (la.kind == 101) { lexer.NextToken(); Expr( -#line 1584 "cs.ATG" +#line 1590 "cs.ATG" out expr); -#line 1584 "cs.ATG" +#line 1590 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 53) { lexer.NextToken(); -#line 1585 "cs.ATG" +#line 1591 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(198); Expect(11); @@ -3796,90 +3802,90 @@ out expr); lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1588 "cs.ATG" +#line 1594 "cs.ATG" out expr); } Expect(11); -#line 1588 "cs.ATG" +#line 1594 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 112) { lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1589 "cs.ATG" +#line 1595 "cs.ATG" out expr); } Expect(11); -#line 1589 "cs.ATG" +#line 1595 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(6)) { StatementExpr( -#line 1592 "cs.ATG" +#line 1598 "cs.ATG" out statement); while (!(la.kind == 0 || la.kind == 11)) {SynErr(199); lexer.NextToken(); } Expect(11); } else if (la.kind == 114) { TryStatement( -#line 1595 "cs.ATG" +#line 1601 "cs.ATG" out statement); } else if (la.kind == 86) { lexer.NextToken(); Expect(20); Expr( -#line 1598 "cs.ATG" +#line 1604 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1599 "cs.ATG" +#line 1605 "cs.ATG" out embeddedStatement); -#line 1599 "cs.ATG" +#line 1605 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 121) { -#line 1602 "cs.ATG" +#line 1608 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1604 "cs.ATG" +#line 1610 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1605 "cs.ATG" +#line 1611 "cs.ATG" out embeddedStatement); -#line 1605 "cs.ATG" +#line 1611 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 119) { lexer.NextToken(); Block( -#line 1608 "cs.ATG" +#line 1614 "cs.ATG" out embeddedStatement); -#line 1608 "cs.ATG" +#line 1614 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 74) { -#line 1610 "cs.ATG" +#line 1616 "cs.ATG" Statement pointerDeclarationStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1612 "cs.ATG" +#line 1618 "cs.ATG" out pointerDeclarationStmt); Expect(21); EmbeddedStatement( -#line 1613 "cs.ATG" +#line 1619 "cs.ATG" out embeddedStatement); -#line 1613 "cs.ATG" +#line 1619 "cs.ATG" statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); } else SynErr(200); -#line 1615 "cs.ATG" +#line 1621 "cs.ATG" if (statement != null) { statement.StartLocation = startLocation; statement.EndLocation = t.EndLocation; @@ -3888,10 +3894,10 @@ out embeddedStatement); } void IfStatement( -#line 1622 "cs.ATG" +#line 1628 "cs.ATG" out Statement statement) { -#line 1624 "cs.ATG" +#line 1630 "cs.ATG" Expression expr = null; Statement embeddedStatement = null; statement = null; @@ -3899,26 +3905,26 @@ out Statement statement) { Expect(79); Expect(20); Expr( -#line 1630 "cs.ATG" +#line 1636 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1631 "cs.ATG" +#line 1637 "cs.ATG" out embeddedStatement); -#line 1632 "cs.ATG" +#line 1638 "cs.ATG" Statement elseStatement = null; if (la.kind == 67) { lexer.NextToken(); EmbeddedStatement( -#line 1633 "cs.ATG" +#line 1639 "cs.ATG" out elseStatement); } -#line 1634 "cs.ATG" +#line 1640 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1635 "cs.ATG" +#line 1641 "cs.ATG" if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ (statement as IfElseStatement).ElseIfSections.Add( @@ -3931,29 +3937,29 @@ out elseStatement); } void SwitchSections( -#line 1665 "cs.ATG" +#line 1671 "cs.ATG" List switchSections) { -#line 1667 "cs.ATG" +#line 1673 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1671 "cs.ATG" +#line 1677 "cs.ATG" out label); -#line 1671 "cs.ATG" +#line 1677 "cs.ATG" SafeAdd(switchSection, switchSection.SwitchLabels, label); -#line 1672 "cs.ATG" +#line 1678 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(32)) { if (la.kind == 55 || la.kind == 63) { SwitchLabel( -#line 1674 "cs.ATG" +#line 1680 "cs.ATG" out label); -#line 1675 "cs.ATG" +#line 1681 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3969,145 +3975,145 @@ out label); } } -#line 1687 "cs.ATG" +#line 1693 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1646 "cs.ATG" +#line 1652 "cs.ATG" out List initializer) { -#line 1648 "cs.ATG" +#line 1654 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1652 "cs.ATG" +#line 1658 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1652 "cs.ATG" +#line 1658 "cs.ATG" out stmt); -#line 1652 "cs.ATG" +#line 1658 "cs.ATG" initializer.Add(stmt); } else if (StartOf(6)) { StatementExpr( -#line 1653 "cs.ATG" +#line 1659 "cs.ATG" out stmt); -#line 1653 "cs.ATG" +#line 1659 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1653 "cs.ATG" +#line 1659 "cs.ATG" out stmt); -#line 1653 "cs.ATG" +#line 1659 "cs.ATG" initializer.Add(stmt); } } else SynErr(201); } void ForIterator( -#line 1656 "cs.ATG" +#line 1662 "cs.ATG" out List iterator) { -#line 1658 "cs.ATG" +#line 1664 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1662 "cs.ATG" +#line 1668 "cs.ATG" out stmt); -#line 1662 "cs.ATG" +#line 1668 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1662 "cs.ATG" +#line 1668 "cs.ATG" out stmt); -#line 1662 "cs.ATG" +#line 1668 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1744 "cs.ATG" +#line 1750 "cs.ATG" out Statement stmt) { -#line 1745 "cs.ATG" +#line 1751 "cs.ATG" Expression expr; stmt = null; Expect(78); if (StartOf(19)) { Identifier(); -#line 1749 "cs.ATG" +#line 1755 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1750 "cs.ATG" +#line 1756 "cs.ATG" out expr); Expect(11); -#line 1750 "cs.ATG" +#line 1756 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(11); -#line 1751 "cs.ATG" +#line 1757 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(202); } void StatementExpr( -#line 1771 "cs.ATG" +#line 1777 "cs.ATG" out Statement stmt) { -#line 1772 "cs.ATG" +#line 1778 "cs.ATG" Expression expr; Expr( -#line 1774 "cs.ATG" +#line 1780 "cs.ATG" out expr); -#line 1777 "cs.ATG" +#line 1783 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1697 "cs.ATG" +#line 1703 "cs.ATG" out Statement tryStatement) { -#line 1699 "cs.ATG" +#line 1705 "cs.ATG" Statement blockStmt = null, finallyStmt = null; CatchClause catchClause = null; List catchClauses = new List(); Expect(114); Block( -#line 1704 "cs.ATG" +#line 1710 "cs.ATG" out blockStmt); while (la.kind == 56) { CatchClause( -#line 1706 "cs.ATG" +#line 1712 "cs.ATG" out catchClause); -#line 1707 "cs.ATG" +#line 1713 "cs.ATG" if (catchClause != null) catchClauses.Add(catchClause); } if (la.kind == 73) { lexer.NextToken(); Block( -#line 1709 "cs.ATG" +#line 1715 "cs.ATG" out finallyStmt); } -#line 1711 "cs.ATG" +#line 1717 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); if (catchClauses != null) { foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; @@ -4116,59 +4122,59 @@ out finallyStmt); } void ResourceAcquisition( -#line 1755 "cs.ATG" +#line 1761 "cs.ATG" out Statement stmt) { -#line 1757 "cs.ATG" +#line 1763 "cs.ATG" stmt = null; Expression expr; if ( -#line 1762 "cs.ATG" +#line 1768 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1762 "cs.ATG" +#line 1768 "cs.ATG" out stmt); } else if (StartOf(6)) { Expr( -#line 1763 "cs.ATG" +#line 1769 "cs.ATG" out expr); -#line 1767 "cs.ATG" +#line 1773 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(203); } void SwitchLabel( -#line 1690 "cs.ATG" +#line 1696 "cs.ATG" out CaseLabel label) { -#line 1691 "cs.ATG" +#line 1697 "cs.ATG" Expression expr = null; label = null; if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1693 "cs.ATG" +#line 1699 "cs.ATG" out expr); Expect(9); -#line 1693 "cs.ATG" +#line 1699 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(9); -#line 1694 "cs.ATG" +#line 1700 "cs.ATG" label = new CaseLabel(); } else SynErr(204); } void CatchClause( -#line 1718 "cs.ATG" +#line 1724 "cs.ATG" out CatchClause catchClause) { Expect(56); -#line 1720 "cs.ATG" +#line 1726 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; @@ -4177,35 +4183,35 @@ out CatchClause catchClause) { if (la.kind == 16) { Block( -#line 1728 "cs.ATG" +#line 1734 "cs.ATG" out stmt); -#line 1728 "cs.ATG" +#line 1734 "cs.ATG" catchClause = new CatchClause(stmt); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1731 "cs.ATG" +#line 1737 "cs.ATG" out typeRef, false); -#line 1731 "cs.ATG" +#line 1737 "cs.ATG" identifier = null; if (StartOf(19)) { Identifier(); -#line 1732 "cs.ATG" +#line 1738 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1733 "cs.ATG" +#line 1739 "cs.ATG" out stmt); -#line 1734 "cs.ATG" +#line 1740 "cs.ATG" catchClause = new CatchClause(typeRef, identifier, stmt); } else SynErr(205); -#line 1737 "cs.ATG" +#line 1743 "cs.ATG" if (catchClause != null) { catchClause.StartLocation = startPos; catchClause.EndLocation = t.Location; @@ -4214,75 +4220,75 @@ out stmt); } void UnaryExpr( -#line 1804 "cs.ATG" +#line 1810 "cs.ATG" out Expression uExpr) { -#line 1806 "cs.ATG" +#line 1812 "cs.ATG" TypeReference type = null; Expression expr = null; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(33) || -#line 1828 "cs.ATG" +#line 1834 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1815 "cs.ATG" +#line 1821 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1816 "cs.ATG" +#line 1822 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 1817 "cs.ATG" +#line 1823 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1818 "cs.ATG" +#line 1824 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1819 "cs.ATG" +#line 1825 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1820 "cs.ATG" +#line 1826 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 1821 "cs.ATG" +#line 1827 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 1822 "cs.ATG" +#line 1828 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf)); } else { Expect(20); Type( -#line 1828 "cs.ATG" +#line 1834 "cs.ATG" out type); Expect(21); -#line 1828 "cs.ATG" +#line 1834 "cs.ATG" expressions.Add(new CastExpression(type)); } } if ( -#line 1833 "cs.ATG" +#line 1839 "cs.ATG" LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { Expect(2); -#line 1836 "cs.ATG" +#line 1842 "cs.ATG" expressions.RemoveAt(expressions.Count - 1); if (t.literalValue is uint) { expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); @@ -4294,11 +4300,11 @@ LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffi } else if (StartOf(34)) { PrimaryExpr( -#line 1845 "cs.ATG" +#line 1851 "cs.ATG" out expr); } else SynErr(206); -#line 1847 "cs.ATG" +#line 1853 "cs.ATG" for (int i = 0; i < expressions.Count; ++i) { Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr; if (expressions[i] is CastExpression) { @@ -4316,325 +4322,325 @@ out expr); } void ConditionalOrExpr( -#line 2169 "cs.ATG" +#line 2175 "cs.ATG" ref Expression outExpr) { -#line 2170 "cs.ATG" +#line 2176 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2172 "cs.ATG" +#line 2178 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2172 "cs.ATG" +#line 2178 "cs.ATG" out expr); ConditionalAndExpr( -#line 2172 "cs.ATG" +#line 2178 "cs.ATG" ref expr); -#line 2172 "cs.ATG" +#line 2178 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1864 "cs.ATG" +#line 1870 "cs.ATG" out Expression pexpr) { -#line 1866 "cs.ATG" +#line 1872 "cs.ATG" TypeReference type = null; Expression expr; pexpr = null; -#line 1871 "cs.ATG" +#line 1877 "cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); -#line 1873 "cs.ATG" +#line 1879 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); -#line 1874 "cs.ATG" +#line 1880 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); -#line 1875 "cs.ATG" +#line 1881 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1876 "cs.ATG" +#line 1882 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( -#line 1877 "cs.ATG" +#line 1883 "cs.ATG" StartOfQueryExpression()) { QueryExpression( -#line 1878 "cs.ATG" +#line 1884 "cs.ATG" out pexpr); } else if ( -#line 1879 "cs.ATG" +#line 1885 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 1880 "cs.ATG" +#line 1886 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1881 "cs.ATG" +#line 1887 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); -#line 1882 "cs.ATG" +#line 1888 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(19)) { Identifier(); -#line 1886 "cs.ATG" +#line 1892 "cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || -#line 1889 "cs.ATG" +#line 1895 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( -#line 1888 "cs.ATG" +#line 1894 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { -#line 1890 "cs.ATG" +#line 1896 "cs.ATG" List typeList; TypeArgumentList( -#line 1891 "cs.ATG" +#line 1897 "cs.ATG" out typeList, false); -#line 1892 "cs.ATG" +#line 1898 "cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( -#line 1894 "cs.ATG" +#line 1900 "cs.ATG" IsLambdaExpression()) { LambdaExpression( -#line 1895 "cs.ATG" +#line 1901 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1898 "cs.ATG" +#line 1904 "cs.ATG" out expr); Expect(21); -#line 1898 "cs.ATG" +#line 1904 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(35)) { -#line 1901 "cs.ATG" +#line 1907 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); -#line 1902 "cs.ATG" +#line 1908 "cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); -#line 1903 "cs.ATG" +#line 1909 "cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); -#line 1904 "cs.ATG" +#line 1910 "cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); -#line 1905 "cs.ATG" +#line 1911 "cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); -#line 1906 "cs.ATG" +#line 1912 "cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); -#line 1907 "cs.ATG" +#line 1913 "cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); -#line 1908 "cs.ATG" +#line 1914 "cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); -#line 1909 "cs.ATG" +#line 1915 "cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); -#line 1910 "cs.ATG" +#line 1916 "cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); -#line 1911 "cs.ATG" +#line 1917 "cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); -#line 1912 "cs.ATG" +#line 1918 "cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); -#line 1913 "cs.ATG" +#line 1919 "cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); -#line 1914 "cs.ATG" +#line 1920 "cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); -#line 1915 "cs.ATG" +#line 1921 "cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); -#line 1916 "cs.ATG" +#line 1922 "cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); -#line 1917 "cs.ATG" +#line 1923 "cs.ATG" val = "System.Void"; break; } } -#line 1919 "cs.ATG" +#line 1925 "cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); -#line 1922 "cs.ATG" +#line 1928 "cs.ATG" pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 51) { lexer.NextToken(); -#line 1924 "cs.ATG" +#line 1930 "cs.ATG" pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 89) { NewExpression( -#line 1927 "cs.ATG" +#line 1933 "cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( -#line 1931 "cs.ATG" +#line 1937 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1931 "cs.ATG" +#line 1937 "cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( -#line 1932 "cs.ATG" +#line 1938 "cs.ATG" out type, true, true); } else SynErr(207); Expect(21); -#line 1934 "cs.ATG" +#line 1940 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( -#line 1936 "cs.ATG" +#line 1942 "cs.ATG" out type); Expect(21); -#line 1936 "cs.ATG" +#line 1942 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( -#line 1937 "cs.ATG" +#line 1943 "cs.ATG" out type); Expect(21); -#line 1937 "cs.ATG" +#line 1943 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( -#line 1938 "cs.ATG" +#line 1944 "cs.ATG" out expr); Expect(21); -#line 1938 "cs.ATG" +#line 1944 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( -#line 1939 "cs.ATG" +#line 1945 "cs.ATG" out expr); Expect(21); -#line 1939 "cs.ATG" +#line 1945 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( -#line 1940 "cs.ATG" +#line 1946 "cs.ATG" out expr); -#line 1940 "cs.ATG" +#line 1946 "cs.ATG" pexpr = expr; } else SynErr(208); -#line 1942 "cs.ATG" +#line 1948 "cs.ATG" if (pexpr != null) { if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; @@ -4645,78 +4651,78 @@ out expr); while (StartOf(36)) { if (la.kind == 31 || la.kind == 32) { -#line 1950 "cs.ATG" +#line 1956 "cs.ATG" startLocation = la.Location; if (la.kind == 31) { lexer.NextToken(); -#line 1952 "cs.ATG" +#line 1958 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1953 "cs.ATG" +#line 1959 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(209); } else if (la.kind == 47) { PointerMemberAccess( -#line 1956 "cs.ATG" +#line 1962 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 15) { MemberAccess( -#line 1957 "cs.ATG" +#line 1963 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 20) { lexer.NextToken(); -#line 1961 "cs.ATG" +#line 1967 "cs.ATG" List parameters = new List(); -#line 1962 "cs.ATG" +#line 1968 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); if (StartOf(26)) { Argument( -#line 1963 "cs.ATG" +#line 1969 "cs.ATG" out expr); -#line 1963 "cs.ATG" +#line 1969 "cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1964 "cs.ATG" +#line 1970 "cs.ATG" out expr); -#line 1964 "cs.ATG" +#line 1970 "cs.ATG" SafeAdd(pexpr, parameters, expr); } } Expect(21); } else { -#line 1970 "cs.ATG" +#line 1976 "cs.ATG" List indices = new List(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( -#line 1973 "cs.ATG" +#line 1979 "cs.ATG" out expr); -#line 1973 "cs.ATG" +#line 1979 "cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1974 "cs.ATG" +#line 1980 "cs.ATG" out expr); -#line 1974 "cs.ATG" +#line 1980 "cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); -#line 1977 "cs.ATG" +#line 1983 "cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; @@ -4727,83 +4733,83 @@ out expr); } void QueryExpression( -#line 2407 "cs.ATG" +#line 2413 "cs.ATG" out Expression outExpr) { -#line 2408 "cs.ATG" +#line 2414 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2412 "cs.ATG" +#line 2418 "cs.ATG" out fromClause); -#line 2412 "cs.ATG" +#line 2418 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2413 "cs.ATG" +#line 2419 "cs.ATG" ref q); -#line 2414 "cs.ATG" +#line 2420 "cs.ATG" q.EndLocation = t.EndLocation; outExpr = q; /* set outExpr to q again if QueryExpressionBody changed it (can happen with 'into' clauses) */ } void ShortedLambdaExpression( -#line 2089 "cs.ATG" +#line 2095 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 2090 "cs.ATG" +#line 2096 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 2095 "cs.ATG" +#line 2101 "cs.ATG" lambda.StartLocation = ident.StartLocation; SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; LambdaExpressionBody( -#line 2100 "cs.ATG" +#line 2106 "cs.ATG" lambda); } void TypeArgumentList( -#line 2341 "cs.ATG" +#line 2347 "cs.ATG" out List types, bool canBeUnbound) { -#line 2343 "cs.ATG" +#line 2349 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2348 "cs.ATG" +#line 2354 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2349 "cs.ATG" +#line 2355 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2350 "cs.ATG" +#line 2356 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2351 "cs.ATG" +#line 2357 "cs.ATG" out type); -#line 2351 "cs.ATG" +#line 2357 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2352 "cs.ATG" +#line 2358 "cs.ATG" out type); -#line 2352 "cs.ATG" +#line 2358 "cs.ATG" if (type != null) { types.Add(type); } } } else SynErr(210); @@ -4811,10 +4817,10 @@ out type); } void LambdaExpression( -#line 2069 "cs.ATG" +#line 2075 "cs.ATG" out Expression outExpr) { -#line 2071 "cs.ATG" +#line 2077 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; @@ -4823,33 +4829,33 @@ out Expression outExpr) { Expect(20); if (StartOf(18)) { LambdaExpressionParameter( -#line 2079 "cs.ATG" +#line 2085 "cs.ATG" out p); -#line 2079 "cs.ATG" +#line 2085 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 2081 "cs.ATG" +#line 2087 "cs.ATG" out p); -#line 2081 "cs.ATG" +#line 2087 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 2086 "cs.ATG" +#line 2092 "cs.ATG" lambda); } void NewExpression( -#line 2016 "cs.ATG" +#line 2022 "cs.ATG" out Expression pexpr) { -#line 2017 "cs.ATG" +#line 2023 "cs.ATG" pexpr = null; List parameters = new List(); TypeReference type = null; @@ -4858,65 +4864,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 2024 "cs.ATG" +#line 2030 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 2030 "cs.ATG" +#line 2036 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 2031 "cs.ATG" +#line 2037 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); if (StartOf(26)) { Argument( -#line 2032 "cs.ATG" +#line 2038 "cs.ATG" out expr); -#line 2032 "cs.ATG" +#line 2038 "cs.ATG" SafeAdd(oce, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2033 "cs.ATG" +#line 2039 "cs.ATG" out expr); -#line 2033 "cs.ATG" +#line 2039 "cs.ATG" SafeAdd(oce, parameters, expr); } } Expect(21); -#line 2035 "cs.ATG" +#line 2041 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 2036 "cs.ATG" +#line 2042 "cs.ATG" out expr); -#line 2036 "cs.ATG" +#line 2042 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 2037 "cs.ATG" +#line 2043 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 2038 "cs.ATG" +#line 2044 "cs.ATG" out expr); -#line 2038 "cs.ATG" +#line 2044 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 2039 "cs.ATG" +#line 2045 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 2044 "cs.ATG" +#line 2050 "cs.ATG" ArrayCreateExpression ace = new ArrayCreateExpression(type); /* we must not change RankSpecifier on the null type reference*/ if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } @@ -4927,80 +4933,80 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 2051 "cs.ATG" +#line 2057 "cs.ATG" dims += 1; } Expect(19); -#line 2052 "cs.ATG" +#line 2058 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2053 "cs.ATG" +#line 2059 "cs.ATG" ++dims; } Expect(19); -#line 2053 "cs.ATG" +#line 2059 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2054 "cs.ATG" +#line 2060 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 2055 "cs.ATG" +#line 2061 "cs.ATG" out expr); -#line 2055 "cs.ATG" +#line 2061 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 2056 "cs.ATG" +#line 2062 "cs.ATG" out expr); -#line 2056 "cs.ATG" +#line 2062 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2057 "cs.ATG" +#line 2063 "cs.ATG" dims += 1; Expr( -#line 2058 "cs.ATG" +#line 2064 "cs.ATG" out expr); -#line 2058 "cs.ATG" +#line 2064 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2060 "cs.ATG" +#line 2066 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2061 "cs.ATG" +#line 2067 "cs.ATG" ++dims; } Expect(19); -#line 2061 "cs.ATG" +#line 2067 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2062 "cs.ATG" +#line 2068 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 2063 "cs.ATG" +#line 2069 "cs.ATG" out expr); -#line 2063 "cs.ATG" +#line 2069 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } } else SynErr(211); @@ -5008,10 +5014,10 @@ out expr); } void AnonymousMethodExpr( -#line 2136 "cs.ATG" +#line 2142 "cs.ATG" out Expression outExpr) { -#line 2138 "cs.ATG" +#line 2144 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -5022,59 +5028,59 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 2147 "cs.ATG" +#line 2153 "cs.ATG" p); -#line 2147 "cs.ATG" +#line 2153 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 2149 "cs.ATG" +#line 2155 "cs.ATG" expr.HasParameterList = true; } BlockInsideExpression( -#line 2151 "cs.ATG" +#line 2157 "cs.ATG" out stmt); -#line 2151 "cs.ATG" +#line 2157 "cs.ATG" expr.Body = stmt; -#line 2152 "cs.ATG" +#line 2158 "cs.ATG" expr.EndLocation = t.Location; } void PointerMemberAccess( -#line 2004 "cs.ATG" +#line 2010 "cs.ATG" out Expression expr, Expression target) { -#line 2005 "cs.ATG" +#line 2011 "cs.ATG" List typeList; Expect(47); Identifier(); -#line 2009 "cs.ATG" +#line 2015 "cs.ATG" expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2010 "cs.ATG" +#line 2016 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2011 "cs.ATG" +#line 2017 "cs.ATG" out typeList, false); -#line 2012 "cs.ATG" +#line 2018 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void MemberAccess( -#line 1985 "cs.ATG" +#line 1991 "cs.ATG" out Expression expr, Expression target) { -#line 1986 "cs.ATG" +#line 1992 "cs.ATG" List typeList; -#line 1988 "cs.ATG" +#line 1994 "cs.ATG" if (ShouldConvertTargetExpressionToTypeReference(target)) { TypeReference type = GetTypeReferenceFromExpression(target); if (type != null) { @@ -5085,35 +5091,35 @@ out Expression expr, Expression target) { Expect(15); Identifier(); -#line 1997 "cs.ATG" +#line 2003 "cs.ATG" expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 1998 "cs.ATG" +#line 2004 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 1999 "cs.ATG" +#line 2005 "cs.ATG" out typeList, false); -#line 2000 "cs.ATG" +#line 2006 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void LambdaExpressionParameter( -#line 2103 "cs.ATG" +#line 2109 "cs.ATG" out ParameterDeclarationExpression p) { -#line 2104 "cs.ATG" +#line 2110 "cs.ATG" Location start = la.Location; p = null; TypeReference type; ParameterModifiers mod = ParameterModifiers.In; if ( -#line 2109 "cs.ATG" +#line 2115 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 2111 "cs.ATG" +#line 2117 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5122,21 +5128,21 @@ Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { if (la.kind == 100) { lexer.NextToken(); -#line 2114 "cs.ATG" +#line 2120 "cs.ATG" mod = ParameterModifiers.Ref; } else { lexer.NextToken(); -#line 2115 "cs.ATG" +#line 2121 "cs.ATG" mod = ParameterModifiers.Out; } } Type( -#line 2117 "cs.ATG" +#line 2123 "cs.ATG" out type); Identifier(); -#line 2119 "cs.ATG" +#line 2125 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5144,263 +5150,263 @@ out type); } void LambdaExpressionBody( -#line 2125 "cs.ATG" +#line 2131 "cs.ATG" LambdaExpression lambda) { -#line 2126 "cs.ATG" +#line 2132 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { BlockInsideExpression( -#line 2129 "cs.ATG" +#line 2135 "cs.ATG" out stmt); -#line 2129 "cs.ATG" +#line 2135 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 2130 "cs.ATG" +#line 2136 "cs.ATG" out expr); -#line 2130 "cs.ATG" +#line 2136 "cs.ATG" lambda.ExpressionBody = expr; } else SynErr(214); -#line 2132 "cs.ATG" +#line 2138 "cs.ATG" lambda.EndLocation = t.EndLocation; -#line 2133 "cs.ATG" +#line 2139 "cs.ATG" lambda.ExtendedEndLocation = la.Location; } void BlockInsideExpression( -#line 2155 "cs.ATG" +#line 2161 "cs.ATG" out BlockStatement outStmt) { -#line 2156 "cs.ATG" +#line 2162 "cs.ATG" Statement stmt = null; outStmt = null; -#line 2160 "cs.ATG" +#line 2166 "cs.ATG" if (compilationUnit != null) { Block( -#line 2161 "cs.ATG" +#line 2167 "cs.ATG" out stmt); -#line 2161 "cs.ATG" +#line 2167 "cs.ATG" outStmt = (BlockStatement)stmt; -#line 2162 "cs.ATG" +#line 2168 "cs.ATG" } else { Expect(16); -#line 2164 "cs.ATG" +#line 2170 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 2166 "cs.ATG" +#line 2172 "cs.ATG" } } void ConditionalAndExpr( -#line 2175 "cs.ATG" +#line 2181 "cs.ATG" ref Expression outExpr) { -#line 2176 "cs.ATG" +#line 2182 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2178 "cs.ATG" +#line 2184 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2178 "cs.ATG" +#line 2184 "cs.ATG" out expr); InclusiveOrExpr( -#line 2178 "cs.ATG" +#line 2184 "cs.ATG" ref expr); -#line 2178 "cs.ATG" +#line 2184 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2181 "cs.ATG" +#line 2187 "cs.ATG" ref Expression outExpr) { -#line 2182 "cs.ATG" +#line 2188 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2184 "cs.ATG" +#line 2190 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2184 "cs.ATG" +#line 2190 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2184 "cs.ATG" +#line 2190 "cs.ATG" ref expr); -#line 2184 "cs.ATG" +#line 2190 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2187 "cs.ATG" +#line 2193 "cs.ATG" ref Expression outExpr) { -#line 2188 "cs.ATG" +#line 2194 "cs.ATG" Expression expr; AndExpr( -#line 2190 "cs.ATG" +#line 2196 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2190 "cs.ATG" +#line 2196 "cs.ATG" out expr); AndExpr( -#line 2190 "cs.ATG" +#line 2196 "cs.ATG" ref expr); -#line 2190 "cs.ATG" +#line 2196 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2193 "cs.ATG" +#line 2199 "cs.ATG" ref Expression outExpr) { -#line 2194 "cs.ATG" +#line 2200 "cs.ATG" Expression expr; EqualityExpr( -#line 2196 "cs.ATG" +#line 2202 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2196 "cs.ATG" +#line 2202 "cs.ATG" out expr); EqualityExpr( -#line 2196 "cs.ATG" +#line 2202 "cs.ATG" ref expr); -#line 2196 "cs.ATG" +#line 2202 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2199 "cs.ATG" +#line 2205 "cs.ATG" ref Expression outExpr) { -#line 2201 "cs.ATG" +#line 2207 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2205 "cs.ATG" +#line 2211 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2208 "cs.ATG" +#line 2214 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2209 "cs.ATG" +#line 2215 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2211 "cs.ATG" +#line 2217 "cs.ATG" out expr); RelationalExpr( -#line 2211 "cs.ATG" +#line 2217 "cs.ATG" ref expr); -#line 2211 "cs.ATG" +#line 2217 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2215 "cs.ATG" +#line 2221 "cs.ATG" ref Expression outExpr) { -#line 2217 "cs.ATG" +#line 2223 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2222 "cs.ATG" +#line 2228 "cs.ATG" ref outExpr); while (StartOf(37)) { if (StartOf(38)) { if (la.kind == 23) { lexer.NextToken(); -#line 2224 "cs.ATG" +#line 2230 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2225 "cs.ATG" +#line 2231 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2226 "cs.ATG" +#line 2232 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2227 "cs.ATG" +#line 2233 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(215); UnaryExpr( -#line 2229 "cs.ATG" +#line 2235 "cs.ATG" out expr); ShiftExpr( -#line 2230 "cs.ATG" +#line 2236 "cs.ATG" ref expr); -#line 2231 "cs.ATG" +#line 2237 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2234 "cs.ATG" +#line 2240 "cs.ATG" out type, false, false); if ( -#line 2235 "cs.ATG" +#line 2241 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2236 "cs.ATG" +#line 2242 "cs.ATG" ref type); } -#line 2237 "cs.ATG" +#line 2243 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2239 "cs.ATG" +#line 2245 "cs.ATG" out type, false, false); if ( -#line 2240 "cs.ATG" +#line 2246 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2241 "cs.ATG" +#line 2247 "cs.ATG" ref type); } -#line 2242 "cs.ATG" +#line 2248 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(216); } @@ -5408,83 +5414,83 @@ ref type); } void ShiftExpr( -#line 2247 "cs.ATG" +#line 2253 "cs.ATG" ref Expression outExpr) { -#line 2249 "cs.ATG" +#line 2255 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2253 "cs.ATG" +#line 2259 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2256 "cs.ATG" +#line 2262 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2255 "cs.ATG" +#line 2261 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2257 "cs.ATG" +#line 2263 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2260 "cs.ATG" +#line 2266 "cs.ATG" out expr); AdditiveExpr( -#line 2260 "cs.ATG" +#line 2266 "cs.ATG" ref expr); -#line 2260 "cs.ATG" +#line 2266 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2264 "cs.ATG" +#line 2270 "cs.ATG" ref Expression outExpr) { -#line 2266 "cs.ATG" +#line 2272 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2270 "cs.ATG" +#line 2276 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2273 "cs.ATG" +#line 2279 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2274 "cs.ATG" +#line 2280 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2276 "cs.ATG" +#line 2282 "cs.ATG" out expr); MultiplicativeExpr( -#line 2276 "cs.ATG" +#line 2282 "cs.ATG" ref expr); -#line 2276 "cs.ATG" +#line 2282 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2280 "cs.ATG" +#line 2286 "cs.ATG" ref Expression outExpr) { -#line 2282 "cs.ATG" +#line 2288 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5492,82 +5498,82 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2288 "cs.ATG" +#line 2294 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2289 "cs.ATG" +#line 2295 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2290 "cs.ATG" +#line 2296 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2292 "cs.ATG" +#line 2298 "cs.ATG" out expr); -#line 2292 "cs.ATG" +#line 2298 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2398 "cs.ATG" +#line 2404 "cs.ATG" out TypeReference type) { -#line 2399 "cs.ATG" +#line 2405 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2401 "cs.ATG" +#line 2407 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2402 "cs.ATG" +#line 2408 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2403 "cs.ATG" +#line 2409 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2404 "cs.ATG" +#line 2410 "cs.ATG" out t); -#line 2404 "cs.ATG" +#line 2410 "cs.ATG" type = t; } else SynErr(217); } void QueryExpressionFromClause( -#line 2419 "cs.ATG" +#line 2425 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2420 "cs.ATG" +#line 2426 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; Expect(137); QueryExpressionFromOrJoinClause( -#line 2424 "cs.ATG" +#line 2430 "cs.ATG" fc); -#line 2425 "cs.ATG" +#line 2431 "cs.ATG" fc.EndLocation = t.EndLocation; } void QueryExpressionBody( -#line 2455 "cs.ATG" +#line 2461 "cs.ATG" ref QueryExpression q) { -#line 2456 "cs.ATG" +#line 2462 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionOrderClause orderClause; @@ -5576,249 +5582,249 @@ ref QueryExpression q) { while (StartOf(39)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2462 "cs.ATG" +#line 2468 "cs.ATG" out fromClause); -#line 2462 "cs.ATG" +#line 2468 "cs.ATG" SafeAdd(q, q.MiddleClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2463 "cs.ATG" +#line 2469 "cs.ATG" out whereClause); -#line 2463 "cs.ATG" +#line 2469 "cs.ATG" SafeAdd(q, q.MiddleClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2464 "cs.ATG" +#line 2470 "cs.ATG" out letClause); -#line 2464 "cs.ATG" +#line 2470 "cs.ATG" SafeAdd(q, q.MiddleClauses, letClause); } else if (la.kind == 142) { QueryExpressionJoinClause( -#line 2465 "cs.ATG" +#line 2471 "cs.ATG" out joinClause); -#line 2465 "cs.ATG" +#line 2471 "cs.ATG" SafeAdd(q, q.MiddleClauses, joinClause); } else { QueryExpressionOrderByClause( -#line 2466 "cs.ATG" +#line 2472 "cs.ATG" out orderClause); -#line 2466 "cs.ATG" +#line 2472 "cs.ATG" SafeAdd(q, q.MiddleClauses, orderClause); } } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2468 "cs.ATG" +#line 2474 "cs.ATG" out selectClause); -#line 2468 "cs.ATG" +#line 2474 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2469 "cs.ATG" +#line 2475 "cs.ATG" out groupClause); -#line 2469 "cs.ATG" +#line 2475 "cs.ATG" q.SelectOrGroupClause = groupClause; } else SynErr(218); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2471 "cs.ATG" +#line 2477 "cs.ATG" ref q); } } void QueryExpressionFromOrJoinClause( -#line 2445 "cs.ATG" +#line 2451 "cs.ATG" QueryExpressionFromOrJoinClause fjc) { -#line 2446 "cs.ATG" +#line 2452 "cs.ATG" TypeReference type; Expression expr; -#line 2448 "cs.ATG" +#line 2454 "cs.ATG" fjc.Type = null; if ( -#line 2449 "cs.ATG" +#line 2455 "cs.ATG" IsLocalVarDecl()) { Type( -#line 2449 "cs.ATG" +#line 2455 "cs.ATG" out type); -#line 2449 "cs.ATG" +#line 2455 "cs.ATG" fjc.Type = type; } Identifier(); -#line 2450 "cs.ATG" +#line 2456 "cs.ATG" fjc.Identifier = t.val; Expect(81); Expr( -#line 2452 "cs.ATG" +#line 2458 "cs.ATG" out expr); -#line 2452 "cs.ATG" +#line 2458 "cs.ATG" fjc.InExpression = expr; } void QueryExpressionJoinClause( -#line 2428 "cs.ATG" +#line 2434 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2429 "cs.ATG" +#line 2435 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; Expect(142); QueryExpressionFromOrJoinClause( -#line 2434 "cs.ATG" +#line 2440 "cs.ATG" jc); Expect(143); Expr( -#line 2436 "cs.ATG" +#line 2442 "cs.ATG" out expr); -#line 2436 "cs.ATG" +#line 2442 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2438 "cs.ATG" +#line 2444 "cs.ATG" out expr); -#line 2438 "cs.ATG" +#line 2444 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2440 "cs.ATG" +#line 2446 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2442 "cs.ATG" +#line 2448 "cs.ATG" jc.EndLocation = t.EndLocation; } void QueryExpressionWhereClause( -#line 2474 "cs.ATG" +#line 2480 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2475 "cs.ATG" +#line 2481 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2478 "cs.ATG" +#line 2484 "cs.ATG" out expr); -#line 2478 "cs.ATG" +#line 2484 "cs.ATG" wc.Condition = expr; -#line 2479 "cs.ATG" +#line 2485 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2482 "cs.ATG" +#line 2488 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2483 "cs.ATG" +#line 2489 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2486 "cs.ATG" +#line 2492 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2488 "cs.ATG" +#line 2494 "cs.ATG" out expr); -#line 2488 "cs.ATG" +#line 2494 "cs.ATG" wc.Expression = expr; -#line 2489 "cs.ATG" +#line 2495 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2492 "cs.ATG" +#line 2498 "cs.ATG" out QueryExpressionOrderClause oc) { -#line 2493 "cs.ATG" +#line 2499 "cs.ATG" QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; Expect(140); QueryExpressionOrdering( -#line 2496 "cs.ATG" +#line 2502 "cs.ATG" out ordering); -#line 2496 "cs.ATG" +#line 2502 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrdering( -#line 2498 "cs.ATG" +#line 2504 "cs.ATG" out ordering); -#line 2498 "cs.ATG" +#line 2504 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); } -#line 2500 "cs.ATG" +#line 2506 "cs.ATG" oc.EndLocation = t.EndLocation; } void QueryExpressionSelectClause( -#line 2513 "cs.ATG" +#line 2519 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2514 "cs.ATG" +#line 2520 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2517 "cs.ATG" +#line 2523 "cs.ATG" out expr); -#line 2517 "cs.ATG" +#line 2523 "cs.ATG" sc.Projection = expr; -#line 2518 "cs.ATG" +#line 2524 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2521 "cs.ATG" +#line 2527 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2522 "cs.ATG" +#line 2528 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2525 "cs.ATG" +#line 2531 "cs.ATG" out expr); -#line 2525 "cs.ATG" +#line 2531 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2527 "cs.ATG" +#line 2533 "cs.ATG" out expr); -#line 2527 "cs.ATG" +#line 2533 "cs.ATG" gc.GroupBy = expr; -#line 2528 "cs.ATG" +#line 2534 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2531 "cs.ATG" +#line 2537 "cs.ATG" ref QueryExpression q) { -#line 2532 "cs.ATG" +#line 2538 "cs.ATG" QueryExpression firstQuery = q; QueryExpression continuedQuery = new QueryExpression(); continuedQuery.StartLocation = q.StartLocation; @@ -5833,43 +5839,43 @@ ref QueryExpression q) { Expect(136); Identifier(); -#line 2545 "cs.ATG" +#line 2551 "cs.ATG" continuedQuery.FromClause.Identifier = t.val; -#line 2546 "cs.ATG" +#line 2552 "cs.ATG" continuedQuery.FromClause.EndLocation = t.EndLocation; QueryExpressionBody( -#line 2547 "cs.ATG" +#line 2553 "cs.ATG" ref q); } void QueryExpressionOrdering( -#line 2503 "cs.ATG" +#line 2509 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2504 "cs.ATG" +#line 2510 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2506 "cs.ATG" +#line 2512 "cs.ATG" out expr); -#line 2506 "cs.ATG" +#line 2512 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2507 "cs.ATG" +#line 2513 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2508 "cs.ATG" +#line 2514 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2510 "cs.ATG" +#line 2516 "cs.ATG" ordering.EndLocation = t.EndLocation; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 5b2b5fefbd..1901e1978b 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -880,6 +880,7 @@ StructMemberDecl attributes> List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Name = (isImplicit ? "op_Implicit" : "op_Explicit"), Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, @@ -915,11 +916,16 @@ StructMemberDecl attributes> (. Location endPos = t.Location; .) ")" ( Block | ";" ) (. + if (op == OverloadableOperatorType.Add && secondType == null) + op = OverloadableOperatorType.UnaryPlus; + if (op == OverloadableOperatorType.Subtract && secondType == null) + op = OverloadableOperatorType.UnaryMinus; OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, TypeReference = type, OverloadableOperator = op, + Name = GetReflectionNameForOperator(op), Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs index 219f5731d0..5e249c7106 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs @@ -36,12 +36,25 @@ namespace ICSharpCode.NRefactory.Tests.Ast } [Test] - public void CSharpPlusOperatorDeclarationTest() + public void CSharpBinaryPlusOperatorDeclarationTest() { OperatorDeclaration od = ParseUtilCSharp.ParseTypeMember("public static MyObject operator +(MyObject a, MyObject b) {}"); Assert.IsTrue(!od.IsConversionOperator); + Assert.AreEqual(OverloadableOperatorType.Add, od.OverloadableOperator); Assert.AreEqual(2, od.Parameters.Count); Assert.AreEqual("MyObject", od.TypeReference.Type); + Assert.AreEqual("op_Addition", od.Name); + } + + [Test] + public void CSharpUnaryPlusOperatorDeclarationTest() + { + OperatorDeclaration od = ParseUtilCSharp.ParseTypeMember("public static MyObject operator +(MyObject a) {}"); + Assert.IsTrue(!od.IsConversionOperator); + Assert.AreEqual(OverloadableOperatorType.UnaryPlus, od.OverloadableOperator); + Assert.AreEqual(1, od.Parameters.Count); + Assert.AreEqual("MyObject", od.TypeReference.Type); + Assert.AreEqual("op_UnaryPlus", od.Name); } #endregion diff --git a/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs b/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs index 672b3cd5ad..5913f75d20 100644 --- a/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs +++ b/src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs @@ -23,10 +23,11 @@ namespace ICSharpCode.SharpDevelop public const int LocalVariableIndex = 16; public const int ParameterIndex = 17; - public const int KeywordIndex = NamespaceIndex; // TODO: give keywords their own icon - public const int CodeTemplateIndex = 18; + public const int OperatorIndex = 18; + public const int KeywordIndex = NamespaceIndex; //19; + public const int CodeTemplateIndex = 20; - public const int ClassIndex = 19; + public const int ClassIndex = 21; public const int StructIndex = ClassIndex + 1 * 4; public const int InterfaceIndex = ClassIndex + 2 * 4; public const int EnumIndex = ClassIndex + 3 * 4; @@ -79,7 +80,10 @@ namespace ICSharpCode.SharpDevelop public static int GetIcon(IMethod method) { - return MethodIndex + GetModifierOffset(method.Modifiers); + if (method.GetIsOperator()) + return OperatorIndex; + else + return MethodIndex + GetModifierOffset(method.Modifiers); } public static int GetIcon(IProperty property) @@ -242,9 +246,11 @@ namespace ICSharpCode.SharpDevelop imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.Local")); imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.Parameter")); + imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.Operator")); + imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.Keyword")); imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.TextFileIcon")); - imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.Class")); //19 + imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.Class")); //21 imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.InternalClass")); imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.ProtectedClass")); imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.16x16.PrivateClass")); diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultMethod.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultMethod.cs index b8e5c1d590..a1385815e9 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultMethod.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultMethod.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Dom } [Serializable] - public class DefaultMethod : AbstractMember, IMethod + public class DefaultMethod : AbstractMember, IMethod, IMethod2 { IList parameters; IList typeParameters; @@ -166,6 +166,12 @@ namespace ICSharpCode.SharpDevelop.Dom } } + public virtual bool IsOperator { + get { + return Name.StartsWith("op_", StringComparison.Ordinal); + } + } + public DefaultMethod(IClass declaringType, string name) : base(declaringType, name) { } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/IMethod.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/IMethod.cs index 94c970df07..ae7962c428 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/IMethod.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/IMethod.cs @@ -35,4 +35,23 @@ namespace ICSharpCode.SharpDevelop.Dom get; } } + + public interface IMethod2 : IMethod + { + bool IsOperator { + get; + } + } + + public static class Method2Compatibility + { + public static bool GetIsOperator(this IMethod method) + { + IMethod2 method2 = method as IMethod2; + if (method2 != null) + return method2.IsOperator; + else + return false; + } + } } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs index 97b5b16258..e0d569d9d0 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs @@ -222,10 +222,12 @@ namespace ICSharpCode.SharpDevelop.Dom public virtual bool ShowMember(IMember member, bool showStatic) { - if (member is IProperty && ((IProperty)member).IsIndexer) { + IProperty property = member as IProperty; + if (property != null && property.IsIndexer) { return false; } - if (member is IMethod && ((IMethod)member).IsConstructor) { + IMethod method = member as IMethod; + if (method != null && (method.IsConstructor || method.GetIsOperator())) { return false; } return member.IsStatic == showStatic; @@ -335,7 +337,8 @@ namespace ICSharpCode.SharpDevelop.Dom if (member is ArrayReturnType.ArrayIndexer) { return false; } - if (member is IMethod && ((IMethod)member).IsConstructor) { + IMethod method = member as IMethod; + if (method != null && (method.IsConstructor || method.GetIsOperator())) { return false; } return member.IsStatic || !showStatic; diff --git a/src/Main/StartUp/Project/Resources/BitmapResources.resources b/src/Main/StartUp/Project/Resources/BitmapResources.resources index cb3727cac4..841b74faec 100644 Binary files a/src/Main/StartUp/Project/Resources/BitmapResources.resources and b/src/Main/StartUp/Project/Resources/BitmapResources.resources differ