diff --git a/src/Libraries/NRefactory/ICSharpCode.Editor/ITextSource.cs b/src/Libraries/NRefactory/ICSharpCode.Editor/ITextSource.cs index 1f9cda9e75..3eb6c18867 100644 --- a/src/Libraries/NRefactory/ICSharpCode.Editor/ITextSource.cs +++ b/src/Libraries/NRefactory/ICSharpCode.Editor/ITextSource.cs @@ -97,11 +97,31 @@ namespace ICSharpCode.Editor /// Gets the index of the first occurrence of any character in the specified array. /// /// Characters to search for - /// Start index of the search. + /// Start index of the area to search. /// Length of the area to search. /// The first index where any character was found; or -1 if no occurrence was found. int IndexOfAny(char[] anyOf, int startIndex, int count); + /// + /// Gets the index of the first occurrence of the specified search text in this text source. + /// + /// The search text + /// Start index of the area to search. + /// Length of the area to search. + /// String comparison to use. + /// The first index where the search term was found; or -1 if no occurrence was found. + int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType); + + /// + /// Gets the index of the last occurrence of the specified search text in this text source. + /// + /// The search text + /// Start index of the area to search. + /// Length of the area to search. + /// String comparison to use. + /// The last index where the search term was found; or -1 if no occurrence was found. + int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType); + /* What about: void Insert (int offset, string value); void Remove (int offset, int count); @@ -116,7 +136,7 @@ namespace ICSharpCode.Editor IEnumerable SearchBackward (string pattern, int startIndex); IEnumerable SearchBackwardIgnoreCase (string pattern, int startIndex); - */ + */ } /// diff --git a/src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs b/src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs index 059d9d8d90..442b387592 100644 --- a/src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs +++ b/src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs @@ -327,6 +327,18 @@ namespace ICSharpCode.Editor return textSource.IndexOfAny(anyOf, startIndex, count); } + /// + public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType) + { + return textSource.IndexOf(searchText, startIndex, count, comparisonType); + } + + /// + public int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType) + { + return textSource.LastIndexOf(searchText, startIndex, count, comparisonType); + } + object IServiceProvider.GetService(Type serviceType) { return null; diff --git a/src/Libraries/NRefactory/ICSharpCode.Editor/StringTextSource.cs b/src/Libraries/NRefactory/ICSharpCode.Editor/StringTextSource.cs index e498f09338..ca59e40ffe 100644 --- a/src/Libraries/NRefactory/ICSharpCode.Editor/StringTextSource.cs +++ b/src/Libraries/NRefactory/ICSharpCode.Editor/StringTextSource.cs @@ -102,5 +102,17 @@ namespace ICSharpCode.Editor { return text.IndexOfAny(anyOf, startIndex, count); } + + /// + public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType) + { + return text.IndexOf(searchText, startIndex, count, comparisonType); + } + + /// + public int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType) + { + return text.LastIndexOf(searchText, startIndex, count, comparisonType); + } } } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Demo/CSDemo.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Demo/CSDemo.cs index 1ccb5de511..a65040678a 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Demo/CSDemo.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Demo/CSDemo.cs @@ -225,7 +225,7 @@ namespace ICSharpCode.NRefactory.Demo foreach (TreeNode t in c) { AstNode node = t.Tag as AstNode; if (node != null) { - ResolveResult rr = v.GetResolveResult(node); + ResolveResult rr = v.GetResolveResultIfResolved(node); if (rr != null) t.Text = GetNodeTitle(node) + " " + rr.ToString(); else @@ -282,10 +282,12 @@ namespace ICSharpCode.NRefactory.Demo FindReferences fr = new FindReferences(); int referenceCount = 0; - fr.ReferenceFound += delegate { referenceCount++; }; + FoundReferenceCallback callback = delegate(AstNode matchNode, ResolveResult result) { + referenceCount++; + }; var searchScopes = fr.GetSearchScopes(entity); - navigator = new CompositeResolveVisitorNavigator(searchScopes.ToArray()); + navigator = new CompositeResolveVisitorNavigator(searchScopes.Select(s => s.GetNavigator(callback)).ToArray()); visitor = new ResolveVisitor(resolver, parsedFile, navigator); visitor.Scan(compilationUnit); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayCreateExpressionTests.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayCreateExpressionTests.cs index 2fb3c1ad7d..bb96d1e5b8 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayCreateExpressionTests.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayCreateExpressionTests.cs @@ -57,6 +57,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression "new int[] { 1 }", new ArrayCreateExpression { Type = new PrimitiveType("int"), + AdditionalArraySpecifiers = { + new ArraySpecifier(0) + }, Initializer = new ArrayInitializerExpression { Elements = { new PrimitiveExpression(1) } } @@ -70,7 +73,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression "new int[,] { { 1 } }", new ArrayCreateExpression { Type = new PrimitiveType("int"), - Arguments = { new EmptyExpression(), new EmptyExpression() }, // TODO: can we improve the AST for this? + AdditionalArraySpecifiers = { new ArraySpecifier (2) }, Initializer = new ArrayInitializerExpression { Elements = { new ArrayInitializerExpression { @@ -87,6 +90,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression ParseUtilCSharp.AssertExpression( "new[] { 1, 10, 100, 1000 }", new ArrayCreateExpression { + AdditionalArraySpecifiers = { + new ArraySpecifier(0) + }, Initializer = new ArrayInitializerExpression { Elements = { new PrimitiveExpression(1), @@ -103,7 +109,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression ParseUtilCSharp.AssertExpression( "new [,] { { 1, 10 }, { 100, 1000 } }", new ArrayCreateExpression { - Arguments = { new EmptyExpression(), new EmptyExpression() }, // TODO: can we improve the AST for this? + AdditionalArraySpecifiers = { + new ArraySpecifier(2), + }, Initializer = new ArrayInitializerExpression { Elements = { new ArrayInitializerExpression { @@ -128,6 +136,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression ParseUtilCSharp.AssertExpression( "new [] { a = 10 }", new ArrayCreateExpression { + AdditionalArraySpecifiers = { + new ArraySpecifier(0) + }, Initializer = new ArrayInitializerExpression { Elements = { new AssignmentExpression(new IdentifierExpression("a"), new PrimitiveExpression(10)) diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs index c1a7571a21..213238dc56 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs @@ -88,7 +88,7 @@ public class Form1 { }}}); } - [Test, Ignore("Parser doesn't support attributes on type parameters")] + [Test] public void AttributesOnTypeParameter() { ParseUtilCSharp.AssertGlobal( @@ -148,7 +148,7 @@ public class Form1 { // TODO: Tests for other contexts where attributes can appear - [Test, Ignore("Parser does not support NamedArgumentExpression in attributes")] + [Test] public void AttributeWithNamedArguments() { ParseUtilCSharp.AssertTypeMember( diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs index a5869b5a27..fa4c82ad62 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser } var testCasePC = new SimpleProjectContent(); - ParsedFile parsedFile = new TypeSystemConvertVisitor(testCasePC, fileName).Convert(cu); + CSharpParsedFile parsedFile = new TypeSystemConvertVisitor(testCasePC, fileName).Convert(cu); parsedFile.Freeze(); testCasePC.UpdateProjectContent(null, parsedFile); return testCasePC; diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Refactoring/TypeSystemAstBuilderTests.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Refactoring/TypeSystemAstBuilderTests.cs index 7e90fd8ad4..b85b674dc1 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Refactoring/TypeSystemAstBuilderTests.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Refactoring/TypeSystemAstBuilderTests.cs @@ -55,7 +55,7 @@ namespace OtherNS { SimpleProjectContent pc; ITypeResolveContext ctx; ITypeDefinition baseClass, derivedClass, nestedClass, systemClass; - ParsedFile parsedFile; + CSharpParsedFile parsedFile; [SetUp] public void SetUp() diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LinqTests.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LinqTests.cs index f23bb83c69..71e8ec078a 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LinqTests.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LinqTests.cs @@ -313,5 +313,24 @@ class XYZ Assert.AreEqual("GroupJoin", rr.Member.Name); Assert.AreEqual("System.Int32", rr.Type.FullName); } + + [Test] + public void GroupWithQueryContinuation() + { + string program = @"using System; using System.Linq; +class TestClass +{ + static void M(string[] args) + { + var query = + from w in ""one to three"".Split() + group w by w.Length into g + orderby g.Key descending + select new { g.Key, Count = g.Count(), Avg = g.Average ($w$ => w.Length) }; + } +}"; + var rr = Resolve(program); + Assert.AreEqual("System.String", rr.Type.FullName); + } } } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs index 75cc3f65d3..ee8de8cefc 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs @@ -194,7 +194,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver SetUp(); - ParsedFile parsedFile = new ParsedFile("test.cs", resolver.CurrentUsingScope); + CSharpParsedFile parsedFile = new CSharpParsedFile("test.cs", resolver.CurrentUsingScope); TypeSystemConvertVisitor convertVisitor = new TypeSystemConvertVisitor(parsedFile, resolver.CurrentUsingScope, null); cu.AcceptVisitor(convertVisitor, null); project.UpdateProjectContent(null, convertVisitor.ParsedFile); @@ -259,7 +259,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver SetUp(); - ParsedFile parsedFile = new ParsedFile("test.cs", resolver.CurrentUsingScope); + CSharpParsedFile parsedFile = new CSharpParsedFile("test.cs", resolver.CurrentUsingScope); TypeSystemConvertVisitor convertVisitor = new TypeSystemConvertVisitor(parsedFile, resolver.CurrentUsingScope, null); cu.AcceptVisitor(convertVisitor, null); project.UpdateProjectContent(null, convertVisitor.ParsedFile); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs index 8146213d65..bbf4e00eb6 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs @@ -20,6 +20,7 @@ using System; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.TypeSystem.TestCase; using NUnit.Framework; @@ -132,14 +133,15 @@ namespace ICSharpCode.NRefactory.TypeSystem var posArgs = typeTest.GetPositionalArguments(ctx); Assert.AreEqual(3, posArgs.Count); // first argument is (int)42 - Assert.AreEqual(42, (int)posArgs[0].GetValue(ctx)); + Assert.AreEqual(42, (int)posArgs[0].ConstantValue); // second argument is typeof(System.Action<>) - IType rt = (IType)posArgs[1].GetValue(ctx); - Assert.IsFalse(rt is ParameterizedType); // rt must not be constructed - it's just an unbound type - Assert.AreEqual("System.Action", rt.FullName); - Assert.AreEqual(1, rt.TypeParameterCount); + TypeOfResolveResult rt = (TypeOfResolveResult)posArgs[1]; + Assert.IsFalse(rt.ReferencedType is ParameterizedType); // rt must not be constructed - it's just an unbound type + Assert.AreEqual("System.Action", rt.ReferencedType.FullName); + Assert.AreEqual(1, rt.ReferencedType.TypeParameterCount); // third argument is typeof(IDictionary>) - ParameterizedType crt = (ParameterizedType)posArgs[2].GetValue(ctx); + rt = (TypeOfResolveResult)posArgs[2]; + ParameterizedType crt = (ParameterizedType)rt.ReferencedType; Assert.AreEqual("System.Collections.Generic.IDictionary", crt.FullName); Assert.AreEqual("System.String", crt.TypeArguments[0].FullName); // ? for NUnit.TestAttribute (because that assembly isn't in ctx) @@ -153,8 +155,8 @@ namespace ICSharpCode.NRefactory.TypeSystem var forwardAttribute = attributes.Single(a => a.AttributeType.Resolve(ctx).FullName == typeof(TypeForwardedToAttribute).FullName); var posArgs = forwardAttribute.GetPositionalArguments(ctx); Assert.AreEqual(1, posArgs.Count); - IType rt = (IType)posArgs[0].GetValue(ctx); - Assert.AreEqual("System.Func`2", rt.ReflectionName); + TypeOfResolveResult rt = (TypeOfResolveResult)posArgs[0]; + Assert.AreEqual("System.Func`2", rt.ReferencedType.ReflectionName); } [Test] @@ -254,33 +256,25 @@ namespace ICSharpCode.NRefactory.TypeSystem Assert.IsTrue(f.IsStatic); Assert.IsTrue(f.IsConst); Assert.AreEqual(Accessibility.Public, f.Accessibility); - Assert.AreSame(e, f.ConstantValue.GetValueType(ctx)); - Assert.AreEqual(typeof(short), f.ConstantValue.GetValue(ctx).GetType()); + Assert.AreSame(e, f.ConstantValue.Resolve(ctx).Type); + Assert.AreEqual(typeof(short), f.ConstantValue.Resolve(ctx).ConstantValue.GetType()); } Assert.AreEqual("First", e.Fields[0].Name); - Assert.AreEqual(0, e.Fields[0].ConstantValue.GetValue(ctx)); + Assert.AreEqual(0, e.Fields[0].ConstantValue.Resolve(ctx).ConstantValue); Assert.AreEqual("Second", e.Fields[1].Name); - Assert.AreSame(e, e.Fields[1].ConstantValue.GetValueType(ctx)); - Assert.AreEqual(1, e.Fields[1].ConstantValue.GetValue(ctx)); + Assert.AreSame(e, e.Fields[1].ConstantValue.Resolve(ctx).Type); + Assert.AreEqual(1, e.Fields[1].ConstantValue.Resolve(ctx).ConstantValue); Assert.AreEqual("Flag1", e.Fields[2].Name); - Assert.AreEqual(0x10, e.Fields[2].ConstantValue.GetValue(ctx)); + Assert.AreEqual(0x10, e.Fields[2].ConstantValue.Resolve(ctx).ConstantValue); Assert.AreEqual("Flag2", e.Fields[3].Name); - Assert.AreEqual(0x20, e.Fields[3].ConstantValue.GetValue(ctx)); + Assert.AreEqual(0x20, e.Fields[3].ConstantValue.Resolve(ctx).ConstantValue); Assert.AreEqual("CombinedFlags", e.Fields[4].Name); - Assert.AreEqual(0x30, e.Fields[4].ConstantValue.GetValue(ctx)); - } - - [Test] - public void GetNestedTypesFromGenericClassTest() - { - ITypeDefinition b = ctx.GetTypeDefinition(typeof(Base<>)); - // Base.GetNestedTypes() = { Base`1+Nested`1[`0, unbound] } - + Assert.AreEqual(0x30, e.Fields[4].ConstantValue.Resolve(ctx).ConstantValue); } [Test] @@ -336,20 +330,20 @@ namespace ICSharpCode.NRefactory.TypeSystem { IAttribute attr = ctx.GetTypeDefinition(typeof(ExplicitFieldLayoutStruct)).Attributes.Single(); Assert.AreEqual("System.Runtime.InteropServices.StructLayoutAttribute", attr.AttributeType.Resolve(ctx).FullName); - IConstantValue arg1 = attr.GetPositionalArguments(ctx).Single(); - Assert.AreEqual("System.Runtime.InteropServices.LayoutKind", arg1.GetValueType(ctx).FullName); - Assert.AreEqual((int)LayoutKind.Explicit, arg1.GetValue(ctx)); + ResolveResult arg1 = attr.GetPositionalArguments(ctx).Single(); + Assert.AreEqual("System.Runtime.InteropServices.LayoutKind", arg1.Type.FullName); + Assert.AreEqual((int)LayoutKind.Explicit, arg1.ConstantValue); var namedArgs = attr.GetNamedArguments(ctx); var arg2 = namedArgs[0]; Assert.AreEqual("CharSet", arg2.Key); - Assert.AreEqual("System.Runtime.InteropServices.CharSet", arg2.Value.GetValueType(ctx).FullName); - Assert.AreEqual((int)CharSet.Unicode, arg2.Value.GetValue(ctx)); + Assert.AreEqual("System.Runtime.InteropServices.CharSet", arg2.Value.Type.FullName); + Assert.AreEqual((int)CharSet.Unicode, arg2.Value.ConstantValue); var arg3 = namedArgs[1]; Assert.AreEqual("Pack", arg3.Key); - Assert.AreEqual("System.Int32", arg3.Value.GetValueType(ctx).FullName); - Assert.AreEqual(8, arg3.Value.GetValue(ctx)); + Assert.AreEqual("System.Int32", arg3.Value.Type.FullName); + Assert.AreEqual(8, arg3.Value.ConstantValue); } [Test] @@ -357,15 +351,15 @@ namespace ICSharpCode.NRefactory.TypeSystem { IField field = ctx.GetTypeDefinition(typeof(ExplicitFieldLayoutStruct)).Fields.Single(f => f.Name == "Field0"); Assert.AreEqual("System.Runtime.InteropServices.FieldOffsetAttribute", field.Attributes.Single().AttributeType.Resolve(ctx).FullName); - IConstantValue arg = field.Attributes.Single().GetPositionalArguments(ctx).Single(); - Assert.AreEqual("System.Int32", arg.GetValueType(ctx).FullName); - Assert.AreEqual(0, arg.GetValue(ctx)); + ResolveResult arg = field.Attributes.Single().GetPositionalArguments(ctx).Single(); + Assert.AreEqual("System.Int32", arg.Type.FullName); + Assert.AreEqual(0, arg.ConstantValue); field = ctx.GetTypeDefinition(typeof(ExplicitFieldLayoutStruct)).Fields.Single(f => f.Name == "Field100"); Assert.AreEqual("System.Runtime.InteropServices.FieldOffsetAttribute", field.Attributes.Single().AttributeType.Resolve(ctx).FullName); arg = field.Attributes.Single().GetPositionalArguments(ctx).Single(); - Assert.AreEqual("System.Int32", arg.GetValueType(ctx).FullName); - Assert.AreEqual(100, arg.GetValue(ctx)); + Assert.AreEqual("System.Int32", arg.Type.FullName); + Assert.AreEqual(100, arg.ConstantValue); } [Test] @@ -374,8 +368,8 @@ namespace ICSharpCode.NRefactory.TypeSystem IMethod method = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod"); IAttribute dllImport = method.Attributes.Single(); Assert.AreEqual("System.Runtime.InteropServices.DllImportAttribute", dllImport.AttributeType.Resolve(ctx).FullName); - Assert.AreEqual("unmanaged.dll", dllImport.GetPositionalArguments(ctx)[0].GetValue(ctx)); - Assert.AreEqual((int)CharSet.Unicode, dllImport.GetNamedArguments(ctx).Single().Value.GetValue(ctx)); + Assert.AreEqual("unmanaged.dll", dllImport.GetPositionalArguments(ctx)[0].ConstantValue); + Assert.AreEqual((int)CharSet.Unicode, dllImport.GetNamedArguments(ctx).Single().Value.ConstantValue); } [Test] @@ -394,7 +388,7 @@ namespace ICSharpCode.NRefactory.TypeSystem { IMethod method = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod"); IAttribute marshalAs = method.ReturnTypeAttributes.Single(); - Assert.AreEqual((int)UnmanagedType.Bool, marshalAs.GetPositionalArguments(ctx).Single().GetValue(ctx)); + Assert.AreEqual((int)UnmanagedType.Bool, marshalAs.GetPositionalArguments(ctx).Single().ConstantValue); } [Test] diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj b/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj index 11ff834a12..aab1620cb7 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj @@ -62,8 +62,7 @@ - ..\lib\nunit.framework.dll - True + ..\..\Mono.Cecil\Test\libs\nunit-2.4.8\nunit.framework.dll diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CSharpModifierToken.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CSharpModifierToken.cs index 3fc7fa2912..28d72cb996 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CSharpModifierToken.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CSharpModifierToken.cs @@ -1,6 +1,6 @@ // // CSharpModifierToken.cs -// +// // Author: // Mike Krüger // @@ -37,14 +37,8 @@ namespace ICSharpCode.NRefactory.CSharp public Modifiers Modifier { get { return modifier; } set { - for (int i = 0; i < lengthTable.Count; i++) { - if (lengthTable[i].Key == value) { - this.modifier = value; - this.tokenLength = lengthTable[i].Value; - return; - } - } - throw new ArgumentException ("Modifier " + value + " is invalid."); + this.tokenLength = GetModifierName(value).Length; + this.modifier = value; } } @@ -56,30 +50,18 @@ namespace ICSharpCode.NRefactory.CSharp // Not worth using a dictionary for such few elements. // This table is sorted in the order that modifiers should be output when generating code. - static readonly List> lengthTable = new List> () { - new KeyValuePair(Modifiers.Public, "public".Length), - new KeyValuePair(Modifiers.Protected, "protected".Length), - new KeyValuePair(Modifiers.Private, "private".Length), - new KeyValuePair(Modifiers.Internal, "internal".Length), - new KeyValuePair(Modifiers.New, "new".Length), - new KeyValuePair(Modifiers.Unsafe, "unsafe".Length), - new KeyValuePair(Modifiers.Abstract, "abstract".Length), - new KeyValuePair(Modifiers.Virtual, "virtual".Length), - new KeyValuePair(Modifiers.Sealed, "sealed".Length), - new KeyValuePair(Modifiers.Static, "static".Length), - new KeyValuePair(Modifiers.Override, "override".Length), - new KeyValuePair(Modifiers.Readonly, "readonly".Length), - new KeyValuePair(Modifiers.Volatile, "volatile".Length), - new KeyValuePair(Modifiers.Extern, "extern".Length), - new KeyValuePair(Modifiers.Partial, "partial".Length), - new KeyValuePair(Modifiers.Const, "const".Length), - - // even though it's used for patterns only, it needs to be in this table to be usable in the AST - new KeyValuePair(Modifiers.Any, "any".Length) + static readonly Modifiers[] allModifiers = { + Modifiers.Public, Modifiers.Protected, Modifiers.Private, Modifiers.Internal, + Modifiers.New, + Modifiers.Unsafe, + Modifiers.Abstract, Modifiers.Virtual, Modifiers.Sealed, Modifiers.Static, Modifiers.Override, + Modifiers.Readonly, Modifiers.Volatile, + Modifiers.Extern, Modifiers.Partial, Modifiers.Const, + Modifiers.Any }; public static IEnumerable AllModifiers { - get { return lengthTable.Select(p => p.Key); } + get { return allModifiers; } } public CSharpModifierToken (AstLocation location, Modifiers modifier) : base (location, 0) @@ -122,8 +104,9 @@ namespace ICSharpCode.NRefactory.CSharp return "volatile"; case Modifiers.Unsafe: return "unsafe"; - case Modifiers.Fixed: - return "fixed"; + case Modifiers.Any: + // even though it's used for patterns only, it needs to be in this list to be usable in the AST + return "any"; default: throw new NotSupportedException("Invalid value for Modifiers"); } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Modifiers.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Modifiers.cs index 700a3c04d1..fec58e1761 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Modifiers.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Modifiers.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp //Overloads = 0x10000, //WithEvents = 0x20000, //Default = 0x40000, - Fixed = 0x80000, + //Fixed = 0x80000, //ProtectedOrInternal = Internal | Protected, //ProtectedAndInternal = 0x100000, (not supported in C#) diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs index 62ad069cb8..cf5e9e2c84 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs @@ -551,7 +551,8 @@ namespace ICSharpCode.NRefactory.CSharp StartNode (arrayCreateExpression); WriteKeyword ("new"); arrayCreateExpression.Type.AcceptVisitor (this, data); - WriteCommaSeparatedListInBrackets (arrayCreateExpression.Arguments); + if (arrayCreateExpression.Arguments.Count > 0) + WriteCommaSeparatedListInBrackets (arrayCreateExpression.Arguments); foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) specifier.AcceptVisitor (this, data); arrayCreateExpression.Initializer.AcceptVisitor (this, data); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs index c0247bb75a..0d0ff8bd22 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs @@ -195,9 +195,22 @@ namespace ICSharpCode.NRefactory.CSharp if (attr.PosArguments != null) { foreach (var arg in attr.PosArguments) { + var na = arg as NamedArgument; + if (na != null) { + var newArg = new NamedArgumentExpression (); + newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); + + var argLoc = LocationsBag.GetLocations (na); + if (argLoc != null) + newArg.AddChild (new CSharpTokenNode (Convert (argLoc[0]), 1), NamedArgumentExpression.Roles.Assign); + newArg.AddChild ((Expression)na.Expr.Accept (this), NamedExpression.Roles.Expression); + result.AddChild (newArg, Attribute.Roles.Argument); + continue; + } result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument); } } + Console.WriteLine ("---"); if (attr.NamedArguments != null) { foreach (NamedArgument na in attr.NamedArguments) { var newArg = new NamedExpression (); @@ -714,7 +727,14 @@ namespace ICSharpCode.NRefactory.CSharp { if (a.OptAttributes == null) return; - foreach (var attr in a.OptAttributes.Sections) { + AddAttributeSection (parent, a.OptAttributes); + } + + public void AddAttributeSection (AstNode parent, Attributes attrs) + { + if (attrs == null) + return; + foreach (var attr in attrs.Sections) { parent.AddChild (ConvertAttributeSection (attr), AttributedNode.AttributeRole); } } @@ -2156,7 +2176,9 @@ namespace ICSharpCode.NRefactory.CSharp if (arg == null) continue; TypeParameterDeclaration tp = new TypeParameterDeclaration(); - // TODO: attributes + + AddAttributeSection (tp, arg.OptAttributes); + switch (arg.Variance) { case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; @@ -2432,7 +2454,11 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (arrayCreationExpression.NewType), ArrayCreateExpression.Roles.Type); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayCreateExpression.Roles.LBracket); + + var next = arrayCreationExpression.Rank; if (arrayCreationExpression.Arguments != null) { + // skip first array rank. + next = next.Next; var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments); for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) { result.AddChild ((Expression)arrayCreationExpression.Arguments[i].Accept (this), ArrayCreateExpression.Roles.Argument); @@ -2440,7 +2466,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), ArrayCreateExpression.Roles.Comma); } } - var next = arrayCreationExpression.Rank.Next; + while (next != null) { ArraySpecifier spec = new ArraySpecifier (next.Dimension); var loc = LocationsBag.GetLocations (next); @@ -2888,7 +2914,6 @@ namespace ICSharpCode.NRefactory.CSharp var result = new QueryJoinClause (); var location = LocationsBag.GetLocations (join); result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); - result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), QueryJoinClause.JoinIdentifierRole); if (location != null) @@ -2898,11 +2923,17 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); - // TODO: on expression + + var outer = join.OuterSelector.Statements.FirstOrDefault () as ContextualReturn; + if (outer != null) + result.AddChild ((Expression)outer.Expr.Accept (this), QueryJoinClause.OnExpressionRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); - // TODO: equals expression + + var inner = join.InnerSelector.Statements.FirstOrDefault () as ContextualReturn; + if (inner != null) + result.AddChild ((Expression)inner.Expr.Accept (this), QueryJoinClause.EqualsExpressionRole); return result; } @@ -2919,16 +2950,19 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); - result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.InExpressionRole); + var outer = join.OuterSelector.Statements.FirstOrDefault () as ContextualReturn; + if (outer != null) + result.AddChild ((Expression)outer.Expr.Accept (this), QueryJoinClause.OnExpressionRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); - - // TODO: on expression + result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.InExpressionRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); - // TODO: equals expression + var inner = join.InnerSelector.Statements.FirstOrDefault () as ContextualReturn; + if (inner != null) + result.AddChild ((Expression)inner.Expr.Accept (this), QueryJoinClause.EqualsExpressionRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[3]), "into".Length), QueryJoinClause.IntoKeywordRole); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs index 50c3ad8d11..984edaa2a9 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.NRefactory.CSharp /// Represents a file that was parsed and converted for the type system. /// [Serializable] - public sealed class ParsedFile : AbstractFreezable, IParsedFile + public sealed class CSharpParsedFile : AbstractFreezable, IParsedFile { readonly string fileName; readonly UsingScope rootUsingScope; @@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.CSharp usingScopes = FreezeList(usingScopes); } - public ParsedFile(string fileName, UsingScope rootUsingScope) + public CSharpParsedFile(string fileName, UsingScope rootUsingScope) { if (fileName == null) throw new ArgumentNullException("fileName"); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs index d055c90a1c..ab96afe447 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs @@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public class TypeSystemConvertVisitor : DepthFirstAstVisitor { - readonly ParsedFile parsedFile; + readonly CSharpParsedFile parsedFile; UsingScope usingScope; DefaultTypeDefinition currentTypeDefinition; DefaultMethod currentMethod; @@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.CSharp throw new ArgumentNullException("pc"); if (fileName == null) throw new ArgumentNullException("fileName"); - this.parsedFile = new ParsedFile(fileName, new UsingScope(pc)); + this.parsedFile = new CSharpParsedFile(fileName, new UsingScope(pc)); this.usingScope = parsedFile.RootUsingScope; } @@ -71,7 +71,7 @@ namespace ICSharpCode.NRefactory.CSharp /// The parsed file to which members should be added. /// The current using scope. /// The current type definition. - public TypeSystemConvertVisitor(ParsedFile parsedFile, UsingScope currentUsingScope = null, DefaultTypeDefinition currentTypeDefinition = null) + public TypeSystemConvertVisitor(CSharpParsedFile parsedFile, UsingScope currentUsingScope = null, DefaultTypeDefinition currentTypeDefinition = null) { if (parsedFile == null) throw new ArgumentNullException("parsedFile"); @@ -80,13 +80,13 @@ namespace ICSharpCode.NRefactory.CSharp this.currentTypeDefinition = currentTypeDefinition; } - public ParsedFile Convert(AstNode node) + public CSharpParsedFile Convert(AstNode node) { node.AcceptVisitor(this, null); return parsedFile; } - public ParsedFile ParsedFile { + public CSharpParsedFile ParsedFile { get { return parsedFile; } } @@ -340,9 +340,6 @@ namespace ICSharpCode.NRefactory.CSharp field.IsReadOnly = (modifiers & Modifiers.Readonly) != 0; field.ReturnType = ConvertType(fieldDeclaration.ReturnType); - if ((modifiers & Modifiers.Fixed) != 0) { - field.ReturnType = PointerTypeReference.Create(field.ReturnType); - } if ((modifiers & Modifiers.Const) != 0) { field.ConstantValue = ConvertConstantValue(field.ReturnType, vi.Initializer); @@ -356,6 +353,12 @@ namespace ICSharpCode.NRefactory.CSharp return isSingleField ? field : null; } + public override IEntity VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, object data) + { + // TODO: add support for fixed fields + return base.VisitFixedFieldDeclaration(fixedFieldDeclaration, data); + } + public override IEntity VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data) { DefaultField field = new DefaultField(currentTypeDefinition, enumMemberDeclaration.Name); @@ -762,12 +765,12 @@ namespace ICSharpCode.NRefactory.CSharp namedCtorArguments = new List>(); namedCtorArguments.Add(new KeyValuePair(nae.Identifier, ConvertAttributeArgument(nae.Expression))); } else { - AssignmentExpression ae = expr as AssignmentExpression; - if (ae != null && ae.Left is IdentifierExpression && ae.Operator == AssignmentOperatorType.Assign) { - string name = ((IdentifierExpression)ae.Left).Identifier; + NamedExpression namedExpression = expr as NamedExpression; + if (namedExpression != null) { + string name = namedExpression.Identifier; if (namedArguments == null) namedArguments = new List>(); - namedArguments.Add(new KeyValuePair(name, ConvertAttributeArgument(ae.Right))); + namedArguments.Add(new KeyValuePair(name, ConvertAttributeArgument(namedExpression.Expression))); } else { if (positionalArguments == null) positionalArguments = new List(); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs index 151d483b2c..f77ba27ac9 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs @@ -147,6 +147,7 @@ namespace Mono.CSharp Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; Location savedAttrParenOpenLocation, savedAttrParenCloseLocation; Stack> locationListStack = new Stack> (); // used for type parameters + List attributeCommas = new List (); object lastYYVal; @@ -1398,20 +1399,20 @@ namespace Mono.CSharp yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { case 1: -#line 395 "cs-parser.jay" +#line 396 "cs-parser.jay" { Lexer.check_incorrect_doc_comment (); } break; case 2: -#line 396 "cs-parser.jay" +#line 397 "cs-parser.jay" { Lexer.CompleteOnEOF = false; } break; case 6: case_6(); break; case 7: -#line 413 "cs-parser.jay" +#line 414 "cs-parser.jay" { module.AddAttributes ((Attributes) yyVals[0+yyTop], current_namespace); } @@ -1423,7 +1424,7 @@ case 13: case_13(); break; case 14: -#line 451 "cs-parser.jay" +#line 452 "cs-parser.jay" { syntax_error (GetLocation (yyVals[-1+yyTop]), "`alias' expected"); /* TODO: better*/ } @@ -1468,7 +1469,7 @@ case 41: case_41(); break; case 42: -#line 640 "cs-parser.jay" +#line 641 "cs-parser.jay" { current_namespace.DeclarationFound = true; } @@ -1498,18 +1499,18 @@ case 57: case_57(); break; case 58: -#line 733 "cs-parser.jay" +#line 737 "cs-parser.jay" { yyVal = "event"; } break; case 59: -#line 734 "cs-parser.jay" +#line 738 "cs-parser.jay" { yyVal = "return"; } break; case 60: case_60(); break; case 61: -#line 751 "cs-parser.jay" +#line 755 "cs-parser.jay" { yyVal = new List (4) { (Attribute) yyVals[0+yyTop] }; } @@ -1518,7 +1519,7 @@ case 62: case_62(); break; case 63: -#line 766 "cs-parser.jay" +#line 770 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1527,14 +1528,14 @@ case 64: case_64(); break; case 66: -#line 790 "cs-parser.jay" +#line 794 "cs-parser.jay" { yyVal = null; } break; case 67: case_67(); break; case 68: -#line 801 "cs-parser.jay" +#line 805 "cs-parser.jay" { yyVal = null; } break; case 69: @@ -1550,13 +1551,13 @@ case 72: case_72(); break; case 73: -#line 845 "cs-parser.jay" +#line 849 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 75: -#line 853 "cs-parser.jay" +#line 857 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1568,17 +1569,17 @@ case 77: case_77(); break; case 78: -#line 878 "cs-parser.jay" +#line 882 "cs-parser.jay" { yyVal = null; } break; case 79: -#line 882 "cs-parser.jay" +#line 886 "cs-parser.jay" { yyVal = Argument.AType.Ref; } break; case 80: -#line 886 "cs-parser.jay" +#line 890 "cs-parser.jay" { yyVal = Argument.AType.Out; } @@ -1587,7 +1588,7 @@ case 95: case_95(); break; case 96: -#line 927 "cs-parser.jay" +#line 931 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1605,7 +1606,7 @@ case 100: case_100(); break; case 101: -#line 959 "cs-parser.jay" +#line 963 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1614,7 +1615,7 @@ case 102: case_102(); break; case 103: -#line 971 "cs-parser.jay" +#line 975 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } @@ -1626,13 +1627,13 @@ case 119: case_119(); break; case 122: -#line 1040 "cs-parser.jay" +#line 1044 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 123: -#line 1044 "cs-parser.jay" +#line 1048 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1641,7 +1642,7 @@ case 124: case_124(); break; case 125: -#line 1060 "cs-parser.jay" +#line 1064 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1665,7 +1666,7 @@ case 133: case_133(); break; case 134: -#line 1139 "cs-parser.jay" +#line 1143 "cs-parser.jay" { report.Error (1641, GetLocation (yyVals[-1+yyTop]), "A fixed size buffer field must have the array size specifier after the field name"); } @@ -1677,13 +1678,13 @@ case 137: case_137(); break; case 140: -#line 1169 "cs-parser.jay" +#line 1173 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 141: -#line 1173 "cs-parser.jay" +#line 1177 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1692,7 +1693,7 @@ case 142: case_142(); break; case 143: -#line 1186 "cs-parser.jay" +#line 1190 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1701,13 +1702,13 @@ case 144: case_144(); break; case 147: -#line 1205 "cs-parser.jay" +#line 1209 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 148: -#line 1209 "cs-parser.jay" +#line 1213 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1716,7 +1717,7 @@ case 149: case_149(); break; case 150: -#line 1225 "cs-parser.jay" +#line 1229 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1737,13 +1738,13 @@ case 157: case_157(); break; case 158: -#line 1292 "cs-parser.jay" +#line 1296 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; case 159: -#line 1296 "cs-parser.jay" +#line 1300 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1752,7 +1753,7 @@ case 160: case_160(); break; case 161: -#line 1336 "cs-parser.jay" +#line 1340 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -1761,7 +1762,7 @@ case 162: case_162(); break; case 163: -#line 1346 "cs-parser.jay" +#line 1350 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1773,11 +1774,11 @@ case 165: case_165(); break; case 167: -#line 1420 "cs-parser.jay" +#line 1424 "cs-parser.jay" { yyVal = null; } break; case 168: -#line 1424 "cs-parser.jay" +#line 1428 "cs-parser.jay" { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 170: @@ -1802,13 +1803,13 @@ case 176: case_176(); break; case 177: -#line 1483 "cs-parser.jay" +#line 1487 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); } break; case 178: -#line 1487 "cs-parser.jay" +#line 1491 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); } @@ -1832,7 +1833,7 @@ case 184: case_184(); break; case 185: -#line 1562 "cs-parser.jay" +#line 1566 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1841,7 +1842,7 @@ case 186: case_186(); break; case 187: -#line 1603 "cs-parser.jay" +#line 1607 "cs-parser.jay" { yyVal = Parameter.Modifier.NONE; } break; case 189: @@ -1875,7 +1876,7 @@ case 198: case_198(); break; case 199: -#line 1701 "cs-parser.jay" +#line 1705 "cs-parser.jay" { Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); } @@ -1896,7 +1897,7 @@ case 204: case_204(); break; case 205: -#line 1755 "cs-parser.jay" +#line 1759 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; } @@ -1905,7 +1906,7 @@ case 206: case_206(); break; case 207: -#line 1784 "cs-parser.jay" +#line 1788 "cs-parser.jay" { lexer.PropertyParsing = false; } @@ -1935,7 +1936,7 @@ case 220: case_220(); break; case 221: -#line 1929 "cs-parser.jay" +#line 1933 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1953,43 +1954,43 @@ case 225: case_225(); break; case 226: -#line 1962 "cs-parser.jay" +#line 1966 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; case 231: -#line 1979 "cs-parser.jay" +#line 1983 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; case 232: -#line 1983 "cs-parser.jay" +#line 1987 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; case 237: -#line 1991 "cs-parser.jay" +#line 1995 "cs-parser.jay" { report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators"); } break; case 238: -#line 1995 "cs-parser.jay" +#line 1999 "cs-parser.jay" { report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors"); } break; case 239: -#line 1999 "cs-parser.jay" +#line 2003 "cs-parser.jay" { report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); } break; case 240: -#line 2005 "cs-parser.jay" +#line 2009 "cs-parser.jay" { } break; @@ -1997,14 +1998,14 @@ case 241: case_241(); break; case 243: -#line 2035 "cs-parser.jay" +#line 2039 "cs-parser.jay" { yyVal = null; } break; case 245: case_245(); break; case 246: -#line 2051 "cs-parser.jay" +#line 2055 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2013,95 +2014,95 @@ case 247: case_247(); break; case 249: -#line 2097 "cs-parser.jay" +#line 2101 "cs-parser.jay" { yyVal = Operator.OpType.LogicalNot; } break; case 250: -#line 2098 "cs-parser.jay" +#line 2102 "cs-parser.jay" { yyVal = Operator.OpType.OnesComplement; } break; case 251: -#line 2099 "cs-parser.jay" +#line 2103 "cs-parser.jay" { yyVal = Operator.OpType.Increment; } break; case 252: -#line 2100 "cs-parser.jay" +#line 2104 "cs-parser.jay" { yyVal = Operator.OpType.Decrement; } break; case 253: -#line 2101 "cs-parser.jay" +#line 2105 "cs-parser.jay" { yyVal = Operator.OpType.True; } break; case 254: -#line 2102 "cs-parser.jay" +#line 2106 "cs-parser.jay" { yyVal = Operator.OpType.False; } break; case 255: -#line 2104 "cs-parser.jay" +#line 2108 "cs-parser.jay" { yyVal = Operator.OpType.Addition; } break; case 256: -#line 2105 "cs-parser.jay" +#line 2109 "cs-parser.jay" { yyVal = Operator.OpType.Subtraction; } break; case 257: -#line 2107 "cs-parser.jay" +#line 2111 "cs-parser.jay" { yyVal = Operator.OpType.Multiply; } break; case 258: -#line 2108 "cs-parser.jay" +#line 2112 "cs-parser.jay" { yyVal = Operator.OpType.Division; } break; case 259: -#line 2109 "cs-parser.jay" +#line 2113 "cs-parser.jay" { yyVal = Operator.OpType.Modulus; } break; case 260: -#line 2110 "cs-parser.jay" +#line 2114 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseAnd; } break; case 261: -#line 2111 "cs-parser.jay" +#line 2115 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseOr; } break; case 262: -#line 2112 "cs-parser.jay" +#line 2116 "cs-parser.jay" { yyVal = Operator.OpType.ExclusiveOr; } break; case 263: -#line 2113 "cs-parser.jay" +#line 2117 "cs-parser.jay" { yyVal = Operator.OpType.LeftShift; } break; case 264: -#line 2114 "cs-parser.jay" +#line 2118 "cs-parser.jay" { yyVal = Operator.OpType.RightShift; } break; case 265: -#line 2115 "cs-parser.jay" +#line 2119 "cs-parser.jay" { yyVal = Operator.OpType.Equality; } break; case 266: -#line 2116 "cs-parser.jay" +#line 2120 "cs-parser.jay" { yyVal = Operator.OpType.Inequality; } break; case 267: -#line 2117 "cs-parser.jay" +#line 2121 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThan; } break; case 268: -#line 2118 "cs-parser.jay" +#line 2122 "cs-parser.jay" { yyVal = Operator.OpType.LessThan; } break; case 269: -#line 2119 "cs-parser.jay" +#line 2123 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThanOrEqual; } break; case 270: -#line 2120 "cs-parser.jay" +#line 2124 "cs-parser.jay" { yyVal = Operator.OpType.LessThanOrEqual; } break; case 271: -#line 2127 "cs-parser.jay" +#line 2131 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2110,7 +2111,7 @@ case 272: case_272(); break; case 273: -#line 2146 "cs-parser.jay" +#line 2150 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2137,11 +2138,11 @@ case 280: case_280(); break; case 282: -#line 2249 "cs-parser.jay" +#line 2253 "cs-parser.jay" { current_block = null; yyVal = null; } break; case 285: -#line 2261 "cs-parser.jay" +#line 2265 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2150,7 +2151,7 @@ case 286: case_286(); break; case 287: -#line 2271 "cs-parser.jay" +#line 2275 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2183,7 +2184,7 @@ case 296: case_296(); break; case 298: -#line 2380 "cs-parser.jay" +#line 2384 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2192,13 +2193,13 @@ case 299: case_299(); break; case 302: -#line 2397 "cs-parser.jay" +#line 2401 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 303: -#line 2401 "cs-parser.jay" +#line 2405 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -2207,7 +2208,7 @@ case 304: case_304(); break; case 305: -#line 2414 "cs-parser.jay" +#line 2418 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2219,7 +2220,7 @@ case 307: case_307(); break; case 308: -#line 2439 "cs-parser.jay" +#line 2443 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2267,7 +2268,7 @@ case 326: case_326(); break; case 329: -#line 2594 "cs-parser.jay" +#line 2598 "cs-parser.jay" { lbag.AddLocation (yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } @@ -2285,7 +2286,7 @@ case 334: case_334(); break; case 335: -#line 2652 "cs-parser.jay" +#line 2656 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; } @@ -2294,7 +2295,7 @@ case 336: case_336(); break; case 337: -#line 2674 "cs-parser.jay" +#line 2678 "cs-parser.jay" { lexer.ConstraintsParsing = false; } @@ -2327,7 +2328,7 @@ case 350: case_350(); break; case 351: -#line 2779 "cs-parser.jay" +#line 2782 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -2372,13 +2373,13 @@ case 366: case_366(); break; case 368: -#line 2897 "cs-parser.jay" +#line 2900 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } break; case 369: -#line 2904 "cs-parser.jay" +#line 2907 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -2393,7 +2394,7 @@ case 375: case_375(); break; case 377: -#line 2942 "cs-parser.jay" +#line 2945 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -2402,7 +2403,7 @@ case 378: case_378(); break; case 379: -#line 2962 "cs-parser.jay" +#line 2965 "cs-parser.jay" { yyVal = new ComposedCast (((MemberName) yyVals[-1+yyTop]).GetTypeExpression (), (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -2411,13 +2412,13 @@ case 380: case_380(); break; case 381: -#line 2971 "cs-parser.jay" +#line 2974 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 382: -#line 2975 "cs-parser.jay" +#line 2978 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -2435,63 +2436,63 @@ case 386: case_386(); break; case 387: -#line 3014 "cs-parser.jay" +#line 3017 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } break; case 388: -#line 3015 "cs-parser.jay" +#line 3018 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } break; case 389: -#line 3016 "cs-parser.jay" +#line 3019 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } break; case 390: -#line 3017 "cs-parser.jay" +#line 3020 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } break; case 391: -#line 3018 "cs-parser.jay" +#line 3021 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } break; case 392: -#line 3019 "cs-parser.jay" +#line 3022 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } break; case 394: -#line 3024 "cs-parser.jay" +#line 3027 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); } break; case 395: -#line 3025 "cs-parser.jay" +#line 3028 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); } break; case 396: -#line 3026 "cs-parser.jay" +#line 3029 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); } break; case 397: -#line 3027 "cs-parser.jay" +#line 3030 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); } break; case 398: -#line 3028 "cs-parser.jay" +#line 3031 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); } break; case 399: -#line 3029 "cs-parser.jay" +#line 3032 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); } break; case 400: -#line 3030 "cs-parser.jay" +#line 3033 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); } break; case 401: -#line 3031 "cs-parser.jay" +#line 3034 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); } break; case 402: -#line 3032 "cs-parser.jay" +#line 3035 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); } break; case 423: @@ -2501,22 +2502,22 @@ case 424: case_424(); break; case 428: -#line 3079 "cs-parser.jay" +#line 3082 "cs-parser.jay" { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } break; case 429: -#line 3083 "cs-parser.jay" +#line 3086 "cs-parser.jay" { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } break; case 430: -#line 3084 "cs-parser.jay" +#line 3087 "cs-parser.jay" { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } break; case 435: case_435(); break; case 436: -#line 3117 "cs-parser.jay" +#line 3120 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); } @@ -2534,7 +2535,7 @@ case 440: case_440(); break; case 441: -#line 3149 "cs-parser.jay" +#line 3152 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); } @@ -2543,7 +2544,7 @@ case 442: case_442(); break; case 443: -#line 3157 "cs-parser.jay" +#line 3160 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); } @@ -2555,7 +2556,7 @@ case 445: case_445(); break; case 446: -#line 3173 "cs-parser.jay" +#line 3176 "cs-parser.jay" { yyVal = null; } break; case 448: @@ -2565,11 +2566,11 @@ case 449: case_449(); break; case 450: -#line 3196 "cs-parser.jay" +#line 3199 "cs-parser.jay" { yyVal = null; } break; case 451: -#line 3200 "cs-parser.jay" +#line 3203 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2587,7 +2588,7 @@ case 455: case_455(); break; case 456: -#line 3233 "cs-parser.jay" +#line 3236 "cs-parser.jay" { yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); } @@ -2602,7 +2603,7 @@ case 459: case_459(); break; case 462: -#line 3261 "cs-parser.jay" +#line 3264 "cs-parser.jay" { yyVal = null; } break; case 464: @@ -2621,7 +2622,7 @@ case 468: case_468(); break; case 469: -#line 3313 "cs-parser.jay" +#line 3316 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } @@ -2657,13 +2658,13 @@ case 483: case_483(); break; case 484: -#line 3400 "cs-parser.jay" +#line 3403 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 486: -#line 3408 "cs-parser.jay" +#line 3411 "cs-parser.jay" { yyVal = new This (GetLocation (yyVals[0+yyTop])); } @@ -2675,13 +2676,13 @@ case 488: case_488(); break; case 489: -#line 3428 "cs-parser.jay" +#line 3431 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; case 490: -#line 3435 "cs-parser.jay" +#line 3438 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } @@ -2708,7 +2709,7 @@ case 497: case_497(); break; case 498: -#line 3501 "cs-parser.jay" +#line 3504 "cs-parser.jay" { ++lexer.parsing_type; } @@ -2720,7 +2721,7 @@ case 500: case_500(); break; case 503: -#line 3528 "cs-parser.jay" +#line 3531 "cs-parser.jay" { yyVal = null; } break; case 505: @@ -2751,25 +2752,25 @@ case 516: case_516(); break; case 517: -#line 3606 "cs-parser.jay" +#line 3609 "cs-parser.jay" { yyVal = 2; } break; case 518: -#line 3610 "cs-parser.jay" +#line 3613 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; case 519: -#line 3617 "cs-parser.jay" +#line 3620 "cs-parser.jay" { yyVal = null; } break; case 520: -#line 3621 "cs-parser.jay" +#line 3624 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2787,7 +2788,7 @@ case 524: case_524(); break; case 525: -#line 3665 "cs-parser.jay" +#line 3668 "cs-parser.jay" { lexer.TypeOfParsing = true; } @@ -2832,7 +2833,7 @@ case 540: case_540(); break; case 541: -#line 3779 "cs-parser.jay" +#line 3782 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); } @@ -2841,25 +2842,25 @@ case 542: case_542(); break; case 543: -#line 3792 "cs-parser.jay" +#line 3795 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); } break; case 544: -#line 3796 "cs-parser.jay" +#line 3799 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); } break; case 545: -#line 3803 "cs-parser.jay" +#line 3806 "cs-parser.jay" { yyVal = ParametersCompiled.Undefined; } break; case 547: -#line 3811 "cs-parser.jay" +#line 3814 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -2871,13 +2872,13 @@ case 549: case_549(); break; case 551: -#line 3837 "cs-parser.jay" +#line 3840 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 552: -#line 3841 "cs-parser.jay" +#line 3844 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2889,37 +2890,37 @@ case 556: case_556(); break; case 558: -#line 3871 "cs-parser.jay" +#line 3874 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 559: -#line 3875 "cs-parser.jay" +#line 3878 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 560: -#line 3879 "cs-parser.jay" +#line 3882 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 561: -#line 3883 "cs-parser.jay" +#line 3886 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 562: -#line 3887 "cs-parser.jay" +#line 3890 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 563: -#line 3891 "cs-parser.jay" +#line 3894 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2937,7 +2938,7 @@ case 569: case_569(); break; case 570: -#line 3923 "cs-parser.jay" +#line 3926 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2946,13 +2947,13 @@ case 571: case_571(); break; case 572: -#line 3932 "cs-parser.jay" +#line 3935 "cs-parser.jay" { yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 573: -#line 3936 "cs-parser.jay" +#line 3939 "cs-parser.jay" { yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3003,7 +3004,7 @@ case 598: case_598(); break; case 599: -#line 4060 "cs-parser.jay" +#line 4063 "cs-parser.jay" { yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3054,14 +3055,14 @@ case 614: case_614(); break; case 615: -#line 4157 "cs-parser.jay" +#line 4160 "cs-parser.jay" { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 616: case_616(); break; case 619: -#line 4172 "cs-parser.jay" +#line 4175 "cs-parser.jay" { start_block (lexer.Location); } @@ -3085,7 +3086,7 @@ case 626: case_626(); break; case 627: -#line 4217 "cs-parser.jay" +#line 4220 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3097,7 +3098,7 @@ case 629: case_629(); break; case 630: -#line 4231 "cs-parser.jay" +#line 4234 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3109,7 +3110,7 @@ case 632: case_632(); break; case 638: -#line 4256 "cs-parser.jay" +#line 4259 "cs-parser.jay" { yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); } @@ -3124,13 +3125,13 @@ case 641: case_641(); break; case 643: -#line 4285 "cs-parser.jay" +#line 4288 "cs-parser.jay" { yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); } break; case 644: -#line 4298 "cs-parser.jay" +#line 4301 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -3148,11 +3149,11 @@ case 648: case_648(); break; case 649: -#line 4337 "cs-parser.jay" +#line 4340 "cs-parser.jay" { yyVal = null; } break; case 650: -#line 4339 "cs-parser.jay" +#line 4342 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } break; case 651: @@ -3207,13 +3208,13 @@ case 669: case_669(); break; case 671: -#line 4459 "cs-parser.jay" +#line 4462 "cs-parser.jay" { current_container.AddBasesForPart (current_class, (List) yyVals[0+yyTop]); } break; case 673: -#line 4467 "cs-parser.jay" +#line 4470 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3243,19 +3244,19 @@ case 681: case_681(); break; case 682: -#line 4556 "cs-parser.jay" +#line 4559 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; case 683: -#line 4560 "cs-parser.jay" +#line 4563 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; case 684: -#line 4567 "cs-parser.jay" +#line 4570 "cs-parser.jay" { yyVal = Variance.None; } @@ -3264,13 +3265,13 @@ case 685: case_685(); break; case 686: -#line 4581 "cs-parser.jay" +#line 4584 "cs-parser.jay" { yyVal = Variance.Covariant; } break; case 687: -#line 4585 "cs-parser.jay" +#line 4588 "cs-parser.jay" { yyVal = Variance.Contravariant; } @@ -3279,7 +3280,7 @@ case 688: case_688(); break; case 689: -#line 4610 "cs-parser.jay" +#line 4613 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3297,13 +3298,13 @@ case 693: case_693(); break; case 698: -#line 4654 "cs-parser.jay" +#line 4657 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; case 699: -#line 4658 "cs-parser.jay" +#line 4661 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } @@ -3312,13 +3313,13 @@ case 701: case_701(); break; case 704: -#line 4682 "cs-parser.jay" +#line 4685 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; case 705: -#line 4686 "cs-parser.jay" +#line 4689 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } @@ -3351,13 +3352,13 @@ case 744: case_744(); break; case 745: -#line 4830 "cs-parser.jay" +#line 4833 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 746: -#line 4834 "cs-parser.jay" +#line 4837 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -3369,7 +3370,7 @@ case 749: case_749(); break; case 750: -#line 4855 "cs-parser.jay" +#line 4858 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); } @@ -3399,7 +3400,7 @@ case 763: case_763(); break; case 764: -#line 4944 "cs-parser.jay" +#line 4947 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); } @@ -3420,15 +3421,15 @@ case 774: case_774(); break; case 775: -#line 4994 "cs-parser.jay" +#line 4997 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 776: -#line 4998 "cs-parser.jay" +#line 5001 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 777: -#line 4999 "cs-parser.jay" +#line 5002 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 778: @@ -3447,7 +3448,7 @@ case 784: case_784(); break; case 785: -#line 5067 "cs-parser.jay" +#line 5070 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); } @@ -3468,13 +3469,13 @@ case 791: case_791(); break; case 792: -#line 5111 "cs-parser.jay" +#line 5114 "cs-parser.jay" { current_block = current_block.CreateSwitchBlock (lexer.Location); } break; case 793: -#line 5115 "cs-parser.jay" +#line 5118 "cs-parser.jay" { yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); } @@ -3489,7 +3490,7 @@ case 796: case_796(); break; case 797: -#line 5144 "cs-parser.jay" +#line 5147 "cs-parser.jay" { yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } @@ -3504,7 +3505,7 @@ case 804: case_804(); break; case 805: -#line 5183 "cs-parser.jay" +#line 5186 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3516,7 +3517,7 @@ case 807: case_807(); break; case 808: -#line 5211 "cs-parser.jay" +#line 5214 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; case 810: @@ -3526,11 +3527,11 @@ case 811: case_811(); break; case 813: -#line 5232 "cs-parser.jay" +#line 5235 "cs-parser.jay" { yyVal = null; } break; case 815: -#line 5237 "cs-parser.jay" +#line 5240 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; case 819: @@ -3573,7 +3574,7 @@ case 837: case_837(); break; case 840: -#line 5392 "cs-parser.jay" +#line 5395 "cs-parser.jay" { yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); } @@ -3594,7 +3595,7 @@ case 845: case_845(); break; case 848: -#line 5445 "cs-parser.jay" +#line 5448 "cs-parser.jay" { yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3603,7 +3604,7 @@ case 849: case_849(); break; case 850: -#line 5464 "cs-parser.jay" +#line 5467 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } @@ -3612,13 +3613,13 @@ case 851: case_851(); break; case 852: -#line 5482 "cs-parser.jay" +#line 5485 "cs-parser.jay" { yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 853: -#line 5489 "cs-parser.jay" +#line 5492 "cs-parser.jay" { yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3627,7 +3628,7 @@ case 854: case_854(); break; case 855: -#line 5499 "cs-parser.jay" +#line 5502 "cs-parser.jay" { yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } @@ -3657,7 +3658,7 @@ case 863: case_863(); break; case 864: -#line 5582 "cs-parser.jay" +#line 5585 "cs-parser.jay" { report.Error (210, lexer.Location, "You must provide an initializer in a fixed or using statement declaration"); } @@ -3690,7 +3691,7 @@ case 873: case_873(); break; case 874: -#line 5682 "cs-parser.jay" +#line 5685 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3699,7 +3700,7 @@ case 875: case_875(); break; case 876: -#line 5697 "cs-parser.jay" +#line 5700 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3714,7 +3715,7 @@ case 880: case_880(); break; case 881: -#line 5742 "cs-parser.jay" +#line 5745 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3735,7 +3736,7 @@ case 889: case_889(); break; case 895: -#line 5801 "cs-parser.jay" +#line 5804 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3744,7 +3745,7 @@ case 896: case_896(); break; case 897: -#line 5820 "cs-parser.jay" +#line 5823 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3777,13 +3778,13 @@ case 906: case_906(); break; case 908: -#line 5964 "cs-parser.jay" +#line 5967 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; case 909: -#line 5971 "cs-parser.jay" +#line 5974 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3804,7 +3805,7 @@ case 916: case_916(); break; case 917: -#line 6017 "cs-parser.jay" +#line 6020 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } @@ -3816,7 +3817,7 @@ case 919: case_919(); break; case 920: -#line 6034 "cs-parser.jay" +#line 6037 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } @@ -3840,13 +3841,13 @@ case 929: case_929(); break; case 937: -#line 6158 "cs-parser.jay" +#line 6161 "cs-parser.jay" { module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; } break; case 938: -#line 6165 "cs-parser.jay" +#line 6168 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; } @@ -3858,13 +3859,13 @@ case 940: case_940(); break; case 941: -#line 6182 "cs-parser.jay" +#line 6185 "cs-parser.jay" { yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], new MemberName (MemberCache.IndexerNameAlias)); } break; case 942: -#line 6186 "cs-parser.jay" +#line 6189 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3882,25 +3883,25 @@ case 946: case_946(); break; case 948: -#line 6222 "cs-parser.jay" +#line 6225 "cs-parser.jay" { yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); } break; case 950: -#line 6230 "cs-parser.jay" +#line 6233 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; case 951: -#line 6234 "cs-parser.jay" +#line 6237 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 952: -#line 6241 "cs-parser.jay" +#line 6244 "cs-parser.jay" { yyVal = new List (0); } @@ -3950,7 +3951,7 @@ case 956: All more than 3 lines long rules are wrapped into a method */ void case_6() -#line 403 "cs-parser.jay" +#line 404 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { Attributes attrs = (Attributes) yyVals[0+yyTop]; @@ -3960,7 +3961,7 @@ void case_6() } void case_8() -#line 415 "cs-parser.jay" +#line 416 "cs-parser.jay" { if (yyToken == Token.EXTERN_ALIAS) report.Error (439, lexer.Location, "An extern alias declaration must precede all other elements"); @@ -3969,7 +3970,7 @@ void case_8() } void case_13() -#line 435 "cs-parser.jay" +#line 436 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -3985,21 +3986,21 @@ void case_13() } void case_17() -#line 461 "cs-parser.jay" +#line 462 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_18() -#line 466 "cs-parser.jay" +#line 467 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_19() -#line 474 "cs-parser.jay" +#line 475 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") { @@ -4012,21 +4013,21 @@ void case_19() } void case_20() -#line 485 "cs-parser.jay" +#line 486 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_21() -#line 493 "cs-parser.jay" +#line 494 "cs-parser.jay" { current_namespace.AddUsing ((MemberName) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); ubag.AddUsing (GetLocation (yyVals[-2+yyTop]), (MemberName) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } void case_22() -#line 506 "cs-parser.jay" +#line 507 "cs-parser.jay" { Attributes attrs = (Attributes) yyVals[-2+yyTop]; MemberName name = (MemberName) yyVals[0+yyTop]; @@ -4059,7 +4060,7 @@ void case_22() } void case_23() -#line 537 "cs-parser.jay" +#line 538 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -4067,7 +4068,7 @@ void case_23() } void case_24() -#line 543 "cs-parser.jay" +#line 544 "cs-parser.jay" { if (yyVals[0+yyTop] != null) lbag.AddLocation (current_namespace, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); @@ -4082,28 +4083,28 @@ void case_24() } void case_25() -#line 559 "cs-parser.jay" +#line 560 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName (lt.Value, lt.Location); } void case_26() -#line 564 "cs-parser.jay" +#line 565 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, lt.Location); } void case_27() -#line 569 "cs-parser.jay" +#line 570 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new MemberName ("", lexer.Location); } void case_32() -#line 587 "cs-parser.jay" +#line 588 "cs-parser.jay" { MemberName name = (MemberName) yyVals[0+yyTop]; @@ -4114,7 +4115,7 @@ void case_32() } void case_41() -#line 619 "cs-parser.jay" +#line 620 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { TypeContainer ds = (TypeContainer)yyVals[0+yyTop]; @@ -4135,15 +4136,19 @@ void case_41() } void case_50() -#line 669 "cs-parser.jay" +#line 670 "cs-parser.jay" { var sect = (List) yyVals[0+yyTop]; yyVal = new Attributes (sect); lbag.AddLocation (sect, savedOpenLocation, savedCloseLocation); + if (attributeCommas.Count > 0) { + lbag.AppendTo (sect, attributeCommas); + attributeCommas.Clear (); + } } void case_51() -#line 675 "cs-parser.jay" +#line 680 "cs-parser.jay" { Attributes attrs = yyVals[-1+yyTop] as Attributes; var sect = (List) yyVals[0+yyTop]; @@ -4155,21 +4160,21 @@ void case_51() } void case_52() -#line 689 "cs-parser.jay" +#line 693 "cs-parser.jay" { lexer.parsing_attribute_section = true; savedOpenLocation = GetLocation (yyVals[0+yyTop]); } void case_53() -#line 694 "cs-parser.jay" +#line 698 "cs-parser.jay" { lexer.parsing_attribute_section = false; yyVal = yyVals[0+yyTop]; } void case_54() -#line 702 "cs-parser.jay" +#line 706 "cs-parser.jay" { current_attr_target = (string) yyVals[-1+yyTop]; if (current_attr_target == "assembly" || current_attr_target == "module") { @@ -4178,7 +4183,7 @@ void case_54() } void case_55() -#line 709 "cs-parser.jay" +#line 713 "cs-parser.jay" { /* when attribute target is invalid*/ if (current_attr_target == string.Empty) @@ -4192,21 +4197,21 @@ void case_55() } void case_56() -#line 721 "cs-parser.jay" +#line 725 "cs-parser.jay" { yyVal = yyVals[-2+yyTop]; savedCloseLocation = GetLocation (yyVals[0+yyTop]); } void case_57() -#line 729 "cs-parser.jay" +#line 733 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = CheckAttributeTarget (lt.Value, lt.Location); } void case_60() -#line 736 "cs-parser.jay" +#line 740 "cs-parser.jay" { if (yyToken == Token.IDENTIFIER) { Error_SyntaxError (yyToken); @@ -4218,17 +4223,17 @@ void case_60() } void case_62() -#line 753 "cs-parser.jay" +#line 757 "cs-parser.jay" { var attrs = (List) yyVals[-2+yyTop]; attrs.Add ((Attribute) yyVals[0+yyTop]); - lbag.AppendTo (attrs, GetLocation (yyVals[-1+yyTop])); + attributeCommas.Add (GetLocation (yyVals[-1+yyTop])); yyVal = attrs; } void case_64() -#line 768 "cs-parser.jay" +#line 772 "cs-parser.jay" { --lexer.parsing_block; MemberName mname = (MemberName) yyVals[-2+yyTop]; @@ -4246,7 +4251,7 @@ void case_64() } void case_67() -#line 792 "cs-parser.jay" +#line 796 "cs-parser.jay" { savedAttrParenOpenLocation = GetLocation (yyVals[-2+yyTop]); savedAttrParenCloseLocation = GetLocation (yyVals[0+yyTop]); @@ -4254,7 +4259,7 @@ void case_67() } void case_69() -#line 803 "cs-parser.jay" +#line 807 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4262,7 +4267,7 @@ void case_69() } void case_70() -#line 809 "cs-parser.jay" +#line 813 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4270,7 +4275,7 @@ void case_70() } void case_71() -#line 815 "cs-parser.jay" +#line 819 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] != null) { @@ -4287,7 +4292,7 @@ void case_71() } void case_72() -#line 830 "cs-parser.jay" +#line 834 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] == null) { @@ -4299,7 +4304,7 @@ void case_72() } void case_76() -#line 855 "cs-parser.jay" +#line 859 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4308,7 +4313,7 @@ void case_76() } void case_77() -#line 865 "cs-parser.jay" +#line 869 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument"); @@ -4321,7 +4326,7 @@ void case_77() } void case_95() -#line 912 "cs-parser.jay" +#line 916 "cs-parser.jay" { report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName (yyToken)); @@ -4330,14 +4335,14 @@ void case_95() } void case_97() -#line 929 "cs-parser.jay" +#line 933 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); push_current_class (new Struct (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); } void case_98() -#line 935 "cs-parser.jay" +#line 939 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -4350,7 +4355,7 @@ void case_98() } void case_99() -#line 946 "cs-parser.jay" +#line 950 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -4358,21 +4363,21 @@ void case_99() } void case_100() -#line 952 "cs-parser.jay" +#line 956 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[0+yyTop])); yyVal = pop_current_class (); } void case_102() -#line 964 "cs-parser.jay" +#line 968 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_118() -#line 1006 "cs-parser.jay" +#line 1010 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var mod = (Modifiers) yyVals[-3+yyTop]; @@ -4387,7 +4392,7 @@ void case_118() } void case_119() -#line 1019 "cs-parser.jay" +#line 1023 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4400,7 +4405,7 @@ void case_119() } void case_124() -#line 1049 "cs-parser.jay" +#line 1053 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4408,7 +4413,7 @@ void case_124() } void case_126() -#line 1062 "cs-parser.jay" +#line 1066 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -4416,14 +4421,14 @@ void case_126() } void case_127() -#line 1068 "cs-parser.jay" +#line 1072 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } void case_130() -#line 1083 "cs-parser.jay" +#line 1087 "cs-parser.jay" { lexer.parsing_generic_declaration = false; @@ -4438,7 +4443,7 @@ void case_130() } void case_131() -#line 1098 "cs-parser.jay" +#line 1102 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4451,7 +4456,7 @@ void case_131() } void case_132() -#line 1111 "cs-parser.jay" +#line 1115 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); @@ -4464,7 +4469,7 @@ void case_132() } void case_133() -#line 1122 "cs-parser.jay" +#line 1126 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4478,7 +4483,7 @@ void case_133() } void case_136() -#line 1145 "cs-parser.jay" +#line 1149 "cs-parser.jay" { ++lexer.parsing_block; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -4486,7 +4491,7 @@ void case_136() } void case_137() -#line 1151 "cs-parser.jay" +#line 1155 "cs-parser.jay" { --lexer.parsing_block; current_field.Initializer = (Expression) yyVals[0+yyTop]; @@ -4496,7 +4501,7 @@ void case_137() } void case_142() -#line 1178 "cs-parser.jay" +#line 1182 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -4504,7 +4509,7 @@ void case_142() } void case_144() -#line 1188 "cs-parser.jay" +#line 1192 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4513,7 +4518,7 @@ void case_144() } void case_149() -#line 1214 "cs-parser.jay" +#line 1218 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4521,7 +4526,7 @@ void case_149() } void case_151() -#line 1227 "cs-parser.jay" +#line 1231 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -4529,14 +4534,14 @@ void case_151() } void case_152() -#line 1233 "cs-parser.jay" +#line 1237 "cs-parser.jay" { report.Error (443, lexer.Location, "Value or constant expected"); yyVal = null; } void case_155() -#line 1243 "cs-parser.jay" +#line 1247 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); @@ -4544,7 +4549,7 @@ void case_155() } void case_156() -#line 1252 "cs-parser.jay" +#line 1256 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; @@ -4554,7 +4559,7 @@ void case_156() } void case_157() -#line 1260 "cs-parser.jay" +#line 1264 "cs-parser.jay" { Method method = (Method) yyVals[-2+yyTop]; method.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4580,7 +4585,7 @@ void case_157() } void case_160() -#line 1298 "cs-parser.jay" +#line 1302 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4615,14 +4620,14 @@ void case_160() } void case_162() -#line 1339 "cs-parser.jay" +#line 1343 "cs-parser.jay" { lexer.parsing_generic_declaration = false; valid_param_mod = ParameterModifierType.All; } void case_164() -#line 1348 "cs-parser.jay" +#line 1352 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4674,7 +4679,7 @@ void case_164() } void case_165() -#line 1401 "cs-parser.jay" +#line 1405 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-3+yyTop]; report.Error (1585, name.Location, @@ -4692,7 +4697,7 @@ void case_165() } void case_170() -#line 1430 "cs-parser.jay" +#line 1434 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); @@ -4700,7 +4705,7 @@ void case_170() } void case_171() -#line 1436 "cs-parser.jay" +#line 1440 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add ((Parameter) yyVals[0+yyTop]); @@ -4709,7 +4714,7 @@ void case_171() } void case_172() -#line 1443 "cs-parser.jay" +#line 1447 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add (new ArglistParameter (GetLocation (yyVals[0+yyTop]))); @@ -4717,7 +4722,7 @@ void case_172() } void case_173() -#line 1449 "cs-parser.jay" +#line 1453 "cs-parser.jay" { if (yyVals[-2+yyTop] != null) report.Error (231, ((Parameter) yyVals[-2+yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list"); @@ -4726,7 +4731,7 @@ void case_173() } void case_174() -#line 1456 "cs-parser.jay" +#line 1460 "cs-parser.jay" { if (yyVals[-2+yyTop] != null) report.Error (231, ((Parameter) yyVals[-2+yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list"); @@ -4738,7 +4743,7 @@ void case_174() } void case_175() -#line 1466 "cs-parser.jay" +#line 1470 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4746,7 +4751,7 @@ void case_175() } void case_176() -#line 1472 "cs-parser.jay" +#line 1476 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4757,14 +4762,14 @@ void case_176() } void case_179() -#line 1489 "cs-parser.jay" +#line 1493 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } void case_180() -#line 1497 "cs-parser.jay" +#line 1501 "cs-parser.jay" { parameters_bucket.Clear (); Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4775,7 +4780,7 @@ void case_180() } void case_181() -#line 1506 "cs-parser.jay" +#line 1510 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4795,7 +4800,7 @@ void case_181() } void case_182() -#line 1530 "cs-parser.jay" +#line 1534 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Parameter.Modifier) yyVals[-2+yyTop], (Attributes) yyVals[-3+yyTop], lt.Location); @@ -4803,7 +4808,7 @@ void case_182() } void case_183() -#line 1539 "cs-parser.jay" +#line 1543 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name"); @@ -4812,7 +4817,7 @@ void case_183() } void case_184() -#line 1549 "cs-parser.jay" +#line 1553 "cs-parser.jay" { Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); @@ -4821,7 +4826,7 @@ void case_184() } void case_186() -#line 1564 "cs-parser.jay" +#line 1568 "cs-parser.jay" { --lexer.parsing_block; if (lang_version <= LanguageVersion.V_3) { @@ -4860,14 +4865,14 @@ void case_186() } void case_189() -#line 1609 "cs-parser.jay" +#line 1613 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; parameterModifierLocation = GetLocation (yyVals[0+yyTop]); } void case_190() -#line 1614 "cs-parser.jay" +#line 1618 "cs-parser.jay" { Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop]; Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2; @@ -4890,7 +4895,7 @@ void case_190() } void case_191() -#line 1638 "cs-parser.jay" +#line 1642 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Ref) == 0) Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop])); @@ -4899,7 +4904,7 @@ void case_191() } void case_192() -#line 1645 "cs-parser.jay" +#line 1649 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Out) == 0) Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop])); @@ -4908,7 +4913,7 @@ void case_192() } void case_193() -#line 1652 "cs-parser.jay" +#line 1656 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop])); @@ -4920,14 +4925,14 @@ void case_193() } void case_194() -#line 1665 "cs-parser.jay" +#line 1669 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ParamsParameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Attributes) yyVals[-3+yyTop], lt.Location); } void case_195() -#line 1670 "cs-parser.jay" +#line 1674 "cs-parser.jay" { report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array"); @@ -4936,21 +4941,21 @@ void case_195() } void case_196() -#line 1677 "cs-parser.jay" +#line 1681 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_197() -#line 1685 "cs-parser.jay" +#line 1689 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Params) == 0) report.Error (1670, (GetLocation (yyVals[0+yyTop])), "The `params' modifier is not allowed in current context"); } void case_198() -#line 1690 "cs-parser.jay" +#line 1694 "cs-parser.jay" { Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop]; if ((mod & Parameter.Modifier.This) != 0) { @@ -4961,21 +4966,21 @@ void case_198() } void case_200() -#line 1706 "cs-parser.jay" +#line 1710 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Arglist) == 0) report.Error (1669, GetLocation (yyVals[0+yyTop]), "__arglist is not valid in this context"); } void case_201() -#line 1717 "cs-parser.jay" +#line 1721 "cs-parser.jay" { if (doc_support) tmpComment = Lexer.consume_doc_comment (); } void case_202() -#line 1722 "cs-parser.jay" +#line 1726 "cs-parser.jay" { var type = (FullNamedExpression) yyVals[-3+yyTop]; current_property = new Property (current_class, type, (Modifiers) yyVals[-4+yyTop], @@ -4991,7 +4996,7 @@ void case_202() } void case_203() -#line 1736 "cs-parser.jay" +#line 1740 "cs-parser.jay" { lexer.PropertyParsing = false; @@ -5000,14 +5005,14 @@ void case_203() } void case_204() -#line 1743 "cs-parser.jay" +#line 1747 "cs-parser.jay" { lbag.AppendToMember (current_property, GetLocation (yyVals[0+yyTop])); current_property = null; } void case_206() -#line 1757 "cs-parser.jay" +#line 1761 "cs-parser.jay" { valid_param_mod = 0; var type = (FullNamedExpression) yyVals[-6+yyTop]; @@ -5034,7 +5039,7 @@ void case_206() } void case_208() -#line 1786 "cs-parser.jay" +#line 1790 "cs-parser.jay" { if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) ((Indexer) current_property).ParameterInfo.CheckParameters (current_property); @@ -5047,7 +5052,7 @@ void case_208() } void case_213() -#line 1805 "cs-parser.jay" +#line 1809 "cs-parser.jay" { if (yyToken == Token.CLOSE_BRACE) { report.Error (548, lexer.Location, "`{0}': property or indexer must have at least one accessor", current_property.GetSignatureForError ()); @@ -5060,7 +5065,7 @@ void case_213() } void case_214() -#line 1819 "cs-parser.jay" +#line 1823 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5084,7 +5089,7 @@ void case_214() } void case_215() -#line 1841 "cs-parser.jay" +#line 1845 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Get.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5104,7 +5109,7 @@ void case_215() } void case_216() -#line 1862 "cs-parser.jay" +#line 1866 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5133,7 +5138,7 @@ void case_216() } void case_217() -#line 1889 "cs-parser.jay" +#line 1893 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Set.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5153,21 +5158,21 @@ void case_217() } void case_219() -#line 1911 "cs-parser.jay" +#line 1915 "cs-parser.jay" { lbag.AppendToMember (lbag.LastMember, GetLocation (yyVals[0+yyTop])); yyVal = null; } void case_220() -#line 1916 "cs-parser.jay" +#line 1920 "cs-parser.jay" { Error_SyntaxError (1043, yyToken, "Invalid accessor body"); yyVal = null; } void case_222() -#line 1931 "cs-parser.jay" +#line 1935 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); push_current_class (new Interface (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); @@ -5175,7 +5180,7 @@ void case_222() } void case_223() -#line 1938 "cs-parser.jay" +#line 1942 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -5188,7 +5193,7 @@ void case_223() } void case_224() -#line 1949 "cs-parser.jay" +#line 1953 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -5196,14 +5201,14 @@ void case_224() } void case_225() -#line 1955 "cs-parser.jay" +#line 1959 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); yyVal = pop_current_class (); } void case_241() -#line 2007 "cs-parser.jay" +#line 2011 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { @@ -5230,14 +5235,14 @@ void case_241() } void case_245() -#line 2041 "cs-parser.jay" +#line 2045 "cs-parser.jay" { report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void"); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_247() -#line 2053 "cs-parser.jay" +#line 2057 "cs-parser.jay" { valid_param_mod = 0; @@ -5279,7 +5284,7 @@ void case_247() } void case_272() -#line 2129 "cs-parser.jay" +#line 2133 "cs-parser.jay" { valid_param_mod = 0; @@ -5296,7 +5301,7 @@ void case_272() } void case_274() -#line 2148 "cs-parser.jay" +#line 2152 "cs-parser.jay" { valid_param_mod = 0; @@ -5313,7 +5318,7 @@ void case_274() } void case_275() -#line 2163 "cs-parser.jay" +#line 2167 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -5321,7 +5326,7 @@ void case_275() } void case_276() -#line 2169 "cs-parser.jay" +#line 2173 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -5329,7 +5334,7 @@ void case_276() } void case_277() -#line 2179 "cs-parser.jay" +#line 2183 "cs-parser.jay" { Constructor c = (Constructor) yyVals[-1+yyTop]; c.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5345,7 +5350,7 @@ void case_277() } void case_278() -#line 2198 "cs-parser.jay" +#line 2202 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5356,7 +5361,7 @@ void case_278() } void case_279() -#line 2207 "cs-parser.jay" +#line 2211 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -5369,7 +5374,7 @@ void case_279() } void case_280() -#line 2218 "cs-parser.jay" +#line 2222 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-6+yyTop]; var mods = (Modifiers) yyVals[-7+yyTop]; @@ -5399,7 +5404,7 @@ void case_280() } void case_286() -#line 2263 "cs-parser.jay" +#line 2267 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorBaseInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -5407,7 +5412,7 @@ void case_286() } void case_288() -#line 2273 "cs-parser.jay" +#line 2277 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorThisInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -5415,14 +5420,14 @@ void case_288() } void case_289() -#line 2279 "cs-parser.jay" +#line 2283 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_290() -#line 2287 "cs-parser.jay" +#line 2291 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5433,7 +5438,7 @@ void case_290() } void case_291() -#line 2296 "cs-parser.jay" +#line 2300 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ @@ -5455,7 +5460,7 @@ void case_291() } void case_292() -#line 2321 "cs-parser.jay" +#line 2325 "cs-parser.jay" { current_event_field = new EventField (current_class, (FullNamedExpression) yyVals[-1+yyTop], (Modifiers) yyVals[-3+yyTop], (MemberName) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop]); current_container.AddEvent (current_event_field); @@ -5469,7 +5474,7 @@ void case_292() } void case_293() -#line 2335 "cs-parser.jay" +#line 2339 "cs-parser.jay" { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); @@ -5481,7 +5486,7 @@ void case_293() } void case_294() -#line 2348 "cs-parser.jay" +#line 2352 "cs-parser.jay" { current_event = new EventProperty (current_class, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-4+yyTop], (MemberName) yyVals[-1+yyTop], (Attributes) yyVals[-5+yyTop]); current_container.AddEvent (current_event); @@ -5491,7 +5496,7 @@ void case_294() } void case_295() -#line 2356 "cs-parser.jay" +#line 2360 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) report.Error (69, GetLocation (yyVals[-2+yyTop]), "Event in interface cannot have add or remove accessors"); @@ -5500,7 +5505,7 @@ void case_295() } void case_296() -#line 2363 "cs-parser.jay" +#line 2367 "cs-parser.jay" { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); @@ -5513,14 +5518,14 @@ void case_296() } void case_299() -#line 2382 "cs-parser.jay" +#line 2386 "cs-parser.jay" { --lexer.parsing_block; current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } void case_304() -#line 2406 "cs-parser.jay" +#line 2410 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -5528,7 +5533,7 @@ void case_304() } void case_306() -#line 2416 "cs-parser.jay" +#line 2420 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -5537,7 +5542,7 @@ void case_306() } void case_307() -#line 2425 "cs-parser.jay" +#line 2429 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", @@ -5551,28 +5556,28 @@ void case_307() } void case_311() -#line 2446 "cs-parser.jay" +#line 2450 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_312() -#line 2451 "cs-parser.jay" +#line 2455 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_313() -#line 2456 "cs-parser.jay" +#line 2460 "cs-parser.jay" { report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } void case_314() -#line 2464 "cs-parser.jay" +#line 2468 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5586,7 +5591,7 @@ void case_314() } void case_315() -#line 2476 "cs-parser.jay" +#line 2480 "cs-parser.jay" { lexer.EventParsing = true; @@ -5601,7 +5606,7 @@ void case_315() } void case_316() -#line 2492 "cs-parser.jay" +#line 2496 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5615,7 +5620,7 @@ void case_316() } void case_317() -#line 2504 "cs-parser.jay" +#line 2508 "cs-parser.jay" { lexer.EventParsing = true; @@ -5630,21 +5635,21 @@ void case_317() } void case_318() -#line 2520 "cs-parser.jay" +#line 2524 "cs-parser.jay" { report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } void case_320() -#line 2532 "cs-parser.jay" +#line 2536 "cs-parser.jay" { if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } void case_321() -#line 2537 "cs-parser.jay" +#line 2541 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -5658,7 +5663,7 @@ void case_321() } void case_322() -#line 2549 "cs-parser.jay" +#line 2553 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ if (doc_support) @@ -5666,7 +5671,7 @@ void case_322() } void case_323() -#line 2555 "cs-parser.jay" +#line 2559 "cs-parser.jay" { if (doc_support) current_class.DocComment = enumTypeComment; @@ -5681,7 +5686,7 @@ void case_323() } void case_325() -#line 2572 "cs-parser.jay" +#line 2576 "cs-parser.jay" { var te = yyVals[0+yyTop] as TypeExpression; if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { @@ -5693,21 +5698,21 @@ void case_325() } void case_326() -#line 2582 "cs-parser.jay" +#line 2586 "cs-parser.jay" { Error_TypeExpected (GetLocation (yyVals[-1+yyTop])); yyVal = null; } void case_331() -#line 2600 "cs-parser.jay" +#line 2604 "cs-parser.jay" { lbag.AddLocation (yyVals[-2+yyTop], GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } void case_332() -#line 2608 "cs-parser.jay" +#line 2612 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var em = new EnumMember ((Enum) current_class, new MemberName (lt.Value, lt.Location), (Attributes) yyVals[-1+yyTop]); @@ -5722,7 +5727,7 @@ void case_332() } void case_333() -#line 2621 "cs-parser.jay" +#line 2625 "cs-parser.jay" { ++lexer.parsing_block; if (doc_support) { @@ -5732,7 +5737,7 @@ void case_333() } void case_334() -#line 2629 "cs-parser.jay" +#line 2633 "cs-parser.jay" { --lexer.parsing_block; @@ -5748,7 +5753,7 @@ void case_334() } void case_336() -#line 2654 "cs-parser.jay" +#line 2658 "cs-parser.jay" { valid_param_mod = 0; @@ -5768,7 +5773,7 @@ void case_336() } void case_338() -#line 2676 "cs-parser.jay" +#line 2680 "cs-parser.jay" { if (doc_support) { current_delegate.DocComment = Lexer.consume_doc_comment (); @@ -5784,7 +5789,7 @@ void case_338() } void case_340() -#line 2694 "cs-parser.jay" +#line 2698 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); @@ -5793,7 +5798,7 @@ void case_340() } void case_342() -#line 2705 "cs-parser.jay" +#line 2709 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5802,7 +5807,7 @@ void case_342() } void case_344() -#line 2716 "cs-parser.jay" +#line 2720 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); @@ -5810,14 +5815,14 @@ void case_344() } void case_345() -#line 2725 "cs-parser.jay" +#line 2729 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } void case_347() -#line 2737 "cs-parser.jay" +#line 2741 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -5830,14 +5835,14 @@ void case_347() } void case_348() -#line 2748 "cs-parser.jay" +#line 2752 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = new TypeArguments (); } void case_349() -#line 2756 "cs-parser.jay" +#line 2760 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -5846,7 +5851,7 @@ void case_349() } void case_350() -#line 2763 "cs-parser.jay" +#line 2767 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -5855,7 +5860,7 @@ void case_350() } void case_352() -#line 2781 "cs-parser.jay" +#line 2784 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -5863,7 +5868,7 @@ void case_352() } void case_353() -#line 2790 "cs-parser.jay" +#line 2793 "cs-parser.jay" { MemberName mn = (MemberName)yyVals[0+yyTop]; if (mn.TypeArguments != null) @@ -5872,7 +5877,7 @@ void case_353() } void case_355() -#line 2801 "cs-parser.jay" +#line 2804 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5880,21 +5885,21 @@ void case_355() } void case_356() -#line 2810 "cs-parser.jay" +#line 2813 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeContainer.DefaultIndexerName, GetLocation (yyVals[0+yyTop])); } void case_357() -#line 2815 "cs-parser.jay" +#line 2818 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName ((MemberName) yyVals[-1+yyTop], TypeContainer.DefaultIndexerName, null, GetLocation (yyVals[-1+yyTop])); } void case_358() -#line 2823 "cs-parser.jay" +#line 2826 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberName (lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); @@ -5902,7 +5907,7 @@ void case_358() } void case_359() -#line 2829 "cs-parser.jay" +#line 2832 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -5912,7 +5917,7 @@ void case_359() } void case_360() -#line 2837 "cs-parser.jay" +#line 2840 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); @@ -5920,7 +5925,7 @@ void case_360() } void case_362() -#line 2847 "cs-parser.jay" +#line 2850 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -5930,7 +5935,7 @@ void case_362() } void case_363() -#line 2858 "cs-parser.jay" +#line 2861 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression)yyVals[0+yyTop]); @@ -5938,7 +5943,7 @@ void case_363() } void case_364() -#line 2864 "cs-parser.jay" +#line 2867 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression)yyVals[0+yyTop]); @@ -5947,14 +5952,14 @@ void case_364() } void case_365() -#line 2874 "cs-parser.jay" +#line 2877 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new TypeParameterName (lt.Value, (Attributes)yyVals[-2+yyTop], (Variance) yyVals[-1+yyTop], lt.Location); } void case_366() -#line 2879 "cs-parser.jay" +#line 2882 "cs-parser.jay" { if (GetTokenName (yyToken) == "type") report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type"); @@ -5965,28 +5970,28 @@ void case_366() } void case_371() -#line 2913 "cs-parser.jay" +#line 2916 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_373() -#line 2922 "cs-parser.jay" +#line 2925 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_375() -#line 2931 "cs-parser.jay" +#line 2934 "cs-parser.jay" { report.Error (1536, GetLocation (yyVals[0+yyTop]), "Invalid parameter type `void'"); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_378() -#line 2947 "cs-parser.jay" +#line 2950 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-1+yyTop]; @@ -6001,14 +6006,14 @@ void case_378() } void case_380() -#line 2964 "cs-parser.jay" +#line 2967 "cs-parser.jay" { if (yyVals[0+yyTop] != null) yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } void case_383() -#line 2980 "cs-parser.jay" +#line 2983 "cs-parser.jay" { var types = new List (2); types.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6016,7 +6021,7 @@ void case_383() } void case_384() -#line 2986 "cs-parser.jay" +#line 2989 "cs-parser.jay" { var types = (List) yyVals[-2+yyTop]; types.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6025,7 +6030,7 @@ void case_384() } void case_385() -#line 2996 "cs-parser.jay" +#line 2999 "cs-parser.jay" { if (yyVals[0+yyTop] is ComposedCast) { report.Error (1521, GetLocation (yyVals[0+yyTop]), "Invalid base type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ()); @@ -6034,35 +6039,35 @@ void case_385() } void case_386() -#line 3003 "cs-parser.jay" +#line 3006 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } void case_423() -#line 3065 "cs-parser.jay" +#line 3068 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } void case_424() -#line 3069 "cs-parser.jay" +#line 3072 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location); } void case_435() -#line 3110 "cs-parser.jay" +#line 3113 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_437() -#line 3122 "cs-parser.jay" +#line 3125 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); @@ -6070,7 +6075,7 @@ void case_437() } void case_438() -#line 3128 "cs-parser.jay" +#line 3131 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); @@ -6078,7 +6083,7 @@ void case_438() } void case_439() -#line 3134 "cs-parser.jay" +#line 3137 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); @@ -6086,7 +6091,7 @@ void case_439() } void case_440() -#line 3140 "cs-parser.jay" +#line 3143 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6096,28 +6101,28 @@ void case_440() } void case_442() -#line 3150 "cs-parser.jay" +#line 3153 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } void case_444() -#line 3158 "cs-parser.jay" +#line 3161 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } void case_445() -#line 3166 "cs-parser.jay" +#line 3169 "cs-parser.jay" { yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_448() -#line 3179 "cs-parser.jay" +#line 3182 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) { yyVal = CollectionOrObjectInitializers.Empty; @@ -6129,14 +6134,14 @@ void case_448() } void case_449() -#line 3189 "cs-parser.jay" +#line 3192 "cs-parser.jay" { yyVal = new CollectionOrObjectInitializers ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_452() -#line 3205 "cs-parser.jay" +#line 3208 "cs-parser.jay" { var a = new List (); a.Add ((Expression) yyVals[0+yyTop]); @@ -6144,7 +6149,7 @@ void case_452() } void case_453() -#line 3211 "cs-parser.jay" +#line 3214 "cs-parser.jay" { var a = (List)yyVals[-2+yyTop]; a.Add ((Expression) yyVals[0+yyTop]); @@ -6153,14 +6158,14 @@ void case_453() } void case_454() -#line 3217 "cs-parser.jay" +#line 3220 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } void case_455() -#line 3225 "cs-parser.jay" +#line 3228 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new ElementInitializer (lt.Value, (Expression)yyVals[0+yyTop], lt.Location); @@ -6168,7 +6173,7 @@ void case_455() } void case_457() -#line 3234 "cs-parser.jay" +#line 3237 "cs-parser.jay" { CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName; if (csn == null) @@ -6178,7 +6183,7 @@ void case_457() } void case_458() -#line 3242 "cs-parser.jay" +#line 3245 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) yyVal = null; @@ -6187,14 +6192,14 @@ void case_458() } void case_459() -#line 3249 "cs-parser.jay" +#line 3252 "cs-parser.jay" { report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty"); yyVal = null; } void case_464() -#line 3267 "cs-parser.jay" +#line 3270 "cs-parser.jay" { Arguments list = new Arguments (4); list.Add ((Argument) yyVals[0+yyTop]); @@ -6202,7 +6207,7 @@ void case_464() } void case_465() -#line 3273 "cs-parser.jay" +#line 3276 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; if (list [list.Count - 1] is NamedArgument) @@ -6214,7 +6219,7 @@ void case_465() } void case_466() -#line 3283 "cs-parser.jay" +#line 3286 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; NamedArgument a = (NamedArgument) yyVals[0+yyTop]; @@ -6231,56 +6236,56 @@ void case_466() } void case_467() -#line 3298 "cs-parser.jay" +#line 3301 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[0+yyTop]), "An argument is missing"); yyVal = yyVals[-1+yyTop]; } void case_468() -#line 3303 "cs-parser.jay" +#line 3306 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } void case_473() -#line 3324 "cs-parser.jay" +#line 3327 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_474() -#line 3329 "cs-parser.jay" +#line 3332 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_475() -#line 3334 "cs-parser.jay" +#line 3337 "cs-parser.jay" { yyVal = new Argument (new Arglist ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]))); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_476() -#line 3339 "cs-parser.jay" +#line 3342 "cs-parser.jay" { yyVal = new Argument (new Arglist (GetLocation (yyVals[-2+yyTop]))); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_478() -#line 3351 "cs-parser.jay" +#line 3354 "cs-parser.jay" { yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_479() -#line 3359 "cs-parser.jay" +#line 3362 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); @@ -6288,7 +6293,7 @@ void case_479() } void case_480() -#line 3365 "cs-parser.jay" +#line 3368 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6297,14 +6302,14 @@ void case_480() } void case_481() -#line 3371 "cs-parser.jay" +#line 3374 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } void case_482() -#line 3379 "cs-parser.jay" +#line 3382 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); @@ -6312,7 +6317,7 @@ void case_482() } void case_483() -#line 3385 "cs-parser.jay" +#line 3388 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6324,21 +6329,21 @@ void case_483() } void case_487() -#line 3413 "cs-parser.jay" +#line 3416 "cs-parser.jay" { yyVal = new ElementAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_488() -#line 3418 "cs-parser.jay" +#line 3421 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } void case_491() -#line 3440 "cs-parser.jay" +#line 3443 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) @@ -6353,7 +6358,7 @@ void case_491() } void case_492() -#line 3453 "cs-parser.jay" +#line 3456 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); @@ -6362,7 +6367,7 @@ void case_492() } void case_493() -#line 3465 "cs-parser.jay" +#line 3468 "cs-parser.jay" { yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List) yyVals[-3+yyTop], new ComposedTypeSpecifier (((List) yyVals[-3+yyTop]).Count, GetLocation (yyVals[-4+yyTop])) { @@ -6372,7 +6377,7 @@ void case_493() } void case_494() -#line 3473 "cs-parser.jay" +#line 3476 "cs-parser.jay" { if (yyVals[0+yyTop] == null) report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6381,7 +6386,7 @@ void case_494() } void case_495() -#line 3480 "cs-parser.jay" +#line 3483 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); @@ -6390,28 +6395,28 @@ void case_495() } void case_496() -#line 3487 "cs-parser.jay" +#line 3490 "cs-parser.jay" { report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop])); } void case_497() -#line 3492 "cs-parser.jay" +#line 3495 "cs-parser.jay" { Error_SyntaxError (1526, yyToken, "Unexpected symbol"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } void case_499() -#line 3503 "cs-parser.jay" +#line 3506 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } void case_500() -#line 3511 "cs-parser.jay" +#line 3514 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); @@ -6423,7 +6428,7 @@ void case_500() } void case_505() -#line 3534 "cs-parser.jay" +#line 3537 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6431,7 +6436,7 @@ void case_505() } void case_506() -#line 3540 "cs-parser.jay" +#line 3543 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6441,7 +6446,7 @@ void case_506() } void case_507() -#line 3551 "cs-parser.jay" +#line 3554 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop]; yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location); @@ -6449,7 +6454,7 @@ void case_507() } void case_508() -#line 3557 "cs-parser.jay" +#line 3560 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location), @@ -6457,14 +6462,14 @@ void case_508() } void case_509() -#line 3563 "cs-parser.jay" +#line 3566 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } void case_510() -#line 3568 "cs-parser.jay" +#line 3571 "cs-parser.jay" { report.Error (746, lexer.Location, "Invalid anonymous type member declarator. Anonymous type members must be a member assignment, simple name or member access expression"); @@ -6472,28 +6477,28 @@ void case_510() } void case_514() -#line 3583 "cs-parser.jay" +#line 3586 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_515() -#line 3591 "cs-parser.jay" +#line 3594 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_516() -#line 3596 "cs-parser.jay" +#line 3599 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_521() -#line 3626 "cs-parser.jay" +#line 3629 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6502,7 +6507,7 @@ void case_521() } void case_522() -#line 3633 "cs-parser.jay" +#line 3636 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6515,7 +6520,7 @@ void case_522() } void case_523() -#line 3647 "cs-parser.jay" +#line 3650 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); @@ -6523,7 +6528,7 @@ void case_523() } void case_524() -#line 3653 "cs-parser.jay" +#line 3656 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6532,7 +6537,7 @@ void case_524() } void case_526() -#line 3667 "cs-parser.jay" +#line 3670 "cs-parser.jay" { lexer.TypeOfParsing = false; yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -6540,14 +6545,14 @@ void case_526() } void case_529() -#line 3678 "cs-parser.jay" +#line 3681 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } void case_530() -#line 3686 "cs-parser.jay" +#line 3689 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6555,7 +6560,7 @@ void case_530() } void case_531() -#line 3692 "cs-parser.jay" +#line 3695 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6565,7 +6570,7 @@ void case_531() } void case_532() -#line 3700 "cs-parser.jay" +#line 3703 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6573,7 +6578,7 @@ void case_532() } void case_533() -#line 3706 "cs-parser.jay" +#line 3709 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6581,7 +6586,7 @@ void case_533() } void case_534() -#line 3712 "cs-parser.jay" +#line 3715 "cs-parser.jay" { var te = ((MemberName) yyVals[-3+yyTop]).GetTypeExpression (); if (te.HasTypeArguments) @@ -6592,7 +6597,7 @@ void case_534() } void case_535() -#line 3724 "cs-parser.jay" +#line 3727 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); @@ -6601,7 +6606,7 @@ void case_535() } void case_536() -#line 3734 "cs-parser.jay" +#line 3737 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; if (lang_version == LanguageVersion.ISO_1) @@ -6611,35 +6616,35 @@ void case_536() } void case_537() -#line 3745 "cs-parser.jay" +#line 3748 "cs-parser.jay" { yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_538() -#line 3753 "cs-parser.jay" +#line 3756 "cs-parser.jay" { yyVal = new CheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_539() -#line 3761 "cs-parser.jay" +#line 3764 "cs-parser.jay" { yyVal = new UnCheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_540() -#line 3769 "cs-parser.jay" +#line 3772 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-3+yyTop], GetLocation (yyVals[-2+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); } void case_542() -#line 3781 "cs-parser.jay" +#line 3784 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); if ((ParametersCompiled) yyVals[-2+yyTop] != ParametersCompiled.Undefined) { @@ -6650,7 +6655,7 @@ void case_542() } void case_548() -#line 3813 "cs-parser.jay" +#line 3816 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; @@ -6659,7 +6664,7 @@ void case_548() } void case_549() -#line 3823 "cs-parser.jay" +#line 3826 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); @@ -6669,147 +6674,147 @@ void case_549() } void case_555() -#line 3848 "cs-parser.jay" +#line 3851 "cs-parser.jay" { yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_556() -#line 3856 "cs-parser.jay" +#line 3859 "cs-parser.jay" { current_block.ParametersBlock.IsAsync = true; yyVal = new Await ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_565() -#line 3897 "cs-parser.jay" +#line 3900 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_566() -#line 3902 "cs-parser.jay" +#line 3905 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_567() -#line 3907 "cs-parser.jay" +#line 3910 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_569() -#line 3916 "cs-parser.jay" +#line 3919 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_571() -#line 3925 "cs-parser.jay" +#line 3928 "cs-parser.jay" { /* Shift/Reduce conflict*/ yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_575() -#line 3942 "cs-parser.jay" +#line 3945 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_576() -#line 3947 "cs-parser.jay" +#line 3950 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_578() -#line 3956 "cs-parser.jay" +#line 3959 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_579() -#line 3961 "cs-parser.jay" +#line 3964 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_580() -#line 3966 "cs-parser.jay" +#line 3969 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_581() -#line 3971 "cs-parser.jay" +#line 3974 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_583() -#line 3980 "cs-parser.jay" +#line 3983 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_584() -#line 3985 "cs-parser.jay" +#line 3988 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_586() -#line 3994 "cs-parser.jay" +#line 3997 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_588() -#line 4003 "cs-parser.jay" +#line 4006 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_590() -#line 4012 "cs-parser.jay" +#line 4015 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_592() -#line 4021 "cs-parser.jay" +#line 4024 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_594() -#line 4030 "cs-parser.jay" +#line 4033 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_596() -#line 4039 "cs-parser.jay" +#line 4042 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); @@ -6818,84 +6823,84 @@ void case_596() } void case_598() -#line 4050 "cs-parser.jay" +#line 4053 "cs-parser.jay" { yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_600() -#line 4062 "cs-parser.jay" +#line 4065 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_601() -#line 4067 "cs-parser.jay" +#line 4070 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_602() -#line 4072 "cs-parser.jay" +#line 4075 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_603() -#line 4077 "cs-parser.jay" +#line 4080 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_604() -#line 4082 "cs-parser.jay" +#line 4085 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_605() -#line 4087 "cs-parser.jay" +#line 4090 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_606() -#line 4092 "cs-parser.jay" +#line 4095 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_607() -#line 4097 "cs-parser.jay" +#line 4100 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_608() -#line 4102 "cs-parser.jay" +#line 4105 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_609() -#line 4107 "cs-parser.jay" +#line 4110 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_610() -#line 4115 "cs-parser.jay" +#line 4118 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -6904,7 +6909,7 @@ void case_610() } void case_611() -#line 4122 "cs-parser.jay" +#line 4125 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -6919,7 +6924,7 @@ void case_611() } void case_612() -#line 4138 "cs-parser.jay" +#line 4141 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6927,7 +6932,7 @@ void case_612() } void case_613() -#line 4144 "cs-parser.jay" +#line 4147 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6935,21 +6940,21 @@ void case_613() } void case_614() -#line 4150 "cs-parser.jay" +#line 4153 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } void case_616() -#line 4158 "cs-parser.jay" +#line 4161 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); } void case_620() -#line 4174 "cs-parser.jay" +#line 4177 "cs-parser.jay" { Block b = end_block (lexer.Location); b.IsCompilerGenerated = true; @@ -6958,14 +6963,14 @@ void case_620() } void case_622() -#line 4185 "cs-parser.jay" +#line 4188 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } void case_623() -#line 4193 "cs-parser.jay" +#line 4196 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); @@ -6973,14 +6978,14 @@ void case_623() } void case_624() -#line 4199 "cs-parser.jay" +#line 4202 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } void case_625() -#line 4204 "cs-parser.jay" +#line 4207 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); @@ -6988,63 +6993,63 @@ void case_625() } void case_626() -#line 4210 "cs-parser.jay" +#line 4213 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_628() -#line 4219 "cs-parser.jay" +#line 4222 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], false, GetLocation (yyVals[-4+yyTop])); } void case_629() -#line 4224 "cs-parser.jay" +#line 4227 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_631() -#line 4233 "cs-parser.jay" +#line 4236 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], true, GetLocation (yyVals[-5+yyTop])); } void case_632() -#line 4238 "cs-parser.jay" +#line 4241 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_639() -#line 4261 "cs-parser.jay" +#line 4264 "cs-parser.jay" { yyVal = new RefValueExpr ((Expression) yyVals[-3+yyTop], (FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_640() -#line 4266 "cs-parser.jay" +#line 4269 "cs-parser.jay" { yyVal = new RefTypeExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_641() -#line 4271 "cs-parser.jay" +#line 4274 "cs-parser.jay" { yyVal = new MakeRefExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_645() -#line 4300 "cs-parser.jay" +#line 4303 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); Class c = new Class (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]); @@ -7056,7 +7061,7 @@ void case_645() } void case_646() -#line 4311 "cs-parser.jay" +#line 4314 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -7070,7 +7075,7 @@ void case_646() } void case_647() -#line 4323 "cs-parser.jay" +#line 4326 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -7078,21 +7083,21 @@ void case_647() } void case_648() -#line 4329 "cs-parser.jay" +#line 4332 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); yyVal = pop_current_class (); } void case_651() -#line 4344 "cs-parser.jay" +#line 4347 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; } void case_654() -#line 4354 "cs-parser.jay" +#line 4357 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -7110,7 +7115,7 @@ void case_654() } void case_655() -#line 4373 "cs-parser.jay" +#line 4376 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7120,91 +7125,91 @@ void case_655() } void case_656() -#line 4381 "cs-parser.jay" +#line 4384 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_657() -#line 4386 "cs-parser.jay" +#line 4389 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_658() -#line 4391 "cs-parser.jay" +#line 4394 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_659() -#line 4396 "cs-parser.jay" +#line 4399 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_660() -#line 4401 "cs-parser.jay" +#line 4404 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_661() -#line 4406 "cs-parser.jay" +#line 4409 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_662() -#line 4411 "cs-parser.jay" +#line 4414 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_663() -#line 4416 "cs-parser.jay" +#line 4419 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_664() -#line 4421 "cs-parser.jay" +#line 4424 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_665() -#line 4426 "cs-parser.jay" +#line 4429 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_666() -#line 4431 "cs-parser.jay" +#line 4434 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_667() -#line 4436 "cs-parser.jay" +#line 4439 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_668() -#line 4441 "cs-parser.jay" +#line 4444 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7213,21 +7218,21 @@ void case_668() } void case_669() -#line 4448 "cs-parser.jay" +#line 4451 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_674() -#line 4469 "cs-parser.jay" +#line 4472 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_675() -#line 4477 "cs-parser.jay" +#line 4480 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); @@ -7235,7 +7240,7 @@ void case_675() } void case_676() -#line 4483 "cs-parser.jay" +#line 4486 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7253,14 +7258,14 @@ void case_676() } void case_677() -#line 4502 "cs-parser.jay" +#line 4505 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); } void case_678() -#line 4510 "cs-parser.jay" +#line 4513 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -7268,7 +7273,7 @@ void case_678() } void case_679() -#line 4516 "cs-parser.jay" +#line 4519 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7293,7 +7298,7 @@ void case_679() } void case_680() -#line 4542 "cs-parser.jay" +#line 4545 "cs-parser.jay" { if (yyVals[0+yyTop] is ComposedCast) report.Error (706, GetLocation (yyVals[0+yyTop]), "Invalid constraint type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ()); @@ -7302,14 +7307,14 @@ void case_680() } void case_681() -#line 4549 "cs-parser.jay" +#line 4552 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Constructor, GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_685() -#line 4569 "cs-parser.jay" +#line 4572 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); @@ -7318,77 +7323,77 @@ void case_685() } void case_688() -#line 4603 "cs-parser.jay" +#line 4606 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } void case_690() -#line 4615 "cs-parser.jay" +#line 4618 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } void case_691() -#line 4620 "cs-parser.jay" +#line 4623 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } void case_692() -#line 4629 "cs-parser.jay" +#line 4632 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } void case_693() -#line 4634 "cs-parser.jay" +#line 4637 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } void case_701() -#line 4661 "cs-parser.jay" +#line 4664 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_734() -#line 4725 "cs-parser.jay" +#line 4728 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } void case_735() -#line 4730 "cs-parser.jay" +#line 4733 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } void case_736() -#line 4735 "cs-parser.jay" +#line 4738 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } void case_737() -#line 4743 "cs-parser.jay" +#line 4746 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } void case_738() -#line 4751 "cs-parser.jay" +#line 4754 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7398,7 +7403,7 @@ void case_738() } void case_741() -#line 4764 "cs-parser.jay" +#line 4767 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7407,7 +7412,7 @@ void case_741() } void case_742() -#line 4780 "cs-parser.jay" +#line 4783 "cs-parser.jay" { /* Ok, the above "primary_expression" is there to get rid of*/ /* both reduce/reduce and shift/reduces in the grammar, it should*/ @@ -7439,7 +7444,7 @@ void case_742() } void case_743() -#line 4810 "cs-parser.jay" +#line 4813 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7452,7 +7457,7 @@ void case_743() } void case_744() -#line 4821 "cs-parser.jay" +#line 4824 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7461,21 +7466,21 @@ void case_744() } void case_747() -#line 4836 "cs-parser.jay" +#line 4839 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_749() -#line 4845 "cs-parser.jay" +#line 4848 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_751() -#line 4860 "cs-parser.jay" +#line 4863 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7484,7 +7489,7 @@ void case_751() } void case_752() -#line 4867 "cs-parser.jay" +#line 4870 "cs-parser.jay" { yyVal = current_variable; current_variable = null; @@ -7492,7 +7497,7 @@ void case_752() } void case_753() -#line 4873 "cs-parser.jay" +#line 4876 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7501,7 +7506,7 @@ void case_753() } void case_754() -#line 4880 "cs-parser.jay" +#line 4883 "cs-parser.jay" { if (current_variable.Initializer != null) { lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); @@ -7513,14 +7518,14 @@ void case_754() } void case_756() -#line 4894 "cs-parser.jay" +#line 4897 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } void case_757() -#line 4899 "cs-parser.jay" +#line 4902 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7531,7 +7536,7 @@ void case_757() } void case_762() -#line 4921 "cs-parser.jay" +#line 4924 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7542,7 +7547,7 @@ void case_762() } void case_763() -#line 4930 "cs-parser.jay" +#line 4933 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7553,14 +7558,14 @@ void case_763() } void case_765() -#line 4946 "cs-parser.jay" +#line 4949 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); current_variable.Initializer = (Expression) yyVals[0+yyTop]; } void case_770() -#line 4964 "cs-parser.jay" +#line 4967 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7571,28 +7576,28 @@ void case_770() } void case_772() -#line 4977 "cs-parser.jay" +#line 4980 "cs-parser.jay" { yyVal = new StackAlloc ((Expression) yyVals[-3+yyTop], (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_773() -#line 4982 "cs-parser.jay" +#line 4985 "cs-parser.jay" { report.Error (1575, GetLocation (yyVals[-1+yyTop]), "A stackalloc expression requires [] after type"); yyVal = new StackAlloc ((Expression) yyVals[0+yyTop], null, GetLocation (yyVals[-1+yyTop])); } void case_774() -#line 4990 "cs-parser.jay" +#line 4993 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_778() -#line 5008 "cs-parser.jay" +#line 5011 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { @@ -7604,7 +7609,7 @@ void case_778() } void case_779() -#line 5021 "cs-parser.jay" +#line 5024 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7614,14 +7619,14 @@ void case_779() } void case_780() -#line 5029 "cs-parser.jay" +#line 5032 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } void case_783() -#line 5043 "cs-parser.jay" +#line 5046 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7631,7 +7636,7 @@ void case_783() } void case_784() -#line 5052 "cs-parser.jay" +#line 5055 "cs-parser.jay" { yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); @@ -7643,7 +7648,7 @@ void case_784() } void case_786() -#line 5069 "cs-parser.jay" +#line 5072 "cs-parser.jay" { yyVal = new Switch ((Expression) yyVals[-5+yyTop], (ExplicitBlock) current_block.Explicit, (List) yyVals[-1+yyTop], GetLocation (yyVals[-7+yyTop])); end_block (GetLocation (yyVals[0+yyTop])); @@ -7651,14 +7656,14 @@ void case_786() } void case_787() -#line 5078 "cs-parser.jay" +#line 5081 "cs-parser.jay" { report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } void case_789() -#line 5087 "cs-parser.jay" +#line 5090 "cs-parser.jay" { var sections = new List (4); @@ -7667,7 +7672,7 @@ void case_789() } void case_790() -#line 5094 "cs-parser.jay" +#line 5097 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -7676,14 +7681,14 @@ void case_790() } void case_791() -#line 5101 "cs-parser.jay" +#line 5104 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } void case_794() -#line 5120 "cs-parser.jay" +#line 5123 "cs-parser.jay" { var labels = new List (2); @@ -7692,7 +7697,7 @@ void case_794() } void case_795() -#line 5127 "cs-parser.jay" +#line 5130 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -7701,14 +7706,14 @@ void case_795() } void case_796() -#line 5137 "cs-parser.jay" +#line 5140 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_802() -#line 5156 "cs-parser.jay" +#line 5159 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7718,21 +7723,21 @@ void case_802() } void case_803() -#line 5168 "cs-parser.jay" +#line 5171 "cs-parser.jay" { yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], GetLocation (yyVals[-6+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_804() -#line 5176 "cs-parser.jay" +#line 5179 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; } void case_806() -#line 5192 "cs-parser.jay" +#line 5195 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7746,14 +7751,14 @@ void case_806() } void case_807() -#line 5204 "cs-parser.jay" +#line 5207 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } void case_810() -#line 5217 "cs-parser.jay" +#line 5220 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7762,14 +7767,14 @@ void case_810() } void case_811() -#line 5224 "cs-parser.jay" +#line 5227 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_819() -#line 5248 "cs-parser.jay" +#line 5251 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -7784,14 +7789,14 @@ void case_819() } void case_820() -#line 5264 "cs-parser.jay" +#line 5267 "cs-parser.jay" { report.Error (230, GetLocation (yyVals[-5+yyTop]), "Type and identifier are both required in a foreach statement"); yyVal = null; } void case_821() -#line 5269 "cs-parser.jay" +#line 5272 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -7802,7 +7807,7 @@ void case_821() } void case_822() -#line 5278 "cs-parser.jay" +#line 5281 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7815,21 +7820,21 @@ void case_822() } void case_829() -#line 5301 "cs-parser.jay" +#line 5304 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_830() -#line 5309 "cs-parser.jay" +#line 5312 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_831() -#line 5317 "cs-parser.jay" +#line 5320 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new Goto (lt.Value, GetLocation (yyVals[-2+yyTop])); @@ -7837,35 +7842,35 @@ void case_831() } void case_832() -#line 5323 "cs-parser.jay" +#line 5326 "cs-parser.jay" { yyVal = new GotoCase ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_833() -#line 5328 "cs-parser.jay" +#line 5331 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_834() -#line 5336 "cs-parser.jay" +#line 5339 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_835() -#line 5344 "cs-parser.jay" +#line 5347 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_836() -#line 5352 "cs-parser.jay" +#line 5355 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -7883,7 +7888,7 @@ void case_836() } void case_837() -#line 5368 "cs-parser.jay" +#line 5371 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -7899,28 +7904,28 @@ void case_837() } void case_841() -#line 5394 "cs-parser.jay" +#line 5397 "cs-parser.jay" { yyVal = new TryFinally ((Statement) yyVals[-2+yyTop], (Block) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_842() -#line 5399 "cs-parser.jay" +#line 5402 "cs-parser.jay" { yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]), true), (Block) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_843() -#line 5404 "cs-parser.jay" +#line 5407 "cs-parser.jay" { report.Error (1524, GetLocation (yyVals[-2+yyTop]), "Expected catch or finally"); yyVal = null; } void case_844() -#line 5412 "cs-parser.jay" +#line 5415 "cs-parser.jay" { var l = new List (2); @@ -7929,7 +7934,7 @@ void case_844() } void case_845() -#line 5419 "cs-parser.jay" +#line 5422 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -7947,7 +7952,7 @@ void case_845() } void case_849() -#line 5447 "cs-parser.jay" +#line 5450 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -7964,7 +7969,7 @@ void case_849() } void case_851() -#line 5466 "cs-parser.jay" +#line 5469 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { report.Error (1015, lexer.Location, @@ -7977,14 +7982,14 @@ void case_851() } void case_854() -#line 5494 "cs-parser.jay" +#line 5497 "cs-parser.jay" { if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } void case_856() -#line 5504 "cs-parser.jay" +#line 5507 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7994,7 +7999,7 @@ void case_856() } void case_857() -#line 5515 "cs-parser.jay" +#line 5518 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8006,14 +8011,14 @@ void case_857() } void case_858() -#line 5525 "cs-parser.jay" +#line 5528 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_859() -#line 5530 "cs-parser.jay" +#line 5533 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8025,7 +8030,7 @@ void case_859() } void case_860() -#line 5543 "cs-parser.jay" +#line 5546 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8037,14 +8042,14 @@ void case_860() } void case_861() -#line 5553 "cs-parser.jay" +#line 5556 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_862() -#line 5558 "cs-parser.jay" +#line 5561 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8056,7 +8061,7 @@ void case_862() } void case_863() -#line 5568 "cs-parser.jay" +#line 5571 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8067,14 +8072,14 @@ void case_863() } void case_865() -#line 5584 "cs-parser.jay" +#line 5587 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; yyVal = current_variable; } void case_866() -#line 5595 "cs-parser.jay" +#line 5598 "cs-parser.jay" { lexer.query_parsing = false; @@ -8088,7 +8093,7 @@ void case_866() } void case_867() -#line 5607 "cs-parser.jay" +#line 5610 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -8100,7 +8105,7 @@ void case_867() } void case_868() -#line 5618 "cs-parser.jay" +#line 5621 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -8110,7 +8115,7 @@ void case_868() } void case_869() -#line 5625 "cs-parser.jay" +#line 5628 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); @@ -8118,7 +8123,7 @@ void case_869() } void case_870() -#line 5634 "cs-parser.jay" +#line 5637 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8128,7 +8133,7 @@ void case_870() } void case_871() -#line 5642 "cs-parser.jay" +#line 5645 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8142,7 +8147,7 @@ void case_871() } void case_872() -#line 5657 "cs-parser.jay" +#line 5660 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8152,7 +8157,7 @@ void case_872() } void case_873() -#line 5665 "cs-parser.jay" +#line 5668 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8166,7 +8171,7 @@ void case_873() } void case_875() -#line 5684 "cs-parser.jay" +#line 5687 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8179,7 +8184,7 @@ void case_875() } void case_877() -#line 5699 "cs-parser.jay" +#line 5702 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8195,7 +8200,7 @@ void case_877() } void case_878() -#line 5716 "cs-parser.jay" +#line 5719 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -8212,14 +8217,14 @@ void case_878() } void case_880() -#line 5732 "cs-parser.jay" +#line 5735 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_882() -#line 5744 "cs-parser.jay" +#line 5747 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8228,7 +8233,7 @@ void case_882() } void case_883() -#line 5751 "cs-parser.jay" +#line 5754 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8238,7 +8243,7 @@ void case_883() } void case_884() -#line 5759 "cs-parser.jay" +#line 5762 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8247,7 +8252,7 @@ void case_884() } void case_885() -#line 5766 "cs-parser.jay" +#line 5769 "cs-parser.jay" { yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-3+yyTop], linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); @@ -8257,14 +8262,14 @@ void case_885() } void case_889() -#line 5783 "cs-parser.jay" +#line 5786 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_896() -#line 5803 "cs-parser.jay" +#line 5806 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8278,7 +8283,7 @@ void case_896() } void case_898() -#line 5822 "cs-parser.jay" +#line 5825 "cs-parser.jay" { yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8287,7 +8292,7 @@ void case_898() } void case_899() -#line 5832 "cs-parser.jay" +#line 5835 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8297,7 +8302,7 @@ void case_899() } void case_900() -#line 5840 "cs-parser.jay" +#line 5843 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8307,7 +8312,7 @@ void case_900() } void case_901() -#line 5848 "cs-parser.jay" +#line 5851 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8317,7 +8322,7 @@ void case_901() } void case_902() -#line 5856 "cs-parser.jay" +#line 5859 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8357,7 +8362,7 @@ void case_902() } void case_903() -#line 5894 "cs-parser.jay" +#line 5897 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8367,7 +8372,7 @@ void case_903() } void case_904() -#line 5902 "cs-parser.jay" +#line 5905 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8377,7 +8382,7 @@ void case_904() } void case_905() -#line 5910 "cs-parser.jay" +#line 5913 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8387,7 +8392,7 @@ void case_905() } void case_906() -#line 5918 "cs-parser.jay" +#line 5921 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8429,7 +8434,7 @@ void case_906() } void case_910() -#line 5973 "cs-parser.jay" +#line 5976 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8438,7 +8443,7 @@ void case_910() } void case_912() -#line 5984 "cs-parser.jay" +#line 5987 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8447,14 +8452,14 @@ void case_912() } void case_913() -#line 5991 "cs-parser.jay" +#line 5994 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } void case_915() -#line 6000 "cs-parser.jay" +#line 6003 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8463,42 +8468,42 @@ void case_915() } void case_916() -#line 6007 "cs-parser.jay" +#line 6010 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } void case_918() -#line 6019 "cs-parser.jay" +#line 6022 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_919() -#line 6024 "cs-parser.jay" +#line 6027 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_921() -#line 6036 "cs-parser.jay" +#line 6039 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_922() -#line 6041 "cs-parser.jay" +#line 6044 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_924() -#line 6051 "cs-parser.jay" +#line 6054 "cs-parser.jay" { /* query continuation block is not linked with query block but with block*/ /* before. This means each query can use same range variable names for*/ @@ -8516,7 +8521,7 @@ void case_924() } void case_925() -#line 6067 "cs-parser.jay" +#line 6070 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -8527,7 +8532,7 @@ void case_925() } void case_928() -#line 6094 "cs-parser.jay" +#line 6097 "cs-parser.jay" { current_container = new Class (current_namespace, current_class, new MemberName (""), Modifiers.PUBLIC, null); current_class = current_container; @@ -8559,7 +8564,7 @@ void case_928() } void case_929() -#line 6124 "cs-parser.jay" +#line 6127 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); @@ -8571,7 +8576,7 @@ void case_929() } void case_939() -#line 6167 "cs-parser.jay" +#line 6170 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -8579,7 +8584,7 @@ void case_939() } void case_940() -#line 6173 "cs-parser.jay" +#line 6176 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -8588,14 +8593,14 @@ void case_940() } void case_943() -#line 6188 "cs-parser.jay" +#line 6191 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], new MemberName (MemberCache.IndexerNameAlias)); } void case_944() -#line 6193 "cs-parser.jay" +#line 6196 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8605,7 +8610,7 @@ void case_944() } void case_945() -#line 6201 "cs-parser.jay" +#line 6204 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8615,7 +8620,7 @@ void case_945() } void case_946() -#line 6209 "cs-parser.jay" +#line 6212 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); module.DocumentationBuilder.ParsedParameters = p; @@ -8624,7 +8629,7 @@ void case_946() } void case_954() -#line 6247 "cs-parser.jay" +#line 6250 "cs-parser.jay" { var parameters = new List (); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); @@ -8632,7 +8637,7 @@ void case_954() } void case_955() -#line 6253 "cs-parser.jay" +#line 6256 "cs-parser.jay" { var parameters = yyVals[-2+yyTop] as List; parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); @@ -8640,7 +8645,7 @@ void case_955() } void case_956() -#line 6262 "cs-parser.jay" +#line 6265 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); @@ -11976,7 +11981,7 @@ void case_956() -1, -1, -1, -1, -1, -1, -1, -1, -1, 362, }; -#line 6271 "cs-parser.jay" +#line 6274 "cs-parser.jay" // // A class used to hold info about an operator declarator diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay index bda42e60bd..48471ff2a8 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay @@ -145,6 +145,7 @@ namespace Mono.CSharp Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; Location savedAttrParenOpenLocation, savedAttrParenCloseLocation; Stack> locationListStack = new Stack> (); // used for type parameters + List attributeCommas = new List (); object lastYYVal; @@ -670,6 +671,10 @@ attribute_sections var sect = (List) $1; $$ = new Attributes (sect); lbag.AddLocation (sect, savedOpenLocation, savedCloseLocation); + if (attributeCommas.Count > 0) { + lbag.AppendTo (sect, attributeCommas); + attributeCommas.Clear (); + } } | attribute_sections attribute_section { @@ -752,7 +757,7 @@ attribute_list { var attrs = (List) $1; attrs.Add ((Attribute) $3); - lbag.AppendTo (attrs, GetLocation ($2)); + attributeCommas.Add (GetLocation ($2)); $$ = attrs; } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs index 3e3a68a1c6..d33b64b9b8 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs @@ -335,17 +335,31 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring { if (constantValue == null) throw new ArgumentNullException("constantValue"); - IType type = constantValue.GetValueType(context); - object val = constantValue.GetValue(context); - if (val == null) { - if (type.IsReferenceType(context) == true) - return new NullReferenceExpression(); - else - return new DefaultValueExpression(ConvertType(type)); - } else if (type.Kind == TypeKind.Enum) { + return ConvertConstantValue(constantValue.Resolve(context)); + } + + Expression ConvertConstantValue(ResolveResult rr) + { + if (rr is TypeOfResolveResult) { + return new TypeOfExpression(ConvertType(((TypeOfResolveResult)rr).Type)); + } else if (rr is ArrayCreateResolveResult) { + ArrayCreateResolveResult acrr = (ArrayCreateResolveResult)rr; + AstType type = ConvertType(acrr.Type); throw new NotImplementedException(); + } else if (rr.IsCompileTimeConstant) { + object val = rr.ConstantValue; + if (val == null) { + if (rr.Type.IsReferenceType(context) == true) + return new NullReferenceExpression(); + else + return new DefaultValueExpression(ConvertType(rr.Type)); + } else if (rr.Type.Kind == TypeKind.Enum) { + throw new NotImplementedException(); + } else { + return new PrimitiveExpression(val); + } } else { - return new PrimitiveExpression(val); + return new EmptyExpression(); } } #endregion diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs index c3b47e51fc..2533112abc 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs @@ -19,6 +19,8 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem.Implementation; @@ -70,14 +72,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (positionalArguments != null) { while (i < positionalArguments.Count) { IConstantValue cv = positionalArguments[i]; - arguments[i] = new ConstantResolveResult(cv.GetValueType(context), cv.GetValue(context)); + arguments[i] = cv.Resolve(context); i++; } } if (namedCtorArguments != null) { foreach (var pair in namedCtorArguments) { argumentNames[i] = pair.Key; - arguments[i] = new ConstantResolveResult(pair.Value.GetValueType(context), pair.Value.GetValue(context)); + arguments[i] = pair.Value.Resolve(context); i++; } } @@ -85,17 +87,19 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver return mrr != null ? mrr.Member as IMethod : null; } - public IList GetPositionalArguments(ITypeResolveContext context) + public IList GetPositionalArguments(ITypeResolveContext context) { + List result = new List(); + if (positionalArguments != null) { + foreach (var arg in positionalArguments) { + result.Add(Resolve(arg, context)); + } + } if (namedCtorArguments == null || namedCtorArguments.Count == 0) { // no namedCtorArguments: just return the positionalArguments - if (positionalArguments != null) - return new ReadOnlyCollection(positionalArguments); - else - return EmptyList.Instance; + return result.AsReadOnly(); } // we do have namedCtorArguments, which need to be re-ordered and appended to the positional arguments - List result = new List(this.positionalArguments); IMethod method = ResolveConstructor(context); if (method != null) { for (int i = result.Count; i < method.Parameters.Count; i++) { @@ -103,25 +107,40 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver bool found = false; foreach (var pair in namedCtorArguments) { if (pair.Key == p.Name) { - result.Add(pair.Value); + result.Add(Resolve(pair.Value, context)); found = true; } } if (!found) { // add the parameter's default value: - result.Add(p.DefaultValue ?? new SimpleConstantValue(p.Type, CSharpResolver.GetDefaultValue(p.Type.Resolve(context)))); + if (p.DefaultValue != null) { + result.Add(Resolve(p.DefaultValue, context)); + } else { + IType type = p.Type.Resolve(context); + result.Add(new ConstantResolveResult(type, CSharpResolver.GetDefaultValue(type))); + } } } } return result.AsReadOnly(); } - public IList> GetNamedArguments(ITypeResolveContext context) + ResolveResult Resolve(IConstantValue constantValue, ITypeResolveContext context) { - if (namedArguments != null) - return new ReadOnlyCollection>(namedArguments); + if (constantValue != null) + return constantValue.Resolve(context); else - return EmptyList>.Instance; + return new ErrorResolveResult(SharedTypes.UnknownType); + } + + public IList> GetNamedArguments(ITypeResolveContext context) + { + if (namedArguments != null) { + return namedArguments.Select(p => new KeyValuePair(p.Key, p.Value.Resolve(context))) + .ToList().AsReadOnly(); + } else { + return EmptyList>.Instance; + } } } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs index aa70ed5852..bcd0b8968b 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs @@ -1960,7 +1960,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver // Look in local variables foreach (IVariable v in this.LocalVariables) { if (v.Name == identifier) { - object constantValue = v.IsConst ? v.ConstantValue.GetValue(context) : null; + object constantValue = v.IsConst ? v.ConstantValue.Resolve(context).ConstantValue : null; return new LocalResolveResult(v, v.Type.Resolve(context), constantValue); } } @@ -2788,7 +2788,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// Specifies whether to allow treating single-dimensional arrays like compile-time constants. /// This is used for attribute arguments. /// - public ArrayCreateResolveResult ResolveArrayCreation(IType elementType, int dimensions = 1, ResolveResult[] sizeArguments = null, ResolveResult[] initializerElements = null, bool allowArrayConstants = false) + public ArrayCreateResolveResult ResolveArrayCreation(IType elementType, int dimensions = 1, ResolveResult[] sizeArguments = null, ResolveResult[] initializerElements = null) { if (sizeArguments != null && dimensions != Math.Max(1, sizeArguments.Length)) throw new ArgumentException("dimensions and sizeArguments.Length don't match"); @@ -2807,7 +2807,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver initializerElements[i] = Convert(initializerElements[i], elementType); } } - return new ArrayCreateResolveResult(arrayType, sizeArguments, initializerElements, allowArrayConstants); + return new ArrayCreateResolveResult(arrayType, sizeArguments, initializerElements); } #endregion } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs index a26b2d029e..6d9a1a98ca 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs @@ -57,72 +57,56 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver.ConstantValues }; } - sealed class ConstantValueResult - { - public readonly IType ValueType; - public readonly object Value; - - public ConstantValueResult(IType valueType, object value) - { - this.ValueType = valueType; - this.Value = value; - } - } - - ConstantValueResult DoResolve(ITypeResolveContext context) + public ResolveResult Resolve(ITypeResolveContext context) { CacheManager cache = context.CacheManager; if (cache != null) { - ConstantValueResult cachedResult = cache.GetShared(this) as ConstantValueResult; + ResolveResult cachedResult = cache.GetShared(this) as ResolveResult; if (cachedResult != null) return cachedResult; } CSharpResolver resolver = CreateResolver(context); ResolveResult rr = expression.Resolve(resolver); - IType type = rr.Type; - object val = rr.ConstantValue; - if (resolver.Context != context) { - // Retrieve the equivalent type in the new resolve context. - // E.g. if the constant is defined in a .NET 2.0 project, type might be Int32 from mscorlib 2.0. - // However, the calling project might be a .NET 4.0 project, so we need to return Int32 from mscorlib 4.0. - type = type.AcceptVisitor(new MapTypeIntoNewContext(context)); - // If 'val' is a type or an array containing types, we need to map it to the new context. - val = MapToNewContext(val, context); - } - ConstantValueResult result = new ConstantValueResult(type, val); + // Retrieve the equivalent type in the new resolve context. + // E.g. if the constant is defined in a .NET 2.0 project, type might be Int32 from mscorlib 2.0. + // However, the calling project might be a .NET 4.0 project, so we need to return Int32 from mscorlib 4.0. + rr = MapToNewContext(rr, new MapTypeIntoNewContext(context)); if (cache != null) - cache.SetShared(this, result); - return result; - } - - public IType GetValueType(ITypeResolveContext context) - { - return DoResolve(context).ValueType; - } - - public object GetValue(ITypeResolveContext context) - { - return DoResolve(context).Value; + cache.SetShared(this, rr); + return rr; + } + + static ResolveResult MapToNewContext(ResolveResult rr, MapTypeIntoNewContext mapping) + { + if (rr is TypeOfResolveResult) { + return new TypeOfResolveResult( + rr.Type.AcceptVisitor(mapping), + ((TypeOfResolveResult)rr).ReferencedType.AcceptVisitor(mapping)); + } else if (rr is ArrayCreateResolveResult) { + ArrayCreateResolveResult acrr = (ArrayCreateResolveResult)rr; + return new ArrayCreateResolveResult( + acrr.Type.AcceptVisitor(mapping), + MapToNewContext(acrr.SizeArguments, mapping), + MapToNewContext(acrr.InitializerElements, mapping)); + } else if (rr.IsCompileTimeConstant) { + return new ConstantResolveResult( + rr.Type.AcceptVisitor(mapping), + rr.ConstantValue + ); + } else { + return new ErrorResolveResult(rr.Type.AcceptVisitor(mapping)); + } } - static object MapToNewContext(object val, ITypeResolveContext context) + static ResolveResult[] MapToNewContext(ResolveResult[] input, MapTypeIntoNewContext mapping) { - IType type = val as IType; - if (type != null) { - return type.AcceptVisitor(new MapTypeIntoNewContext(context)); - } - object[] arr = val as object[]; - if (arr != null) { - object[] newArr = new object[arr.Length]; - bool modified = false; - for (int i = 0; i < arr.Length; i++) { - newArr[i] = MapToNewContext(arr[i], context); - modified |= arr[i] != newArr[i]; - } - if (modified) - return newArr; + if (input == null) + return null; + ResolveResult[] output = new ResolveResult[input.Length]; + for (int i = 0; i < input.Length; i++) { + output[i] = MapToNewContext(input[i], mapping); } - return val; + return output; } void ISupportsInterning.PrepareForInterning(IInterningProvider provider) @@ -170,21 +154,19 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver.ConstantValues } } - public IType GetValueType(ITypeResolveContext context) + public ResolveResult Resolve(ITypeResolveContext context) { - return baseValue.GetValueType(context); - } - - public object GetValue(ITypeResolveContext context) - { - object val = baseValue.GetValue(context); - if (val == null) - return null; - TypeCode typeCode = Type.GetTypeCode(val.GetType()); - if (!(typeCode >= TypeCode.SByte && typeCode <= TypeCode.UInt64)) - return null; - long intVal = (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, val, false); - return CSharpPrimitiveCast.Cast(typeCode, unchecked(intVal + incrementAmount), false); + ResolveResult rr = baseValue.Resolve(context); + if (rr.IsCompileTimeConstant && rr.ConstantValue != null) { + object val = rr.ConstantValue; + TypeCode typeCode = Type.GetTypeCode(val.GetType()); + if (typeCode >= TypeCode.SByte && typeCode <= TypeCode.UInt64) { + long intVal = (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, val, false); + object newVal = CSharpPrimitiveCast.Cast(typeCode, unchecked(intVal + incrementAmount), false); + return new ConstantResolveResult(rr.Type, newVal); + } + } + return new ErrorResolveResult(rr.Type); } void ISupportsInterning.PrepareForInterning(IInterningProvider provider) @@ -672,9 +654,9 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver.ConstantValues elements[i] = arrayElements[i].Resolve(resolver); } if (elementType != null) { - return resolver.ResolveArrayCreation(elementType.Resolve(resolver.Context), 1, null, elements, true); + return resolver.ResolveArrayCreation(elementType.Resolve(resolver.Context), 1, null, elements); } else { - return resolver.ResolveArrayCreation(null, 1, null, elements, true); + return resolver.ResolveArrayCreation(null, 1, null, elements); } } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/FindReferences.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/FindReferences.cs index 92b40721bd..8773852fed 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/FindReferences.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/FindReferences.cs @@ -31,7 +31,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// /// 'Find references' implementation. /// - public class FindReferences + /// + /// This class is thread-safe. + /// The intended multi-threaded usage is to call GetSearchScopes() once, and then + /// call FindReferencesInFile() concurrently on multiple threads (parallel foreach over all interesting files). + /// + public sealed class FindReferences { #region Properties /// @@ -214,7 +219,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } #endregion - #region FindReferencesInSolution + #region GetInterestingFileNames /// /// Gets the file names that possibly contain references to the element being searched for. /// @@ -275,7 +280,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// The compilation unit of the file being searched. /// The type resolve context to use for resolving the file. /// Callback used to report the references that were found. - public void FindReferencesInFile(IFindReferenceSearchScope searchScope, ParsedFile parsedFile, CompilationUnit compilationUnit, + public void FindReferencesInFile(IFindReferenceSearchScope searchScope, CSharpParsedFile parsedFile, CompilationUnit compilationUnit, ITypeResolveContext context, FoundReferenceCallback callback) { if (searchScope == null) @@ -291,7 +296,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// The compilation unit of the file being searched. /// The type resolve context to use for resolving the file. /// Callback used to report the references that were found. - public void FindReferencesInFile(IList searchScopes, ParsedFile parsedFile, CompilationUnit compilationUnit, + public void FindReferencesInFile(IList searchScopes, CSharpParsedFile parsedFile, CompilationUnit compilationUnit, ITypeResolveContext context, FoundReferenceCallback callback) { if (searchScopes == null) diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/MemberResolveResult.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/MemberResolveResult.cs index b47b4764c0..bd46c151fb 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/MemberResolveResult.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/MemberResolveResult.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (field != null) { isConstant = field.IsConst; if (isConstant) - constantValue = field.ConstantValue.GetValue(context); + constantValue = field.ConstantValue.Resolve(context).ConstantValue; } } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/OperatorResolveResult.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/OperatorResolveResult.cs index 5643680814..f28af6ccef 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/OperatorResolveResult.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/OperatorResolveResult.cs @@ -147,60 +147,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver readonly object[] constantArray; - public ArrayCreateResolveResult(IType arrayType, ResolveResult[] sizeArguments, ResolveResult[] initializerElements, - bool allowArrayConstants) + public ArrayCreateResolveResult(IType arrayType, ResolveResult[] sizeArguments, ResolveResult[] initializerElements) : base(arrayType) { this.SizeArguments = sizeArguments; this.InitializerElements = initializerElements; - if (allowArrayConstants) { - this.constantArray = MakeConstantArray(sizeArguments, initializerElements); - } - } - - static object[] MakeConstantArray(ResolveResult[] sizeArguments, ResolveResult[] initializerElements) - { - if (initializerElements == null) - return null; - - for (int i = 0; i < initializerElements.Length; i++) { - if (!initializerElements[i].IsCompileTimeConstant) - return null; - } - - if (sizeArguments != null && sizeArguments.Length > 0) { - if (sizeArguments.Length > 1) { - // 2D-arrays can't be constant - return null; - } - if (!sizeArguments[0].IsCompileTimeConstant) - return null; - - int expectedSize; - try { - expectedSize = (int)CSharpPrimitiveCast.Cast(TypeCode.Int32, sizeArguments[0].ConstantValue, true); - } catch (InvalidCastException) { - return null; - } catch (OverflowException) { - return null; - } - if (expectedSize != initializerElements.Length) - return null; - } - - object[] constants = new object[initializerElements.Length]; - for (int i = 0; i < initializerElements.Length; i++) { - constants[i] = initializerElements[i].ConstantValue; - } - return constants; - } - - public override object ConstantValue { - get { return constantArray; } - } - - public override bool IsCompileTimeConstant { - get { return constantArray != null; } } public override IEnumerable GetChildResults() diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveAtLocation.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveAtLocation.cs index 2f16a7ebf0..d32f45cf5e 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveAtLocation.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveAtLocation.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// public static class ResolveAtLocation { - public static ResolveResult Resolve(ITypeResolveContext context, ParsedFile parsedFile, CompilationUnit cu, AstLocation location, + public static ResolveResult Resolve(ITypeResolveContext context, CSharpParsedFile parsedFile, CompilationUnit cu, AstLocation location, CancellationToken cancellationToken = default(CancellationToken)) { AstNode node = cu.GetNodeAt(location); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs index 2b4fe979e1..0b3168a524 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs @@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver SimpleNameLookupMode currentTypeLookupMode = SimpleNameLookupMode.Type; /// Resolve result of the current LINQ query ResolveResult currentQueryResult; - readonly ParsedFile parsedFile; + readonly CSharpParsedFile parsedFile; readonly Dictionary resolveResultCache = new Dictionary(); readonly Dictionary resolverBeforeDict = new Dictionary(); @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// If you pass null, then nothing will be resolved on the initial scan, and the resolver /// will resolve additional nodes on demand (when one of the Get-methods is called). /// - public ResolveVisitor(CSharpResolver resolver, ParsedFile parsedFile, IResolveVisitorNavigator navigator = null) + public ResolveVisitor(CSharpResolver resolver, CSharpParsedFile parsedFile, IResolveVisitorNavigator navigator = null) { if (resolver == null) throw new ArgumentNullException("resolver"); @@ -374,14 +374,23 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (resolveResultCache.TryGetValue(node, out result)) return result; + bool needResolveParent = (node.NodeType == NodeType.Token || IsVar(node)); + + AstNode nodeToResolve = node; + if (needResolveParent) { + nodeToResolve = node.Parent; + if (resolveResultCache.ContainsKey(nodeToResolve)) + return null; + } + AstNode parent; - CSharpResolver storedResolver = GetPreviouslyScannedContext(node, out parent); + CSharpResolver storedResolver = GetPreviouslyScannedContext(nodeToResolve, out parent); ResetContext( storedResolver.Clone(), delegate { - navigator = new NodeListResolveVisitorNavigator(node); - if (parent == node) { - Resolve(node); + navigator = new NodeListResolveVisitorNavigator(nodeToResolve); + if (parent == nodeToResolve) { + Resolve(nodeToResolve); } else { Debug.Assert(!resolverEnabled); parent.AcceptVisitor(this, null); @@ -598,7 +607,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver string identifier = variableInitializer.Name; foreach (IVariable v in resolver.LocalVariables) { if (v.Name == identifier) { - object constantValue = v.IsConst ? v.ConstantValue.GetValue(resolver.Context) : null; + object constantValue = v.IsConst ? v.ConstantValue.Resolve(resolver.Context).ConstantValue : null; result = new LocalResolveResult(v, v.Type.Resolve(resolver.Context), constantValue); break; } @@ -927,18 +936,23 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver int dimensions = arrayCreateExpression.Arguments.Count; ResolveResult[] sizeArguments; + IEnumerable additionalArraySpecifiers; if (dimensions == 0) { - dimensions = 1; - sizeArguments = null; - } else { - if (arrayCreateExpression.Arguments.All(e => e is EmptyExpression)) { - sizeArguments = null; + var firstSpecifier = arrayCreateExpression.AdditionalArraySpecifiers.FirstOrDefault(); + if (firstSpecifier != null) { + dimensions = firstSpecifier.Dimensions; + additionalArraySpecifiers = arrayCreateExpression.AdditionalArraySpecifiers.Skip(1); } else { - sizeArguments = new ResolveResult[dimensions]; - int pos = 0; - foreach (var node in arrayCreateExpression.Arguments) - sizeArguments[pos++] = Resolve(node); + dimensions = 0; + additionalArraySpecifiers = arrayCreateExpression.AdditionalArraySpecifiers; } + sizeArguments = null; + } else { + sizeArguments = new ResolveResult[dimensions]; + int pos = 0; + foreach (var node in arrayCreateExpression.Arguments) + sizeArguments[pos++] = Resolve(node); + additionalArraySpecifiers = arrayCreateExpression.AdditionalArraySpecifiers; } List initializerElements; @@ -962,7 +976,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver acrr = resolver.ResolveArrayCreation(null, dimensions, sizeArguments, initializerElementResults); } else { IType elementType = ResolveType(arrayCreateExpression.Type); - foreach (var spec in arrayCreateExpression.AdditionalArraySpecifiers.Reverse()) { + foreach (var spec in additionalArraySpecifiers.Reverse()) { elementType = new ArrayType(elementType, spec.Dimensions); } acrr = resolver.ResolveArrayCreation(elementType, dimensions, sizeArguments, initializerElementResults); @@ -1798,7 +1812,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver readonly QuerySelectClause selectClause; readonly CSharpResolver storedContext; - readonly ParsedFile parsedFile; + readonly CSharpParsedFile parsedFile; readonly List hypotheses = new List(); readonly List parameters = new List(); @@ -2343,6 +2357,9 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ITypeReference type; if (needResolve) { type = Resolve(vi.Initializer).Type; + if (!resolveResultCache.ContainsKey(variableDeclarationStatement.Type)) { + StoreResult(variableDeclarationStatement.Type, new TypeResolveResult(type.Resolve(resolver.Context))); + } } else { Scan(vi.Initializer); type = MakeVarTypeReference(vi.Initializer, false); @@ -2528,7 +2545,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver #endregion #region Local Variable Type Inference - static bool IsVar(AstType returnType) + static bool IsVar(AstNode returnType) { SimpleType st = returnType as SimpleType; return st != null && st.Identifier == "var" && st.TypeArguments.Count == 0; diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/TypeOfResolveResult.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/TypeOfResolveResult.cs new file mode 100644 index 0000000000..23559d501d --- /dev/null +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Resolver/TypeOfResolveResult.cs @@ -0,0 +1,44 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Resolver +{ + /// + /// Represents the 'typeof'. + /// + public class TypeOfResolveResult : ResolveResult + { + readonly IType referencedType; + + public TypeOfResolveResult(IType systemType, IType referencedType) + : base(systemType) + { + this.referencedType = referencedType; + } + + /// + /// The type referenced by the 'typeof'. + /// + public IType ReferencedType { + get { return referencedType; } + } + } +} diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/src/Libraries/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj index 4d7ea32385..0ab23d3a44 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj @@ -115,6 +115,7 @@ + diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IAttribute.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IAttribute.cs index d66a7b93df..e7b7947a62 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IAttribute.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IAttribute.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; +using ICSharpCode.NRefactory.CSharp.Resolver; namespace ICSharpCode.NRefactory.TypeSystem { @@ -44,12 +45,12 @@ namespace ICSharpCode.NRefactory.TypeSystem /// /// Gets the positional arguments passed to the attribute. /// - IList GetPositionalArguments(ITypeResolveContext context); + IList GetPositionalArguments(ITypeResolveContext context); /// /// Gets the named arguments passed to the attribute. /// - IList> GetNamedArguments(ITypeResolveContext context); + IList> GetNamedArguments(ITypeResolveContext context); /// /// Resolves the constructor method used for this attribute invocation. diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs index 283e007f34..e3f5b64a49 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IConstantValue.cs @@ -18,6 +18,7 @@ using System; using System.Diagnostics.Contracts; +using ICSharpCode.NRefactory.CSharp.Resolver; namespace ICSharpCode.NRefactory.TypeSystem { @@ -27,40 +28,21 @@ namespace ICSharpCode.NRefactory.TypeSystem public interface IConstantValue : IFreezable { /// - /// Gets the type of the constant value. + /// Resolves the value of this constant. /// - IType GetValueType(ITypeResolveContext context); - - /// - /// Gets the .NET value of the constant value. - /// Possible return values are: - /// - null - /// - primitive integers - /// - float/double - /// - bool - /// - string - /// - IType (for typeof-expressions) - /// and arrays of these values. Enum values are returned using the underlying primitive integer. - /// - /// TODO: how do we represent errors (value not available?) - /// - object GetValue(ITypeResolveContext context); + /// Type resolve context where the constant value will be used. + /// Resolve result representing the constant value. + ResolveResult Resolve(ITypeResolveContext context); } #if WITH_CONTRACTS [ContractClassFor(typeof(IConstantValue))] abstract class IConstantValueContract : IFreezableContract, IConstantValue { - IType IConstantValue.GetValueType(ITypeResolveContext context) - { - Contract.Requires(context != null); - Contract.Ensures(Contract.Result() != null); - return null; - } - - object IConstantValue.GetValue(ITypeResolveContext context) + ResolveResult IConstantValue.Resolve(ITypeResolveContext context) { Contract.Requires(context != null); + Contract.Ensures(Contract.Result() != null); return null; } } diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAttribute.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAttribute.cs index 152146d52e..669bd0759b 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAttribute.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAttribute.cs @@ -21,6 +21,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; +using ICSharpCode.NRefactory.CSharp.Resolver; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { @@ -84,9 +85,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } - IList IAttribute.GetPositionalArguments(ITypeResolveContext context) + public IList GetPositionalArguments(ITypeResolveContext context) { - return this.PositionalArguments; + return this.PositionalArguments.Select(a => a.Resolve(context)).ToList(); } public IList> NamedArguments { @@ -97,9 +98,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } - IList> IAttribute.GetNamedArguments(ITypeResolveContext context) + public IList> GetNamedArguments(ITypeResolveContext context) { - return this.NamedArguments; + return this.NamedArguments.Select(p => new KeyValuePair(p.Key, p.Value.Resolve(context))).ToList(); } public IMethod ResolveConstructor(ITypeResolveContext context) diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs index fc035938fe..1c41fa577a 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs @@ -105,14 +105,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } - public object GetDefaultValue(ITypeResolveContext context) - { - if (defaultValue == null) - throw new InvalidOperationException(); - else - return defaultValue.GetValue(context); - } - public DomRegion Region { get { return region; } set { diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs index b378430374..0ef06d05f8 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using ICSharpCode.NRefactory.CSharp.Resolver; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { @@ -37,17 +38,13 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation this.value = value; } - public IType GetValueType(ITypeResolveContext context) + public ResolveResult Resolve(ITypeResolveContext context) { - return type.Resolve(context); - } - - public object GetValue(ITypeResolveContext context) - { - if (value is ITypeReference) - return ((ITypeReference)value).Resolve(context); - else - return value; + if (value is ITypeReference) { + return new TypeOfResolveResult(type.Resolve(context), ((ITypeReference)value).Resolve(context)); + } else { + return new ConstantResolveResult(type.Resolve(context), value); + } } public override string ToString() diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs index a5d93f3e4a..0189d3cca1 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs @@ -129,8 +129,13 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation if (compoundTypeDef != null) { // Remove one part from a compound class var newParts = new List(compoundTypeDef.GetParts()); - if (newParts.Remove(typeDefinition)) { - ((DefaultTypeDefinition)typeDefinition).SetCompoundTypeDefinition(typeDefinition); + // We cannot use newParts.Remove() because we need to use reference equality + for (int i = 0; i < newParts.Count; i++) { + if (newParts[i] == typeDefinition) { + newParts.RemoveAt(i); + ((DefaultTypeDefinition)typeDefinition).SetCompoundTypeDefinition(typeDefinition); + break; + } } types.UpdateType(CompoundTypeDefinition.Create(newParts)); } else { diff --git a/src/Libraries/NRefactory/NRefactory.sln b/src/Libraries/NRefactory/NRefactory.sln index 5c501e9af1..04649dd469 100644 --- a/src/Libraries/NRefactory/NRefactory.sln +++ b/src/Libraries/NRefactory/NRefactory.sln @@ -1,6 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 +# SharpDevelop 4.1.0.7854-beta Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DC98210E-1646-483B-819A-2BB8272461E4}" ProjectSection(SolutionItems) = preProject README = README @@ -13,8 +14,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB", "ICSharpCode.NRefactory.VB\ICSharpCode.NRefactory.VB.csproj", "{7B82B671-419F-45F4-B778-D9286F996EFA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB.Tests", "ICSharpCode.NRefactory.VB.Tests\ICSharpCode.NRefactory.VB.Tests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "..\Mono.Cecil\Mono.Cecil.csproj", "{D68133BD-1E63-496E-9EDE-4FBDBF77B486}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Demo", "ICSharpCode.NRefactory.Demo\ICSharpCode.NRefactory.Demo.csproj", "{9C19E629-C93E-4ACB-9A4B-13072B5AEF9D}" @@ -53,14 +52,6 @@ Global {7B82B671-419F-45F4-B778-D9286F996EFA}.Release|Any CPU.Build.0 = Release|Any CPU {7B82B671-419F-45F4-B778-D9286F996EFA}.Release|x86.ActiveCfg = Release|Any CPU {7B82B671-419F-45F4-B778-D9286F996EFA}.Release|x86.Build.0 = Release|Any CPU - {870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|Any CPU.Build.0 = Debug|Any CPU - {870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|x86.ActiveCfg = Debug|x86 - {870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|x86.Build.0 = Debug|x86 - {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|Any CPU.Build.0 = Release|Any CPU - {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.ActiveCfg = Release|x86 - {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.Build.0 = Release|x86 {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.ActiveCfg = net_4_0_Debug|Any CPU