diff --git a/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/ICSharpCode.Decompiler/Ast/AstBuilder.cs index 84883bccc..37fbb8f9c 100644 --- a/ICSharpCode.Decompiler/Ast/AstBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstBuilder.cs @@ -88,10 +88,10 @@ namespace ICSharpCode.Decompiler.Ast var outputFormatter = new TextOutputFormatter(output); var formattingPolicy = new CSharpFormattingPolicy(); // disable whitespace in front of parentheses: - formattingPolicy.BeforeMethodCallParentheses = false; - formattingPolicy.BeforeMethodDeclarationParentheses = false; - formattingPolicy.BeforeConstructorDeclarationParentheses = false; - formattingPolicy.BeforeDelegateDeclarationParentheses = false; + formattingPolicy.SpaceBeforeMethodCallParentheses = false; + formattingPolicy.SpaceBeforeMethodDeclarationParentheses = false; + formattingPolicy.SpaceBeforeConstructorDeclarationParentheses = false; + formattingPolicy.SpaceBeforeDelegateDeclarationParentheses = false; astCompileUnit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null); } diff --git a/NRefactory/ICSharpCode.NRefactory.Demo/ICSharpCode.NRefactory.Demo.csproj b/NRefactory/ICSharpCode.NRefactory.Demo/ICSharpCode.NRefactory.Demo.csproj index 906a94773..169dd2a0d 100644 --- a/NRefactory/ICSharpCode.NRefactory.Demo/ICSharpCode.NRefactory.Demo.csproj +++ b/NRefactory/ICSharpCode.NRefactory.Demo/ICSharpCode.NRefactory.Demo.csproj @@ -46,11 +46,11 @@ VBEditDialog.cs - + UserControl - - VBDomView.cs + + VBAstView.cs Form @@ -81,8 +81,8 @@ VBEditDialog.cs - - VBDomView.cs + + VBAstView.cs MainForm.cs diff --git a/NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.Designer.cs b/NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.Designer.cs similarity index 96% rename from NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.Designer.cs rename to NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.Designer.cs index d4d5d2d44..9cdb32334 100644 --- a/NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.Designer.cs +++ b/NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.Designer.cs @@ -3,7 +3,7 @@ namespace ICSharpCode.NRefactory.Demo { - partial class VBDomView : System.Windows.Forms.UserControl + partial class VBAstView : System.Windows.Forms.UserControl { /// /// Designer variable used to keep track of non-visual components. diff --git a/NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.cs b/NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.cs similarity index 97% rename from NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.cs rename to NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.cs index 3a0ac9af1..42be32e73 100644 --- a/NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.cs +++ b/NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.cs @@ -6,12 +6,12 @@ using System.Collections; using System.Windows.Forms; using System.Reflection; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB; namespace ICSharpCode.NRefactory.Demo { - public partial class VBDomView + public partial class VBAstView { CompilationUnit unit; @@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.Demo tree.SelectedNode = tree.Nodes[0]; } - public VBDomView() + public VBAstView() { InitializeComponent(); } @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.Demo ((ElementNode)node).Update(); } - public void ApplyTransformation(IDomVisitor visitor) + public void ApplyTransformation(IAstVisitor visitor) { if (tree.SelectedNode == tree.Nodes[0]) { unit.AcceptVisitor(visitor, null); diff --git a/NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.resx b/NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.resx similarity index 100% rename from NRefactory/ICSharpCode.NRefactory.Demo/VBDomView.resx rename to NRefactory/ICSharpCode.NRefactory.Demo/VBAstView.resx diff --git a/NRefactory/ICSharpCode.NRefactory.Demo/VBDemo.Designer.cs b/NRefactory/ICSharpCode.NRefactory.Demo/VBDemo.Designer.cs index 88644b236..f4cba1760 100644 --- a/NRefactory/ICSharpCode.NRefactory.Demo/VBDemo.Designer.cs +++ b/NRefactory/ICSharpCode.NRefactory.Demo/VBDemo.Designer.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Demo this.codeView = new System.Windows.Forms.TextBox(); this.editNodeButton = new System.Windows.Forms.Button(); this.clearSpecialsButton = new System.Windows.Forms.Button(); - this.syntaxTree = new ICSharpCode.NRefactory.Demo.VBDomView(); + this.syntaxTree = new ICSharpCode.NRefactory.Demo.VBAstView(); this.generateCodeButton = new System.Windows.Forms.Button(); this.parseButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -154,7 +154,7 @@ namespace ICSharpCode.NRefactory.Demo } private System.Windows.Forms.Button clearSpecialsButton; private System.Windows.Forms.Button editNodeButton; - private ICSharpCode.NRefactory.Demo.VBDomView syntaxTree; + private ICSharpCode.NRefactory.Demo.VBAstView syntaxTree; private System.Windows.Forms.TextBox codeView; private System.Windows.Forms.Button generateCodeButton; private System.Windows.Forms.Button parseButton; diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs b/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs index 5fa0b5469..ea7a3e43f 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under MIT X11 license (for details please see \doc\license.txt) using System; @@ -146,10 +146,10 @@ namespace ICSharpCode.NRefactory.CSharp Assert.AreEqual("a is int? ? b : c", InsertRequired(expr)); Assert.AreEqual("(a is int?) ? b : c", InsertReadable(expr)); - policy.ConditionalOperatorBeforeConditionSpace = false; - policy.ConditionalOperatorAfterConditionSpace = false; - policy.ConditionalOperatorBeforeSeparatorSpace = false; - policy.ConditionalOperatorAfterSeparatorSpace = false; + policy.SpaceBeforeConditionalOperatorCondition = false; + policy.SpaceAfterConditionalOperatorCondition = false; + policy.SpaceBeforeConditionalOperatorSeparator = false; + policy.SpaceAfterConditionalOperatorSeparator = false; Assert.AreEqual("a is int? ?b:c", InsertRequired(expr)); Assert.AreEqual("(a is int?)?b:c", InsertReadable(expr)); diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs index 874816450..19183532c 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs @@ -272,5 +272,14 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 Assert.AreEqual("N", ns.Name); Assert.AreEqual("MyClass", ((TypeDeclaration)ns.Members.Single()).Name); } + + [Test] + public void EnumWithInitializer() + { + TypeDeclaration td = ParseUtilCSharp.ParseGlobal("enum MyEnum { Val1 = 10 }"); + EnumMemberDeclaration member = (EnumMemberDeclaration)td.Members.Single(); + Assert.AreEqual("Val1", member.Name); + Assert.AreEqual(10, ((PrimitiveExpression)member.Initializer).Value); + } } } diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs b/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs index db7de9560..f81a7f2d9 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs @@ -171,7 +171,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver protected T Resolve(string code) where T : ResolveResult { ResolveResult rr = Resolve(code); - Assert.IsInstanceOf(typeof(T), rr); + Assert.IsTrue(rr is T, "Resolve should be " + typeof(T).Name + ", but was " + (rr != null ? rr.GetType().Name : "null")); return (T)rr; } diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs new file mode 100644 index 000000000..ad8a6584b --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs @@ -0,0 +1,285 @@ +// +// TastBlankLineFormatting.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// 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 System.IO; +using NUnit.Framework; +using ICSharpCode.NRefactory.CSharp; + +namespace ICSharpCode.NRefactory.FormattingTests +{ + [TestFixture()] + public class TestBlankLineFormatting : TestBase + { + [Test()] + public void TestBlankLinesAfterUsings () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesAfterUsings = 2; + + var adapter = Test (policy, @"using System; +using System.Text; +namespace Test +{ +}", +@"using System; +using System.Text; + + +namespace Test +{ +}"); + + policy.BlankLinesAfterUsings = 0; + Continue (policy, adapter, +@"using System; +using System.Text; +namespace Test +{ +}"); + } + + [Test()] + public void TestBlankLinesBeforeUsings () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesAfterUsings = 0; + policy.BlankLinesBeforeUsings = 2; + + var adapter = Test (policy, @"using System; +using System.Text; +namespace Test +{ +}", +@" + +using System; +using System.Text; +namespace Test +{ +}"); + + policy.BlankLinesBeforeUsings = 0; + Continue (policy, adapter, +@"using System; +using System.Text; +namespace Test +{ +}"); + } + + [Test()] + public void TestBlankLinesBeforeFirstDeclaration () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesBeforeFirstDeclaration = 2; + + var adapter = Test (policy, @"namespace Test +{ + class Test + { + } +}", +@"namespace Test +{ + + + class Test + { + } +}"); + + policy.BlankLinesBeforeFirstDeclaration = 0; + Continue (policy, adapter, +@"namespace Test +{ + class Test + { + } +}"); + } + + [Test()] + public void TestBlankLinesBetweenTypes () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesBetweenTypes = 1; + + var adapter = Test (policy, @"namespace Test +{ + class Test1 + { + } + class Test2 + { + } + class Test3 + { + } +}", +@"namespace Test +{ + class Test1 + { + } + + class Test2 + { + } + + class Test3 + { + } +}"); + + policy.BlankLinesBetweenTypes = 0; + Continue (policy, adapter, @"namespace Test +{ + class Test1 + { + } + class Test2 + { + } + class Test3 + { + } +}"); + } + + [Test()] + public void TestBlankLinesBetweenFields () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesBetweenFields = 1; + + var adapter = Test (policy, @"class Test +{ + int a; + int b; + int c; +}", +@"class Test +{ + int a; + + int b; + + int c; +}"); + + policy.BlankLinesBetweenFields = 0; + Continue (policy, adapter, @"class Test +{ + int a; + int b; + int c; +}"); + } + + [Test()] + public void TestBlankLinesBetweenEventFields () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesBetweenEventFields = 1; + + var adapter = Test (policy, @"class Test +{ + public event EventHandler a; + public event EventHandler b; + public event EventHandler c; +}", +@"class Test +{ + public event EventHandler a; + + public event EventHandler b; + + public event EventHandler c; +}"); + + policy.BlankLinesBetweenEventFields = 0; + Continue (policy, adapter, +@"class Test +{ + public event EventHandler a; + public event EventHandler b; + public event EventHandler c; +}"); + } + + [Test()] + public void TestBlankLinesBetweenMembers () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.BlankLinesBetweenMembers = 1; + + var adapter = Test (policy,@"class Test +{ + void AMethod () + { + } + void BMethod () + { + } + void CMethod () + { + } +}", @"class Test +{ + void AMethod () + { + } + + void BMethod () + { + } + + void CMethod () + { + } +}"); + + policy.BlankLinesBetweenMembers = 0; + Continue (policy, adapter, @"class Test +{ + void AMethod () + { + } + void BMethod () + { + } + void CMethod () + { + } +}"); + } + + + + } +} + diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs index 23cc5e8dd..ed83c8d4a 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs @@ -23,245 +23,184 @@ // 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 System.IO; using NUnit.Framework; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; -using MonoDevelop.Core; -using MonoDevelop.Ide.CodeCompletion; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.CSharp.Parser; -using MonoDevelop.CSharp.Resolver; -using MonoDevelop.CSharp.Completion; -using Mono.TextEditor; -using MonoDevelop.CSharp.Formatting; +using ICSharpCode.NRefactory.CSharp; -namespace MonoDevelop.CSharpBinding.FormattingTests +namespace ICSharpCode.NRefactory.FormattingTests { [TestFixture()] - public class TestBraceStyle : UnitTests.TestBase + public class TestBraceStyle : TestBase { [Test()] - [Ignore("currently failing because namespaces are not inserted")] public void TestNamespaceBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"namespace A -{ -namespace B { - class Test {} -} -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.NamespaceBraceStyle = BraceStyle.EndOfLine; policy.ClassBraceStyle = BraceStyle.DoNotChange; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"namespace A { + var adapter = Test (policy, @"namespace A +{ +namespace B { + class Test {} +} +}", +@"namespace A { namespace B { class Test {} } -}", data.Document.Text); +}"); policy.NamespaceBraceStyle = BraceStyle.NextLineShifted; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"namespace A + Continue (policy, adapter, +@"namespace A { namespace B { class Test {} } - }", data.Document.Text); + }"); } - - + [Test()] public void TestClassBraceStlye () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test {}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.EndOfLine; + policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { -}", data.Document.Text); + Test (policy, +@"class Test {}", +@"class Test { +}"); } - + [Test()] public void TestStructBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"struct Test {}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.StructBraceStyle = BraceStyle.NextLine; + policy.StructBraceStyle = BraceStyle.NextLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"struct Test + Test (policy, +@"struct Test {}", +@"struct Test { -}", data.Document.Text); +}"); } - + [Test()] public void TestInterfaceBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"interface Test {}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.InterfaceBraceStyle = BraceStyle.NextLine; + policy.InterfaceBraceStyle = BraceStyle.NextLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"interface Test + Test (policy, +@"interface Test {}", +@"interface Test { -}", data.Document.Text); +}"); } - + [Test()] public void TestEnumBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"enum Test { - A -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.EnumBraceStyle = BraceStyle.NextLineShifted; + policy.EnumBraceStyle = BraceStyle.NextLineShifted; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"enum Test + Test (policy, @"enum Test { + A +}", +@"enum Test { A - }", data.Document.Text); + }"); } - + [Test()] public void TestMethodBraceStlye () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test MyMethod() {} -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.MethodBraceStyle = BraceStyle.NextLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test + Test (policy, @"class Test { - Test MyMethod() + Test MyMethod() {} +}", +@"class Test +{ + Test MyMethod () { } -}", data.Document.Text); +}"); } - + [Test()] public void TestConstructorBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test() {} -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.ConstructorBraceStyle = BraceStyle.NextLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test + Test (policy, @"class Test { - Test() + Test() {} +}", +@"class Test +{ + Test () { } -}", data.Document.Text); +}"); } - + [Test()] public void TestDestructorBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - ~Test() {} -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.DestructorBraceStyle = BraceStyle.NextLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test + Test (policy, @"class Test +{ + ~Test() {} +}", +@"class Test { - ~Test() + ~Test () { } -}", data.Document.Text); +}"); } - + [Test()] public void TestPropertyBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertyBraceStyle = BraceStyle.NextLine; + + Test (policy, @"class Test { Test A { get; set; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PropertyBraceStyle = BraceStyle.NextLine; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { Test A { get; set; } -}", data.Document.Text); +}"); } - + [Test()] public void TestPropertyGetBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertyGetBraceStyle = BraceStyle.NextLine; + + Test (policy, @"class Test { Test A { get { @@ -269,16 +208,8 @@ namespace B { } set; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PropertyGetBraceStyle = BraceStyle.NextLine; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { Test A { get @@ -287,32 +218,26 @@ namespace B { } set; } -}", data.Document.Text); +}"); } - + [Test()] public void TestAllowPropertyGetBlockInline () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test A { - get { return null; } - set { ; } - } -}"; CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.PropertyBraceStyle = BraceStyle.DoNotChange; policy.AllowPropertyGetBlockInline = true; policy.AllowPropertySetBlockInline = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test + var adapter = Test (policy, @"class Test +{ + Test A { + get { return null; } + set { ; } + } +}", +@"class Test { Test A { get { return null; } @@ -320,13 +245,11 @@ namespace B { ; } } -}", data.Document.Text); +}"); policy.AllowPropertyGetBlockInline = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test + Continue (policy, adapter, +@"class Test { Test A { get { @@ -336,32 +259,25 @@ namespace B { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestAllowPropertySetBlockInline () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test A { - get { return null; } - set { ; } - } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.PropertyBraceStyle = BraceStyle.DoNotChange; policy.AllowPropertyGetBlockInline = false; policy.AllowPropertySetBlockInline = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test + var adapter = Test (policy, @"class Test +{ + Test A { + get { return null; } + set { ; } + } +}", +@"class Test { Test A { get { @@ -369,13 +285,11 @@ namespace B { } set { ; } } -}", data.Document.Text); +}"); policy.AllowPropertySetBlockInline = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test + Continue (policy, adapter, +@"class Test { Test A { get { @@ -385,15 +299,16 @@ namespace B { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestPropertySetBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertySetBraceStyle = BraceStyle.NextLine; + + Test (policy, @"class Test { Test A { get; @@ -401,16 +316,8 @@ namespace B { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PropertySetBraceStyle = BraceStyle.NextLine; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { Test A { get; @@ -419,15 +326,18 @@ namespace B { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestEventBraceStyle () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.EventBraceStyle = BraceStyle.NextLine; + policy.EventAddBraceStyle = BraceStyle.NextLine; + policy.EventRemoveBraceStyle = BraceStyle.NextLine; + + Test (policy, @"class Test { public event EventHandler Handler { add { @@ -435,18 +345,8 @@ namespace B { remove { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.EventBraceStyle = BraceStyle.NextLine; - policy.EventAddBraceStyle = BraceStyle.NextLine; - policy.EventRemoveBraceStyle = BraceStyle.NextLine; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { public event EventHandler Handler { @@ -457,31 +357,24 @@ namespace B { { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestAllowEventAddBlockInline () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.AllowEventAddBlockInline = true; + policy.AllowEventRemoveBlockInline = false; + + Test (policy, @"class Test { public event EventHandler Handler { add { ; } remove { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AllowEventAddBlockInline = true; - policy.AllowEventRemoveBlockInline = false; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { public event EventHandler Handler { add { ; } @@ -489,31 +382,24 @@ namespace B { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestAllowEventRemoveBlockInline () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.AllowEventAddBlockInline = false; + policy.AllowEventRemoveBlockInline = true; + + Test (policy, @"class Test { public event EventHandler Handler { add { ; } remove { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AllowEventAddBlockInline = false; - policy.AllowEventRemoveBlockInline = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { public event EventHandler Handler { add { @@ -521,10 +407,7 @@ namespace B { } remove { ; } } -}", data.Document.Text); +}"); } - - - } -}*/ +} \ No newline at end of file diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs index 0a6a2d6f8..b4370368a 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs @@ -23,27 +23,16 @@ // 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 System.IO; using NUnit.Framework; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; -using MonoDevelop.Core; -using MonoDevelop.Ide.CodeCompletion; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.CSharp.Parser; -using MonoDevelop.CSharp.Resolver; -using MonoDevelop.CSharp.Completion; -using Mono.TextEditor; -using MonoDevelop.CSharp.Formatting; -using System.Collections.Generic; -using MonoDevelop.Refactoring; +using ICSharpCode.NRefactory.CSharp; -namespace MonoDevelop.CSharpBinding.FormattingTests +namespace ICSharpCode.NRefactory.FormattingTests { [TestFixture()] - public class TestFormattingBugs : UnitTests.TestBase + public class TestFormattingBugs : TestBase { /// /// Bug 325187 - Bug in smart indent @@ -71,8 +60,7 @@ Console.WriteLine (""Bad indent"");", /// Bug 415469 - return ternary in a switch is not tabbed properly /// [Test()] - [Ignore("currently failing because of 'string' has the wrong offset - mcs bug")] - public void TestBug415469 () + public void TestBug415469 () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); @@ -111,52 +99,99 @@ using (IDisposable b = null) { }"); } - - + /// + /// Bug 655635 - Auto format document doesn't indent comments as well + /// + [Test()] + public void TestBug655635 () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + TestStatementFormatting (policy, +@"try { + // Comment 1 + myObject.x = Run (); +} catch (InvalidOperationException e) { + Console.WriteLine (e.Message); +}", @"try { + // Comment 1 + myObject.x = Run (); +} catch (InvalidOperationException e) { + Console.WriteLine (e.Message); +}"); + } - - static void TestStatementFormatting (CSharpFormattingPolicy policy, string input, string expectedOutput) + void TestStatementFormatting (CSharpFormattingPolicy policy, string input, string expectedOutput) { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = -@"class Test + var result = GetResult (policy, @"class Test { MyType TestMethod () { " + input + @" } -}"; - - Console.WriteLine (data.Document.Text); - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - DomSpacingVisitor domSpacingVisitor = new DomSpacingVisitor (policy, data); - domSpacingVisitor.AutoAcceptChanges = false; - compilationUnit.AcceptVisitor (domSpacingVisitor, null); - - DomIndentationVisitor domIndentationVisitor = new DomIndentationVisitor (policy, data); - domIndentationVisitor.AutoAcceptChanges = false; - compilationUnit.AcceptVisitor (domIndentationVisitor, null); - - List changes = new List (); - changes.AddRange (domSpacingVisitor.Changes); - changes.AddRange (domIndentationVisitor.Changes); - RefactoringService.AcceptChanges (null, null, changes); - - for (int i = 0; i < data.Document.LineCount; i++) { - LineSegment line = data.Document.GetLine (i); - if (line.EditableLength < 2) - continue; - data.Remove (line.Offset, 2); - } - string text = data.Document.GetTextBetween (data.Document.GetLine (4).Offset, - data.Document.GetLine (data.Document.LineCount - 2).Offset).Trim (); - Console.WriteLine (text); +}"); + int start = result.GetLineOffset (5); + int end = result.GetLineOffset (result.LineCount - 1); + string text = result.GetTextAt (start, end - start).Trim (); + expectedOutput = expectedOutput.Replace ("\n", "\n\t\t"); Assert.AreEqual (expectedOutput, text); } + /// + /// Bug 659675 - on-the-fly code formatting breaks @-prefixed identifiers + /// + [Test()] + public void TestBug659675 () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + TestStatementFormatting (policy, "@string=@int;", "@string = @int;"); + } + + /// + /// Bug 670213 - Document formatter deletes valid text! + /// + [Test()] + public void TestBug670213 () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.MethodBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test +{ + Test MyMethod() // Comment + { + } +}", +@"class Test +{ + Test MyMethod () { // Comment + } +}"); + } + + + /// + /// Bug 677261 - Format Document with constructor with over-indented opening curly brace + /// + [Test()] + public void TestBug677261 () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ConstructorBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test +{ + Test () + { + } +}", +@"class Test +{ + Test () { + } +}"); + } } } -*/ + diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs index 9a2cdc821..0f4bc4416 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs @@ -23,777 +23,608 @@ // 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 System.IO; using NUnit.Framework; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; -using MonoDevelop.Core; -using MonoDevelop.Ide.CodeCompletion; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.CSharp.Parser; -using MonoDevelop.CSharp.Resolver; -using MonoDevelop.CSharp.Completion; -using Mono.TextEditor; -using MonoDevelop.CSharp.Formatting; - -namespace MonoDevelop.CSharpBinding.FormattingTests +using ICSharpCode.NRefactory.CSharp; + +namespace ICSharpCode.NRefactory.FormattingTests { [TestFixture()] - public class TestSpacingVisitor : UnitTests.TestBase + public class TestSpacingVisitor : TestBase { [Test()] public void TestFieldSpacesBeforeComma1 () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - int a , b, c; -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.EndOfLine; - policy.SpacesAfterComma = false; - policy.SpacesBeforeComma = false; + policy.ClassBraceStyle = BraceStyle.EndOfLine; + policy.SpaceBeforeFieldDeclarationComma = false; + policy.SpaceAfterFieldDeclarationComma = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"class Test { + Test (policy, @"class Test { + int a , b, c; +}", +@"class Test { int a,b,c; -}", data.Document.Text); +}"); } - + [Test()] public void TestFieldSpacesBeforeComma2 () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - int a , b, c; -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.EndOfLine; - policy.SpacesAfterComma = true; - policy.SpacesBeforeComma = true; + policy.ClassBraceStyle = BraceStyle.EndOfLine; + policy.SpaceBeforeFieldDeclarationComma = true; + policy.SpaceAfterFieldDeclarationComma = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"class Test { + Test (policy, @"class Test { + int a , b, c; +}", +@"class Test { int a , b , c; -}", data.Document.Text); +}"); } - + [Test()] public void TestFixedFieldSpacesBeforeComma () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - fixed int a[10] , b[10], c[10]; -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.EndOfLine; - policy.SpacesAfterComma = true; - policy.SpacesBeforeComma = true; + policy.ClassBraceStyle = BraceStyle.EndOfLine; + policy.SpaceAfterFieldDeclarationComma = true; + policy.SpaceBeforeFieldDeclarationComma = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"class Test { + Test (policy, @"class Test { + fixed int a[10] , b[10], c[10]; +}", + @"class Test { fixed int a[10] , b[10] , c[10]; -}", data.Document.Text); +}"); } [Test()] public void TestConstFieldSpacesBeforeComma () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - const int a = 1 , b = 2, c = 3; -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.EndOfLine; - policy.SpacesAfterComma = false; - policy.SpacesBeforeComma = false; + policy.ClassBraceStyle = BraceStyle.EndOfLine; + policy.SpaceAfterFieldDeclarationComma = false; + policy.SpaceBeforeFieldDeclarationComma = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"class Test { + Test (policy, @"class Test { + const int a = 1 , b = 2, c = 3; +}", +@"class Test { const int a = 1,b = 2,c = 3; -}", data.Document.Text); - } - - [Test()] - public void TestBeforeDelegateDeclarationParentheses () - { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = "delegate void TestDelegate();"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.BeforeDelegateDeclarationParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"delegate void TestDelegate ();", data.Document.Text); +}"); } - + [Test()] - public void TestBeforeDelegateDeclarationParenthesesComplex () + public void TestBeforeMethodDeclarationParentheses () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = "delegate void TestDelegate\n\t\t\t();"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.BeforeDelegateDeclarationParentheses = true; + policy.SpaceBeforeMethodDeclarationParentheses = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"delegate void TestDelegate ();", data.Document.Text); - } - - [Test()] - public void TestBeforeMethodDeclarationParentheses () - { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"public abstract class Test + Test (policy, @"public abstract class Test { public abstract Test TestMethod(); -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.BeforeMethodDeclarationParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"public abstract class Test +}", +@"public abstract class Test { public abstract Test TestMethod (); -}", data.Document.Text); +}"); } - + [Test()] - public void TestBeforeConstructorDeclarationParentheses () + public void TestBeforeConstructorDeclarationParenthesesDestructorCase () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test() - { - } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.BeforeConstructorDeclarationParentheses = true; + policy.SpaceBeforeConstructorDeclarationParentheses = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"class Test -{ - Test () - { - } -}", data.Document.Text); - } - - - - [Test()] - public void TestBeforeConstructorDeclarationParenthesesDestructorCase () - { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + Test (policy, @"class Test { ~Test() { } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.BeforeConstructorDeclarationParentheses = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { ~Test () { } -}", data.Document.Text); +}"); } - - - + static void TestBinaryOperator (CSharpFormattingPolicy policy, string op) { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = "class Test { void TestMe () { result = left" +op+"right; } }"; + var result = GetResult (policy, "class Test { void TestMe () { result = left" + op + "right; } }"); - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("left"); - int i2 = data.Document.Text.IndexOf ("right") + "right".Length; + int i1 = result.Text.IndexOf ("left"); + int i2 = result.Text.IndexOf ("right") + "right".Length; if (i1 < 0 || i2 < 0) - Assert.Fail ("text invalid:" + data.Document.Text); - Assert.AreEqual ("left " + op + " right", data.Document.GetTextBetween (i1, i2)); + Assert.Fail ("text invalid:" + result.Text); + Assert.AreEqual ("left " + op + " right", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestSpacesAroundMultiplicativeOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundMultiplicativeOperatorParentheses = true; + policy.SpaceAroundMultiplicativeOperator = true; TestBinaryOperator (policy, "*"); TestBinaryOperator (policy, "/"); } - + [Test()] public void TestSpacesAroundShiftOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundShiftOperatorParentheses = true; + policy.SpaceAroundShiftOperator = true; TestBinaryOperator (policy, "<<"); TestBinaryOperator (policy, ">>"); } - + [Test()] public void TestSpacesAroundAdditiveOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundAdditiveOperatorParentheses = true; + policy.SpaceAroundAdditiveOperator = true; TestBinaryOperator (policy, "+"); TestBinaryOperator (policy, "-"); } - + [Test()] public void TestSpacesAroundBitwiseOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundBitwiseOperatorParentheses = true; + policy.SpaceAroundBitwiseOperator = true; TestBinaryOperator (policy, "&"); TestBinaryOperator (policy, "|"); TestBinaryOperator (policy, "^"); } - + [Test()] public void TestSpacesAroundRelationalOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundRelationalOperatorParentheses = true; + policy.SpaceAroundRelationalOperator = true; TestBinaryOperator (policy, "<"); TestBinaryOperator (policy, "<="); TestBinaryOperator (policy, ">"); TestBinaryOperator (policy, ">="); } - + [Test()] public void TestSpacesAroundEqualityOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundEqualityOperatorParentheses = true; + policy.SpaceAroundEqualityOperator = true; TestBinaryOperator (policy, "=="); TestBinaryOperator (policy, "!="); } - + [Test()] public void TestSpacesAroundLogicalOperator () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundLogicalOperatorParentheses = true; + policy.SpaceAroundLogicalOperator = true; TestBinaryOperator (policy, "&&"); TestBinaryOperator (policy, "||"); } - + [Test()] public void TestConditionalOperator () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeConditionalOperatorCondition = true; + policy.SpaceAfterConditionalOperatorCondition = true; + policy.SpaceBeforeConditionalOperatorSeparator = true; + policy.SpaceAfterConditionalOperatorSeparator = true; + + var result = GetResult (policy, @"class Test { void TestMe () { result = condition?trueexpr:falseexpr; } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ConditionalOperatorAfterConditionSpace = true; - policy.ConditionalOperatorAfterSeparatorSpace = true; - policy.ConditionalOperatorBeforeConditionSpace = true; - policy.ConditionalOperatorBeforeSeparatorSpace = true; +}"); + int i1 = result.Text.IndexOf ("condition"); + int i2 = result.Text.IndexOf ("falseexpr") + "falseexpr".Length; + Assert.AreEqual (@"condition ? trueexpr : falseexpr", result.GetTextAt (i1, i2 - i1)); - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("condition"); - int i2 = data.Document.Text.IndexOf ("falseexpr") + "falseexpr".Length; - Assert.AreEqual (@"condition ? trueexpr : falseexpr", data.Document.GetTextBetween (i1, i2)); + policy.SpaceBeforeConditionalOperatorCondition = false; + policy.SpaceAfterConditionalOperatorCondition = false; + policy.SpaceBeforeConditionalOperatorSeparator = false; + policy.SpaceAfterConditionalOperatorSeparator = false; - - data.Document.Text = @"class Test { + result = GetResult (policy, @"class Test { void TestMe () { result = true ? trueexpr : falseexpr; } -}"; - policy.ConditionalOperatorAfterConditionSpace = false; - policy.ConditionalOperatorAfterSeparatorSpace = false; - policy.ConditionalOperatorBeforeConditionSpace = false; - policy.ConditionalOperatorBeforeSeparatorSpace = false; - - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - i1 = data.Document.Text.IndexOf ("true"); - i2 = data.Document.Text.IndexOf ("falseexpr") + "falseexpr".Length; - Assert.AreEqual (@"true?trueexpr:falseexpr", data.Document.GetTextBetween (i1, i2)); +}"); + i1 = result.Text.IndexOf ("true"); + i2 = result.Text.IndexOf ("falseexpr") + "falseexpr".Length; + Assert.AreEqual (@"true?trueexpr:falseexpr", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeMethodCallParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeMethodCallParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { MethodCall(); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.BeforeMethodCallParentheses = true; +}"); - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("MethodCall"); - int i2 = data.Document.Text.IndexOf (";") + ";".Length; - Assert.AreEqual (@"MethodCall ();", data.Document.GetTextBetween (i1, i2)); + int i1 = result.Text.IndexOf ("MethodCall"); + int i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"MethodCall ();", result.GetTextAt (i1, i2 - i1)); - data.Document.Text = @"class Test { + result = GetResult (policy, @"class Test { void TestMe () { MethodCall (); } -}"; - policy.BeforeMethodCallParentheses = false; +}"); + policy.SpaceBeforeMethodCallParentheses = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - i1 = data.Document.Text.IndexOf ("MethodCall"); - i2 = data.Document.Text.IndexOf (";") + ";".Length; - Assert.AreEqual (@"MethodCall();", data.Document.GetTextBetween (i1, i2)); + result = GetResult (policy, result.Text); + i1 = result.Text.IndexOf ("MethodCall"); + i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"MethodCall();", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinMethodCallParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceWithinMethodCallParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { MethodCall(true); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinMethodCallParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( true )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( true )", result.GetTextAt (i1, i2 - i1)); - data.Document.Text = @"class Test { + policy.SpaceWithinMethodCallParentheses = false; + result = GetResult (policy, @"class Test { void TestMe () { MethodCall( true ); } -}"; - policy.WithinMethodCallParentheses = false; +}"); - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - i1 = data.Document.Text.LastIndexOf ("("); - i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"(true)", data.Document.GetTextBetween (i1, i2)); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(true)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeIfParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeIfParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { if(true); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IfParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("if"); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"if (true)", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("if"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"if (true)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinIfParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinIfParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { if (true); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinIfParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( true )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( true )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeWhileParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeWhileParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { while(true); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WhileParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("while"); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"while (true)", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("while"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"while (true)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinWhileParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinWhileParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { while (true); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinWhileParentheses = true; +}"); - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( true )", data.Document.GetTextBetween (i1, i2)); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( true )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeForParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeForParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { for(;;); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ForParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("for"); - int i2 = data.Document.Text.LastIndexOf ("(") + "(".Length; - Assert.AreEqual (@"for (", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("for"); + int i2 = result.Text.LastIndexOf ("(") + "(".Length; + Assert.AreEqual (@"for (", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinForParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinForParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { for(;;); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinForParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( ;; )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( ;; )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeForeachParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeForeachParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { foreach(var o in list); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ForeachParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("foreach"); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"foreach (var o in list)", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("foreach"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"foreach (var o in list)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinForeachParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinForeachParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { foreach(var o in list); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinForEachParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( var o in list )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( var o in list )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeCatchParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeCatchParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { try {} catch(Exception) {} } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.CatchParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("catch"); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"catch (Exception)", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("catch"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"catch (Exception)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinCatchParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinCatchParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { try {} catch(Exception) {} } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinCatchParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( Exception )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( Exception )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeLockParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeLockParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { lock(this) {} } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.LockParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("lock"); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"lock (this)", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("lock"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"lock (this)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinLockParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinLockParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { lock(this) {} } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinLockParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( this )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( this )", result.GetTextAt (i1, i2 - i1)); } - - + [Test()] - public void TestSpacesAfterSemicolon () + public void TestSpacesAfterForSemicolon () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceAfterForSemicolon = true; + + var result = GetResult (policy, @"class Test { void TestMe () { for (int i;true;i++) ; } -}"; +}"); + int i1 = result.Text.LastIndexOf ("for"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + + Assert.AreEqual (@"for (int i; true; i++)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestSpacesBeforeForSemicolon () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.SpacesAfterSemicolon = true; + policy.SpaceBeforeForSemicolon = true; + policy.SpaceAfterForSemicolon = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("for"); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; + var result = GetResult (policy, @"class Test { + void TestMe () + { + for (int i;true;i++) ; + } +}"); + int i1 = result.Text.LastIndexOf ("for"); + int i2 = result.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"for (int i; true; i++)", data.Document.GetTextBetween (i1, i2)); + Assert.AreEqual (@"for (int i ;true ;i++)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestSpacesAfterTypecast () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceAfterTypecast = true; + + var result = GetResult (policy, @"class Test { Test TestMe () { return (Test)null; } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.SpacesAfterTypecast = true; +}"); + int i1 = result.Text.LastIndexOf ("return"); + int i2 = result.Text.LastIndexOf ("null") + "null".Length; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("return"); - int i2 = data.Document.Text.LastIndexOf ("null") + "null".Length; - - Assert.AreEqual (@"return (Test) null", data.Document.GetTextBetween (i1, i2)); + Assert.AreEqual (@"return (Test) null", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeUsingParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeUsingParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { using(a) {} } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.UsingParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("using"); - int i2 = data.Document.Text.LastIndexOf ("(") + "(".Length; - Assert.AreEqual (@"using (", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("using"); + int i2 = result.Text.LastIndexOf ("(") + "(".Length; + Assert.AreEqual (@"using (", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinUsingParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinUsingParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { using(a) {} } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinUsingParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( a )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( a )", result.GetTextAt (i1, i2 - i1)); } - + static void TestAssignmentOperator (CSharpFormattingPolicy policy, string op) { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = "class Test { void TestMe () { left" +op+"right; } }"; + var result = GetResult (policy, "class Test { void TestMe () { left" + op + "right; } }"); - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("left"); - int i2 = data.Document.Text.IndexOf ("right") + "right".Length; + int i1 = result.Text.IndexOf ("left"); + int i2 = result.Text.IndexOf ("right") + "right".Length; if (i1 < 0 || i2 < 0) - Assert.Fail ("text invalid:" + data.Document.Text); - Assert.AreEqual ("left " + op + " right", data.Document.GetTextBetween (i1, i2)); + Assert.Fail ("text invalid:" + result.Text); + Assert.AreEqual ("left " + op + " right", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestAroundAssignmentSpace () { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundAssignmentParentheses = true; + policy.SpaceAroundAssignment = true; TestAssignmentOperator (policy, "="); TestAssignmentOperator (policy, "*="); @@ -807,361 +638,946 @@ return (Test)null; TestAssignmentOperator (policy, "|="); TestAssignmentOperator (policy, "^="); } - + [Test()] public void TestAroundAssignmentSpaceInDeclarations () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceAroundAssignment = true; + var result = GetResult (policy, @"class Test { void TestMe () { int left=right; } -}"; +}"); - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.AroundAssignmentParentheses = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("left"); - int i2 = data.Document.Text.LastIndexOf ("right") + "right".Length; - Assert.AreEqual (@"left = right", data.Document.GetTextBetween (i1, i2)); + int i1 = result.Text.LastIndexOf ("left"); + int i2 = result.Text.LastIndexOf ("right") + "right".Length; + Assert.AreEqual (@"left = right", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestBeforeSwitchParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeSwitchParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { switch (test) { default: break; } } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.SwitchParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("switch"); - int i2 = data.Document.Text.LastIndexOf ("(") + "(".Length; - Assert.AreEqual (@"switch (", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.IndexOf ("switch"); + int i2 = result.Text.LastIndexOf ("(") + "(".Length; + Assert.AreEqual (@"switch (", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinSwitchParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinSwitchParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { switch (test) { default: break; } } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinSwitchParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( test )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( test )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { c = (test); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( test )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( test )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinMethodDeclarationParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceWithinMethodDeclarationParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe (int a) { } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinMethodDeclarationParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( int a )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( int a )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinCastParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinCastParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { a = (int)b; } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinCastParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( int )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( int )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] public void TestWithinSizeOfParenthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinSizeOfParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { a = sizeof(int); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinSizeOfParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( int )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( int )", result.GetTextAt (i1, i2 - i1)); } - + [Test()] - public void TestWithinTypeOfParenthesesSpace () + public void TestBeforeSizeOfParentheses () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeSizeOfParentheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { - a = typeof(int); + a = sizeof(int); } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinTypeOfParentheses = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( int )", data.Document.GetTextBetween (i1, i2)); +}"); + int i1 = result.Text.LastIndexOf ("sizeof"); + int i2 = result.Text.LastIndexOf ("(") + "(".Length; + Assert.AreEqual (@"sizeof (", result.GetTextAt (i1, i2 - i1)); } - + + [Test()] + public void TestWithinTypeOfParenthesesSpace () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinTypeOfParentheses = true; + + var result = GetResult (policy, @"class Test { + void TestMe () + { + a = typeof(int); + } +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( int )", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBeforeTypeOfParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeTypeOfParentheses = true; + + var result = GetResult (policy, @"class Test { + void TestMe () + { + a = typeof(int); + } +}"); + + int i1 = result.Text.LastIndexOf ("typeof"); + int i2 = result.Text.LastIndexOf ("(") + "(".Length; + Assert.AreEqual (@"typeof (", result.GetTextAt (i1, i2 - i1)); + } + [Test()] public void TestWithinCheckedExpressionParanthesesSpace () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinCheckedExpressionParantheses = true; + + var result = GetResult (policy, @"class Test { void TestMe () { a = checked(a + b); } -}"; +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( a + b )", result.GetTextAt (i1, i2 - i1)); + + result = GetResult (policy, @"class Test { + void TestMe () + { + a = unchecked(a + b); + } +}"); + + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( a + b )", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestSpaceBeforeNewParentheses () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinCheckedExpressionParantheses = true; + policy.SpaceBeforeNewParentheses = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("("); - int i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( a + b )", data.Document.GetTextBetween (i1, i2)); + var result = GetResult (policy, @"class Test { + void TestMe () + { + new Test(); + } +}"); + int i1 = result.Text.LastIndexOf ("new"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"new Test ();", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestWithinNewParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinNewParentheses = true; - data.Document.Text = @"class Test { + var result = GetResult (policy, @"class Test { void TestMe () { - a = unchecked(a + b); + new Test (1); } -}"; +}"); + int i1 = result.Text.LastIndexOf ("new"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"new Test ( 1 );", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBetweenEmptyNewParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesBetweenEmptyNewParentheses = true; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - i1 = data.Document.Text.LastIndexOf ("("); - i2 = data.Document.Text.LastIndexOf (")") + ")".Length; - Assert.AreEqual (@"( a + b )", data.Document.GetTextBetween (i1, i2)); + var result = GetResult (policy, @"class Test { + void TestMe () + { + new Test (); + } +}"); + int i1 = result.Text.LastIndexOf ("new"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"new Test ( );", result.GetTextAt (i1, i2 - i1)); } - + [Test()] - public void TestSpacesWithinBrackets () + public void TestBeforeNewParameterComma () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - Test this[int i] { - get {} - set {} + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeNewParameterComma = true; + policy.SpaceAfterNewParameterComma = false; + + var result = GetResult (policy, @"class Test { + void TestMe () + { + new Test (1,2); } - +}"); + int i1 = result.Text.LastIndexOf ("new"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"new Test (1 ,2);", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestAfterNewParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceAfterNewParameterComma = true; + + var result = GetResult (policy, @"class Test { void TestMe () { - this[0] = 5; + new Test (1,2); } -}"; +}"); + int i1 = result.Text.LastIndexOf ("new"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"new Test (1, 2);", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestFieldDeclarationComma () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.SpacesWithinBrackets = true; + policy.SpaceBeforeFieldDeclarationComma = false; + policy.SpaceAfterFieldDeclarationComma = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); + var result = GetResult (policy, @"class Test { + int a,b,c; +}"); + int i1 = result.Text.LastIndexOf ("int"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"int a, b, c;", result.GetTextAt (i1, i2 - i1)); + policy.SpaceBeforeFieldDeclarationComma = true; + + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("int"); + i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"int a , b , c;", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceBeforeFieldDeclarationComma = false; + policy.SpaceAfterFieldDeclarationComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("int"); + i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"int a,b,c;", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBeforeMethodDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeMethodDeclarationParameterComma = true; + policy.SpaceAfterMethodDeclarationParameterComma = false; + + var result = GetResult (policy, @"class Test { + public void Foo (int a,int b,int c) {} +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a ,int b ,int c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceBeforeMethodDeclarationParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a,int b,int c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestAfterMethodDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeMethodDeclarationParameterComma = false; + policy.SpaceAfterMethodDeclarationParameterComma = true; + + var result = GetResult (policy, @"class Test { + public void Foo (int a,int b,int c) {} +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a, int b, int c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceAfterMethodDeclarationParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a,int b,int c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestSpacesInLambdaExpression () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinWhileParentheses = true; - Assert.AreEqual (@"class Test { - Test this[ int i ] { - get {} - set {} + var result = GetResult (policy, @"class Test { + void TestMe () + { + var v = x=>x!=null; } - +}"); + int i1 = result.Text.IndexOf ("x"); + int i2 = result.Text.LastIndexOf ("null") + "null".Length; + Assert.AreEqual (@"x => x != null", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBeforeLocalVariableDeclarationComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeLocalVariableDeclarationComma = true; + policy.SpaceAfterLocalVariableDeclarationComma = false; + + var result = GetResult (policy, @"class Test { void TestMe () { - this[ 0 ] = 5; + int a,b,c; + } +}"); + int i1 = result.Text.IndexOf ("int"); + int i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"int a ,b ,c;", result.GetTextAt (i1, i2 - i1)); + + result = GetResult (policy, result.Text); + + policy.SpaceBeforeLocalVariableDeclarationComma = false; + + result = GetResult (policy, result.Text); + i1 = result.Text.IndexOf ("int"); + i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"int a,b,c;", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestLocalVariableDeclarationComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeLocalVariableDeclarationComma = true; + policy.SpaceAfterLocalVariableDeclarationComma = true; + + var result = GetResult (policy, @"class Test { + void TestMe () + { + int a = 5,b = 6,c; + } +}"); + int i1 = result.Text.IndexOf ("int"); + int i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"int a = 5 , b = 6 , c;", result.GetTextAt (i1, i2 - i1)); + + result = GetResult (policy, result.Text); + + policy.SpaceBeforeLocalVariableDeclarationComma = false; + policy.SpaceAfterLocalVariableDeclarationComma = false; + + result = GetResult (policy, result.Text); + i1 = result.Text.IndexOf ("int"); + i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"int a = 5,b = 6,c;", result.GetTextAt (i1, i2 - i1)); + } + + #region Constructors + + [Test()] + public void TestBeforeConstructorDeclarationParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeConstructorDeclarationParentheses = true; + + var result = GetResult (policy, @"class Test +{ + Test() + { + } +}"); + + Assert.AreEqual (@"class Test +{ + Test () + { } -}", data.Document.Text); +}", result.Text); + } + + [Test()] + public void TestBeforeConstructorDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeConstructorDeclarationParameterComma = true; + policy.SpaceAfterConstructorDeclarationParameterComma = false; + + var result = GetResult (policy, @"class Test { + public Test (int a,int b,int c) {} +}"); + + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a ,int b ,int c)", result.GetTextAt (i1, i2 - i1)); - policy.SpacesWithinBrackets = false; + policy.SpaceBeforeConstructorDeclarationParameterComma = false; + result = GetResult (policy, result.Text); - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a,int b,int c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestAfterConstructorDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeConstructorDeclarationParameterComma = false; + policy.SpaceAfterConstructorDeclarationParameterComma = true; + + var result = GetResult (policy, @"class Test { + public Test (int a,int b,int c) {} +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a, int b, int c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceAfterConstructorDeclarationParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a,int b,int c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestWithinConstructorDeclarationParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceWithinConstructorDeclarationParentheses = true; - Assert.AreEqual (@"class Test { - Test this[int i] { - get {} - set {} + var result = GetResult (policy, @"class Test { + Test (int a) + { } - - void TestMe () +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( int a )", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBetweenEmptyConstructorDeclarationParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBetweenEmptyConstructorDeclarationParentheses = true; + + var result = GetResult (policy, @"class Test { + Test () { - this[0] = 5; } -}", data.Document.Text); +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( )", result.GetTextAt (i1, i2 - i1)); } + + #endregion + #region Delegates + [Test()] + public void TestBeforeDelegateDeclarationParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeDelegateDeclarationParentheses = true; + + var result = GetResult (policy, @"delegate void Test();"); + + Assert.AreEqual (@"delegate void Test ();", result.Text); + } + + [Test()] + public void TestBeforeDelegateDeclarationParenthesesComplex () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeDelegateDeclarationParentheses = true; + + var result = GetResult (policy, "delegate void TestDelegate\t\t\t();"); + + Assert.AreEqual (@"delegate void TestDelegate ();", result.Text); + } + + [Test()] + public void TestBeforeDelegateDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeDelegateDeclarationParameterComma = true; + policy.SpaceAfterDelegateDeclarationParameterComma = false; + + var result = GetResult (policy, @"delegate void Test (int a,int b,int c);"); + + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a ,int b ,int c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceBeforeDelegateDeclarationParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a,int b,int c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestAfterDelegateDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeDelegateDeclarationParameterComma = false; + policy.SpaceAfterDelegateDeclarationParameterComma = true; + + var result = GetResult (policy, @"delegate void Test (int a,int b,int c);"); + + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a, int b, int c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceAfterDelegateDeclarationParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(int a,int b,int c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestWithinDelegateDeclarationParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceWithinDelegateDeclarationParentheses = true; + var result = GetResult (policy, @"delegate void Test (int a);"); + + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( int a )", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBetweenEmptyDelegateDeclarationParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBetweenEmptyDelegateDeclarationParentheses = true; + var result = GetResult (policy, @"delegate void Test();"); + + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( )", result.GetTextAt (i1, i2 - i1)); + } + + #endregion + #region Method invocations [Test()] - public void TestSpaceBeforeNewParentheses () + public void TestBeforeMethodCallParentheses () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - void TestMe () + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeMethodCallParentheses = true; + + var result = GetResult (policy, @"class FooBar +{ + public void Foo () { - new Test(); + Test(); } -}"; +}"); + + Assert.AreEqual (@"class FooBar +{ + public void Foo () + { + Test (); + } +}", result.Text); + } + + [Test()] + public void TestBeforeMethodCallParameterComma () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.NewParentheses = true; + policy.SpaceBeforeMethodCallParameterComma = true; + policy.SpaceAfterMethodCallParameterComma = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("new"); - int i2 = data.Document.Text.LastIndexOf (";") + ";".Length; - Assert.AreEqual (@"new Test ();", data.Document.GetTextBetween (i1, i2)); + var result = GetResult (policy, @"class FooBar +{ + public void Foo () + { + Test(a,b,c); + } +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(a ,b ,c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceBeforeMethodCallParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(a,b,c)", result.GetTextAt (i1, i2 - i1)); } - + [Test()] - public void TestSpacesBeforeComma () + public void TestAfterMethodCallParameterComma () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { - void TestMe () + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeMethodCallParameterComma = false; + policy.SpaceAfterMethodCallParameterComma = true; + + var result = GetResult (policy, @"class FooBar +{ + public void Foo () { - int[] i = new int[] { 1,3,3,7 }; + Test(a,b,c); } -}"; +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(a, b, c)", result.GetTextAt (i1, i2 - i1)); + + policy.SpaceAfterMethodCallParameterComma = false; + result = GetResult (policy, result.Text); + i1 = result.Text.LastIndexOf ("("); + i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"(a,b,c)", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestWithinMethodCallParentheses () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.SpacesBeforeComma = true; - policy.SpacesAfterComma = false; + policy.SpaceWithinMethodCallParentheses = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("new"); - int i2 = data.Document.Text.LastIndexOf (";") + ";".Length; - Assert.AreEqual (@"new int[] { 1 ,3 ,3 ,7 };", data.Document.GetTextBetween (i1, i2)); - policy.SpacesBeforeComma = false; + var result = GetResult (policy, @"class FooBar +{ + public void Foo () + { + Test(a); + } +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( a )", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestBetweenEmptyMethodCallParentheses () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBetweenEmptyMethodCallParentheses = true; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - i1 = data.Document.Text.LastIndexOf ("new"); - i2 = data.Document.Text.LastIndexOf (";") + ";".Length; - Assert.AreEqual (@"new int[] { 1,3,3,7 };", data.Document.GetTextBetween (i1, i2)); + var result = GetResult (policy, @"class FooBar +{ + public void Foo () + { + Test(); + } +}"); + int i1 = result.Text.LastIndexOf ("("); + int i2 = result.Text.LastIndexOf (")") + ")".Length; + Assert.AreEqual (@"( )", result.GetTextAt (i1, i2 - i1)); } + + #endregion + #region Indexer declarations + [Test()] + public void TestBeforeIndexerDeclarationBracket () + { + + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeIndexerDeclarationBracket = true; + + var result = GetResult (policy, @"class FooBar +{ + public int this[int a, int b] { + get { + return a + b; + } + } +}"); + Assert.AreEqual (@"class FooBar +{ + public int this [int a, int b] { + get { + return a + b; + } + } +}", result.Text); + } + [Test()] - public void TestSpacesAfterComma () + public void TestBeforeIndexerDeclarationParameterComma () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeIndexerDeclarationParameterComma = true; + policy.SpaceAfterIndexerDeclarationParameterComma = false; + + var result = GetResult (policy, @"class FooBar +{ + public int this[int a,int b] { + get { + return a + b; + } + } +}"); + int i1 = result.Text.LastIndexOf ("["); + int i2 = result.Text.LastIndexOf ("]") + "]".Length; + Assert.AreEqual (@"[int a ,int b]", result.GetTextAt (i1, i2 - i1)); + + } + + [Test()] + public void TestAfterIndexerDeclarationParameterComma () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceAfterIndexerDeclarationParameterComma = true; + + var result = GetResult (policy, @"class FooBar +{ + public int this[int a,int b] { + get { + return a + b; + } + } +}"); + int i1 = result.Text.LastIndexOf ("["); + int i2 = result.Text.LastIndexOf ("]") + "]".Length; + Assert.AreEqual (@"[int a, int b]", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestWithinIndexerDeclarationBracket () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceWithinIndexerDeclarationBracket = true; + + var result = GetResult (policy, @"class FooBar +{ + public int this[int a, int b] { + get { + return a + b; + } + } +}"); + int i1 = result.Text.LastIndexOf ("["); + int i2 = result.Text.LastIndexOf ("]") + "]".Length; + Assert.AreEqual (@"[ int a, int b ]", result.GetTextAt (i1, i2 - i1)); + } + + #endregion + + #region Brackets + + [Test()] + public void TestSpacesWithinBrackets () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpacesWithinBrackets = true; + policy.SpacesBeforeBrackets = false; + + var result = GetResult (policy, @"class Test { + void TestMe () + { + this[0] = 5; + } +}"); + Assert.AreEqual (@"class Test +{ void TestMe () { - int[] i = new int[] { 1,3,3,7 }; + this[ 0 ] = 5; } -}"; +}", result.Text); + + + } + + [Test()] + public void TestSpacesBeforeBrackets () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.SpacesBeforeComma = false; - policy.SpacesAfterComma = true; + policy.SpacesBeforeBrackets = true; + + var result = GetResult (policy, @"class Test +{ + void TestMe () + { + this[0] = 5; + } +}"); + Assert.AreEqual (@"class Test +{ + void TestMe () + { + this [0] = 5; + } +}", result.Text); - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.LastIndexOf ("new"); - int i2 = data.Document.Text.LastIndexOf (";") + ";".Length; - Assert.AreEqual (@"new int[] { 1, 3, 3, 7 };", data.Document.GetTextBetween (i1, i2)); - policy.SpacesAfterComma = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - i1 = data.Document.Text.LastIndexOf ("new"); - i2 = data.Document.Text.LastIndexOf (";") + ";".Length; - Assert.AreEqual (@"new int[] { 1,3,3,7 };", data.Document.GetTextBetween (i1, i2)); } - + [Test()] - public void TestSpacesInLambdaExpression () + public void TestBeforeBracketComma () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeBracketComma = true; + policy.SpaceAfterBracketComma = false; + + var result = GetResult (policy, @"class Test { void TestMe () { - var v = x=>x!=null; + this[1,2,3] = 5; } -}"; +}"); + + int i1 = result.Text.LastIndexOf ("["); + int i2 = result.Text.LastIndexOf ("]") + "]".Length; + Assert.AreEqual (@"[1 ,2 ,3]", result.GetTextAt (i1, i2 - i1)); + } + + [Test()] + public void TestAfterBracketComma () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.WithinWhileParentheses = true; + policy.SpaceAfterBracketComma = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomSpacingVisitor (policy, data), null); - int i1 = data.Document.Text.IndexOf ("x"); - int i2 = data.Document.Text.LastIndexOf ("null") + "null".Length; - Assert.AreEqual (@"x => x != null", data.Document.GetTextBetween (i1, i2)); + var result = GetResult (policy, @"class Test { + void TestMe () + { + this[1,2,3] = 5; + } +}"); + + int i1 = result.Text.LastIndexOf ("["); + int i2 = result.Text.LastIndexOf ("]") + "]".Length; + Assert.AreEqual (@"[1, 2, 3]", result.GetTextAt (i1, i2 - i1)); + } + + #endregion + + [Test()] + public void TestSpacesBeforeArrayDeclarationBrackets () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.SpaceBeforeArrayDeclarationBrackets = true; + + var result = GetResult (policy, @"class Test { + int[] a; + int[][] b; +}"); + + Assert.AreEqual (@"class Test +{ + int [] a; + int [][] b; +}", result.Text); + + + } + + [Test()] + public void TestRemoveWhitespacesBeforeSemicolon () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + var result = GetResult (policy, @"class Test { + void TestMe () + { + Foo () ; + } +}"); + int i1 = result.Text.IndexOf ("Foo"); + int i2 = result.Text.LastIndexOf (";") + ";".Length; + Assert.AreEqual (@"Foo ();", result.GetTextAt (i1, i2 - i1)); } } } - */ \ No newline at end of file diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs index 6d483a6c7..38a5d6c4a 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs @@ -23,71 +23,54 @@ // 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 System.IO; using NUnit.Framework; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; -using MonoDevelop.Core; -using MonoDevelop.Ide.CodeCompletion; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.CSharp.Parser; -using MonoDevelop.CSharp.Resolver; -using MonoDevelop.CSharp.Completion; -using Mono.TextEditor; -using MonoDevelop.CSharp.Formatting; +using ICSharpCode.NRefactory.CSharp; -namespace MonoDevelop.CSharpBinding.FormattingTests +namespace ICSharpCode.NRefactory.FormattingTests { [TestFixture()] - public class TestStatementIndentation : UnitTests.TestBase + public class TestStatementIndentation : TestBase { [Test()] public void TestInvocationIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, +@"class Test { Test TestMethod () { this.TestMethod (); } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { this.TestMethod (); } -}", data.Document.Text); +}"); } - + [Test()] public void TestIndentBlocks () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentBlocks = true; + + var adapter = Test (policy, +@"class Test { Test TestMethod () { { {} } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.IndentBlocks = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -95,12 +78,9 @@ this.TestMethod (); {} } } -}", data.Document.Text); +}"); policy.IndentBlocks = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test + Continue (policy, adapter, @"class Test { Test TestMethod () { @@ -108,197 +88,163 @@ this.TestMethod (); {} } } -}", data.Document.Text); - policy.IndentBlocks = false; +}"); } - + [Test()] public void TestBreakIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, +@"class Test { Test TestMethod () { break; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { break; } -}", data.Document.Text); +}"); } - + [Test()] public void TestCheckedIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + + Test (policy, @"class Test { Test TestMethod () { checked { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", @"class Test { Test TestMethod () { checked { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestBaseIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { base.FooBar(); } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", @"class Test { Test TestMethod () { - base.FooBar(); + base.FooBar (); } -}", data.Document.Text); +}"); } - + [Test()] public void TestUncheckedIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { unchecked { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { unchecked { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestContinueIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { continue; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { continue; } -}", data.Document.Text); +}"); } - + [Test()] public void TestEmptyStatementIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", @"class Test { Test TestMethod () { ; } -}", data.Document.Text); +}"); } - + [Test()] public void TestFixedStatementIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { fixed (object* obj = &obj) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { fixed (object* obj = &obj) ; } -}", data.Document.Text); +}"); } - + [Test()] public void TestFixedForcementAdd () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.FixedBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test { Test TestMethod () { @@ -306,16 +252,8 @@ fixed (object* obj = &obj) } fixed (object* obj = &obj) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - policy.FixedBraceForcement = BraceForcement.AddBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -325,228 +263,191 @@ fixed (object* obj = &obj) ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForeachIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { foreach (var obj in col) { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", @"class Test { Test TestMethod () { foreach (var obj in col) { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { for (;;) { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", @"class Test { Test TestMethod () { for (;;) { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestGotoIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { goto label; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { goto label; } -}", data.Document.Text); +}"); } - + [Test()] public void TestReturnIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { return; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { return; } -}", data.Document.Text); +}"); } - + [Test()] public void TestLockIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { lock (this) { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { lock (this) { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestThrowIndentation () { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { throw new NotSupportedException (); } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { throw new NotSupportedException (); } -}", data.Document.Text); +}"); } - + [Test()] public void TestUnsafeIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { unsafe { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { unsafe { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestUsingIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { using (var o = new MyObj()) { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", @"class Test { Test TestMethod () { using (var o = new MyObj()) { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestUsingForcementAdd () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.UsingBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test { Test TestMethod () { @@ -554,16 +455,8 @@ using (var o = new MyObj()) { } using (var o = new MyObj()) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - policy.UsingBraceForcement = BraceForcement.AddBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -573,15 +466,18 @@ using (var o = new MyObj()) { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestUsingForcementDoNotChange () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.UsingBraceForcement = BraceForcement.DoNotChange; + + Test (policy, @"class Test { Test TestMethod () { @@ -589,16 +485,8 @@ using (var o = new MyObj()) { } using (var o = new MyObj()) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - policy.UsingBraceForcement = BraceForcement.DoNotChange; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -607,163 +495,185 @@ using (var o = new MyObj()) { using (var o = new MyObj()) ; } -}", data.Document.Text); +}"); } - - + [Test()] - public void TestVariableDeclarationIndentation () + public void TestUsingAlignment () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.AlignEmbeddedUsingStatements = true; + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + var adapter = Test (policy, @"class Test { Test TestMethod () { -Test a; +using (var p = new MyObj()) +using (var o = new MyObj()) { +} } -}"; - +}", +@"class Test { + Test TestMethod () + { + using (var p = new MyObj()) + using (var o = new MyObj()) { + } + } +}"); + policy.AlignEmbeddedUsingStatements = false; + Continue (policy, adapter, @"class Test { + Test TestMethod () + { + using (var p = new MyObj()) + using (var o = new MyObj()) { + } + } +}"); + } + + [Test()] + public void TestVariableDeclarationIndentation () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - Console.WriteLine (data.Document.Text); policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { + + Test (policy, @"class Test { + Test TestMethod () + { +Test a; + } +}", +@"class Test { Test TestMethod () { Test a; } -}", data.Document.Text); +}"); } - - + [Test()] - public void TestYieldIndentation () + public void TestConstantVariableDeclarationIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { -yield return null; +const int a = 5; } -}"; - +}", +@"class Test { + Test TestMethod () + { + const int a = 5; + } +}"); + } + + [Test()] + public void TestYieldIndentation () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { + Test (policy, @"class Test { + Test TestMethod () + { +yield return null; + } +}", +@"class Test { Test TestMethod () { yield return null; } -}", data.Document.Text); +}"); } - + [Test()] public void TestWhileIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { while (true) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { while (true) ; } -}", data.Document.Text); +}"); } - + [Test()] public void TestDoWhileIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.ClassBraceStyle = BraceStyle.EndOfLine; + Test (policy, @"class Test { Test TestMethod () { do { } while (true); } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.ClassBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test { +}", +@"class Test { Test TestMethod () { do { } while (true); } -}", data.Document.Text); +}"); } - - + [Test()] public void TestForeachBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + Test (policy, @"class Test { Test TestMethod () { foreach (var obj in col) {} } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { foreach (var obj in col) { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForeachBracketPlacement2 () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLineShifted2; + Test (policy, @"class Test { Test TestMethod () { foreach (var obj in col) {;} } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.NextLineShifted2; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -772,15 +682,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForEachBraceForcementAdd () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLine; + policy.ForEachBraceForcement = BraceForcement.AddBraces; + Test (policy, @"class Test { Test TestMethod () { @@ -789,18 +701,8 @@ do { } foreach (var obj in col) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.NextLine; - policy.ForEachBraceForcement = BraceForcement.AddBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -812,15 +714,18 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForBraceForcementAdd () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLine; + policy.ForBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test { Test TestMethod () { @@ -829,16 +734,8 @@ do { } for (;;) ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.NextLine; - policy.ForBraceForcement = BraceForcement.AddBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -850,15 +747,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForEachBraceForcementRemove () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLine; + policy.ForEachBraceForcement = BraceForcement.RemoveBraces; + Test (policy, @"class Test { Test TestMethod () { @@ -872,18 +771,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.NextLine; - policy.ForEachBraceForcement = BraceForcement.RemoveBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -895,38 +784,33 @@ do { foreach (var obj in col) ; } -}", data.Document.Text); +}"); } - - + [Test()] public void TestIfBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { if (true) {} } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { if (true) { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestAllowIfBlockInline () { @@ -934,168 +818,290 @@ do { policy.StatementBraceStyle = BraceStyle.EndOfLine; policy.AllowIfBlockInline = true; - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + Test (policy, @"class Test { Test TestMethod () { if (true) {} } -}"; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", @"class Test { Test TestMethod () { if (true) {} } -}", data.Document.Text); +}"); - data.Document.Text = @"class Test + Test (policy, @"class Test { Test TestMethod () { if (true) { Foo (); } } -}"; - - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", @"class Test { Test TestMethod () { if (true) { Foo (); } } -}", data.Document.Text); +}"); - data.Document.Text = @"class Test + Test (policy, @"class Test { Test TestMethod () { if (true) Foo (); } -}"; - - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", @"class Test { Test TestMethod () { if (true) Foo (); } -}", data.Document.Text); +}"); - data.Document.Text = @"class Test + Test (policy, @"class Test { Test TestMethod () { if (true) Foo (); } -}"; - - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { if (true) Foo (); } -}", data.Document.Text); - - +}"); } - + [Test()] public void TestIfElseBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { if (true) {} else {} } -}"; +}", +@"class Test +{ + Test TestMethod () + { + if (true) { + } else { + } + } +}"); + } + + [Test()] + public void TestIfForcementRemove () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLine; + policy.IfElseBraceForcement = BraceForcement.RemoveBraces; + + Test (policy, @"class Test +{ + Test TestMethod () + { + if (true) + { + ; + ; + } + if (true) + { + ; + } + } +}", +@"class Test +{ + Test TestMethod () + { + if (true) + { + ; + ; + } + if (true) + ; + } +}"); + } + + [Test()] + public void TestIfAlignment () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.AlignEmbeddedIfStatements = true; + policy.ClassBraceStyle = BraceStyle.EndOfLine; + + var adapter = Test (policy, @"class Test { + Test TestMethod () + { +if (a) +if (b) { +} + } +}", +@"class Test { + Test TestMethod () + { + if (a) + if (b) { + } + } +}"); + policy.AlignEmbeddedIfStatements = false; + Continue (policy, adapter, @"class Test { + Test TestMethod () + { + if (a) + if (b) { + } + } +}"); + } + + [Test()] + public void TestIfForcementAdd () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.IfElseBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test +{ + void TestMethod () + { + if (true) + Call (); + } +}", +@"class Test +{ + void TestMethod () + { + if (true) { + Call (); + } + } +}"); + } + + [Test()] + public void TestIfForcementWithComment () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.IfElseBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test +{ + void TestMethod () + { + if (true) // TestComment + Call (); + } +}", +@"class Test +{ + void TestMethod () + { + if (true) { + // TestComment + Call (); + } + } +}"); + } + + [Test()] + public void TestIfElseForcementAdd () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + policy.IfElseBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test +{ + void TestMethod () + { + if (true) + Call (); + else + Call2 (); + } +}", +@"class Test { - Test TestMethod () + void TestMethod () { if (true) { + Call (); } else { + Call2 (); } } -}", data.Document.Text); +}"); } - + [Test()] - public void TestIfForcementRemove () - { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test TestMethod () - { - if (true) - { - ; - ; - } - if (true) + public void TestIfElseIFForcementAdd () { - ; - } - } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.StatementBraceStyle = BraceStyle.NextLine; - policy.IfElseBraceForcement = BraceForcement.RemoveBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.IfElseBraceForcement = BraceForcement.AddBraces; - Assert.AreEqual (@"class Test + Test (policy, @"class Test { - Test TestMethod () + void TestMethod () { if (true) - { - ; - ; + Call (); + else if (false) + Call2 (); + } +}", +@"class Test +{ + void TestMethod () + { + if (true) { + Call (); + } else if (false) { + Call2 (); } - if (true) - ; } -}", data.Document.Text); +}"); } - + [Test()] public void TestElseOnNewLine () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PlaceElseOnNewLine = true; + + Test (policy, @"class Test { Test TestMethod () { @@ -1105,16 +1111,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PlaceElseOnNewLine = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1125,15 +1123,16 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestElseIfOnNewLine () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PlaceElseIfOnNewLine = true; + + Test (policy, @"class Test { Test TestMethod () { @@ -1143,14 +1142,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PlaceElseIfOnNewLine = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1161,15 +1154,16 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestElseOnNewLineOff () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PlaceElseOnNewLine = false; + + Test (policy, @"class Test { Test TestMethod () { @@ -1180,16 +1174,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PlaceElseOnNewLine = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1199,16 +1185,45 @@ do { ; } } -}", data.Document.Text); +}"); } - - + + [Test()] + public void TestSimpleIfElseComment () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + policy.PlaceElseIfOnNewLine = false; // for simple statements it must be new line. + + Test (policy, @"class Test +{ + void TestMethod () + { + if (true) Call (); else Call (); + } +}", +@"class Test +{ + void TestMethod () + { + if (true) + Call (); + else + Call (); + } +}"); + } + [Test()] public void TestWhileForcementRemove () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLine; + policy.WhileBraceForcement = BraceForcement.RemoveBraces; + + Test (policy, @"class Test { Test TestMethod () { @@ -1222,18 +1237,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.NextLine; - policy.WhileBraceForcement = BraceForcement.RemoveBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1245,15 +1250,18 @@ do { while (true) ; } -}", data.Document.Text); +}"); } - + [Test()] public void TestFixedBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.NextLineShifted; + policy.FixedBraceForcement = BraceForcement.AddBraces; + + Test (policy, @"class Test { Test TestMethod () { @@ -1261,15 +1269,8 @@ do { ; } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.NextLineShifted; - policy.FixedBraceForcement = BraceForcement.AddBraces; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1278,28 +1279,23 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestForBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace; + Test (policy, @"class Test { Test TestMethod () { for (;;) {;} } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1307,28 +1303,24 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestCheckedBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace; + + Test (policy, @"class Test { Test TestMethod () { checked {;} } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1336,28 +1328,24 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestUncheckedBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace; + + Test (policy, @"class Test { Test TestMethod () { unchecked {;} } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1365,15 +1353,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestLockBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { @@ -1382,14 +1372,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1397,15 +1381,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestUnsafeBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { @@ -1414,14 +1400,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1429,15 +1409,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestUsingBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { @@ -1446,14 +1428,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1461,15 +1437,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestWhileBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { @@ -1478,14 +1456,8 @@ do { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1493,15 +1465,17 @@ do { ; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestDoWhileBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { @@ -1510,14 +1484,8 @@ do { ; } while (true); } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1525,104 +1493,90 @@ do { ; } while (true); } -}", data.Document.Text); +}"); } - + [Test()] public void TestSwitchFormatting1 () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test TestMethod () - { - switch (a) { case 1: case 2: DoSomething(); break; default: Foo (); break;} - } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.IndentSwitchBody = true; policy.IndentCaseBody = true; policy.IndentBreakStatements = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + + Test (policy, @"class Test +{ + Test TestMethod () + { + switch (a) { case 1: case 2: DoSomething(); break; default: Foo (); break;} + } +}", +@"class Test { Test TestMethod () { switch (a) { case 1: case 2: - DoSomething(); + DoSomething (); break; default: Foo (); break; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestSwitchFormatting2 () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test -{ - Test TestMethod () - { - switch (a) { case 1: case 2: DoSomething(); break; default: Foo (); break;} - } -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.IndentSwitchBody = false; policy.IndentCaseBody = false; policy.IndentBreakStatements = false; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + + Test (policy, @"class Test +{ + Test TestMethod () + { + switch (a) { case 1: case 2: DoSomething(); break; default: Foo (); break;} + } +}", +@"class Test { Test TestMethod () { switch (a) { case 1: case 2: - DoSomething(); + DoSomething (); break; default: Foo (); break; } } -}", data.Document.Text); +}"); } - + [Test()] public void TestTryCatchBracketPlacement () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.StatementBraceStyle = BraceStyle.EndOfLine; + + Test (policy, @"class Test { Test TestMethod () { try { ; } catch (Exception e) { } finally { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.StatementBraceStyle = BraceStyle.EndOfLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1632,15 +1586,17 @@ do { } finally { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestPlaceCatchOnNewLine () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.PlaceCatchOnNewLine = true; + + Test (policy, @"class Test { Test TestMethod () { @@ -1650,16 +1606,8 @@ do { } finally { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.PlaceCatchOnNewLine = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMethod () { @@ -1670,15 +1618,16 @@ do { } finally { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestPlaceFinallyOnNewLine () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PlaceFinallyOnNewLine = true; + + Test (policy, @"class Test { Test TestMethod () { @@ -1688,16 +1637,8 @@ do { } finally { } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.PlaceFinallyOnNewLine = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", + @"class Test { Test TestMethod () { @@ -1708,15 +1649,17 @@ do { finally { } } -}", data.Document.Text); +}"); } - + [Test()] public void TestPlaceWhileOnNewLine () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = @"class Test + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + policy.PlaceWhileOnNewLine = true; + + Test (policy, @"class Test { Test TestMethod () { @@ -1724,16 +1667,8 @@ do { ; } while (true); } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - policy.PlaceWhileOnNewLine = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - - Console.WriteLine (data.Document.Text); - Assert.AreEqual (@"class Test +}", + @"class Test { Test TestMethod () { @@ -1742,8 +1677,8 @@ do { } while (true); } -}", data.Document.Text); +}"); } } -}*/ +} diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs index c41489eb5..4e486b79f 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs @@ -1,6 +1,6 @@ // // TestTypeLevelIndentation.cs -// +// // Author: // Mike Krüger // @@ -23,164 +23,196 @@ // 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 System.IO; using NUnit.Framework; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; -using MonoDevelop.Core; -using MonoDevelop.Ide.CodeCompletion; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.CSharp.Parser; -using MonoDevelop.CSharp.Resolver; -using MonoDevelop.CSharp.Completion; -using Mono.TextEditor; -using MonoDevelop.CSharp.Formatting; +using ICSharpCode.NRefactory.CSharp; -namespace MonoDevelop.CSharpBinding.FormattingTests +namespace ICSharpCode.NRefactory.FormattingTests { [TestFixture()] - public class TestTypeLevelIndentation : UnitTests.TestBase + public class TestTypeLevelIndentation : TestBase { [Test()] public void TestClassIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = -@" class Test {}"; + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.ClassBraceStyle = BraceStyle.DoNotChange; + + Test (policy, +@" class Test {}", +@"class Test {}"); + } + + + [Test()] + public void TestClassIndentationInNamespaces () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.NamespaceBraceStyle = BraceStyle.EndOfLine; + policy.ClassBraceStyle = BraceStyle.DoNotChange; + + Test (policy, +@"namespace A { class Test {} }", +@"namespace A { + class Test {} +}"); + } + + [Test()] + public void TestNoIndentationInNamespaces () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.NamespaceBraceStyle = BraceStyle.EndOfLine; + policy.ClassBraceStyle = BraceStyle.DoNotChange; + policy.IndentNamespaceBody = false; + Test (policy, +@"namespace A { class Test {} }", +@"namespace A { +class Test {} +}"); + } + + [Test()] + public void TestClassIndentationInNamespacesCase2 () + { CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.DoNotChange; + policy.NamespaceBraceStyle = BraceStyle.NextLine; + policy.ClassBraceStyle = BraceStyle.NextLine; + policy.ConstructorBraceStyle = BraceStyle.NextLine; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test {}", data.Document.Text); + Test (policy, +@"using System; + +namespace MonoDevelop.CSharp.Formatting { + public class FormattingProfileService { + public FormattingProfileService () { + } + } +}", +@"using System; + +namespace MonoDevelop.CSharp.Formatting +{ + public class FormattingProfileService + { + public FormattingProfileService () + { + } + } +}"); } [Test()] public void TestIndentClassBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentClassBody = true; + Test (policy, @"class Test { Test a; -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IndentClassBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", @"class Test { Test a; -}", data.Document.Text); +}"); + policy.IndentClassBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + Test (policy, +@"class Test +{ + Test a; +}", +@"class Test { Test a; -}", data.Document.Text); +}"); } [Test()] public void TestIndentInterfaceBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = -@"interface Test -{ - Test Foo (); -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.IndentInterfaceBody = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"interface Test + Test (policy, +@"interface Test +{ + Test Foo (); +}", @"interface Test { Test Foo (); -}", data.Document.Text); +}"); policy.IndentInterfaceBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"interface Test + Test (policy, +@"interface Test +{ + Test Foo (); +}", @"interface Test { Test Foo (); -}", data.Document.Text); +}"); } [Test()] public void TestIndentStructBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = -@"struct Test -{ - Test a; -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.IndentStructBody = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"struct Test + Test (policy, +@"struct Test { - Test a; -}", data.Document.Text); + Test Foo (); +}", @"struct Test +{ + Test Foo (); +}"); policy.IndentStructBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"struct Test + Test (policy, +@"struct Test { -Test a; -}", data.Document.Text); + Test Foo (); +}", @"struct Test +{ +Test Foo (); +}"); } [Test()] public void TestIndentEnumBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = -@"enum Test -{ - A -}"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); policy.IndentEnumBody = true; - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"enum Test + Test (policy, +@"enum Test +{ + A +}", @"enum Test { A -}", data.Document.Text); +}"); policy.IndentEnumBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"enum Test + Test (policy, +@"enum Test +{ + A +}", @"enum Test { A -}", data.Document.Text); +}"); } [Test()] public void TestIndentMethodBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentMethodBody = true; + + Test (policy, @"class Test { Test Foo () @@ -188,40 +220,42 @@ A ; ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IndentMethodBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test Foo () { ; ; } -}", data.Document.Text); +}"); policy.IndentMethodBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + Test (policy, +@"class Test +{ + Test Foo () + { + ; + ; + } +}", +@"class Test { Test Foo () { ; ; } -}", data.Document.Text); +}"); } [Test()] public void TestIndentMethodBodyOperatorCase () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentMethodBody = true; + + var adapter = Test (policy, @"class Test { static Test operator+(Test left, Test right) @@ -229,78 +263,104 @@ A ; ; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IndentMethodBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { - static Test operator+(Test left, Test right) + static Test operator+ (Test left, Test right) { ; ; } -}", data.Document.Text); +}"); policy.IndentMethodBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + Continue (policy, adapter, @"class Test { - static Test operator+(Test left, Test right) + static Test operator+ (Test left, Test right) { ; ; } -}", data.Document.Text); +}"); } [Test()] public void TestIndentPropertyBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentPropertyBody = true; + + var adapter = Test (policy, @"class Test { Test TestMe { get; set; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IndentPropertyBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { Test TestMe { get; set; } -}", data.Document.Text); +}"); policy.IndentPropertyBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + + Continue (policy, adapter, +@"class Test { Test TestMe { get; set; } -}", data.Document.Text); +}"); + } + + [Test()] + public void TestIndentPropertyOneLine () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertyFormatting = PropertyFormatting.AllowOneLine; + policy.AllowPropertyGetBlockInline = true; + policy.AllowPropertySetBlockInline = true; + + Test (policy, +@"class Test +{ + Test TestMe { get;set; } +}", +@"class Test +{ + Test TestMe { get; set; } +}"); + } + + [Test()] + public void TestIndentPropertyOneLineCase2 () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertyFormatting = PropertyFormatting.AllowOneLine; + policy.AllowPropertyGetBlockInline = true; + policy.AllowPropertySetBlockInline = true; + + Test (policy, +@"class Test +{ + Test TestMe { get { ; }set{;} } +}", +@"class Test +{ + Test TestMe { get { ; } set { ; } } +}"); } [Test()] public void TestIndentPropertyBodyIndexerCase () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentPropertyBody = true; + + var adapter = Test (policy, @"class Test { Test this[int a] { @@ -311,16 +371,10 @@ set { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IndentPropertyBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { - Test this[int a] { + Test this [int a] { get { return null; } @@ -328,13 +382,12 @@ set { ; } } -}", data.Document.Text); +}"); policy.IndentPropertyBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + Continue (policy, adapter, +@"class Test { - Test this[int a] { + Test this [int a] { get { return null; } @@ -342,117 +395,129 @@ set { ; } } -}", data.Document.Text); +}"); } + + [Test()] + public void TestPropertyAlignment () + { + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertyFormatting = PropertyFormatting.AllowOneLine; + var adapter = Test (policy, +@"class Test +{ + Test TestMe { get; set; } +}", +@"class Test +{ + Test TestMe { get; set; } +}"); + policy.PropertyFormatting = PropertyFormatting.ForceNewLine; + Continue (policy, adapter, +@"class Test +{ + Test TestMe { + get; + set; + } +}"); + policy.PropertyFormatting = PropertyFormatting.ForceOneLine; + + Continue (policy, adapter, +@"class Test +{ + Test TestMe { get; set; } +}"); + } + [Test()] - [Ignore("currently failing because namespaces are not inserted")] public void TestIndentNamespaceBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = -@" namespace Test { -class FooBar {} - }"; - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.ClassBraceStyle = BraceStyle.DoNotChange; + policy.ClassBraceStyle = BraceStyle.DoNotChange; + policy.NamespaceBraceStyle = BraceStyle.EndOfLine; policy.IndentNamespaceBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"namespace Test { + var adapter = Test (policy, +@" namespace Test { +class FooBar {} + }", +@"namespace Test { class FooBar {} -}", data.Document.Text); +}"); policy.IndentNamespaceBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"namespace Test { + Continue (policy, adapter, +@"namespace Test { class FooBar {} -}", data.Document.Text); +}"); } + [Test()] public void TestMethodIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.MethodBraceStyle = BraceStyle.DoNotChange; + + Test (policy, @"class Test { MyType TestMethod () {} -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.MethodBraceStyle = BraceStyle.DoNotChange; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { MyType TestMethod () {} -}", data.Document.Text); +}"); } [Test()] public void TestPropertyIndentation () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.PropertyBraceStyle = BraceStyle.DoNotChange; + + Test (policy, @"class Test { public int Prop { get; set; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.PropertyBraceStyle = BraceStyle.DoNotChange; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}",@"class Test { public int Prop { get; set; } -}", data.Document.Text); +}"); } [Test()] public void TestPropertyIndentationCase2 () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + + Test (policy, @"class Test { public int Prop { get; set; } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { public int Prop { get; set; } -}", data.Document.Text); +}"); } [Test()] public void TestIndentEventBody () { - TextEditorData data = new TextEditorData (); - data.Document.FileName = "a.cs"; - data.Document.Text = + CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); + policy.IndentEventBody = true; + + var adapter = Test (policy, @"class Test { public event EventHandler TestMe { @@ -463,14 +528,8 @@ remove { ; } } -}"; - - CSharpFormattingPolicy policy = new CSharpFormattingPolicy (); - policy.IndentEventBody = true; - - CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test +}", +@"class Test { public event EventHandler TestMe { add { @@ -480,11 +539,10 @@ remove { ; } } -}", data.Document.Text); +}"); policy.IndentEventBody = false; - compilationUnit = new CSharpParser ().Parse (data); - compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null); - Assert.AreEqual (@"class Test + Continue (policy, adapter, +@"class Test { public event EventHandler TestMe { add { @@ -494,7 +552,7 @@ remove { ; } } -}", data.Document.Text); +}"); } } -}*/ +} diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs new file mode 100644 index 000000000..f5b489fe1 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.CSharp; +using System.IO; +using NUnit.Framework; + +namespace ICSharpCode.NRefactory.FormattingTests +{ + /// + /// Text editor test adapter. Only implemented for testing purposes. Don't use in production code. + /// + class TextEditorTestAdapter : ITextEditorAdapter + { + string text; + + public string Text { + get { + return this.text; + } + } + + List delimiters; + + struct Delimiter + { + public readonly int Offset; + public readonly int Length; + + public int EndOffset { + get { return Offset + Length; } + } + + public Delimiter (int offset, int length) + { + Offset = offset; + Length = length; + } + + public override string ToString () + { + return string.Format ("[Delimiter: Offset={0}, Length={1}]", Offset, Length); + } + } + + static IEnumerable FindDelimiter (string text) + { + for (int i = 0; i < text.Length; i++) { + switch (text [i]) { + case '\r': + if (i + 1 < text.Length && text [i + 1] == '\n') { + yield return new Delimiter (i, 2); + i++; + } else { + yield return new Delimiter (i, 1); + } + break; + case '\n': + yield return new Delimiter (i, 1); + break; + } + } + } + + public TextEditorTestAdapter (string text) + { + this.text = text; + delimiters = new List (FindDelimiter (text)); + } + + class Segment + { + public readonly int Offset; + public readonly int Length; + public readonly int DelimiterLength; + + public Segment (int offset, int length, int delimiterLength) + { + this.Offset = offset; + this.Length = length; + this.DelimiterLength = delimiterLength; + } + + public override string ToString () + { + return string.Format ("[Segment: Offset={0}, Length={1}, DelimiterLength={2}]", Offset, Length, DelimiterLength); + } + } + + Segment Get (int number) + { + number--; + if (number < 0 || number - 1 >= delimiters.Count) + return null; + int startOffset = number > 0 ? delimiters [number - 1].EndOffset : 0; + int endOffset; + int delimiterLength; + if (number < delimiters.Count) { + endOffset = delimiters [number].EndOffset; + delimiterLength = delimiters [number].Length; + } else { + endOffset = text.Length; + delimiterLength = 0; + } + return new Segment (startOffset, endOffset - startOffset, delimiterLength); + } + + public void ApplyChanges (List changes) + { + changes.Sort ((x, y) => x.Offset.CompareTo (y.Offset)); + changes.Reverse (); + foreach (var change in changes) { + text = text.Substring (0, change.Offset) + change.InsertedText + text.Substring (change.Offset + change.RemovedChars); + } + delimiters = new List (FindDelimiter (text)); + } + + #region ITextEditorAdapter implementation + public int LocationToOffset (int line, int col) + { + Segment seg = Get (line); + if (seg == null) + return 0; + return seg.Offset + col - 1; + } + + public char GetCharAt (int offset) + { + if (offset < 0 || offset >= text.Length) + return '\0'; + return text [offset]; + } + + public string GetTextAt (int offset, int length) + { + if (offset < 0 || offset + length >= text.Length) + return ""; + if (length <= 0) + return ""; + + return text.Substring (offset, length); + } + + public int GetEditableLength (int lineNumber) + { + var seg = Get (lineNumber); + if (seg == null) + return 0; + return seg.Length - seg.DelimiterLength; + } + + public string GetIndentation (int lineNumber) + { + var seg = Get (lineNumber); + if (seg == null) + return ""; + int start = seg.Offset; + int end = seg.Offset; + int endOffset = seg.Offset + seg.Length - seg.DelimiterLength; + + while (end < endOffset && (text[end] == ' ' || text[end] == '\t')) + end++; + + return start < end ? text.Substring (start, end - start) : ""; + } + + public int GetLineOffset (int lineNumber) + { + var seg = Get (lineNumber); + if (seg == null) + return 0; + return seg.Offset; + } + + public int GetLineLength (int lineNumber) + { + var seg = Get (lineNumber); + if (seg == null) + return 0; + return seg.Length; + } + + public int GetLineEndOffset (int lineNumber) + { + var seg = Get (lineNumber); + if (seg == null) + return 0; + return seg.Offset + seg.Length; + } + + public bool TabsToSpaces { + get { + return false; + } + } + + public int TabSize { + get { + return 4; + } + } + + public string EolMarker { + get { + return Environment.NewLine; + } + } + + public int Length { + get { + return text.Length; + } + } + + public int LineCount { + get { + return delimiters.Count + 1; + } + } + #endregion + } + + public abstract class TestBase + { + protected static ITextEditorAdapter GetResult (CSharpFormattingPolicy policy, string input) + { + var adapter = new TextEditorTestAdapter (input); + var visitior = new AstFormattingVisitor (policy, adapter); + + var compilationUnit = new CSharpParser ().Parse (new StringReader (adapter.Text)); + compilationUnit.AcceptVisitor (visitior, null); + adapter.ApplyChanges (visitior.Changes); + + return adapter; + } + + protected static ITextEditorAdapter Test (CSharpFormattingPolicy policy, string input, string expectedOutput) + { + var adapter = new TextEditorTestAdapter (input); + var visitior = new AstFormattingVisitor (policy, adapter); + + var compilationUnit = new CSharpParser ().Parse (new StringReader (adapter.Text)); + compilationUnit.AcceptVisitor (visitior, null); + adapter.ApplyChanges (visitior.Changes); + Assert.AreEqual (expectedOutput, adapter.Text); + return adapter; + } + + protected static void Continue (CSharpFormattingPolicy policy, ITextEditorAdapter adapter, string expectedOutput) + { + var visitior = new AstFormattingVisitor (policy, adapter); + + var compilationUnit = new CSharpParser ().Parse (new StringReader (adapter.Text)); + compilationUnit.AcceptVisitor (visitior, null); + ((TextEditorTestAdapter)adapter).ApplyChanges (visitior.Changes); + Assert.AreEqual (expectedOutput, adapter.Text); + } + + + } +} + diff --git a/NRefactory/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj b/NRefactory/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj index 6d351a08a..403af99e2 100644 --- a/NRefactory/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj +++ b/NRefactory/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj @@ -11,7 +11,6 @@ Properties 10.0.0 2.0 - Client x86 @@ -33,23 +32,17 @@ TRACE - true - full - false 4 - true true - none - true 4 true - ..\lib\nunit.framework.dll + ..\..\Mono.Cecil\Test\libs\nunit-2.4.8\nunit.framework.dll @@ -155,6 +148,8 @@ + + @@ -163,11 +158,11 @@ - - - - - + + + + + \ No newline at end of file diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs index 3dfc9c2aa..2db6aa293 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs @@ -4,7 +4,7 @@ using System; using System.Reflection; using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; using ICSharpCode.NRefactory.VB.Visitors; @@ -58,10 +58,10 @@ namespace ICSharpCode.NRefactory.VB.Tests // } [Test] - public void TestIDomVisitor() + public void TestIAstVisitor() { Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes(); - Type visitor = typeof(IDomVisitor); + Type visitor = typeof(IAstVisitor); foreach (Type type in allTypes) { if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { @@ -79,10 +79,10 @@ namespace ICSharpCode.NRefactory.VB.Tests } [Test] - public void TestAbstractDomVisitorVisitor() + public void TestAbstractAstVisitorVisitor() { Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes(); - Type visitor = typeof(AbstractDomVisitor); + Type visitor = typeof(AbstractAstVisitor); foreach (Type type in allTypes) { if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs index 760c7372a..174a96343 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs @@ -481,12 +481,14 @@ End Module", enter Expression enter Expression enter Expression + enter Expression + exit Expression exit Expression exit Expression - exit Expression - enter Expression enter Expression enter Expression + enter Expression + exit Expression exit Expression exit Expression exit Expression diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs index 948948e57..6d4bb2da9 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs @@ -3,7 +3,7 @@ using System; using System.CodeDom; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; using NUnit.Framework; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs index 366ac4cea..2d1c89d1b 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs @@ -3,7 +3,7 @@ using System; using System.CodeDom; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; using NUnit.Framework; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs index 86d23d13f..fffd395c1 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs @@ -5,7 +5,7 @@ using System; using System.CodeDom; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; using NUnit.Framework; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs index 63fd43775..94f52b45e 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs @@ -5,7 +5,7 @@ using System; using System.CodeDom; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; using NUnit.Framework; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs index d92b7899e..7e8961e63 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.IO; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; using ICSharpCode.NRefactory.VB.PrettyPrinter; using ICSharpCode.NRefactory.VB.Visitors; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs index 6a6b9f461..dc8160638 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs @@ -3,7 +3,7 @@ using System; using System.IO; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; using ICSharpCode.NRefactory.VB.PrettyPrinter; using ICSharpCode.NRefactory.VB.Visitors; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/CheckParentVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/CheckParentVisitor.cs index a24409327..8c7a4f27e 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/CheckParentVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/CheckParentVisitor.cs @@ -4,15 +4,15 @@ using NUnit.Framework; using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { /// /// Ensures that all nodes have the Parent property correctly set. /// - public class CheckParentVisitor : NodeTrackingDomVisitor + public class CheckParentVisitor : NodeTrackingAstVisitor { Stack nodeStack = new Stack(); diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs index 364d041e7..40df05fef 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class AddressOfExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs index 91288f82b..673c6f8ab 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ArrayCreateExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs index 31f67e0e9..f01c4e272 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class AssignmentExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs index 6d7b4a451..0747f40f6 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class BaseReferenceExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs index a96353f4a..030d17132 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs @@ -5,10 +5,10 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.PrettyPrinter; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class BinaryOperatorExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs index 0968fdac6..b4ec88756 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class CastExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs index 1d8b43f7d..b9b892956 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ClassReferenceExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs index 33e6095dd..715d716f7 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ConditionalExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs index 08e52a285..54445299f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class GlobalReferenceExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs index 26ce34f97..9c929a2e5 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class IdentifierExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs index 00ef8bb3c..8fbe1c289 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class InvocationExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs index 7afe3ed54..b88297f04 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class LambdaExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs index fdf3f263e..bdf73af4b 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class MemberReferenceExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs index 416e716b6..478dcf330 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ObjectCreateExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs index 50c2292b2..b3ed4f87a 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ParenthesizedExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs index 7aba4aba3..af197957f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class PrimitiveExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs index cfc27dfbf..dad3349c4 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs @@ -5,11 +5,11 @@ using System; using System.IO; using System.Linq; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class QueryExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs index b5c736ba1..4762bbeb0 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ThisReferenceExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs index 87f1ca03a..a86a722a8 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class TypeOfExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs index 6af478d8e..9d7da043d 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class TypeOfIsExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs index d3d816ba0..c002b4b54 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class TypeReferenceExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs index 771291c38..5bbaa66f1 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class UnaryOperatorExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs index 9c5602dc7..cc9012cc6 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class XmlExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs index 09d074fa4..23f39194b 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class XmlMemberAccessExpressionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs index b7f3cf94e..8a877ed9e 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class AttributeSectionTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/DelegateDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/DelegateDeclarationTests.cs index 24489603e..3328c8f2c 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/DelegateDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/DelegateDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class DelegateDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs index a06be924b..ca6dd92d7 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class NamespaceDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionDeclarationTests.cs index 1c2c0ac30..cf1b9ba98 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionDeclarationTests.cs @@ -4,10 +4,10 @@ using System; using System.IO; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class OptionDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs index 9528799cf..39e41144a 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class TypeDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/UsingDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/UsingDeclarationTests.cs index 7cce8b7b3..83681327c 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/UsingDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/UsingDeclarationTests.cs @@ -4,10 +4,10 @@ using System; using System.IO; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class UsingDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/LocationAssignmentCheckVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/LocationAssignmentCheckVisitor.cs index 4b2bbd464..50f72fd0d 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/LocationAssignmentCheckVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/LocationAssignmentCheckVisitor.cs @@ -2,13 +2,13 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { - public class LocationAssignmentCheckVisitor : NodeTrackingDomVisitor + public class LocationAssignmentCheckVisitor : NodeTrackingAstVisitor { protected override void BeginVisit(INode node) { diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs index 917b5bde3..4ed9d2197 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs @@ -4,10 +4,10 @@ using System; using System.IO; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { public class ParseUtil { diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs index adf945a7b..40da76cae 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs @@ -1,7 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using System; using NUnit.Framework; diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs index efa0dc751..714476ef6 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class AddHandlerStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs index 0dcba6367..85d2dd39b 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class BlockStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs index 0b50f9ed4..630054149 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ContinueStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs index 5b8c2c827..512e7f111 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class DoLoopStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs index bec0b212f..9041a2763 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class EndStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs index 4bfa39ed2..742c0fdc2 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class EraseStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs index 0f2cfb9eb..e5ae7289f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ErrorStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs index 57c08f3df..926229402 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ExpressionStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs index 6ce3d9410..68433fd30 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ForNextStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs index 581514eb1..f6e874a96 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ForeachStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs index 72b51bba1..f4c2c5133 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class GotoStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs index 93e73fb55..dee85e7fd 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class IfElseStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs index 1b3a270b1..8bdd6f7fa 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class LabelStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs index 294d2a1f1..d0b9ced62 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class LocalVariableDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs index 1d32d6062..ec3501c75 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class LockStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs index 2ee72a573..db4c5ab96 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class OnErrorStatementTest diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs index 3f6f43c4e..96bbd89e6 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class RaiseEventStatementTest diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs index 7bcb79a2b..4a4ea8db1 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ReDimStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs index a0804c773..fb01666ae 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class RemoveHandlerStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs index 34729c06b..85ab30a31 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ResumeStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs index 2122a0ada..f6403d5eb 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ReturnStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs index 00dd5cc26..0a0d27595 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class StopStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs index 6e2bdffae..c7dcb48fa 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class SwitchStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs index 9386387c5..c9df1d692 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ThrowStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs index a2c3bf268..8d4b49289 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class TryCatchStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs index 8ee0649bb..059eb21a0 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class UsingStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs index 4df188f19..7f0ce5c44 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class WithStatementTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs index ca5e54e80..8c6d27a66 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class ConstructorDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs index c5cdebdd7..5634c982b 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs @@ -5,9 +5,9 @@ using System; using System.IO; using NUnit.Framework; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class CustomEventTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs index 47a56ded9..3b1ae48c0 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class DeclareDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs index 498182888..f88e8e27f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class EventDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs index 12f3e4998..2aa54fdb2 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class FieldDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs index 1fc606bb2..5be86af63 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class MethodDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs index b50063a99..049f7f464 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs @@ -2,10 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class OperatorDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs index bd4b1bf1b..c31f7bb9d 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs @@ -3,10 +3,10 @@ using System; using System.IO; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using NUnit.Framework; -namespace ICSharpCode.NRefactory.VB.Tests.Dom +namespace ICSharpCode.NRefactory.VB.Tests.Ast { [TestFixture] public class PropertyDeclarationTests diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/AbstractNode.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/AbstractNode.cs similarity index 90% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/AbstractNode.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/AbstractNode.cs index 113d12229..2347f4f05 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/AbstractNode.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/AbstractNode.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public abstract class AbstractNode : INode { @@ -35,9 +35,9 @@ namespace ICSharpCode.NRefactory.VB.Dom children.Add(childNode); } - public abstract object AcceptVisitor(IDomVisitor visitor, object data); + public abstract object AcceptVisitor(IAstVisitor visitor, object data); - public virtual object AcceptChildren(IDomVisitor visitor, object data) + public virtual object AcceptChildren(IAstVisitor visitor, object data) { foreach (INode child in children) { Debug.Assert(child != null); diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/Enums.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs similarity index 99% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/Enums.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs index bf2149747..f0c6c27b4 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/Enums.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs @@ -3,7 +3,7 @@ using System; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { [Flags] public enum Modifiers diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/BlockStatement.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/BlockStatement.cs similarity index 83% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/General/BlockStatement.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/General/BlockStatement.cs index 2be9118cc..1a3492c86 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/BlockStatement.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/BlockStatement.cs @@ -3,7 +3,7 @@ using System; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public class BlockStatement : Statement { @@ -15,7 +15,7 @@ namespace ICSharpCode.NRefactory.VB.Dom } } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitBlockStatement(this, data); } @@ -37,11 +37,11 @@ namespace ICSharpCode.NRefactory.VB.Dom } } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return data; } - public override object AcceptChildren(IDomVisitor visitor, object data) + public override object AcceptChildren(IAstVisitor visitor, object data) { return data; } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/CompilationUnit.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/CompilationUnit.cs similarity index 86% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/General/CompilationUnit.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/General/CompilationUnit.cs index b40f061a2..41bc8e647 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/CompilationUnit.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/CompilationUnit.cs @@ -4,14 +4,14 @@ using System; using System.Collections; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public class CompilationUnit : AbstractNode { // Children in C#: UsingAliasDeclaration, UsingDeclaration, AttributeSection, NamespaceDeclaration // Children in VB: OptionStatements, ImportsStatement, AttributeSection, NamespaceDeclaration - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitCompilationUnit(this, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/Expression.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/Expression.cs similarity index 96% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/General/Expression.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/General/Expression.cs index 09f39f5b5..24824ac73 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/Expression.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/Expression.cs @@ -3,7 +3,7 @@ using System; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public abstract class Expression : AbstractNode, INullable { @@ -90,7 +90,7 @@ namespace ICSharpCode.NRefactory.VB.Dom } } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/LocalVariableDeclaration.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/LocalVariableDeclaration.cs similarity index 95% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/General/LocalVariableDeclaration.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/General/LocalVariableDeclaration.cs index 845d37743..bc5a9f3f2 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/LocalVariableDeclaration.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/LocalVariableDeclaration.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public class LocalVariableDeclaration : Statement { @@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.VB.Dom return null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitLocalVariableDeclaration(this, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/PrimitiveExpression.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/PrimitiveExpression.cs similarity index 92% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/General/PrimitiveExpression.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/General/PrimitiveExpression.cs index 6e053d388..b7676a663 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/PrimitiveExpression.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/PrimitiveExpression.cs @@ -4,7 +4,7 @@ using ICSharpCode.NRefactory.VB.PrettyPrinter; using System; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public class PrimitiveExpression : Expression { @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.VB.Dom this.StringValue = stringValue; } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitPrimitiveExpression(this, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/Statement.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/Statement.cs similarity index 91% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/General/Statement.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/General/Statement.cs index 1114a23ed..8859bbc2f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/General/Statement.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/General/Statement.cs @@ -3,7 +3,7 @@ using System; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public abstract class Statement : AbstractNode, INullable { @@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.VB.Dom get { return true; } } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return data; } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/Generated.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Generated.cs similarity index 93% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/Generated.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/Generated.cs index a2daebfc8..64315b83f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/Generated.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Generated.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace ICSharpCode.NRefactory.VB.Dom { +namespace ICSharpCode.NRefactory.VB.Ast { using System; using System.Collections.Generic; @@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { HandlerExpression = handlerExpression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitAddHandlerStatement(this, data); } @@ -71,7 +71,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitAddressOfExpression(this, data); } @@ -141,7 +141,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitArrayCreateExpression(this, data); } @@ -193,7 +193,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Right = right; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitAssignmentExpression(this, data); } @@ -249,7 +249,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { NamedArguments = namedArguments; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitAttribute(this, data); } @@ -300,7 +300,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { string attributeTarget; - List attributes; + List attributes; public string AttributeTarget { get { @@ -311,7 +311,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public List Attributes { + public List Attributes { get { return attributes; } @@ -325,7 +325,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { attributes = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitAttributeSection(this, data); } @@ -339,7 +339,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { public BaseReferenceExpression() { } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitBaseReferenceExpression(this, data); } @@ -396,7 +396,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Right = right; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitBinaryOperatorExpression(this, data); } @@ -469,7 +469,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitCaseLabel(this, data); } @@ -526,7 +526,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { CastType = castType; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitCastExpression(this, data); } @@ -605,7 +605,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { condition = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitCatchClause(this, data); } @@ -620,7 +620,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { public ClassReferenceExpression() { } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitClassReferenceExpression(this, data); } @@ -656,7 +656,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitCollectionInitializerExpression(this, data); } @@ -675,7 +675,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -739,7 +739,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitCollectionRangeVariable(this, data); } @@ -758,7 +758,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -817,7 +817,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { FalseExpression = falseExpression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitConditionalExpression(this, data); } @@ -870,7 +870,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { body = BlockStatement.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitConstructorDeclaration(this, data); } @@ -920,7 +920,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitConstructorInitializer(this, data); } @@ -939,7 +939,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -968,7 +968,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { ContinueType = continueType; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitContinueStatement(this, data); } @@ -1035,7 +1035,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Charset = charset; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitDeclareDeclaration(this, data); } @@ -1063,7 +1063,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { TypeReference = typeReference; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitDefaultValueExpression(this, data); } @@ -1128,7 +1128,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { templates = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitDelegateDeclaration(this, data); } @@ -1168,7 +1168,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitDirectionExpression(this, data); } @@ -1220,7 +1220,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { ConditionPosition = conditionPosition; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitDoLoopStatement(this, data); } @@ -1249,7 +1249,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { EmbeddedStatement = embeddedStatement; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitElseIfSection(this, data); } @@ -1263,7 +1263,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { public EndStatement() { } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitEndStatement(this, data); } @@ -1293,7 +1293,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Expressions = expressions; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitEraseStatement(this, data); } @@ -1320,7 +1320,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitErrorStatement(this, data); } @@ -1341,7 +1341,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitEventAddRegion(this, data); } @@ -1364,7 +1364,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -1510,7 +1510,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitEventDeclaration(this, data); } @@ -1533,7 +1533,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitEventRaiseRegion(this, data); } @@ -1556,7 +1556,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -1577,7 +1577,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitEventRemoveRegion(this, data); } @@ -1600,7 +1600,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -1626,7 +1626,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { ExitType = exitType; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitExitStatement(this, data); } @@ -1690,7 +1690,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitExpressionRangeVariable(this, data); } @@ -1709,7 +1709,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -1736,7 +1736,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitExpressionStatement(this, data); } @@ -1762,7 +1762,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { name = ""; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitExternAliasDirective(this, data); } @@ -1829,7 +1829,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { return null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitFieldDeclaration(this, data); } @@ -1903,7 +1903,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { NextExpression = nextExpression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitForeachStatement(this, data); } @@ -2007,7 +2007,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { loopVariableExpression = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitForNextStatement(this, data); } @@ -2034,7 +2034,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Label = label; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitGotoStatement(this, data); } @@ -2072,7 +2072,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { typeArguments = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitIdentifierExpression(this, data); } @@ -2163,7 +2163,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { if (falseStatement != null) falseStatement.Parent = this; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitIfElseStatement(this, data); } @@ -2203,7 +2203,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { MemberName = memberName; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitInterfaceImplementation(this, data); } @@ -2247,7 +2247,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Arguments = arguments; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitInvocationExpression(this, data); } @@ -2273,7 +2273,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { Label = label; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitLabelStatement(this, data); } @@ -2340,7 +2340,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { public Location ExtendedEndLocation { get; set; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitLambdaExpression(this, data); } @@ -2369,7 +2369,7 @@ public Location ExtendedEndLocation { get; set; } EmbeddedStatement = embeddedStatement; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitLockStatement(this, data); } @@ -2424,7 +2424,7 @@ public Location ExtendedEndLocation { get; set; } Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitMemberInitializerExpression(this, data); } @@ -2515,7 +2515,7 @@ public Location ExtendedEndLocation { get; set; } typeArguments = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitMemberReferenceExpression(this, data); } @@ -2577,7 +2577,7 @@ public Location ExtendedEndLocation { get; set; } templates = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitMethodDeclaration(this, data); } @@ -2623,7 +2623,7 @@ public Location ExtendedEndLocation { get; set; } Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitNamedArgumentExpression(this, data); } @@ -2649,7 +2649,7 @@ public Location ExtendedEndLocation { get; set; } Name = name; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitNamespaceDeclaration(this, data); } @@ -2707,7 +2707,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitObjectCreateExpression(this, data); } @@ -2722,7 +2722,7 @@ public Location ExtendedEndLocation { get; set; } EmbeddedStatement = embeddedStatement; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitOnErrorStatement(this, data); } @@ -2764,7 +2764,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitOperatorDeclaration(this, data); } @@ -2804,7 +2804,7 @@ public Location ExtendedEndLocation { get; set; } OptionValue = optionValue; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitOptionDeclaration(this, data); } @@ -2895,7 +2895,7 @@ public Location ExtendedEndLocation { get; set; } attributes = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitParameterDeclarationExpression(this, data); } @@ -2960,7 +2960,7 @@ public Location ExtendedEndLocation { get; set; } Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitParenthesizedExpression(this, data); } @@ -3083,7 +3083,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitPropertyDeclaration(this, data); } @@ -3106,7 +3106,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitPropertyGetRegion(this, data); } @@ -3129,7 +3129,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -3188,7 +3188,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitPropertySetRegion(this, data); } @@ -3211,7 +3211,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -3237,7 +3237,7 @@ public Location ExtendedEndLocation { get; set; } clauses = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpression(this, data); } @@ -3288,7 +3288,7 @@ public Location ExtendedEndLocation { get; set; } intoVariables = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionAggregateClause(this, data); } @@ -3325,7 +3325,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -3339,7 +3339,7 @@ public Location ExtendedEndLocation { get; set; } public QueryExpressionDistinctClause() { } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionDistinctClause(this, data); } @@ -3371,7 +3371,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionFromClause(this, data); } @@ -3390,7 +3390,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -3430,7 +3430,7 @@ public Location ExtendedEndLocation { get; set; } groupBy = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionGroupClause(this, data); } @@ -3469,7 +3469,7 @@ public Location ExtendedEndLocation { get; set; } intoVariables = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionGroupJoinVBClause(this, data); } @@ -3519,7 +3519,7 @@ public Location ExtendedEndLocation { get; set; } intoVariables = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionGroupVBClause(this, data); } @@ -3585,7 +3585,7 @@ public Location ExtendedEndLocation { get; set; } intoIdentifier = ""; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionJoinClause(this, data); } @@ -3626,7 +3626,7 @@ public Location ExtendedEndLocation { get; set; } rightSide = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionJoinConditionVB(this, data); } @@ -3684,7 +3684,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionJoinVBClause(this, data); } @@ -3703,7 +3703,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -3742,7 +3742,7 @@ public Location ExtendedEndLocation { get; set; } expression = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionLetClause(this, data); } @@ -3768,7 +3768,7 @@ public Location ExtendedEndLocation { get; set; } variables = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionLetVBClause(this, data); } @@ -3794,7 +3794,7 @@ public Location ExtendedEndLocation { get; set; } orderings = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionOrderClause(this, data); } @@ -3832,7 +3832,7 @@ public Location ExtendedEndLocation { get; set; } criteria = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionOrdering(this, data); } @@ -3870,7 +3870,7 @@ public Location ExtendedEndLocation { get; set; } expression = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionPartitionVBClause(this, data); } @@ -3897,7 +3897,7 @@ public Location ExtendedEndLocation { get; set; } projection = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionSelectClause(this, data); } @@ -3923,7 +3923,7 @@ public Location ExtendedEndLocation { get; set; } variables = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionSelectVBClause(this, data); } @@ -3950,7 +3950,7 @@ public Location ExtendedEndLocation { get; set; } condition = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitQueryExpressionWhereClause(this, data); } @@ -3988,7 +3988,7 @@ public Location ExtendedEndLocation { get; set; } Arguments = arguments; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitRaiseEventStatement(this, data); } @@ -4026,7 +4026,7 @@ public Location ExtendedEndLocation { get; set; } reDimClauses = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitReDimStatement(this, data); } @@ -4066,7 +4066,7 @@ public Location ExtendedEndLocation { get; set; } HandlerExpression = handlerExpression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitRemoveHandlerStatement(this, data); } @@ -4108,7 +4108,7 @@ public Location ExtendedEndLocation { get; set; } LabelName = labelName; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitResumeStatement(this, data); } @@ -4135,7 +4135,7 @@ public Location ExtendedEndLocation { get; set; } Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitReturnStatement(this, data); } @@ -4149,7 +4149,7 @@ public Location ExtendedEndLocation { get; set; } public StopStatement() { } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitStopStatement(this, data); } @@ -4179,7 +4179,7 @@ public Location ExtendedEndLocation { get; set; } SwitchLabels = switchLabels; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitSwitchSection(this, data); } @@ -4218,7 +4218,7 @@ public Location ExtendedEndLocation { get; set; } SwitchSections = switchSections; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitSwitchStatement(this, data); } @@ -4273,7 +4273,7 @@ public Location ExtendedEndLocation { get; set; } bases = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTemplateDefinition(this, data); } @@ -4288,7 +4288,7 @@ public Location ExtendedEndLocation { get; set; } public ThisReferenceExpression() { } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitThisReferenceExpression(this, data); } @@ -4315,7 +4315,7 @@ public Location ExtendedEndLocation { get; set; } Expression = expression; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitThrowStatement(this, data); } @@ -4367,7 +4367,7 @@ public Location ExtendedEndLocation { get; set; } FinallyBlock = finallyBlock; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTryCatchStatement(this, data); } @@ -4442,7 +4442,7 @@ public Location ExtendedEndLocation { get; set; } bodyStartLocation = Location.Empty; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTypeDeclaration(this, data); } @@ -4470,7 +4470,7 @@ public Location ExtendedEndLocation { get; set; } TypeReference = typeReference; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTypeOfExpression(this, data); } @@ -4510,7 +4510,7 @@ public Location ExtendedEndLocation { get; set; } TypeReference = typeReference; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTypeOfIsExpression(this, data); } @@ -4537,7 +4537,7 @@ public Location ExtendedEndLocation { get; set; } TypeReference = typeReference; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTypeReferenceExpression(this, data); } @@ -4581,7 +4581,7 @@ public Location ExtendedEndLocation { get; set; } Op = op; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitUnaryOperatorExpression(this, data); } @@ -4656,7 +4656,7 @@ public Location ExtendedEndLocation { get; set; } } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitUsing(this, data); } @@ -4688,7 +4688,7 @@ public UsingDeclaration(string @namespace) : this(@namespace, TypeReference.Null public UsingDeclaration(string @namespace, TypeReference alias) { usings = new List(1); usings.Add(new Using(@namespace, alias)); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitUsingDeclaration(this, data); } @@ -4716,7 +4716,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L EmbeddedStatement = embeddedStatement; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitUsingStatement(this, data); } @@ -4795,7 +4795,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L fixedArrayInitialization = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitVariableDeclaration(this, data); } @@ -4836,7 +4836,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L body = BlockStatement.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitWithStatement(this, data); } @@ -4904,7 +4904,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitXmlAttributeExpression(this, data); } @@ -4943,7 +4943,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L Type = type; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitXmlContentExpression(this, data); } @@ -4969,7 +4969,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L expressions = new List(); } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitXmlDocumentExpression(this, data); } @@ -5045,7 +5045,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L } } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitXmlElementExpression(this, data); } @@ -5072,7 +5072,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L inlineVBExpression = Expression.Null; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitXmlEmbeddedExpression(this, data); } @@ -5141,7 +5141,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L IsXmlIdentifier = isXmlIdentifier; } - public override object AcceptVisitor(IDomVisitor visitor, object data) { + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitXmlMemberAccessExpression(this, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/INode.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/INode.cs similarity index 86% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/INode.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/INode.cs index 2bfa18115..f64420108 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/INode.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/INode.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public interface INode { @@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.VB.Dom /// The visitor to accept /// Additional data for the visitor /// The paremeter - object AcceptChildren(IDomVisitor visitor, object data); + object AcceptChildren(IAstVisitor visitor, object data); /// /// Accept the visitor @@ -46,6 +46,6 @@ namespace ICSharpCode.NRefactory.VB.Dom /// The visitor to accept /// Additional data for the visitor /// The value the visitor returns after the visit - object AcceptVisitor(IDomVisitor visitor, object data); + object AcceptVisitor(IAstVisitor visitor, object data); } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/INullable.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/INullable.cs similarity index 86% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/INullable.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/INullable.cs index c12c54b69..14a65a444 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/INullable.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/INullable.cs @@ -1,7 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public interface INullable { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Dom/TypeReference.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/TypeReference.cs similarity index 98% rename from NRefactory/ICSharpCode.NRefactory.VB/Dom/TypeReference.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Ast/TypeReference.cs index a3c82d0ee..a0ab71390 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Dom/TypeReference.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/TypeReference.cs @@ -8,7 +8,7 @@ using System.Globalization; using System.Runtime.InteropServices; using System.Text; -namespace ICSharpCode.NRefactory.VB.Dom +namespace ICSharpCode.NRefactory.VB.Ast { public class TypeReference : AbstractNode, INullable, ICloneable { @@ -290,7 +290,7 @@ namespace ICSharpCode.NRefactory.VB.Dom protected TypeReference() {} - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitTypeReference(this, data); } @@ -360,7 +360,7 @@ namespace ICSharpCode.NRefactory.VB.Dom { return this; } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; } @@ -399,7 +399,7 @@ namespace ICSharpCode.NRefactory.VB.Dom this.baseType = outerClass; } - public override object AcceptVisitor(IDomVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitInnerClassTypeReference(this, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/DomBuilder/ExpressionBuilder.cs b/NRefactory/ICSharpCode.NRefactory.VB/AstBuilder/ExpressionBuilder.cs similarity index 97% rename from NRefactory/ICSharpCode.NRefactory.VB/DomBuilder/ExpressionBuilder.cs rename to NRefactory/ICSharpCode.NRefactory.VB/AstBuilder/ExpressionBuilder.cs index 5b832efb2..c2992e19c 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/DomBuilder/ExpressionBuilder.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/AstBuilder/ExpressionBuilder.cs @@ -3,9 +3,9 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.DomBuilder +namespace ICSharpCode.NRefactory.VB.AstBuilder { /// /// Extension methods for NRefactory.Dom.Expression. diff --git a/NRefactory/ICSharpCode.NRefactory.VB/DomBuilder/StatementBuilder.cs b/NRefactory/ICSharpCode.NRefactory.VB/AstBuilder/StatementBuilder.cs similarity index 95% rename from NRefactory/ICSharpCode.NRefactory.VB/DomBuilder/StatementBuilder.cs rename to NRefactory/ICSharpCode.NRefactory.VB/AstBuilder/StatementBuilder.cs index cf5225356..807dfe8ab 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/DomBuilder/StatementBuilder.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/AstBuilder/StatementBuilder.cs @@ -3,9 +3,9 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; -namespace ICSharpCode.NRefactory.VB.DomBuilder +namespace ICSharpCode.NRefactory.VB.AstBuilder { /// /// Extension methods for NRefactory.Dom.Expression. diff --git a/NRefactory/ICSharpCode.NRefactory.VB/IDomVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs similarity index 98% rename from NRefactory/ICSharpCode.NRefactory.VB/IDomVisitor.cs rename to NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs index f934f2d63..5e81a2be0 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/IDomVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs @@ -10,10 +10,10 @@ namespace ICSharpCode.NRefactory.VB { using System; - using ICSharpCode.NRefactory.VB.Dom; + using ICSharpCode.NRefactory.VB.Ast; - public interface IDomVisitor { + public interface IAstVisitor { object VisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data); @@ -23,7 +23,7 @@ namespace ICSharpCode.NRefactory.VB { object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data); - object VisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data); + object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data); object VisitAttributeSection(AttributeSection attributeSection, object data); diff --git a/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj index 477002241..b8cc68148 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ b/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj @@ -41,22 +41,22 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + @@ -99,22 +99,22 @@ - - + + - - + + - - - + + + @@ -126,6 +126,7 @@ CocoParserGenerator ICSharpCode.NRefactory.VB.Parser + Parser.cs @@ -137,6 +138,7 @@ ICSharpCode.NRefactory.VB.Parser CocoParserGenerator + Parser.cs diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg b/NRefactory/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg index 21548a063..b0961d47f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg +++ b/NRefactory/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg @@ -367,13 +367,13 @@ TypeOrMemberModifier = InterfaceEvent = "Event" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | "(" [ ParameterList ] ")" ] + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | ParameterListInParenthesis ] StatementTerminator . InterfaceProperty = "Property" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "(" [ ParameterList ] ")" ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ] + [ ParameterListInParenthesis ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ] StatementTerminator . @@ -435,7 +435,7 @@ ExternalMemberDeclaration = (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) "Lib" LiteralString [ "Alias" LiteralString ] - [ "(" [ ParameterList ] ")" ] + [ ParameterListInParenthesis ] [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminator . @@ -443,10 +443,10 @@ ExternalMemberDeclaration = EventMemberDeclaration = "Event" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ "(" [ ParameterList ] ")" ] ) + ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ ParameterListInParenthesis ] ) [ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ] - /* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */ + /* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammar we just leave that out */ StatementTerminator . @@ -463,8 +463,8 @@ CustomEventMemberDeclaration = PropertyDeclaration = "Property" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "(" [ ParameterList ] ")" ] - [ "As" { AttributeBlock } ( NewExpression | (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ) ] + [ ParameterListInParenthesis ] + [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } ( NewExpression | TypeName ) (. PopContext(); .) ] [ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ] [ "=" Expression ] StatementTerminator @@ -474,10 +474,10 @@ PropertyDeclaration = // so we need to simulate it (.OnEachPossiblePath: SetIdentifierExpected(la); .) } [ (. PushContext(Context.Member, la, t); .) - ( "Get" | "Set" ) [ "(" [ ParameterList ] ")" ] + ( "Get" | "Set" ) [ ParameterListInParenthesis ] StatementTerminatorAndBlock "End" ( "Get" | "Set" ) StatementTerminator - [ { AttributeBlock } { AccessModifier } ( "Get" | "Set" ) [ "(" [ ParameterList ] ")" ] + [ { AttributeBlock } { AccessModifier } ( "Get" | "Set" ) [ ParameterListInParenthesis ] StatementTerminatorAndBlock "End" ( "Get" | "Set" ) StatementTerminator ] @@ -686,15 +686,19 @@ LambdaExpression = . SubLambdaExpression = - "Sub" "(" [ ParameterList ] ")" + "Sub" ParameterListInParenthesis ( GREEDY Statement | StatementTerminatorAndBlock "End" "Sub" ) . FunctionLambdaExpression = - "Function" "(" [ ParameterList ] ")" + "Function" ParameterListInParenthesis ( GREEDY Expression | [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminatorAndBlock "End" "Function" ) . +ParameterListInParenthesis = + "(" (. PushContext(Context.Default, la, t); .) [ ParameterList ] (. PopContext(); .) ")" +. + QueryExpression (. PushContext(Context.Query, la, t); .) = @@ -848,7 +852,7 @@ PrimitiveTypeName = TypeName = ( "Global" | Identifier | PrimitiveTypeName | "?" /* used for ? = completion */ ) { TypeSuffix } { "." IdentifierOrKeyword { TypeSuffix } } . -TypeSuffix = "(" ( "Of" [ TypeName ] { "," [ TypeName ] } | [ ArgumentList ] ) ")" . +TypeSuffix = "(" (. PushContext(Context.Expression, la, t); .) ( "Of" [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] { "," [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] } | [ ArgumentList ] ) (. PopContext(); .) ")" . IdentifierOrKeyword = ident | "AddHandler" @@ -1076,12 +1080,14 @@ VariableDeclarationStatement = ( "Dim" | "Static" | "Const" ) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } + [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] + [ "=" Expression ] { "," (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } + [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] + [ "=" Expression ] } - [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] - [ "=" Expression ] . WithOrLockStatement = @@ -1093,7 +1099,7 @@ AddOrRemoveHandlerStatement = . RaiseEventStatement = - "RaiseEvent" IdentifierOrKeyword [ "(" [ ArgumentList ] ")" ] + "RaiseEvent" IdentifierOrKeyword [ "(" (. PushContext(Context.Expression, la, t); .) [ ArgumentList ] (. PopContext(); .) ")" ] . IfStatement = diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Parser.cs b/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Parser.cs index f1cd830b9..400c9a0f3 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Parser.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Parser.cs @@ -9,8 +9,8 @@ namespace ICSharpCode.NRefactory.VB.Parser { partial class ExpressionFinder { - const int startOfExpression = 56; - const int endOfStatementTerminatorAndBlock = 267; + const int startOfExpression = 55; + const int endOfStatementTerminatorAndBlock = 263; static BitArray GetExpectedSet(int state) { switch (state) { @@ -25,9 +25,9 @@ partial class ExpressionFinder { case 5: return set[3]; case 6: - case 89: - case 268: - case 525: + case 88: + case 264: + case 528: { BitArray a = new BitArray(239); return a; @@ -45,23 +45,23 @@ partial class ExpressionFinder { return a; } case 11: - case 194: - case 200: - case 206: - case 245: - case 249: - case 299: - case 400: - case 410: - case 469: - case 512: - case 522: + case 193: + case 199: + case 205: + case 244: + case 248: + case 295: + case 399: + case 405: + case 472: + case 518: + case 525: case 533: case 563: case 599: - case 656: - case 673: - case 749: + case 648: + case 662: + case 735: return set[6]; case 12: case 13: @@ -81,22 +81,22 @@ partial class ExpressionFinder { case 23: case 24: case 36: + case 256: + case 259: case 260: - case 263: - case 264: + case 296: case 300: - case 304: - case 326: - case 341: - case 352: - case 355: - case 361: - case 366: - case 376: - case 377: - case 397: - case 421: - case 518: + case 322: + case 337: + case 348: + case 351: + case 357: + case 362: + case 372: + case 373: + case 396: + case 423: + case 524: case 530: case 536: case 540: @@ -111,12 +111,12 @@ partial class ExpressionFinder { case 614: case 621: case 624: - case 651: - case 654: - case 681: - case 692: - case 728: - case 748: + case 643: + case 646: + case 670: + case 678: + case 714: + case 734: { BitArray a = new BitArray(239); a.Set(1, true); @@ -130,19 +130,19 @@ partial class ExpressionFinder { case 18: return set[8]; case 19: - case 261: - case 275: - case 302: - case 356: - case 398: - case 449: + case 257: + case 271: + case 298: + case 352: + case 397: + case 452: case 573: case 593: case 612: case 616: case 622: - case 652: - case 693: + case 644: + case 679: { BitArray a = new BitArray(239); a.Set(113, true); @@ -162,7 +162,7 @@ partial class ExpressionFinder { case 27: return set[10]; case 28: - case 732: + case 718: return set[11]; case 29: return set[12]; @@ -170,67 +170,67 @@ partial class ExpressionFinder { return set[13]; case 31: case 32: - case 153: + case 152: + case 217: case 218: - case 219: - case 269: - case 280: - case 281: - case 436: - case 437: - case 457: - case 458: - case 459: + case 265: + case 276: + case 277: + case 442: + case 443: case 460: + case 461: + case 462: + case 463: case 551: case 552: case 585: case 586: - case 687: - case 688: - case 741: - case 742: + case 673: + case 674: + case 727: + case 728: return set[14]; case 33: case 34: - case 513: - case 514: - case 523: - case 524: + case 519: + case 520: + case 526: + case 527: case 553: case 554: - case 678: + case 667: return set[15]; case 35: case 37: - case 158: - case 169: - case 172: - case 188: - case 204: - case 222: - case 311: - case 336: - case 420: - case 433: - case 472: + case 157: + case 168: + case 171: + case 187: + case 203: + case 221: + case 307: + case 332: + case 422: + case 439: + case 475: case 529: case 547: case 555: - case 633: - case 636: - case 660: - case 663: - case 668: - case 680: - case 696: - case 698: - case 721: - case 724: - case 727: - case 733: - case 736: - case 754: + case 627: + case 630: + case 652: + case 655: + case 657: + case 669: + case 682: + case 684: + case 707: + case 710: + case 713: + case 719: + case 722: + case 740: return set[16]; case 38: case 41: @@ -238,23 +238,24 @@ partial class ExpressionFinder { case 39: return set[18]; case 40: - case 98: - case 102: - case 164: - case 392: - case 476: + case 97: + case 101: + case 163: + case 388: + case 479: return set[19]; case 42: - case 178: - case 185: - case 190: - case 254: - case 443: - case 468: + case 177: + case 184: + case 189: + case 253: + case 424: + case 449: case 471: + case 474: case 587: case 588: - case 648: + case 640: { BitArray a = new BitArray(239); a.Set(37, true); @@ -262,287 +263,283 @@ partial class ExpressionFinder { } case 43: case 44: + case 165: case 166: - case 167: return set[20]; case 45: - case 168: - case 189: - case 257: - case 446: - case 470: + case 46: + case 167: + case 188: + case 392: + case 427: case 473: - case 490: - case 521: - case 528: + case 476: + case 496: case 559: case 590: - case 627: - case 630: case 642: - case 650: - case 667: - case 684: - case 702: - case 731: - case 740: + case 688: + case 717: + case 726: { BitArray a = new BitArray(239); a.Set(38, true); return a; } - case 46: case 47: - case 51: - case 52: - case 53: - case 55: - case 414: - case 415: - case 417: - case 418: - case 484: - case 485: - case 715: - case 716: - return set[21]; case 48: + return set[21]; case 49: - return set[22]; - case 50: - case 180: - case 187: - case 395: + case 179: + case 186: + case 394: { BitArray a = new BitArray(239); a.Set(22, true); return a; } + case 50: + case 51: + case 52: case 54: - case 170: - case 171: - case 173: - case 182: - case 416: + case 390: + case 391: + case 412: + case 413: case 419: - case 423: - case 431: - case 480: - case 483: + case 420: case 487: - case 497: - case 504: - case 511: - case 717: + case 488: + case 701: + case 702: + return set[22]; + case 53: + case 169: + case 170: + case 172: + case 181: + case 414: + case 421: + case 429: + case 437: + case 483: + case 486: + case 490: + case 492: + case 493: + case 503: + case 510: + case 517: + case 703: { BitArray a = new BitArray(239); a.Set(22, true); a.Set(38, true); return a; } + case 55: case 56: - case 57: - case 71: + case 70: + case 75: case 76: case 77: - case 78: - case 84: - case 100: - case 156: - case 179: - case 181: - case 183: - case 186: - case 196: - case 198: - case 216: - case 240: - case 278: - case 288: - case 290: - case 291: - case 308: - case 325: - case 330: - case 339: - case 345: + case 83: + case 99: + case 155: + case 178: + case 180: + case 182: + case 185: + case 195: + case 197: + case 215: + case 239: + case 274: + case 284: + case 286: + case 287: + case 304: + case 321: + case 326: + case 335: + case 341: + case 343: case 347: - case 351: - case 354: - case 360: - case 371: - case 373: - case 374: - case 380: - case 394: - case 396: - case 432: - case 462: - case 478: - case 479: + case 350: + case 356: + case 367: + case 369: + case 370: + case 376: + case 393: + case 395: + case 415: + case 438: + case 465: case 481: case 482: + case 484: + case 485: case 546: - case 632: + case 626: return set[23]; - case 58: - case 79: - case 159: + case 57: + case 78: + case 158: return set[24]; - case 59: + case 58: return set[25]; - case 60: + case 59: { BitArray a = new BitArray(239); a.Set(216, true); return a; } - case 61: + case 60: { BitArray a = new BitArray(239); a.Set(145, true); return a; } - case 62: - case 157: + case 61: + case 156: { BitArray a = new BitArray(239); a.Set(144, true); return a; } - case 63: + case 62: { BitArray a = new BitArray(239); a.Set(236, true); return a; } - case 64: + case 63: { BitArray a = new BitArray(239); a.Set(177, true); return a; } - case 65: + case 64: { BitArray a = new BitArray(239); a.Set(175, true); return a; } - case 66: + case 65: { BitArray a = new BitArray(239); a.Set(61, true); return a; } - case 67: + case 66: { BitArray a = new BitArray(239); a.Set(60, true); return a; } - case 68: + case 67: { BitArray a = new BitArray(239); a.Set(150, true); return a; } - case 69: + case 68: { BitArray a = new BitArray(239); a.Set(42, true); return a; } - case 70: + case 69: { BitArray a = new BitArray(239); a.Set(43, true); return a; } - case 72: - case 435: + case 71: + case 441: { BitArray a = new BitArray(239); a.Set(40, true); return a; } - case 73: + case 72: { BitArray a = new BitArray(239); a.Set(41, true); return a; } - case 74: - case 99: + case 73: + case 98: + case 222: case 223: - case 224: - case 286: - case 287: - case 338: - case 406: - case 750: + case 282: + case 283: + case 334: + case 736: { BitArray a = new BitArray(239); a.Set(20, true); return a; } - case 75: + case 74: { BitArray a = new BitArray(239); a.Set(154, true); return a; } - case 80: - case 92: - case 94: - case 149: + case 79: + case 91: + case 93: + case 148: { BitArray a = new BitArray(239); a.Set(35, true); return a; } + case 80: case 81: - case 82: return set[26]; - case 83: + case 82: { BitArray a = new BitArray(239); a.Set(36, true); return a; } - case 85: - case 101: - case 507: + case 84: + case 100: + case 513: { BitArray a = new BitArray(239); a.Set(22, true); a.Set(36, true); return a; } - case 86: - case 122: + case 85: + case 121: { BitArray a = new BitArray(239); a.Set(162, true); return a; } + case 86: case 87: - case 88: return set[27]; - case 90: - case 93: + case 89: + case 92: + case 149: case 150: - case 151: - case 154: + case 153: return set[28]; - case 91: - case 103: - case 148: + case 90: + case 102: + case 147: { BitArray a = new BitArray(239); a.Set(233, true); return a; } - case 95: + case 94: { BitArray a = new BitArray(239); a.Set(26, true); @@ -550,103 +547,103 @@ partial class ExpressionFinder { a.Set(147, true); return a; } - case 96: + case 95: { BitArray a = new BitArray(239); a.Set(26, true); a.Set(147, true); return a; } - case 97: - case 697: + case 96: + case 683: { BitArray a = new BitArray(239); a.Set(26, true); return a; } - case 104: - case 357: + case 103: + case 353: { BitArray a = new BitArray(239); a.Set(231, true); return a; } - case 105: + case 104: { BitArray a = new BitArray(239); a.Set(230, true); return a; } - case 106: + case 105: { BitArray a = new BitArray(239); a.Set(224, true); return a; } - case 107: + case 106: { BitArray a = new BitArray(239); a.Set(223, true); return a; } - case 108: - case 303: + case 107: + case 299: { BitArray a = new BitArray(239); a.Set(218, true); return a; } - case 109: + case 108: { BitArray a = new BitArray(239); a.Set(213, true); return a; } - case 110: + case 109: { BitArray a = new BitArray(239); a.Set(212, true); return a; } - case 111: + case 110: { BitArray a = new BitArray(239); a.Set(211, true); return a; } - case 112: - case 450: + case 111: + case 453: { BitArray a = new BitArray(239); a.Set(210, true); return a; } - case 113: + case 112: { BitArray a = new BitArray(239); a.Set(209, true); return a; } - case 114: + case 113: { BitArray a = new BitArray(239); a.Set(206, true); return a; } - case 115: + case 114: { BitArray a = new BitArray(239); a.Set(203, true); return a; } - case 116: - case 363: + case 115: + case 359: { BitArray a = new BitArray(239); a.Set(197, true); return a; } - case 117: + case 116: case 598: case 617: { @@ -654,300 +651,300 @@ partial class ExpressionFinder { a.Set(186, true); return a; } - case 118: + case 117: { BitArray a = new BitArray(239); a.Set(184, true); return a; } - case 119: + case 118: { BitArray a = new BitArray(239); a.Set(176, true); return a; } - case 120: + case 119: { BitArray a = new BitArray(239); a.Set(170, true); return a; - } - case 121: - case 320: - case 327: - case 342: + } + case 120: + case 316: + case 323: + case 338: { BitArray a = new BitArray(239); a.Set(163, true); return a; } - case 123: + case 122: { BitArray a = new BitArray(239); a.Set(147, true); return a; } - case 124: - case 227: - case 232: - case 234: + case 123: + case 226: + case 231: + case 233: { BitArray a = new BitArray(239); a.Set(146, true); return a; } - case 125: - case 229: - case 233: + case 124: + case 228: + case 232: { BitArray a = new BitArray(239); a.Set(143, true); return a; } - case 126: + case 125: { BitArray a = new BitArray(239); a.Set(139, true); return a; } - case 127: + case 126: { BitArray a = new BitArray(239); a.Set(133, true); return a; } - case 128: - case 262: + case 127: + case 258: { BitArray a = new BitArray(239); a.Set(127, true); return a; } - case 129: - case 152: - case 252: + case 128: + case 151: + case 251: { BitArray a = new BitArray(239); a.Set(126, true); return a; } - case 130: + case 129: { BitArray a = new BitArray(239); a.Set(124, true); return a; } - case 131: + case 130: { BitArray a = new BitArray(239); a.Set(121, true); return a; } - case 132: - case 197: + case 131: + case 196: { BitArray a = new BitArray(239); a.Set(116, true); return a; } - case 133: + case 132: { BitArray a = new BitArray(239); a.Set(108, true); return a; } - case 134: + case 133: { BitArray a = new BitArray(239); a.Set(107, true); return a; } - case 135: + case 134: { BitArray a = new BitArray(239); a.Set(104, true); return a; } - case 136: - case 643: + case 135: + case 635: { BitArray a = new BitArray(239); a.Set(98, true); return a; } - case 137: + case 136: { BitArray a = new BitArray(239); a.Set(87, true); return a; } - case 138: + case 137: { BitArray a = new BitArray(239); a.Set(84, true); return a; } - case 139: - case 209: - case 239: + case 138: + case 208: + case 238: { BitArray a = new BitArray(239); a.Set(70, true); return a; } - case 140: + case 139: { BitArray a = new BitArray(239); a.Set(67, true); return a; } - case 141: + case 140: { BitArray a = new BitArray(239); a.Set(66, true); return a; } - case 142: + case 141: { BitArray a = new BitArray(239); a.Set(65, true); return a; } - case 143: + case 142: { BitArray a = new BitArray(239); a.Set(64, true); return a; } - case 144: + case 143: { BitArray a = new BitArray(239); a.Set(62, true); return a; } - case 145: - case 251: + case 144: + case 250: { BitArray a = new BitArray(239); a.Set(58, true); return a; } - case 146: + case 145: { BitArray a = new BitArray(239); a.Set(2, true); return a; } - case 147: + case 146: return set[29]; - case 155: + case 154: return set[30]; - case 160: + case 159: return set[31]; - case 161: + case 160: return set[32]; + case 161: case 162: - case 163: - case 474: - case 475: + case 477: + case 478: return set[33]; - case 165: + case 164: return set[34]; + case 173: case 174: - case 175: - case 323: - case 332: + case 319: + case 328: return set[35]; - case 176: - case 452: + case 175: + case 455: return set[36]; - case 177: - case 379: + case 176: + case 375: { BitArray a = new BitArray(239); a.Set(135, true); return a; } - case 184: + case 183: return set[37]; - case 191: + case 190: { BitArray a = new BitArray(239); a.Set(58, true); a.Set(126, true); return a; } + case 191: case 192: - case 193: return set[38]; - case 195: + case 194: { BitArray a = new BitArray(239); a.Set(171, true); return a; } - case 199: - case 213: - case 231: - case 236: - case 242: - case 244: - case 248: - case 250: + case 198: + case 212: + case 230: + case 235: + case 241: + case 243: + case 247: + case 249: return set[39]; + case 200: case 201: - case 202: { BitArray a = new BitArray(239); a.Set(63, true); a.Set(138, true); return a; } - case 203: - case 205: - case 324: + case 202: + case 204: + case 320: { BitArray a = new BitArray(239); a.Set(138, true); return a; } + case 206: case 207: - case 208: - case 210: - case 212: + case 209: + case 211: + case 213: case 214: - case 215: - case 225: - case 230: - case 235: - case 243: - case 247: + case 224: + case 229: + case 234: + case 242: + case 246: + case 269: case 273: - case 277: return set[40]; - case 211: + case 210: { BitArray a = new BitArray(239); a.Set(22, true); a.Set(143, true); return a; } - case 217: + case 216: return set[41]; - case 220: - case 282: + case 219: + case 278: return set[42]; - case 221: - case 283: + case 220: + case 279: return set[43]; - case 226: + case 225: { BitArray a = new BitArray(239); a.Set(22, true); a.Set(70, true); return a; } - case 228: + case 227: { BitArray a = new BitArray(239); a.Set(133, true); @@ -955,75 +952,56 @@ partial class ExpressionFinder { a.Set(146, true); return a; } + case 236: case 237: - case 238: return set[44]; - case 241: + case 240: { BitArray a = new BitArray(239); a.Set(64, true); a.Set(104, true); return a; } - case 246: + case 245: return set[45]; - case 253: + case 252: case 550: + case 661: case 672: - case 686: - case 694: + case 680: { BitArray a = new BitArray(239); a.Set(127, true); a.Set(210, true); return a; } + case 254: case 255: - case 256: - case 444: - case 445: - case 519: - case 520: - case 526: - case 527: - case 625: - case 626: - case 628: - case 629: - case 640: - case 641: - case 665: - case 666: - case 682: - case 683: return set[46]; - case 258: - case 259: + case 261: + case 262: return set[47]; - case 265: - case 266: + case 263: return set[48]; - case 267: + case 266: return set[49]; - case 270: + case 267: + case 268: + case 381: return set[50]; - case 271: - case 272: - case 385: - return set[51]; - case 274: - case 279: - case 369: - case 661: - case 662: - case 664: - case 705: - case 722: + case 270: + case 275: + case 365: + case 653: + case 654: + case 656: + case 691: + case 708: + case 709: + case 711: + case 720: + case 721: case 723: - case 725: - case 734: - case 735: - case 737: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1031,31 +1009,32 @@ partial class ExpressionFinder { a.Set(22, true); return a; } - case 276: + case 272: { BitArray a = new BitArray(239); a.Set(226, true); return a; } - case 284: + case 280: + case 281: + return set[51]; case 285: + case 327: + case 342: + case 404: return set[52]; + case 288: case 289: - case 331: - case 346: + case 309: + case 310: + case 324: + case 325: + case 339: + case 340: return set[53]; - case 292: - case 293: - case 313: - case 314: - case 328: - case 329: - case 343: - case 344: - return set[54]; - case 294: - case 386: - case 389: + case 290: + case 382: + case 385: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1063,7 +1042,7 @@ partial class ExpressionFinder { a.Set(111, true); return a; } - case 295: + case 291: { BitArray a = new BitArray(239); a.Set(108, true); @@ -1071,18 +1050,18 @@ partial class ExpressionFinder { a.Set(231, true); return a; } - case 296: + case 292: + return set[54]; + case 293: + case 312: return set[55]; - case 297: - case 316: - return set[56]; - case 298: + case 294: { BitArray a = new BitArray(239); a.Set(5, true); return a; } - case 301: + case 297: { BitArray a = new BitArray(239); a.Set(75, true); @@ -1090,11 +1069,11 @@ partial class ExpressionFinder { a.Set(123, true); return a; } - case 305: - case 306: - return set[57]; - case 307: - case 312: + case 301: + case 302: + return set[56]; + case 303: + case 308: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1102,36 +1081,36 @@ partial class ExpressionFinder { a.Set(229, true); return a; } - case 309: - case 310: + case 305: + case 306: + return set[57]; + case 311: return set[58]; - case 315: - return set[59]; - case 317: + case 313: { BitArray a = new BitArray(239); a.Set(118, true); return a; } + case 314: + case 315: + return set[59]; + case 317: case 318: - case 319: return set[60]; - case 321: - case 322: + case 329: + case 330: return set[61]; - case 333: - case 334: + case 331: return set[62]; - case 335: - return set[63]; - case 337: + case 333: { BitArray a = new BitArray(239); a.Set(20, true); a.Set(138, true); return a; } - case 340: + case 336: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1139,38 +1118,38 @@ partial class ExpressionFinder { a.Set(205, true); return a; } - case 348: - return set[64]; + case 344: + return set[63]; + case 345: case 349: - case 353: { BitArray a = new BitArray(239); a.Set(152, true); return a; } - case 350: + case 346: + return set[64]; + case 354: + case 355: return set[65]; case 358: - case 359: - return set[66]; - case 362: { BitArray a = new BitArray(239); a.Set(74, true); a.Set(113, true); return a; } + case 360: + case 361: + return set[66]; + case 363: case 364: - case 365: return set[67]; - case 367: + case 366: case 368: return set[68]; - case 370: - case 372: - return set[69]; - case 375: - case 381: + case 371: + case 377: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1178,7 +1157,7 @@ partial class ExpressionFinder { a.Set(214, true); return a; } - case 378: + case 374: { BitArray a = new BitArray(239); a.Set(111, true); @@ -1186,7 +1165,7 @@ partial class ExpressionFinder { a.Set(113, true); return a; } - case 382: + case 378: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1194,57 +1173,61 @@ partial class ExpressionFinder { a.Set(135, true); return a; } + case 379: + case 380: + case 450: + case 451: + return set[69]; case 383: case 384: - case 447: - case 448: - return set[70]; + case 386: case 387: - case 388: - case 390: - case 391: + return set[70]; + case 389: return set[71]; - case 393: - return set[72]; - case 399: + case 398: { BitArray a = new BitArray(239); a.Set(211, true); a.Set(233, true); return a; } + case 400: case 401: + case 406: + case 407: + return set[72]; case 402: - case 411: - case 412: + case 408: return set[73]; case 403: - case 413: + case 411: + case 418: return set[74]; - case 404: - return set[75]; - case 405: case 409: - return set[76]; - case 407: - case 408: - case 712: - case 713: - return set[77]; - case 422: - case 424: + case 410: + case 416: + case 417: + case 698: + case 699: + return set[75]; case 425: - case 589: - case 649: - return set[78]; case 426: - case 427: - return set[79]; + return set[76]; case 428: - case 429: - return set[80]; case 430: + case 431: + case 589: + case 641: + return set[77]; + case 432: + case 433: + return set[78]; case 434: + case 435: + return set[79]; + case 436: + case 440: { BitArray a = new BitArray(239); a.Set(20, true); @@ -1252,78 +1235,79 @@ partial class ExpressionFinder { a.Set(38, true); return a; } - case 438: - case 442: + case 444: + case 448: + return set[80]; + case 445: + case 446: return set[81]; - case 439: - case 440: - return set[82]; - case 441: + case 447: { BitArray a = new BitArray(239); a.Set(21, true); return a; } - case 451: - return set[83]; - case 453: - case 466: - return set[84]; case 454: - case 467: - return set[85]; - case 455: + return set[82]; case 456: + case 469: + return set[83]; + case 457: + case 470: + return set[84]; + case 458: + case 459: { BitArray a = new BitArray(239); a.Set(10, true); return a; } - case 461: + case 464: { BitArray a = new BitArray(239); a.Set(12, true); return a; } - case 463: + case 466: { BitArray a = new BitArray(239); a.Set(13, true); return a; } - case 464: + case 467: + return set[85]; + case 468: return set[86]; - case 465: + case 480: return set[87]; - case 477: - return set[88]; - case 486: - return set[89]; - case 488: case 489: + case 491: + return set[88]; + case 494: + case 495: case 557: case 558: - case 700: - case 701: - return set[90]; - case 491: - case 492: - case 493: + case 686: + case 687: + return set[89]; + case 497: case 498: case 499: + case 504: + case 505: case 560: - case 703: - case 730: - case 739: - return set[91]; - case 494: + case 689: + case 716: + case 725: + return set[90]; case 500: - case 509: - return set[92]; - case 495: - case 496: + case 506: + case 515: + return set[91]; case 501: case 502: + case 507: + case 508: { BitArray a = new BitArray(239); a.Set(22, true); @@ -1331,18 +1315,18 @@ partial class ExpressionFinder { a.Set(63, true); return a; } - case 503: - case 505: - case 510: + case 509: + case 511: + case 516: + return set[92]; + case 512: + case 514: return set[93]; - case 506: - case 508: - return set[94]; - case 515: + case 521: case 534: case 535: case 591: - case 679: + case 668: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1350,11 +1334,11 @@ partial class ExpressionFinder { a.Set(63, true); return a; } - case 516: - case 517: + case 522: + case 523: case 595: case 596: - return set[95]; + return set[94]; case 531: case 532: case 539: @@ -1365,10 +1349,10 @@ partial class ExpressionFinder { } case 537: case 538: - return set[96]; + return set[95]; case 542: case 543: - return set[97]; + return set[96]; case 544: case 545: case 604: @@ -1397,25 +1381,25 @@ partial class ExpressionFinder { } case 567: case 568: - return set[98]; + return set[97]; case 569: case 570: - return set[99]; + return set[98]; case 571: case 572: case 583: - return set[100]; + return set[99]; case 577: case 578: - return set[101]; + return set[100]; case 579: case 580: - case 719: - return set[102]; + case 705: + return set[101]; case 581: - return set[103]; + return set[102]; case 582: - return set[104]; + return set[103]; case 584: case 594: { @@ -1425,17 +1409,17 @@ partial class ExpressionFinder { } case 600: case 601: - return set[105]; + return set[104]; case 602: - return set[106]; + return set[105]; case 603: - case 639: - return set[107]; + case 634: + return set[106]; case 606: case 607: case 608: - case 631: - return set[108]; + case 625: + return set[107]; case 609: case 613: case 623: @@ -1446,32 +1430,33 @@ partial class ExpressionFinder { return a; } case 615: - return set[109]; + return set[108]; case 618: - return set[110]; + return set[109]; case 619: + return set[110]; + case 628: + case 629: + case 631: + case 697: + case 700: return set[111]; - case 634: - case 635: - case 637: - case 711: - case 714: + case 632: + case 633: return set[112]; + case 636: case 638: - return set[113]; - case 644: - case 646: - case 655: + case 647: { BitArray a = new BitArray(239); a.Set(119, true); return a; } - case 645: + case 637: + return set[113]; + case 639: return set[114]; - case 647: - return set[115]; - case 653: + case 645: { BitArray a = new BitArray(239); a.Set(56, true); @@ -1479,11 +1464,11 @@ partial class ExpressionFinder { a.Set(193, true); return a; } - case 657: + case 649: + case 650: + return set[115]; + case 651: case 658: - return set[116]; - case 659: - case 669: { BitArray a = new BitArray(239); a.Set(1, true); @@ -1491,111 +1476,111 @@ partial class ExpressionFinder { a.Set(136, true); return a; } - case 670: + case 659: { BitArray a = new BitArray(239); a.Set(101, true); return a; } - case 671: - return set[117]; - case 674: - case 675: + case 660: + return set[116]; + case 663: + case 664: { BitArray a = new BitArray(239); a.Set(149, true); return a; } - case 676: - case 685: - case 751: + case 665: + case 671: + case 737: { BitArray a = new BitArray(239); a.Set(3, true); return a; } - case 677: + case 666: + return set[117]; + case 675: + case 676: return set[118]; - case 689: - case 690: + case 677: + case 685: return set[119]; - case 691: - case 699: + case 681: return set[120]; - case 695: + case 690: + case 692: return set[121]; + case 693: case 704: - case 706: return set[122]; - case 707: - case 718: + case 694: + case 695: return set[123]; - case 708: - case 709: + case 696: return set[124]; - case 710: - return set[125]; - case 720: + case 706: { BitArray a = new BitArray(239); a.Set(136, true); return a; } - case 726: + case 712: { BitArray a = new BitArray(239); a.Set(140, true); return a; } - case 729: - case 738: + case 715: + case 724: { BitArray a = new BitArray(239); a.Set(169, true); return a; } - case 743: - return set[126]; - case 744: + case 729: + return set[125]; + case 730: { BitArray a = new BitArray(239); a.Set(160, true); return a; } - case 745: + case 731: { BitArray a = new BitArray(239); a.Set(137, true); return a; } - case 746: - case 747: - return set[127]; - case 752: + case 732: + case 733: + return set[126]; + case 738: { BitArray a = new BitArray(239); a.Set(11, true); return a; } - case 753: - return set[128]; - case 755: + case 739: + return set[127]; + case 741: { BitArray a = new BitArray(239); a.Set(173, true); return a; } - case 756: - return set[129]; - case 757: + case 742: + return set[128]; + case 743: { BitArray a = new BitArray(239); a.Set(67, true); a.Set(213, true); return a; } - case 758: - return set[130]; + case 744: + return set[129]; default: throw new InvalidOperationException(); } } @@ -1651,7 +1636,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 1; break; } if (la.kind == 173) { stateStack.Push(1); - goto case 755; + goto case 741; } else { goto case 2; } @@ -1660,7 +1645,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 2; break; } if (la.kind == 137) { stateStack.Push(2); - goto case 745; + goto case 731; } else { goto case 3; } @@ -1669,7 +1654,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 3; break; } if (la.kind == 40) { stateStack.Push(3); - goto case 435; + goto case 441; } else { goto case 4; } @@ -1688,7 +1673,7 @@ partial class ExpressionFinder { case 5: { if (la == null) { currentState = 5; break; } if (la.kind == 160) { - currentState = 741; + currentState = 727; break; } else { if (set[4].Get(la.kind)) { @@ -1707,14 +1692,14 @@ partial class ExpressionFinder { if (la == null) { currentState = 7; break; } if (la.kind == 40) { stateStack.Push(7); - goto case 435; + goto case 441; } else { goto case 8; } } case 8: { if (la == null) { currentState = 8; break; } - if (set[131].Get(la.kind)) { + if (set[130].Get(la.kind)) { currentState = 8; break; } else { @@ -1752,7 +1737,7 @@ partial class ExpressionFinder { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); stateStack.Push(12); - goto case 206; + goto case 205; } case 12: { PopContext(); @@ -1761,7 +1746,7 @@ partial class ExpressionFinder { case 13: { if (la == null) { currentState = 13; break; } if (la.kind == 37) { - currentState = 738; + currentState = 724; break; } else { goto case 14; @@ -1778,7 +1763,7 @@ partial class ExpressionFinder { case 16: { if (la == null) { currentState = 16; break; } if (la.kind == 140) { - currentState = 733; + currentState = 719; break; } else { goto case 17; @@ -1848,7 +1833,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 27; break; } if (la.kind == 40) { stateStack.Push(26); - goto case 435; + goto case 441; } else { isMissingModifier = true; goto case 28; @@ -1856,8 +1841,8 @@ partial class ExpressionFinder { } case 28: { if (la == null) { currentState = 28; break; } - if (set[132].Get(la.kind)) { - currentState = 732; + if (set[131].Get(la.kind)) { + currentState = 718; break; } else { isMissingModifier = false; @@ -1897,11 +1882,11 @@ partial class ExpressionFinder { case 30: { if (la == null) { currentState = 30; break; } if (la.kind == 119) { - currentState = 522; + currentState = 525; break; } else { if (la.kind == 186) { - currentState = 512; + currentState = 518; break; } else { if (la.kind == 127 || la.kind == 210) { @@ -1930,7 +1915,7 @@ partial class ExpressionFinder { case 34: { if (la == null) { currentState = 34; break; } if (la.kind == 37) { - currentState = 488; + currentState = 494; break; } else { if (la.kind == 63) { @@ -1960,7 +1945,7 @@ partial class ExpressionFinder { currentState = 38; break; } else { - if (set[133].Get(la.kind)) { + if (set[132].Get(la.kind)) { currentState = 38; break; } else { @@ -1996,7 +1981,7 @@ partial class ExpressionFinder { } case 40: { stateStack.Push(41); - goto case 102; + goto case 101; } case 41: { if (la == null) { currentState = 41; break; } @@ -2014,17 +1999,23 @@ partial class ExpressionFinder { break; } case 43: { + PushContext(Context.Expression, la, t); nextTokenIsPotentialStartOfExpression = true; goto case 44; } case 44: { if (la == null) { currentState = 44; break; } if (la.kind == 169) { - currentState = 486; + currentState = 489; break; } else { - if (set[21].Get(la.kind)) { - goto case 46; + if (set[22].Get(la.kind)) { + if (set[21].Get(la.kind)) { + stateStack.Push(45); + goto case 47; + } else { + goto case 45; + } } else { Error(la); goto case 45; @@ -2032,100 +2023,91 @@ partial class ExpressionFinder { } } case 45: { - if (la == null) { currentState = 45; break; } + PopContext(); + goto case 46; + } + case 46: { + if (la == null) { currentState = 46; break; } Expect(38, la); // ")" currentState = stateStack.Pop(); break; } - case 46: { - nextTokenIsPotentialStartOfExpression = true; - goto case 47; - } case 47: { - if (la == null) { currentState = 47; break; } - if (set[22].Get(la.kind)) { - stateStack.Push(45); - goto case 48; - } else { - goto case 45; - } - } - case 48: { nextTokenIsPotentialStartOfExpression = true; - goto case 49; + goto case 48; } - case 49: { - if (la == null) { currentState = 49; break; } + case 48: { + if (la == null) { currentState = 48; break; } if (set[23].Get(la.kind)) { activeArgument = 0; - goto case 482; + goto case 485; } else { if (la.kind == 22) { activeArgument = 0; - goto case 50; + goto case 49; } else { goto case 6; } } } - case 50: { - if (la == null) { currentState = 50; break; } + case 49: { + if (la == null) { currentState = 49; break; } Expect(22, la); // "," - currentState = 51; + currentState = 50; break; } - case 51: { + case 50: { activeArgument++; - goto case 52; + goto case 51; } - case 52: { + case 51: { nextTokenIsPotentialStartOfExpression = true; - goto case 53; + goto case 52; } - case 53: { - if (la == null) { currentState = 53; break; } + case 52: { + if (la == null) { currentState = 52; break; } if (set[23].Get(la.kind)) { - stateStack.Push(54); - goto case 56; + stateStack.Push(53); + goto case 55; } else { - goto case 54; + goto case 53; } } - case 54: { - if (la == null) { currentState = 54; break; } + case 53: { + if (la == null) { currentState = 53; break; } if (la.kind == 22) { - currentState = 55; + currentState = 54; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 55: { + case 54: { activeArgument++; - goto case 52; + goto case 51; } - case 56: { + case 55: { PushContext(Context.Expression, la, t); - goto case 57; + goto case 56; } - case 57: { - stateStack.Push(58); - goto case 76; + case 56: { + stateStack.Push(57); + goto case 75; } - case 58: { - if (la == null) { currentState = 58; break; } + case 57: { + if (la == null) { currentState = 57; break; } if (set[25].Get(la.kind)) { - stateStack.Push(57); - goto case 59; + stateStack.Push(56); + goto case 58; } else { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } } - case 59: { - if (la == null) { currentState = 59; break; } + case 58: { + if (la == null) { currentState = 58; break; } if (la.kind == 31) { currentState = stateStack.Pop(); break; @@ -2151,48 +2133,48 @@ partial class ExpressionFinder { break; } else { if (la.kind == 154) { - goto case 75; + goto case 74; } else { if (la.kind == 20) { - goto case 74; + goto case 73; } else { if (la.kind == 41) { - goto case 73; + goto case 72; } else { if (la.kind == 40) { - goto case 72; + goto case 71; } else { if (la.kind == 39) { - currentState = 71; + currentState = 70; break; } else { if (la.kind == 43) { - goto case 70; + goto case 69; } else { if (la.kind == 42) { - goto case 69; + goto case 68; } else { if (la.kind == 150) { - goto case 68; + goto case 67; } else { if (la.kind == 23) { currentState = stateStack.Pop(); break; } else { if (la.kind == 60) { - goto case 67; + goto case 66; } else { if (la.kind == 61) { - goto case 66; + goto case 65; } else { if (la.kind == 175) { - goto case 65; + goto case 64; } else { if (la.kind == 177) { - goto case 64; + goto case 63; } else { if (la.kind == 236) { - goto case 63; + goto case 62; } else { if (la.kind == 44) { currentState = stateStack.Pop(); @@ -2203,10 +2185,10 @@ partial class ExpressionFinder { break; } else { if (la.kind == 144) { - goto case 62; + goto case 61; } else { if (la.kind == 145) { - goto case 61; + goto case 60; } else { if (la.kind == 47) { currentState = stateStack.Pop(); @@ -2245,7 +2227,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 216) { - goto case 60; + goto case 59; } else { if (la.kind == 55) { currentState = stateStack.Pop(); @@ -2288,6 +2270,11 @@ partial class ExpressionFinder { } } } + case 59: { + if (la == null) { currentState = 59; break; } + currentState = stateStack.Pop(); + break; + } case 60: { if (la == null) { currentState = 60; break; } currentState = stateStack.Pop(); @@ -2339,14 +2326,14 @@ partial class ExpressionFinder { break; } case 70: { - if (la == null) { currentState = 70; break; } + wasNormalAttribute = false; currentState = stateStack.Pop(); - break; + goto switchlbl; } case 71: { - wasNormalAttribute = false; + if (la == null) { currentState = 71; break; } currentState = stateStack.Pop(); - goto switchlbl; + break; } case 72: { if (la == null) { currentState = 72; break; } @@ -2364,193 +2351,188 @@ partial class ExpressionFinder { break; } case 75: { - if (la == null) { currentState = 75; break; } - currentState = stateStack.Pop(); - break; + PushContext(Context.Expression, la, t); + goto case 76; } case 76: { - PushContext(Context.Expression, la, t); + nextTokenIsPotentialStartOfExpression = true; goto case 77; } case 77: { - nextTokenIsPotentialStartOfExpression = true; - goto case 78; - } - case 78: { - if (la == null) { currentState = 78; break; } - if (set[134].Get(la.kind)) { - currentState = 77; + if (la == null) { currentState = 77; break; } + if (set[133].Get(la.kind)) { + currentState = 76; break; } else { if (set[35].Get(la.kind)) { - stateStack.Push(160); - goto case 174; + stateStack.Push(159); + goto case 173; } else { if (la.kind == 220) { - currentState = 156; + currentState = 155; break; } else { if (la.kind == 162) { - stateStack.Push(79); - goto case 86; + stateStack.Push(78); + goto case 85; } else { if (la.kind == 35) { - stateStack.Push(79); - goto case 80; + stateStack.Push(78); + goto case 79; } else { Error(la); - goto case 79; + goto case 78; } } } } } } - case 79: { + case 78: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 80: { - if (la == null) { currentState = 80; break; } + case 79: { + if (la == null) { currentState = 79; break; } Expect(35, la); // "{" - currentState = 81; + currentState = 80; break; } - case 81: { + case 80: { nextTokenIsPotentialStartOfExpression = true; - goto case 82; + goto case 81; } - case 82: { - if (la == null) { currentState = 82; break; } + case 81: { + if (la == null) { currentState = 81; break; } if (set[23].Get(la.kind)) { - goto case 84; - } else { goto case 83; + } else { + goto case 82; } } - case 83: { - if (la == null) { currentState = 83; break; } + case 82: { + if (la == null) { currentState = 82; break; } Expect(36, la); // "}" currentState = stateStack.Pop(); break; } - case 84: { - stateStack.Push(85); - goto case 56; + case 83: { + stateStack.Push(84); + goto case 55; } - case 85: { - if (la == null) { currentState = 85; break; } + case 84: { + if (la == null) { currentState = 84; break; } if (la.kind == 22) { - currentState = 84; + currentState = 83; break; } else { - goto case 83; + goto case 82; } } - case 86: { - if (la == null) { currentState = 86; break; } + case 85: { + if (la == null) { currentState = 85; break; } Expect(162, la); // "New" - currentState = 87; + currentState = 86; break; } - case 87: { + case 86: { PushContext(Context.ObjectCreation, la, t); - goto case 88; + goto case 87; } - case 88: { - if (la == null) { currentState = 88; break; } + case 87: { + if (la == null) { currentState = 87; break; } if (set[16].Get(la.kind)) { - stateStack.Push(147); + stateStack.Push(146); goto case 37; } else { if (la.kind == 233) { PushContext(Context.ObjectInitializer, la, t); - goto case 91; + goto case 90; } else { - goto case 89; + goto case 88; } } } - case 89: { + case 88: { Error(la); - goto case 90; + goto case 89; } - case 90: { + case 89: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 91: { - if (la == null) { currentState = 91; break; } + case 90: { + if (la == null) { currentState = 90; break; } Expect(233, la); // "With" - currentState = 92; + currentState = 91; break; } - case 92: { - stateStack.Push(93); - goto case 94; + case 91: { + stateStack.Push(92); + goto case 93; } - case 93: { + case 92: { PopContext(); - goto case 90; + goto case 89; } - case 94: { - if (la == null) { currentState = 94; break; } + case 93: { + if (la == null) { currentState = 93; break; } Expect(35, la); // "{" - currentState = 95; + currentState = 94; break; } - case 95: { - if (la == null) { currentState = 95; break; } + case 94: { + if (la == null) { currentState = 94; break; } if (la.kind == 26 || la.kind == 147) { - goto case 96; + goto case 95; } else { - goto case 83; + goto case 82; } } - case 96: { - if (la == null) { currentState = 96; break; } + case 95: { + if (la == null) { currentState = 95; break; } if (la.kind == 147) { - currentState = 97; + currentState = 96; break; } else { - goto case 97; + goto case 96; } } - case 97: { - if (la == null) { currentState = 97; break; } + case 96: { + if (la == null) { currentState = 96; break; } Expect(26, la); // "." - currentState = 98; + currentState = 97; break; } - case 98: { - stateStack.Push(99); - goto case 102; + case 97: { + stateStack.Push(98); + goto case 101; } - case 99: { - if (la == null) { currentState = 99; break; } + case 98: { + if (la == null) { currentState = 98; break; } Expect(20, la); // "=" - currentState = 100; + currentState = 99; break; } - case 100: { - stateStack.Push(101); - goto case 56; + case 99: { + stateStack.Push(100); + goto case 55; } - case 101: { - if (la == null) { currentState = 101; break; } + case 100: { + if (la == null) { currentState = 100; break; } if (la.kind == 22) { - currentState = 96; + currentState = 95; break; } else { - goto case 83; + goto case 82; } } - case 102: { - if (la == null) { currentState = 102; break; } + case 101: { + if (la == null) { currentState = 101; break; } if (la.kind == 2) { - goto case 146; + goto case 145; } else { if (la.kind == 56) { currentState = stateStack.Pop(); @@ -2561,36 +2543,36 @@ partial class ExpressionFinder { break; } else { if (la.kind == 58) { - goto case 145; + goto case 144; } else { if (la.kind == 59) { currentState = stateStack.Pop(); break; } else { if (la.kind == 60) { - goto case 67; + goto case 66; } else { if (la.kind == 61) { - goto case 66; + goto case 65; } else { if (la.kind == 62) { - goto case 144; + goto case 143; } else { if (la.kind == 63) { currentState = stateStack.Pop(); break; } else { if (la.kind == 64) { - goto case 143; + goto case 142; } else { if (la.kind == 65) { - goto case 142; + goto case 141; } else { if (la.kind == 66) { - goto case 141; + goto case 140; } else { if (la.kind == 67) { - goto case 140; + goto case 139; } else { if (la.kind == 68) { currentState = stateStack.Pop(); @@ -2601,7 +2583,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 70) { - goto case 139; + goto case 138; } else { if (la.kind == 71) { currentState = stateStack.Pop(); @@ -2656,7 +2638,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 84) { - goto case 138; + goto case 137; } else { if (la.kind == 85) { currentState = stateStack.Pop(); @@ -2667,7 +2649,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 87) { - goto case 137; + goto case 136; } else { if (la.kind == 88) { currentState = stateStack.Pop(); @@ -2710,7 +2692,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 98) { - goto case 136; + goto case 135; } else { if (la.kind == 99) { currentState = stateStack.Pop(); @@ -2733,7 +2715,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 104) { - goto case 135; + goto case 134; } else { if (la.kind == 105) { currentState = stateStack.Pop(); @@ -2744,10 +2726,10 @@ partial class ExpressionFinder { break; } else { if (la.kind == 107) { - goto case 134; + goto case 133; } else { if (la.kind == 108) { - goto case 133; + goto case 132; } else { if (la.kind == 109) { currentState = stateStack.Pop(); @@ -2778,7 +2760,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 116) { - goto case 132; + goto case 131; } else { if (la.kind == 117) { currentState = stateStack.Pop(); @@ -2797,7 +2779,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 121) { - goto case 131; + goto case 130; } else { if (la.kind == 122) { currentState = stateStack.Pop(); @@ -2808,17 +2790,17 @@ partial class ExpressionFinder { break; } else { if (la.kind == 124) { - goto case 130; + goto case 129; } else { if (la.kind == 125) { currentState = stateStack.Pop(); break; } else { if (la.kind == 126) { - goto case 129; + goto case 128; } else { if (la.kind == 127) { - goto case 128; + goto case 127; } else { if (la.kind == 128) { currentState = stateStack.Pop(); @@ -2841,7 +2823,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 133) { - goto case 127; + goto case 126; } else { if (la.kind == 134) { currentState = stateStack.Pop(); @@ -2864,7 +2846,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 139) { - goto case 126; + goto case 125; } else { if (la.kind == 140) { currentState = stateStack.Pop(); @@ -2879,19 +2861,19 @@ partial class ExpressionFinder { break; } else { if (la.kind == 143) { - goto case 125; + goto case 124; } else { if (la.kind == 144) { - goto case 62; + goto case 61; } else { if (la.kind == 145) { - goto case 61; + goto case 60; } else { if (la.kind == 146) { - goto case 124; + goto case 123; } else { if (la.kind == 147) { - goto case 123; + goto case 122; } else { if (la.kind == 148) { currentState = stateStack.Pop(); @@ -2902,7 +2884,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 150) { - goto case 68; + goto case 67; } else { if (la.kind == 151) { currentState = stateStack.Pop(); @@ -2917,7 +2899,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 154) { - goto case 75; + goto case 74; } else { if (la.kind == 155) { currentState = stateStack.Pop(); @@ -2948,10 +2930,10 @@ partial class ExpressionFinder { break; } else { if (la.kind == 162) { - goto case 122; + goto case 121; } else { if (la.kind == 163) { - goto case 121; + goto case 120; } else { if (la.kind == 164) { currentState = stateStack.Pop(); @@ -2978,7 +2960,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 170) { - goto case 120; + goto case 119; } else { if (la.kind == 171) { currentState = stateStack.Pop(); @@ -2997,13 +2979,13 @@ partial class ExpressionFinder { break; } else { if (la.kind == 175) { - goto case 65; + goto case 64; } else { if (la.kind == 176) { - goto case 119; + goto case 118; } else { if (la.kind == 177) { - goto case 64; + goto case 63; } else { if (la.kind == 178) { currentState = stateStack.Pop(); @@ -3030,14 +3012,14 @@ partial class ExpressionFinder { break; } else { if (la.kind == 184) { - goto case 118; + goto case 117; } else { if (la.kind == 185) { currentState = stateStack.Pop(); break; } else { if (la.kind == 186) { - goto case 117; + goto case 116; } else { if (la.kind == 187) { currentState = stateStack.Pop(); @@ -3080,7 +3062,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 197) { - goto case 116; + goto case 115; } else { if (la.kind == 198) { currentState = stateStack.Pop(); @@ -3103,7 +3085,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 203) { - goto case 115; + goto case 114; } else { if (la.kind == 204) { currentState = stateStack.Pop(); @@ -3114,7 +3096,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 206) { - goto case 114; + goto case 113; } else { if (la.kind == 207) { currentState = stateStack.Pop(); @@ -3125,19 +3107,19 @@ partial class ExpressionFinder { break; } else { if (la.kind == 209) { - goto case 113; + goto case 112; } else { if (la.kind == 210) { - goto case 112; + goto case 111; } else { if (la.kind == 211) { - goto case 111; + goto case 110; } else { if (la.kind == 212) { - goto case 110; + goto case 109; } else { if (la.kind == 213) { - goto case 109; + goto case 108; } else { if (la.kind == 214) { currentState = stateStack.Pop(); @@ -3148,14 +3130,14 @@ partial class ExpressionFinder { break; } else { if (la.kind == 216) { - goto case 60; + goto case 59; } else { if (la.kind == 217) { currentState = stateStack.Pop(); break; } else { if (la.kind == 218) { - goto case 108; + goto case 107; } else { if (la.kind == 219) { currentState = stateStack.Pop(); @@ -3174,10 +3156,10 @@ partial class ExpressionFinder { break; } else { if (la.kind == 223) { - goto case 107; + goto case 106; } else { if (la.kind == 224) { - goto case 106; + goto case 105; } else { if (la.kind == 225) { currentState = stateStack.Pop(); @@ -3200,17 +3182,17 @@ partial class ExpressionFinder { break; } else { if (la.kind == 230) { - goto case 105; + goto case 104; } else { if (la.kind == 231) { - goto case 104; + goto case 103; } else { if (la.kind == 232) { currentState = stateStack.Pop(); break; } else { if (la.kind == 233) { - goto case 103; + goto case 102; } else { if (la.kind == 234) { currentState = stateStack.Pop(); @@ -3221,7 +3203,7 @@ partial class ExpressionFinder { break; } else { if (la.kind == 236) { - goto case 63; + goto case 62; } else { if (la.kind == 237) { currentState = stateStack.Pop(); @@ -3412,6 +3394,11 @@ partial class ExpressionFinder { } } } + case 102: { + if (la == null) { currentState = 102; break; } + currentState = stateStack.Pop(); + break; + } case 103: { if (la == null) { currentState = 103; break; } currentState = stateStack.Pop(); @@ -3629,62 +3616,57 @@ partial class ExpressionFinder { } case 146: { if (la == null) { currentState = 146; break; } - currentState = stateStack.Pop(); - break; - } - case 147: { - if (la == null) { currentState = 147; break; } if (la.kind == 35 || la.kind == 126 || la.kind == 233) { if (la.kind == 126) { PushContext(Context.CollectionInitializer, la, t); - goto case 152; + goto case 151; } else { if (la.kind == 35) { PushContext(Context.CollectionInitializer, la, t); - stateStack.Push(151); - goto case 80; + stateStack.Push(150); + goto case 79; } else { if (la.kind == 233) { PushContext(Context.ObjectInitializer, la, t); - goto case 148; + goto case 147; } else { - goto case 89; + goto case 88; } } } } else { - goto case 90; + goto case 89; } } - case 148: { - if (la == null) { currentState = 148; break; } + case 147: { + if (la == null) { currentState = 147; break; } Expect(233, la); // "With" - currentState = 149; + currentState = 148; break; } + case 148: { + stateStack.Push(149); + goto case 93; + } case 149: { - stateStack.Push(150); - goto case 94; + PopContext(); + goto case 89; } case 150: { PopContext(); - goto case 90; + goto case 89; } case 151: { - PopContext(); - goto case 90; - } - case 152: { - if (la == null) { currentState = 152; break; } + if (la == null) { currentState = 151; break; } Expect(126, la); // "From" - currentState = 153; + currentState = 152; break; } - case 153: { - if (la == null) { currentState = 153; break; } + case 152: { + if (la == null) { currentState = 152; break; } if (la.kind == 35) { - stateStack.Push(154); - goto case 80; + stateStack.Push(153); + goto case 79; } else { if (set[30].Get(la.kind)) { currentState = endOfStatementTerminatorAndBlock; /* leave this block */ @@ -3694,80 +3676,80 @@ partial class ExpressionFinder { } else { Error(la); - goto case 154; + goto case 153; } } } - case 154: { + case 153: { PopContext(); - goto case 90; + goto case 89; } - case 155: { - if (la == null) { currentState = 155; break; } - currentState = 154; + case 154: { + if (la == null) { currentState = 154; break; } + currentState = 153; break; } - case 156: { - stateStack.Push(157); - goto case 76; + case 155: { + stateStack.Push(156); + goto case 75; } - case 157: { - if (la == null) { currentState = 157; break; } + case 156: { + if (la == null) { currentState = 156; break; } Expect(144, la); // "Is" - currentState = 158; + currentState = 157; break; } - case 158: { + case 157: { PushContext(Context.Type, la, t); - stateStack.Push(159); + stateStack.Push(158); goto case 37; } - case 159: { + case 158: { PopContext(); - goto case 79; + goto case 78; } - case 160: { - if (la == null) { currentState = 160; break; } + case 159: { + if (la == null) { currentState = 159; break; } if (set[32].Get(la.kind)) { - stateStack.Push(160); - goto case 161; + stateStack.Push(159); + goto case 160; } else { - goto case 79; + goto case 78; } } - case 161: { - if (la == null) { currentState = 161; break; } + case 160: { + if (la == null) { currentState = 160; break; } if (la.kind == 37) { - currentState = 166; + currentState = 165; break; } else { - if (set[135].Get(la.kind)) { - currentState = 162; + if (set[134].Get(la.kind)) { + currentState = 161; break; } else { goto case 6; } } } - case 162: { + case 161: { nextTokenIsStartOfImportsOrAccessExpression = true; - goto case 163; + goto case 162; } - case 163: { - if (la == null) { currentState = 163; break; } + case 162: { + if (la == null) { currentState = 162; break; } if (la.kind == 10) { - currentState = 164; + currentState = 163; break; } else { - goto case 164; + goto case 163; } } - case 164: { - stateStack.Push(165); - goto case 102; + case 163: { + stateStack.Push(164); + goto case 101; } - case 165: { - if (la == null) { currentState = 165; break; } + case 164: { + if (la == null) { currentState = 164; break; } if (la.kind == 11) { currentState = stateStack.Pop(); break; @@ -3776,121 +3758,121 @@ partial class ExpressionFinder { goto switchlbl; } } - case 166: { + case 165: { PushContext(Context.Expression, la, t); nextTokenIsPotentialStartOfExpression = true; - goto case 167; + goto case 166; } - case 167: { - if (la == null) { currentState = 167; break; } + case 166: { + if (la == null) { currentState = 166; break; } if (la.kind == 169) { - currentState = 169; + currentState = 168; break; } else { - if (set[21].Get(la.kind)) { - if (set[22].Get(la.kind)) { - stateStack.Push(168); - goto case 48; + if (set[22].Get(la.kind)) { + if (set[21].Get(la.kind)) { + stateStack.Push(167); + goto case 47; } else { - goto case 168; + goto case 167; } } else { Error(la); - goto case 168; + goto case 167; } } } - case 168: { + case 167: { PopContext(); - goto case 45; + goto case 46; } - case 169: { + case 168: { PushContext(Context.Type, la, t); - stateStack.Push(170); + stateStack.Push(169); goto case 37; } - case 170: { + case 169: { PopContext(); - goto case 171; + goto case 170; } - case 171: { - if (la == null) { currentState = 171; break; } + case 170: { + if (la == null) { currentState = 170; break; } if (la.kind == 22) { - currentState = 172; + currentState = 171; break; } else { - goto case 168; + goto case 167; } } - case 172: { + case 171: { PushContext(Context.Type, la, t); - stateStack.Push(173); + stateStack.Push(172); goto case 37; } - case 173: { + case 172: { PopContext(); - goto case 171; + goto case 170; } - case 174: { + case 173: { PushContext(Context.Expression, la, t); nextTokenIsPotentialStartOfExpression = true; - goto case 175; + goto case 174; } - case 175: { - if (la == null) { currentState = 175; break; } - if (set[136].Get(la.kind)) { - currentState = 176; + case 174: { + if (la == null) { currentState = 174; break; } + if (set[135].Get(la.kind)) { + currentState = 175; break; } else { if (la.kind == 37) { - currentState = 478; + currentState = 481; break; } else { - if (set[137].Get(la.kind)) { - currentState = 176; + if (set[136].Get(la.kind)) { + currentState = 175; break; } else { - if (set[133].Get(la.kind)) { - currentState = 176; + if (set[132].Get(la.kind)) { + currentState = 175; break; } else { - if (set[135].Get(la.kind)) { - currentState = 474; + if (set[134].Get(la.kind)) { + currentState = 477; break; } else { if (la.kind == 129) { - currentState = 471; + currentState = 474; break; } else { if (la.kind == 237) { - currentState = 468; + currentState = 471; break; } else { - if (set[83].Get(la.kind)) { - stateStack.Push(176); + if (set[82].Get(la.kind)) { + stateStack.Push(175); nextTokenIsPotentialStartOfExpression = true; PushContext(Context.Xml, la, t); - goto case 451; + goto case 454; } else { if (la.kind == 127 || la.kind == 210) { - stateStack.Push(176); - goto case 253; + stateStack.Push(175); + goto case 252; } else { if (la.kind == 58 || la.kind == 126) { - stateStack.Push(176); + stateStack.Push(175); PushContext(Context.Query, la, t); - goto case 191; + goto case 190; } else { if (set[37].Get(la.kind)) { - stateStack.Push(176); - goto case 184; + stateStack.Push(175); + goto case 183; } else { if (la.kind == 135) { - stateStack.Push(176); - goto case 177; + stateStack.Push(175); + goto case 176; } else { Error(la); - goto case 176; + goto case 175; } } } @@ -3904,160 +3886,160 @@ partial class ExpressionFinder { } } } - case 176: { + case 175: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } + case 176: { + if (la == null) { currentState = 176; break; } + Expect(135, la); // "If" + currentState = 177; + break; + } case 177: { if (la == null) { currentState = 177; break; } - Expect(135, la); // "If" + Expect(37, la); // "(" currentState = 178; break; } case 178: { - if (la == null) { currentState = 178; break; } - Expect(37, la); // "(" - currentState = 179; - break; + stateStack.Push(179); + goto case 55; } case 179: { - stateStack.Push(180); - goto case 56; - } - case 180: { - if (la == null) { currentState = 180; break; } + if (la == null) { currentState = 179; break; } Expect(22, la); // "," - currentState = 181; + currentState = 180; break; } - case 181: { - stateStack.Push(182); - goto case 56; + case 180: { + stateStack.Push(181); + goto case 55; } - case 182: { - if (la == null) { currentState = 182; break; } + case 181: { + if (la == null) { currentState = 181; break; } if (la.kind == 22) { - currentState = 183; + currentState = 182; break; } else { - goto case 45; + goto case 46; } } - case 183: { - stateStack.Push(45); - goto case 56; + case 182: { + stateStack.Push(46); + goto case 55; } - case 184: { - if (la == null) { currentState = 184; break; } - if (set[138].Get(la.kind)) { - currentState = 190; + case 183: { + if (la == null) { currentState = 183; break; } + if (set[137].Get(la.kind)) { + currentState = 189; break; } else { if (la.kind == 94 || la.kind == 106 || la.kind == 219) { - currentState = 185; + currentState = 184; break; } else { goto case 6; } } } - case 185: { - if (la == null) { currentState = 185; break; } + case 184: { + if (la == null) { currentState = 184; break; } Expect(37, la); // "(" - currentState = 186; + currentState = 185; break; } - case 186: { - stateStack.Push(187); - goto case 56; + case 185: { + stateStack.Push(186); + goto case 55; } - case 187: { - if (la == null) { currentState = 187; break; } + case 186: { + if (la == null) { currentState = 186; break; } Expect(22, la); // "," - currentState = 188; + currentState = 187; break; } - case 188: { + case 187: { PushContext(Context.Type, la, t); - stateStack.Push(189); + stateStack.Push(188); goto case 37; } - case 189: { + case 188: { PopContext(); - goto case 45; + goto case 46; } - case 190: { - if (la == null) { currentState = 190; break; } + case 189: { + if (la == null) { currentState = 189; break; } Expect(37, la); // "(" - currentState = 183; + currentState = 182; break; } - case 191: { - if (la == null) { currentState = 191; break; } + case 190: { + if (la == null) { currentState = 190; break; } if (la.kind == 126) { - stateStack.Push(192); - goto case 252; + stateStack.Push(191); + goto case 251; } else { if (la.kind == 58) { - stateStack.Push(192); - goto case 251; + stateStack.Push(191); + goto case 250; } else { Error(la); - goto case 192; + goto case 191; } } } - case 192: { - if (la == null) { currentState = 192; break; } + case 191: { + if (la == null) { currentState = 191; break; } if (set[38].Get(la.kind)) { - stateStack.Push(192); - goto case 193; + stateStack.Push(191); + goto case 192; } else { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } } - case 193: { - if (la == null) { currentState = 193; break; } + case 192: { + if (la == null) { currentState = 192; break; } if (la.kind == 126) { - currentState = 249; + currentState = 248; break; } else { if (la.kind == 58) { - currentState = 245; + currentState = 244; break; } else { if (la.kind == 197) { - currentState = 243; + currentState = 242; break; } else { if (la.kind == 107) { - goto case 134; + goto case 133; } else { if (la.kind == 230) { - currentState = 56; + currentState = 55; break; } else { if (la.kind == 176) { - currentState = 239; + currentState = 238; break; } else { if (la.kind == 203 || la.kind == 212) { - currentState = 237; + currentState = 236; break; } else { if (la.kind == 148) { - currentState = 235; + currentState = 234; break; } else { if (la.kind == 133) { - currentState = 207; + currentState = 206; break; } else { if (la.kind == 146) { - currentState = 194; + currentState = 193; break; } else { goto case 6; @@ -4072,107 +4054,107 @@ partial class ExpressionFinder { } } } - case 194: { - stateStack.Push(195); - goto case 200; + case 193: { + stateStack.Push(194); + goto case 199; } - case 195: { - if (la == null) { currentState = 195; break; } + case 194: { + if (la == null) { currentState = 194; break; } Expect(171, la); // "On" - currentState = 196; + currentState = 195; break; } - case 196: { - stateStack.Push(197); - goto case 56; + case 195: { + stateStack.Push(196); + goto case 55; } - case 197: { - if (la == null) { currentState = 197; break; } + case 196: { + if (la == null) { currentState = 196; break; } Expect(116, la); // "Equals" - currentState = 198; + currentState = 197; break; } - case 198: { - stateStack.Push(199); - goto case 56; + case 197: { + stateStack.Push(198); + goto case 55; } - case 199: { - if (la == null) { currentState = 199; break; } + case 198: { + if (la == null) { currentState = 198; break; } if (la.kind == 22) { - currentState = 196; + currentState = 195; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 200: { + case 199: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(201); - goto case 206; + stateStack.Push(200); + goto case 205; } - case 201: { + case 200: { PopContext(); - goto case 202; + goto case 201; } - case 202: { - if (la == null) { currentState = 202; break; } + case 201: { + if (la == null) { currentState = 201; break; } if (la.kind == 63) { - currentState = 204; + currentState = 203; break; } else { - goto case 203; + goto case 202; } } - case 203: { - if (la == null) { currentState = 203; break; } + case 202: { + if (la == null) { currentState = 202; break; } Expect(138, la); // "In" - currentState = 56; + currentState = 55; break; } - case 204: { + case 203: { PushContext(Context.Type, la, t); - stateStack.Push(205); + stateStack.Push(204); goto case 37; } - case 205: { + case 204: { PopContext(); - goto case 203; + goto case 202; } - case 206: { - if (la == null) { currentState = 206; break; } - if (set[123].Get(la.kind)) { + case 205: { + if (la == null) { currentState = 205; break; } + if (set[122].Get(la.kind)) { currentState = stateStack.Pop(); break; } else { if (la.kind == 98) { - goto case 136; + goto case 135; } else { goto case 6; } } } - case 207: { + case 206: { SetIdentifierExpected(la); nextTokenIsPotentialStartOfExpression = true; - goto case 208; + goto case 207; } - case 208: { - if (la == null) { currentState = 208; break; } + case 207: { + if (la == null) { currentState = 207; break; } if (la.kind == 146) { - goto case 227; + goto case 226; } else { if (set[40].Get(la.kind)) { if (la.kind == 70) { - currentState = 210; + currentState = 209; break; } else { if (set[40].Get(la.kind)) { - goto case 225; + goto case 224; } else { Error(la); - goto case 209; + goto case 208; } } } else { @@ -4180,87 +4162,87 @@ partial class ExpressionFinder { } } } - case 209: { - if (la == null) { currentState = 209; break; } + case 208: { + if (la == null) { currentState = 208; break; } Expect(70, la); // "By" - currentState = 210; + currentState = 209; break; } - case 210: { - stateStack.Push(211); - goto case 214; + case 209: { + stateStack.Push(210); + goto case 213; } - case 211: { - if (la == null) { currentState = 211; break; } + case 210: { + if (la == null) { currentState = 210; break; } if (la.kind == 22) { - currentState = 210; + currentState = 209; break; } else { Expect(143, la); // "Into" - currentState = 212; + currentState = 211; break; } } - case 212: { - stateStack.Push(213); - goto case 214; + case 211: { + stateStack.Push(212); + goto case 213; } - case 213: { - if (la == null) { currentState = 213; break; } + case 212: { + if (la == null) { currentState = 212; break; } if (la.kind == 22) { - currentState = 212; + currentState = 211; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 214: { + case 213: { SetIdentifierExpected(la); nextTokenIsPotentialStartOfExpression = true; - goto case 215; + goto case 214; } - case 215: { - if (la == null) { currentState = 215; break; } + case 214: { + if (la == null) { currentState = 214; break; } if (set[6].Get(la.kind)) { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(218); - goto case 206; + stateStack.Push(217); + goto case 205; } else { - goto case 216; + goto case 215; } } - case 216: { - stateStack.Push(217); - goto case 56; + case 215: { + stateStack.Push(216); + goto case 55; } - case 217: { + case 216: { if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; currentState = stateStack.Pop(); goto switchlbl; } - case 218: { + case 217: { nextTokenIsPotentialStartOfExpression = true; - goto case 219; + goto case 218; } - case 219: { - if (la == null) { currentState = 219; break; } + case 218: { + if (la == null) { currentState = 218; break; } if (set[42].Get(la.kind)) { PopContext(); isAlreadyInExpr = true; - goto case 220; + goto case 219; } else { - goto case 216; + goto case 215; } } - case 220: { - if (la == null) { currentState = 220; break; } + case 219: { + if (la == null) { currentState = 219; break; } if (la.kind == 63) { - currentState = 222; + currentState = 221; break; } else { if (la.kind == 20) { - currentState = 216; + currentState = 215; break; } else { if (set[43].Get(la.kind)) { @@ -4271,424 +4253,403 @@ partial class ExpressionFinder { } else { Error(la); - goto case 216; + goto case 215; } } } } - case 221: { - if (la == null) { currentState = 221; break; } - currentState = 216; + case 220: { + if (la == null) { currentState = 220; break; } + currentState = 215; break; } - case 222: { + case 221: { PushContext(Context.Type, la, t); - stateStack.Push(223); + stateStack.Push(222); goto case 37; } - case 223: { + case 222: { PopContext(); - goto case 224; + goto case 223; } - case 224: { - if (la == null) { currentState = 224; break; } + case 223: { + if (la == null) { currentState = 223; break; } Expect(20, la); // "=" - currentState = 216; + currentState = 215; break; } - case 225: { - stateStack.Push(226); - goto case 214; + case 224: { + stateStack.Push(225); + goto case 213; } - case 226: { - if (la == null) { currentState = 226; break; } + case 225: { + if (la == null) { currentState = 225; break; } if (la.kind == 22) { - currentState = 225; + currentState = 224; break; } else { - goto case 209; + goto case 208; } } - case 227: { - stateStack.Push(228); - goto case 234; + case 226: { + stateStack.Push(227); + goto case 233; } - case 228: { - if (la == null) { currentState = 228; break; } + case 227: { + if (la == null) { currentState = 227; break; } if (la.kind == 133 || la.kind == 146) { if (la.kind == 133) { - currentState = 232; + currentState = 231; break; } else { if (la.kind == 146) { - goto case 227; + goto case 226; } else { Error(la); - goto case 228; + goto case 227; } } } else { - goto case 229; + goto case 228; } } - case 229: { - if (la == null) { currentState = 229; break; } + case 228: { + if (la == null) { currentState = 228; break; } Expect(143, la); // "Into" - currentState = 230; + currentState = 229; break; } - case 230: { - stateStack.Push(231); - goto case 214; + case 229: { + stateStack.Push(230); + goto case 213; } - case 231: { - if (la == null) { currentState = 231; break; } + case 230: { + if (la == null) { currentState = 230; break; } if (la.kind == 22) { - currentState = 230; + currentState = 229; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } + case 231: { + stateStack.Push(232); + goto case 233; + } case 232: { - stateStack.Push(233); - goto case 234; + stateStack.Push(227); + goto case 228; } case 233: { - stateStack.Push(228); - goto case 229; - } - case 234: { - if (la == null) { currentState = 234; break; } + if (la == null) { currentState = 233; break; } Expect(146, la); // "Join" - currentState = 194; + currentState = 193; break; } - case 235: { - stateStack.Push(236); - goto case 214; + case 234: { + stateStack.Push(235); + goto case 213; } - case 236: { - if (la == null) { currentState = 236; break; } + case 235: { + if (la == null) { currentState = 235; break; } if (la.kind == 22) { - currentState = 235; + currentState = 234; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 237: { + case 236: { nextTokenIsPotentialStartOfExpression = true; - goto case 238; + goto case 237; } - case 238: { - if (la == null) { currentState = 238; break; } + case 237: { + if (la == null) { currentState = 237; break; } if (la.kind == 231) { - currentState = 56; + currentState = 55; break; } else { - goto case 56; + goto case 55; } } - case 239: { - if (la == null) { currentState = 239; break; } + case 238: { + if (la == null) { currentState = 238; break; } Expect(70, la); // "By" - currentState = 240; + currentState = 239; break; } - case 240: { - stateStack.Push(241); - goto case 56; + case 239: { + stateStack.Push(240); + goto case 55; } - case 241: { - if (la == null) { currentState = 241; break; } + case 240: { + if (la == null) { currentState = 240; break; } if (la.kind == 64) { - currentState = 242; + currentState = 241; break; } else { if (la.kind == 104) { - currentState = 242; + currentState = 241; break; } else { Error(la); - goto case 242; + goto case 241; } } } - case 242: { - if (la == null) { currentState = 242; break; } + case 241: { + if (la == null) { currentState = 241; break; } if (la.kind == 22) { - currentState = 240; + currentState = 239; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 243: { - stateStack.Push(244); - goto case 214; + case 242: { + stateStack.Push(243); + goto case 213; } - case 244: { - if (la == null) { currentState = 244; break; } + case 243: { + if (la == null) { currentState = 243; break; } if (la.kind == 22) { - currentState = 243; + currentState = 242; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 245: { - stateStack.Push(246); - goto case 200; + case 244: { + stateStack.Push(245); + goto case 199; } - case 246: { - if (la == null) { currentState = 246; break; } + case 245: { + if (la == null) { currentState = 245; break; } if (set[38].Get(la.kind)) { - stateStack.Push(246); - goto case 193; + stateStack.Push(245); + goto case 192; } else { Expect(143, la); // "Into" - currentState = 247; + currentState = 246; break; } } - case 247: { - stateStack.Push(248); - goto case 214; + case 246: { + stateStack.Push(247); + goto case 213; } - case 248: { - if (la == null) { currentState = 248; break; } + case 247: { + if (la == null) { currentState = 247; break; } if (la.kind == 22) { - currentState = 247; + currentState = 246; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 249: { - stateStack.Push(250); - goto case 200; + case 248: { + stateStack.Push(249); + goto case 199; } - case 250: { - if (la == null) { currentState = 250; break; } + case 249: { + if (la == null) { currentState = 249; break; } if (la.kind == 22) { - currentState = 249; + currentState = 248; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 251: { - if (la == null) { currentState = 251; break; } + case 250: { + if (la == null) { currentState = 250; break; } Expect(58, la); // "Aggregate" - currentState = 245; + currentState = 244; break; } - case 252: { - if (la == null) { currentState = 252; break; } + case 251: { + if (la == null) { currentState = 251; break; } Expect(126, la); // "From" - currentState = 249; + currentState = 248; break; } - case 253: { - if (la == null) { currentState = 253; break; } + case 252: { + if (la == null) { currentState = 252; break; } if (la.kind == 210) { - currentState = 443; + currentState = 449; break; } else { if (la.kind == 127) { - currentState = 254; + currentState = 253; break; } else { goto case 6; } } } - case 254: { - if (la == null) { currentState = 254; break; } - Expect(37, la); // "(" - currentState = 255; - break; - } - case 255: { - SetIdentifierExpected(la); - goto case 256; - } - case 256: { - if (la == null) { currentState = 256; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(257); - goto case 422; - } else { - goto case 257; - } - } - case 257: { - if (la == null) { currentState = 257; break; } - Expect(38, la); // ")" - currentState = 258; - break; + case 253: { + stateStack.Push(254); + goto case 424; } - case 258: { + case 254: { nextTokenIsPotentialStartOfExpression = true; - goto case 259; + goto case 255; } - case 259: { - if (la == null) { currentState = 259; break; } + case 255: { + if (la == null) { currentState = 255; break; } if (set[23].Get(la.kind)) { - goto case 56; + goto case 55; } else { if (la.kind == 1 || la.kind == 21 || la.kind == 63) { if (la.kind == 63) { - currentState = 420; + currentState = 422; break; } else { - goto case 260; + goto case 256; } } else { goto case 6; } } } - case 260: { - stateStack.Push(261); - goto case 263; + case 256: { + stateStack.Push(257); + goto case 259; } - case 261: { - if (la == null) { currentState = 261; break; } + case 257: { + if (la == null) { currentState = 257; break; } Expect(113, la); // "End" - currentState = 262; + currentState = 258; break; } - case 262: { - if (la == null) { currentState = 262; break; } + case 258: { + if (la == null) { currentState = 258; break; } Expect(127, la); // "Function" currentState = stateStack.Pop(); break; } - case 263: { + case 259: { PushContext(Context.Body, la, t); - goto case 264; + goto case 260; } - case 264: { - stateStack.Push(265); + case 260: { + stateStack.Push(261); goto case 23; } - case 265: { + case 261: { nextTokenIsPotentialStartOfExpression = true; - goto case 266; + goto case 262; } - case 266: { - if (la == null) { currentState = 266; break; } - if (set[139].Get(la.kind)) { - if (set[70].Get(la.kind)) { - if (set[51].Get(la.kind)) { - stateStack.Push(264); - goto case 271; + case 262: { + if (la == null) { currentState = 262; break; } + if (set[138].Get(la.kind)) { + if (set[69].Get(la.kind)) { + if (set[50].Get(la.kind)) { + stateStack.Push(260); + goto case 267; } else { - goto case 264; + goto case 260; } } else { if (la.kind == 113) { - currentState = 269; + currentState = 265; break; } else { - goto case 268; + goto case 264; } } } else { - goto case 267; + goto case 263; } } - case 267: { + case 263: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 268: { + case 264: { Error(la); - goto case 265; + goto case 261; } - case 269: { - if (la == null) { currentState = 269; break; } + case 265: { + if (la == null) { currentState = 265; break; } if (la.kind == 1 || la.kind == 21) { - goto case 264; + goto case 260; } else { - if (set[50].Get(la.kind)) { + if (set[49].Get(la.kind)) { currentState = endOfStatementTerminatorAndBlock; /* leave this block */ InformToken(t); /* process End again*/ /* for processing current token (la): go to the position after processing End */ goto switchlbl; } else { - goto case 268; + goto case 264; } } } - case 270: { - if (la == null) { currentState = 270; break; } - currentState = 265; + case 266: { + if (la == null) { currentState = 266; break; } + currentState = 261; break; } - case 271: { + case 267: { nextTokenIsPotentialStartOfExpression = true; - goto case 272; + goto case 268; } - case 272: { - if (la == null) { currentState = 272; break; } + case 268: { + if (la == null) { currentState = 268; break; } if (la.kind == 88 || la.kind == 105 || la.kind == 204) { - currentState = 400; + currentState = 399; break; } else { if (la.kind == 211 || la.kind == 233) { - currentState = 396; + currentState = 395; break; } else { if (la.kind == 56 || la.kind == 193) { - currentState = 394; + currentState = 393; break; } else { if (la.kind == 189) { - currentState = 392; + currentState = 388; break; } else { if (la.kind == 135) { - currentState = 374; + currentState = 370; break; } else { if (la.kind == 197) { - currentState = 358; + currentState = 354; break; } else { if (la.kind == 231) { - currentState = 354; + currentState = 350; break; } else { if (la.kind == 108) { - currentState = 348; + currentState = 344; break; } else { if (la.kind == 124) { - currentState = 321; + currentState = 317; break; } else { if (la.kind == 118 || la.kind == 171 || la.kind == 194) { if (la.kind == 118 || la.kind == 171) { if (la.kind == 171) { - currentState = 317; + currentState = 313; break; } else { - goto case 317; + goto case 313; } } else { if (la.kind == 194) { - currentState = 315; + currentState = 311; break; } else { goto case 6; @@ -4696,31 +4657,31 @@ partial class ExpressionFinder { } } else { if (la.kind == 215) { - currentState = 313; + currentState = 309; break; } else { if (la.kind == 218) { - currentState = 300; + currentState = 296; break; } else { - if (set[140].Get(la.kind)) { + if (set[139].Get(la.kind)) { if (la.kind == 132) { - currentState = 297; + currentState = 293; break; } else { if (la.kind == 120) { - currentState = 296; + currentState = 292; break; } else { if (la.kind == 89) { - currentState = 295; + currentState = 291; break; } else { if (la.kind == 206) { - goto case 114; + goto case 113; } else { if (la.kind == 195) { - currentState = 292; + currentState = 288; break; } else { goto case 6; @@ -4731,23 +4692,23 @@ partial class ExpressionFinder { } } else { if (la.kind == 191) { - currentState = 290; + currentState = 286; break; } else { if (la.kind == 117) { - currentState = 288; + currentState = 284; break; } else { if (la.kind == 226) { - currentState = 273; + currentState = 269; break; } else { - if (set[141].Get(la.kind)) { + if (set[140].Get(la.kind)) { if (la.kind == 73) { - currentState = 56; + currentState = 55; break; } else { - goto case 56; + goto case 55; } } else { goto case 6; @@ -4769,75 +4730,75 @@ partial class ExpressionFinder { } } } - case 273: { - stateStack.Push(274); + case 269: { + stateStack.Push(270); SetIdentifierExpected(la); nextTokenIsPotentialStartOfExpression = true; - goto case 277; + goto case 273; } - case 274: { - if (la == null) { currentState = 274; break; } + case 270: { + if (la == null) { currentState = 270; break; } if (la.kind == 22) { - currentState = 273; + currentState = 269; break; } else { - stateStack.Push(275); - goto case 263; + stateStack.Push(271); + goto case 259; } } - case 275: { - if (la == null) { currentState = 275; break; } + case 271: { + if (la == null) { currentState = 271; break; } Expect(113, la); // "End" - currentState = 276; + currentState = 272; break; } - case 276: { - if (la == null) { currentState = 276; break; } + case 272: { + if (la == null) { currentState = 272; break; } Expect(226, la); // "Using" currentState = stateStack.Pop(); break; } - case 277: { - if (la == null) { currentState = 277; break; } + case 273: { + if (la == null) { currentState = 273; break; } if (set[6].Get(la.kind)) { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(280); - goto case 206; + stateStack.Push(276); + goto case 205; } else { - goto case 278; + goto case 274; } } - case 278: { - stateStack.Push(279); - goto case 56; + case 274: { + stateStack.Push(275); + goto case 55; } - case 279: { + case 275: { if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; currentState = stateStack.Pop(); goto switchlbl; } - case 280: { + case 276: { nextTokenIsPotentialStartOfExpression = true; - goto case 281; + goto case 277; } - case 281: { - if (la == null) { currentState = 281; break; } + case 277: { + if (la == null) { currentState = 277; break; } if (set[42].Get(la.kind)) { PopContext(); isAlreadyInExpr = true; - goto case 282; - } else { goto case 278; + } else { + goto case 274; } } - case 282: { - if (la == null) { currentState = 282; break; } + case 278: { + if (la == null) { currentState = 278; break; } if (la.kind == 63) { - currentState = 284; + currentState = 280; break; } else { if (la.kind == 20) { - currentState = 278; + currentState = 274; break; } else { if (set[43].Get(la.kind)) { @@ -4848,127 +4809,127 @@ partial class ExpressionFinder { } else { Error(la); - goto case 278; + goto case 274; } } } } - case 283: { - if (la == null) { currentState = 283; break; } - currentState = 278; + case 279: { + if (la == null) { currentState = 279; break; } + currentState = 274; break; } - case 284: { + case 280: { nextTokenIsPotentialStartOfExpression = true; - goto case 285; + goto case 281; } - case 285: { - if (la == null) { currentState = 285; break; } + case 281: { + if (la == null) { currentState = 281; break; } if (set[16].Get(la.kind)) { PushContext(Context.Type, la, t); - stateStack.Push(286); + stateStack.Push(282); goto case 37; } else { - goto case 278; + goto case 274; } } - case 286: { + case 282: { PopContext(); - goto case 287; + goto case 283; } - case 287: { - if (la == null) { currentState = 287; break; } + case 283: { + if (la == null) { currentState = 283; break; } Expect(20, la); // "=" - currentState = 278; + currentState = 274; break; } - case 288: { - stateStack.Push(289); - goto case 56; + case 284: { + stateStack.Push(285); + goto case 55; } - case 289: { - if (la == null) { currentState = 289; break; } + case 285: { + if (la == null) { currentState = 285; break; } if (la.kind == 22) { - currentState = 288; + currentState = 284; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 290: { + case 286: { nextTokenIsPotentialStartOfExpression = true; - goto case 291; + goto case 287; } - case 291: { - if (la == null) { currentState = 291; break; } + case 287: { + if (la == null) { currentState = 287; break; } if (la.kind == 184) { - currentState = 56; + currentState = 55; break; } else { - goto case 56; + goto case 55; } } - case 292: { + case 288: { PushContext(Context.Expression, la, t); nextTokenIsPotentialStartOfExpression = true; - goto case 293; + goto case 289; } - case 293: { - if (la == null) { currentState = 293; break; } + case 289: { + if (la == null) { currentState = 289; break; } if (set[23].Get(la.kind)) { - stateStack.Push(294); - goto case 56; + stateStack.Push(290); + goto case 55; } else { - goto case 294; + goto case 290; } } - case 294: { + case 290: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 295: { - if (la == null) { currentState = 295; break; } + case 291: { + if (la == null) { currentState = 291; break; } if (la.kind == 108) { - goto case 133; + goto case 132; } else { if (la.kind == 124) { - goto case 130; + goto case 129; } else { if (la.kind == 231) { - goto case 104; + goto case 103; } else { goto case 6; } } } } - case 296: { - if (la == null) { currentState = 296; break; } + case 292: { + if (la == null) { currentState = 292; break; } if (la.kind == 108) { - goto case 133; + goto case 132; } else { if (la.kind == 124) { - goto case 130; + goto case 129; } else { if (la.kind == 231) { - goto case 104; + goto case 103; } else { if (la.kind == 197) { - goto case 116; + goto case 115; } else { if (la.kind == 210) { - goto case 112; + goto case 111; } else { if (la.kind == 127) { - goto case 128; + goto case 127; } else { if (la.kind == 186) { - goto case 117; + goto case 116; } else { if (la.kind == 218) { - goto case 108; + goto case 107; } else { goto case 6; } @@ -4980,166 +4941,166 @@ partial class ExpressionFinder { } } } - case 297: { - if (la == null) { currentState = 297; break; } + case 293: { + if (la == null) { currentState = 293; break; } if (set[6].Get(la.kind)) { - goto case 299; + goto case 295; } else { if (la.kind == 5) { - goto case 298; + goto case 294; } else { goto case 6; } } } - case 298: { - if (la == null) { currentState = 298; break; } + case 294: { + if (la == null) { currentState = 294; break; } currentState = stateStack.Pop(); break; } - case 299: { - if (la == null) { currentState = 299; break; } + case 295: { + if (la == null) { currentState = 295; break; } currentState = stateStack.Pop(); break; } - case 300: { - stateStack.Push(301); - goto case 263; + case 296: { + stateStack.Push(297); + goto case 259; } - case 301: { - if (la == null) { currentState = 301; break; } + case 297: { + if (la == null) { currentState = 297; break; } if (la.kind == 75) { - currentState = 305; + currentState = 301; break; } else { if (la.kind == 123) { - currentState = 304; + currentState = 300; break; } else { - goto case 302; + goto case 298; } } } - case 302: { - if (la == null) { currentState = 302; break; } + case 298: { + if (la == null) { currentState = 298; break; } Expect(113, la); // "End" - currentState = 303; + currentState = 299; break; } - case 303: { - if (la == null) { currentState = 303; break; } + case 299: { + if (la == null) { currentState = 299; break; } Expect(218, la); // "Try" currentState = stateStack.Pop(); break; } - case 304: { - stateStack.Push(302); - goto case 263; + case 300: { + stateStack.Push(298); + goto case 259; } - case 305: { + case 301: { SetIdentifierExpected(la); - goto case 306; + goto case 302; } - case 306: { - if (la == null) { currentState = 306; break; } + case 302: { + if (la == null) { currentState = 302; break; } if (set[6].Get(la.kind)) { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(309); - goto case 206; + stateStack.Push(305); + goto case 205; } else { - goto case 307; + goto case 303; } } - case 307: { - if (la == null) { currentState = 307; break; } + case 303: { + if (la == null) { currentState = 303; break; } if (la.kind == 229) { - currentState = 308; + currentState = 304; break; } else { - goto case 300; + goto case 296; } } - case 308: { - stateStack.Push(300); - goto case 56; + case 304: { + stateStack.Push(296); + goto case 55; } - case 309: { + case 305: { PopContext(); - goto case 310; + goto case 306; } - case 310: { - if (la == null) { currentState = 310; break; } + case 306: { + if (la == null) { currentState = 306; break; } if (la.kind == 63) { - currentState = 311; + currentState = 307; break; } else { - goto case 307; + goto case 303; } } - case 311: { + case 307: { PushContext(Context.Type, la, t); - stateStack.Push(312); + stateStack.Push(308); goto case 37; } - case 312: { + case 308: { PopContext(); - goto case 307; + goto case 303; } - case 313: { + case 309: { nextTokenIsPotentialStartOfExpression = true; - goto case 314; + goto case 310; } - case 314: { - if (la == null) { currentState = 314; break; } + case 310: { + if (la == null) { currentState = 310; break; } if (set[23].Get(la.kind)) { - goto case 56; + goto case 55; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 315: { - if (la == null) { currentState = 315; break; } + case 311: { + if (la == null) { currentState = 311; break; } if (la.kind == 163) { - goto case 121; + goto case 120; } else { - goto case 316; + goto case 312; } } - case 316: { - if (la == null) { currentState = 316; break; } + case 312: { + if (la == null) { currentState = 312; break; } if (la.kind == 5) { - goto case 298; + goto case 294; } else { if (set[6].Get(la.kind)) { - goto case 299; + goto case 295; } else { goto case 6; } } } - case 317: { - if (la == null) { currentState = 317; break; } + case 313: { + if (la == null) { currentState = 313; break; } Expect(118, la); // "Error" - currentState = 318; + currentState = 314; break; } - case 318: { + case 314: { nextTokenIsPotentialStartOfExpression = true; - goto case 319; + goto case 315; } - case 319: { - if (la == null) { currentState = 319; break; } + case 315: { + if (la == null) { currentState = 315; break; } if (set[23].Get(la.kind)) { - goto case 56; + goto case 55; } else { if (la.kind == 132) { - currentState = 316; + currentState = 312; break; } else { if (la.kind == 194) { - currentState = 320; + currentState = 316; break; } else { goto case 6; @@ -5147,109 +5108,109 @@ partial class ExpressionFinder { } } } - case 320: { - if (la == null) { currentState = 320; break; } + case 316: { + if (la == null) { currentState = 316; break; } Expect(163, la); // "Next" currentState = stateStack.Pop(); break; } - case 321: { + case 317: { nextTokenIsPotentialStartOfExpression = true; SetIdentifierExpected(la); - goto case 322; + goto case 318; } - case 322: { - if (la == null) { currentState = 322; break; } + case 318: { + if (la == null) { currentState = 318; break; } if (set[35].Get(la.kind)) { - stateStack.Push(338); - goto case 332; + stateStack.Push(334); + goto case 328; } else { if (la.kind == 110) { - currentState = 323; + currentState = 319; break; } else { goto case 6; } } } - case 323: { - stateStack.Push(324); - goto case 332; + case 319: { + stateStack.Push(320); + goto case 328; } - case 324: { - if (la == null) { currentState = 324; break; } + case 320: { + if (la == null) { currentState = 320; break; } Expect(138, la); // "In" - currentState = 325; + currentState = 321; break; } - case 325: { - stateStack.Push(326); - goto case 56; + case 321: { + stateStack.Push(322); + goto case 55; } - case 326: { - stateStack.Push(327); - goto case 263; + case 322: { + stateStack.Push(323); + goto case 259; } - case 327: { - if (la == null) { currentState = 327; break; } + case 323: { + if (la == null) { currentState = 323; break; } Expect(163, la); // "Next" - currentState = 328; + currentState = 324; break; } - case 328: { + case 324: { nextTokenIsPotentialStartOfExpression = true; - goto case 329; + goto case 325; } - case 329: { - if (la == null) { currentState = 329; break; } + case 325: { + if (la == null) { currentState = 325; break; } if (set[23].Get(la.kind)) { - goto case 330; + goto case 326; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 330: { - stateStack.Push(331); - goto case 56; + case 326: { + stateStack.Push(327); + goto case 55; } - case 331: { - if (la == null) { currentState = 331; break; } + case 327: { + if (la == null) { currentState = 327; break; } if (la.kind == 22) { - currentState = 330; + currentState = 326; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 332: { + case 328: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(333); - goto case 174; + stateStack.Push(329); + goto case 173; } - case 333: { + case 329: { PopContext(); - goto case 334; + goto case 330; } - case 334: { - if (la == null) { currentState = 334; break; } + case 330: { + if (la == null) { currentState = 330; break; } if (la.kind == 33) { - currentState = 335; + currentState = 331; break; } else { - goto case 335; + goto case 331; } } - case 335: { - if (la == null) { currentState = 335; break; } + case 331: { + if (la == null) { currentState = 331; break; } if (set[32].Get(la.kind)) { - stateStack.Push(335); - goto case 161; + stateStack.Push(331); + goto case 160; } else { if (la.kind == 63) { - currentState = 336; + currentState = 332; break; } else { currentState = stateStack.Pop(); @@ -5257,260 +5218,260 @@ partial class ExpressionFinder { } } } - case 336: { + case 332: { PushContext(Context.Type, la, t); - stateStack.Push(337); + stateStack.Push(333); goto case 37; } - case 337: { + case 333: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 338: { - if (la == null) { currentState = 338; break; } + case 334: { + if (la == null) { currentState = 334; break; } Expect(20, la); // "=" - currentState = 339; + currentState = 335; break; } - case 339: { - stateStack.Push(340); - goto case 56; + case 335: { + stateStack.Push(336); + goto case 55; } - case 340: { - if (la == null) { currentState = 340; break; } + case 336: { + if (la == null) { currentState = 336; break; } if (la.kind == 205) { - currentState = 347; + currentState = 343; break; } else { - goto case 341; + goto case 337; } } - case 341: { - stateStack.Push(342); - goto case 263; + case 337: { + stateStack.Push(338); + goto case 259; } - case 342: { - if (la == null) { currentState = 342; break; } + case 338: { + if (la == null) { currentState = 338; break; } Expect(163, la); // "Next" - currentState = 343; + currentState = 339; break; } - case 343: { + case 339: { nextTokenIsPotentialStartOfExpression = true; - goto case 344; + goto case 340; } - case 344: { - if (la == null) { currentState = 344; break; } + case 340: { + if (la == null) { currentState = 340; break; } if (set[23].Get(la.kind)) { - goto case 345; + goto case 341; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 345: { - stateStack.Push(346); - goto case 56; + case 341: { + stateStack.Push(342); + goto case 55; } - case 346: { - if (la == null) { currentState = 346; break; } + case 342: { + if (la == null) { currentState = 342; break; } if (la.kind == 22) { - currentState = 345; + currentState = 341; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 347: { - stateStack.Push(341); - goto case 56; + case 343: { + stateStack.Push(337); + goto case 55; } - case 348: { - if (la == null) { currentState = 348; break; } + case 344: { + if (la == null) { currentState = 344; break; } if (la.kind == 224 || la.kind == 231) { - currentState = 351; + currentState = 347; break; } else { if (la.kind == 1 || la.kind == 21) { - stateStack.Push(349); - goto case 263; + stateStack.Push(345); + goto case 259; } else { goto case 6; } } } - case 349: { - if (la == null) { currentState = 349; break; } + case 345: { + if (la == null) { currentState = 345; break; } Expect(152, la); // "Loop" - currentState = 350; + currentState = 346; break; } - case 350: { - if (la == null) { currentState = 350; break; } + case 346: { + if (la == null) { currentState = 346; break; } if (la.kind == 224 || la.kind == 231) { - currentState = 56; + currentState = 55; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 351: { - stateStack.Push(352); - goto case 56; + case 347: { + stateStack.Push(348); + goto case 55; } - case 352: { - stateStack.Push(353); - goto case 263; + case 348: { + stateStack.Push(349); + goto case 259; } - case 353: { - if (la == null) { currentState = 353; break; } + case 349: { + if (la == null) { currentState = 349; break; } Expect(152, la); // "Loop" currentState = stateStack.Pop(); break; } - case 354: { - stateStack.Push(355); - goto case 56; + case 350: { + stateStack.Push(351); + goto case 55; } - case 355: { - stateStack.Push(356); - goto case 263; + case 351: { + stateStack.Push(352); + goto case 259; } - case 356: { - if (la == null) { currentState = 356; break; } + case 352: { + if (la == null) { currentState = 352; break; } Expect(113, la); // "End" - currentState = 357; + currentState = 353; break; } - case 357: { - if (la == null) { currentState = 357; break; } + case 353: { + if (la == null) { currentState = 353; break; } Expect(231, la); // "While" currentState = stateStack.Pop(); break; } - case 358: { + case 354: { nextTokenIsPotentialStartOfExpression = true; - goto case 359; + goto case 355; } - case 359: { - if (la == null) { currentState = 359; break; } + case 355: { + if (la == null) { currentState = 355; break; } if (la.kind == 74) { - currentState = 360; + currentState = 356; break; } else { - goto case 360; + goto case 356; } } - case 360: { - stateStack.Push(361); - goto case 56; + case 356: { + stateStack.Push(357); + goto case 55; } - case 361: { - stateStack.Push(362); + case 357: { + stateStack.Push(358); goto case 23; } - case 362: { - if (la == null) { currentState = 362; break; } + case 358: { + if (la == null) { currentState = 358; break; } if (la.kind == 74) { - currentState = 364; + currentState = 360; break; } else { Expect(113, la); // "End" - currentState = 363; + currentState = 359; break; } } - case 363: { - if (la == null) { currentState = 363; break; } + case 359: { + if (la == null) { currentState = 359; break; } Expect(197, la); // "Select" currentState = stateStack.Pop(); break; } - case 364: { + case 360: { nextTokenIsPotentialStartOfExpression = true; - goto case 365; + goto case 361; } - case 365: { - if (la == null) { currentState = 365; break; } + case 361: { + if (la == null) { currentState = 361; break; } if (la.kind == 111) { - currentState = 366; + currentState = 362; break; } else { - if (set[68].Get(la.kind)) { - goto case 367; + if (set[67].Get(la.kind)) { + goto case 363; } else { Error(la); - goto case 366; + goto case 362; } } } - case 366: { - stateStack.Push(362); - goto case 263; + case 362: { + stateStack.Push(358); + goto case 259; } - case 367: { + case 363: { nextTokenIsPotentialStartOfExpression = true; - goto case 368; + goto case 364; } - case 368: { - if (la == null) { currentState = 368; break; } - if (set[142].Get(la.kind)) { + case 364: { + if (la == null) { currentState = 364; break; } + if (set[141].Get(la.kind)) { if (la.kind == 144) { - currentState = 370; + currentState = 366; break; } else { - goto case 370; + goto case 366; } } else { if (set[23].Get(la.kind)) { - stateStack.Push(369); - goto case 56; + stateStack.Push(365); + goto case 55; } else { Error(la); - goto case 369; + goto case 365; } } } - case 369: { - if (la == null) { currentState = 369; break; } + case 365: { + if (la == null) { currentState = 365; break; } if (la.kind == 22) { - currentState = 367; + currentState = 363; break; } else { - goto case 366; + goto case 362; } } - case 370: { - stateStack.Push(371); - goto case 372; + case 366: { + stateStack.Push(367); + goto case 368; } - case 371: { - stateStack.Push(369); - goto case 76; + case 367: { + stateStack.Push(365); + goto case 75; } - case 372: { - if (la == null) { currentState = 372; break; } + case 368: { + if (la == null) { currentState = 368; break; } if (la.kind == 20) { - goto case 74; + goto case 73; } else { if (la.kind == 41) { - goto case 73; + goto case 72; } else { if (la.kind == 40) { - goto case 72; + goto case 71; } else { if (la.kind == 39) { - currentState = 373; + currentState = 369; break; } else { if (la.kind == 42) { - goto case 69; + goto case 68; } else { if (la.kind == 43) { - goto case 70; + goto case 69; } else { goto case 6; } @@ -5520,109 +5481,109 @@ partial class ExpressionFinder { } } } - case 373: { + case 369: { wasNormalAttribute = false; currentState = stateStack.Pop(); goto switchlbl; } - case 374: { - stateStack.Push(375); - goto case 56; + case 370: { + stateStack.Push(371); + goto case 55; } - case 375: { - if (la == null) { currentState = 375; break; } + case 371: { + if (la == null) { currentState = 371; break; } if (la.kind == 214) { - currentState = 383; + currentState = 379; break; } else { - goto case 376; + goto case 372; } } - case 376: { - if (la == null) { currentState = 376; break; } + case 372: { + if (la == null) { currentState = 372; break; } if (la.kind == 1 || la.kind == 21) { - goto case 377; + goto case 373; } else { goto case 6; } } - case 377: { - stateStack.Push(378); - goto case 263; + case 373: { + stateStack.Push(374); + goto case 259; } - case 378: { - if (la == null) { currentState = 378; break; } + case 374: { + if (la == null) { currentState = 374; break; } if (la.kind == 111 || la.kind == 112) { if (la.kind == 111) { - currentState = 382; + currentState = 378; break; } else { if (la.kind == 112) { - currentState = 380; + currentState = 376; break; } else { Error(la); - goto case 377; + goto case 373; } } } else { Expect(113, la); // "End" - currentState = 379; + currentState = 375; break; } } - case 379: { - if (la == null) { currentState = 379; break; } + case 375: { + if (la == null) { currentState = 375; break; } Expect(135, la); // "If" currentState = stateStack.Pop(); break; } - case 380: { - stateStack.Push(381); - goto case 56; + case 376: { + stateStack.Push(377); + goto case 55; } - case 381: { - if (la == null) { currentState = 381; break; } + case 377: { + if (la == null) { currentState = 377; break; } if (la.kind == 214) { - currentState = 377; + currentState = 373; break; } else { - goto case 377; + goto case 373; } } - case 382: { - if (la == null) { currentState = 382; break; } + case 378: { + if (la == null) { currentState = 378; break; } if (la.kind == 135) { - currentState = 380; + currentState = 376; break; } else { - goto case 377; + goto case 373; } } - case 383: { + case 379: { nextTokenIsPotentialStartOfExpression = true; - goto case 384; + goto case 380; } - case 384: { - if (la == null) { currentState = 384; break; } - if (set[51].Get(la.kind)) { - goto case 385; + case 380: { + if (la == null) { currentState = 380; break; } + if (set[50].Get(la.kind)) { + goto case 381; } else { - goto case 376; + goto case 372; } } - case 385: { - stateStack.Push(386); - goto case 271; + case 381: { + stateStack.Push(382); + goto case 267; } - case 386: { - if (la == null) { currentState = 386; break; } + case 382: { + if (la == null) { currentState = 382; break; } if (la.kind == 21) { - currentState = 390; + currentState = 386; break; } else { if (la.kind == 111) { - currentState = 387; + currentState = 383; break; } else { currentState = stateStack.Pop(); @@ -5630,23 +5591,49 @@ partial class ExpressionFinder { } } } - case 387: { + case 383: { nextTokenIsPotentialStartOfExpression = true; - goto case 388; + goto case 384; } - case 388: { - if (la == null) { currentState = 388; break; } - if (set[51].Get(la.kind)) { - stateStack.Push(389); - goto case 271; + case 384: { + if (la == null) { currentState = 384; break; } + if (set[50].Get(la.kind)) { + stateStack.Push(385); + goto case 267; + } else { + goto case 385; + } + } + case 385: { + if (la == null) { currentState = 385; break; } + if (la.kind == 21) { + currentState = 383; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 386: { + nextTokenIsPotentialStartOfExpression = true; + goto case 387; + } + case 387: { + if (la == null) { currentState = 387; break; } + if (set[50].Get(la.kind)) { + goto case 381; } else { - goto case 389; + goto case 382; } } + case 388: { + stateStack.Push(389); + goto case 101; + } case 389: { if (la == null) { currentState = 389; break; } - if (la.kind == 21) { - currentState = 387; + if (la.kind == 37) { + currentState = 390; break; } else { currentState = stateStack.Pop(); @@ -5654,90 +5641,96 @@ partial class ExpressionFinder { } } case 390: { + PushContext(Context.Expression, la, t); nextTokenIsPotentialStartOfExpression = true; goto case 391; } case 391: { if (la == null) { currentState = 391; break; } - if (set[51].Get(la.kind)) { - goto case 385; + if (set[21].Get(la.kind)) { + stateStack.Push(392); + goto case 47; } else { - goto case 386; + goto case 392; } } case 392: { - stateStack.Push(393); - goto case 102; + PopContext(); + goto case 46; } case 393: { - if (la == null) { currentState = 393; break; } - if (la.kind == 37) { - currentState = 46; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } + stateStack.Push(394); + goto case 55; } case 394: { - stateStack.Push(395); - goto case 56; - } - case 395: { - if (la == null) { currentState = 395; break; } + if (la == null) { currentState = 394; break; } Expect(22, la); // "," - currentState = 56; + currentState = 55; break; } + case 395: { + stateStack.Push(396); + goto case 55; + } case 396: { stateStack.Push(397); - goto case 56; + goto case 259; } case 397: { - stateStack.Push(398); - goto case 263; - } - case 398: { - if (la == null) { currentState = 398; break; } + if (la == null) { currentState = 397; break; } Expect(113, la); // "End" - currentState = 399; + currentState = 398; break; } - case 399: { - if (la == null) { currentState = 399; break; } + case 398: { + if (la == null) { currentState = 398; break; } if (la.kind == 233) { - goto case 103; + goto case 102; } else { if (la.kind == 211) { - goto case 111; + goto case 110; } else { goto case 6; } } } - case 400: { + case 399: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(401); - goto case 206; + stateStack.Push(400); + goto case 205; } - case 401: { + case 400: { PopContext(); - goto case 402; + goto case 401; + } + case 401: { + if (la == null) { currentState = 401; break; } + if (la.kind == 33) { + currentState = 402; + break; + } else { + goto case 402; + } } case 402: { if (la == null) { currentState = 402; break; } - if (la.kind == 33) { - currentState = 403; + if (la.kind == 37) { + currentState = 419; break; } else { - goto case 403; + if (la.kind == 63) { + currentState = 416; + break; + } else { + goto case 403; + } } } case 403: { if (la == null) { currentState = 403; break; } - if (la.kind == 37) { - currentState = 417; + if (la.kind == 20) { + currentState = 415; break; } else { goto case 404; @@ -5746,259 +5739,297 @@ partial class ExpressionFinder { case 404: { if (la == null) { currentState = 404; break; } if (la.kind == 22) { - currentState = 410; + currentState = 405; break; - } else { - if (la.kind == 63) { - currentState = 407; - break; - } else { - goto case 405; - } - } - } - case 405: { - if (la == null) { currentState = 405; break; } - if (la.kind == 20) { - goto case 406; } else { currentState = stateStack.Pop(); goto switchlbl; } } + case 405: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(406); + goto case 205; + } case 406: { - if (la == null) { currentState = 406; break; } - currentState = 56; - break; + PopContext(); + goto case 407; } case 407: { - PushContext(Context.Type, la, t); - goto case 408; + if (la == null) { currentState = 407; break; } + if (la.kind == 33) { + currentState = 408; + break; + } else { + goto case 408; + } } case 408: { if (la == null) { currentState = 408; break; } - if (la.kind == 162) { - stateStack.Push(409); - goto case 86; + if (la.kind == 37) { + currentState = 412; + break; } else { - if (set[16].Get(la.kind)) { - stateStack.Push(409); - goto case 37; + if (la.kind == 63) { + currentState = 409; + break; } else { - Error(la); - goto case 409; + goto case 403; } } } case 409: { - PopContext(); - goto case 405; + PushContext(Context.Type, la, t); + goto case 410; } case 410: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(411); - goto case 206; + if (la == null) { currentState = 410; break; } + if (la.kind == 162) { + stateStack.Push(411); + goto case 85; + } else { + if (set[16].Get(la.kind)) { + stateStack.Push(411); + goto case 37; + } else { + Error(la); + goto case 411; + } + } } case 411: { PopContext(); - goto case 412; + goto case 403; } case 412: { - if (la == null) { currentState = 412; break; } - if (la.kind == 33) { - currentState = 413; - break; - } else { - goto case 413; - } + nextTokenIsPotentialStartOfExpression = true; + goto case 413; } case 413: { if (la == null) { currentState = 413; break; } - if (la.kind == 37) { - currentState = 414; - break; - } else { - goto case 404; - } - } - case 414: { - nextTokenIsPotentialStartOfExpression = true; - goto case 415; - } - case 415: { - if (la == null) { currentState = 415; break; } if (set[23].Get(la.kind)) { - stateStack.Push(416); - goto case 56; + stateStack.Push(414); + goto case 55; } else { - goto case 416; + goto case 414; } } - case 416: { - if (la == null) { currentState = 416; break; } + case 414: { + if (la == null) { currentState = 414; break; } if (la.kind == 22) { - currentState = 414; + currentState = 412; break; } else { Expect(38, la); // ")" - currentState = 413; + currentState = 408; break; } } + case 415: { + stateStack.Push(404); + goto case 55; + } + case 416: { + PushContext(Context.Type, la, t); + goto case 417; + } case 417: { - nextTokenIsPotentialStartOfExpression = true; - goto case 418; + if (la == null) { currentState = 417; break; } + if (la.kind == 162) { + stateStack.Push(418); + goto case 85; + } else { + if (set[16].Get(la.kind)) { + stateStack.Push(418); + goto case 37; + } else { + Error(la); + goto case 418; + } + } } case 418: { - if (la == null) { currentState = 418; break; } + PopContext(); + goto case 403; + } + case 419: { + nextTokenIsPotentialStartOfExpression = true; + goto case 420; + } + case 420: { + if (la == null) { currentState = 420; break; } if (set[23].Get(la.kind)) { - stateStack.Push(419); - goto case 56; + stateStack.Push(421); + goto case 55; } else { - goto case 419; + goto case 421; } } - case 419: { - if (la == null) { currentState = 419; break; } + case 421: { + if (la == null) { currentState = 421; break; } if (la.kind == 22) { - currentState = 417; + currentState = 419; break; } else { Expect(38, la); // ")" - currentState = 403; + currentState = 402; break; } } - case 420: { + case 422: { PushContext(Context.Type, la, t); - stateStack.Push(421); + stateStack.Push(423); goto case 37; } - case 421: { + case 423: { PopContext(); - goto case 260; + goto case 256; } - case 422: { - stateStack.Push(423); + case 424: { + if (la == null) { currentState = 424; break; } + Expect(37, la); // "(" + currentState = 425; + break; + } + case 425: { + PushContext(Context.Default, la, t); + SetIdentifierExpected(la); + goto case 426; + } + case 426: { + if (la == null) { currentState = 426; break; } + if (set[77].Get(la.kind)) { + stateStack.Push(427); + goto case 428; + } else { + goto case 427; + } + } + case 427: { + PopContext(); + goto case 46; + } + case 428: { + stateStack.Push(429); PushContext(Context.Parameter, la, t); - goto case 424; + goto case 430; } - case 423: { - if (la == null) { currentState = 423; break; } + case 429: { + if (la == null) { currentState = 429; break; } if (la.kind == 22) { - currentState = 422; + currentState = 428; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 424: { + case 430: { SetIdentifierExpected(la); - goto case 425; + goto case 431; } - case 425: { - if (la == null) { currentState = 425; break; } + case 431: { + if (la == null) { currentState = 431; break; } if (la.kind == 40) { - stateStack.Push(424); - goto case 435; + stateStack.Push(430); + goto case 441; } else { - goto case 426; + goto case 432; } } - case 426: { + case 432: { SetIdentifierExpected(la); - goto case 427; + goto case 433; } - case 427: { - if (la == null) { currentState = 427; break; } - if (set[143].Get(la.kind)) { - currentState = 426; + case 433: { + if (la == null) { currentState = 433; break; } + if (set[142].Get(la.kind)) { + currentState = 432; break; } else { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(428); - goto case 206; + stateStack.Push(434); + goto case 205; } } - case 428: { + case 434: { PopContext(); - goto case 429; + goto case 435; } - case 429: { - if (la == null) { currentState = 429; break; } + case 435: { + if (la == null) { currentState = 435; break; } if (la.kind == 63) { - currentState = 433; + currentState = 439; break; } else { - goto case 430; + goto case 436; } } - case 430: { - if (la == null) { currentState = 430; break; } + case 436: { + if (la == null) { currentState = 436; break; } if (la.kind == 20) { - currentState = 432; + currentState = 438; break; } else { - goto case 431; + goto case 437; } } - case 431: { + case 437: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 432: { - stateStack.Push(431); - goto case 56; + case 438: { + stateStack.Push(437); + goto case 55; } - case 433: { + case 439: { PushContext(Context.Type, la, t); - stateStack.Push(434); + stateStack.Push(440); goto case 37; } - case 434: { + case 440: { PopContext(); - goto case 430; + goto case 436; } - case 435: { - if (la == null) { currentState = 435; break; } + case 441: { + if (la == null) { currentState = 441; break; } Expect(40, la); // "<" - currentState = 436; + currentState = 442; break; } - case 436: { + case 442: { wasNormalAttribute = true; PushContext(Context.Attribute, la, t); - goto case 437; + goto case 443; } - case 437: { - if (la == null) { currentState = 437; break; } + case 443: { + if (la == null) { currentState = 443; break; } if (la.kind == 65 || la.kind == 155) { - currentState = 441; + currentState = 447; break; } else { - goto case 438; + goto case 444; } } - case 438: { - if (la == null) { currentState = 438; break; } - if (set[144].Get(la.kind)) { - currentState = 438; + case 444: { + if (la == null) { currentState = 444; break; } + if (set[143].Get(la.kind)) { + currentState = 444; break; } else { Expect(39, la); // ">" - currentState = 439; + currentState = 445; break; } } - case 439: { + case 445: { PopContext(); - goto case 440; + goto case 446; } - case 440: { - if (la == null) { currentState = 440; break; } + case 446: { + if (la == null) { currentState = 446; break; } if (la.kind == 1) { goto case 25; } else { @@ -6006,537 +6037,535 @@ partial class ExpressionFinder { goto switchlbl; } } - case 441: { - if (la == null) { currentState = 441; break; } + case 447: { + if (la == null) { currentState = 447; break; } Expect(21, la); // ":" - currentState = 442; + currentState = 448; break; } - case 442: { + case 448: { wasNormalAttribute = false; - goto case 438; - } - case 443: { - if (la == null) { currentState = 443; break; } - Expect(37, la); // "(" - currentState = 444; - break; - } - case 444: { - SetIdentifierExpected(la); - goto case 445; - } - case 445: { - if (la == null) { currentState = 445; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(446); - goto case 422; - } else { - goto case 446; - } + goto case 444; } - case 446: { - if (la == null) { currentState = 446; break; } - Expect(38, la); // ")" - currentState = 447; - break; + case 449: { + stateStack.Push(450); + goto case 424; } - case 447: { + case 450: { nextTokenIsPotentialStartOfExpression = true; - goto case 448; + goto case 451; } - case 448: { - if (la == null) { currentState = 448; break; } - if (set[51].Get(la.kind)) { - goto case 271; + case 451: { + if (la == null) { currentState = 451; break; } + if (set[50].Get(la.kind)) { + goto case 267; } else { if (la.kind == 1 || la.kind == 21) { - stateStack.Push(449); - goto case 263; + stateStack.Push(452); + goto case 259; } else { goto case 6; } } } - case 449: { - if (la == null) { currentState = 449; break; } + case 452: { + if (la == null) { currentState = 452; break; } Expect(113, la); // "End" - currentState = 450; + currentState = 453; break; } - case 450: { - if (la == null) { currentState = 450; break; } + case 453: { + if (la == null) { currentState = 453; break; } Expect(210, la); // "Sub" currentState = stateStack.Pop(); break; } - case 451: { - if (la == null) { currentState = 451; break; } + case 454: { + if (la == null) { currentState = 454; break; } if (la.kind == 17 || la.kind == 18 || la.kind == 19) { - currentState = 464; + currentState = 467; break; } else { if (la.kind == 10) { - stateStack.Push(453); - goto case 455; + stateStack.Push(456); + goto case 458; } else { Error(la); - goto case 452; + goto case 455; } } } - case 452: { + case 455: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 453: { - if (la == null) { currentState = 453; break; } + case 456: { + if (la == null) { currentState = 456; break; } if (la.kind == 17) { - currentState = 454; + currentState = 457; break; } else { - goto case 452; + goto case 455; } } - case 454: { - if (la == null) { currentState = 454; break; } + case 457: { + if (la == null) { currentState = 457; break; } if (la.kind == 16) { - currentState = 453; + currentState = 456; break; } else { - goto case 453; + goto case 456; } } - case 455: { + case 458: { PushContext(Context.Xml, la, t); - goto case 456; + goto case 459; } - case 456: { - if (la == null) { currentState = 456; break; } + case 459: { + if (la == null) { currentState = 459; break; } Expect(10, la); // XmlOpenTag - currentState = 457; + currentState = 460; break; } - case 457: { - if (la == null) { currentState = 457; break; } - if (set[145].Get(la.kind)) { - if (set[146].Get(la.kind)) { - currentState = 457; + case 460: { + if (la == null) { currentState = 460; break; } + if (set[144].Get(la.kind)) { + if (set[145].Get(la.kind)) { + currentState = 460; break; } else { if (la.kind == 12) { - stateStack.Push(457); - goto case 461; + stateStack.Push(460); + goto case 464; } else { Error(la); - goto case 457; + goto case 460; } } } else { if (la.kind == 14) { - currentState = 458; + currentState = 461; break; } else { if (la.kind == 11) { - currentState = 459; + currentState = 462; break; } else { Error(la); - goto case 458; + goto case 461; } } } } - case 458: { + case 461: { PopContext(); currentState = stateStack.Pop(); goto switchlbl; } - case 459: { - if (la == null) { currentState = 459; break; } - if (set[147].Get(la.kind)) { - if (set[148].Get(la.kind)) { - currentState = 459; + case 462: { + if (la == null) { currentState = 462; break; } + if (set[146].Get(la.kind)) { + if (set[147].Get(la.kind)) { + currentState = 462; break; } else { if (la.kind == 12) { - stateStack.Push(459); - goto case 461; + stateStack.Push(462); + goto case 464; } else { if (la.kind == 10) { - stateStack.Push(459); - goto case 455; + stateStack.Push(462); + goto case 458; } else { Error(la); - goto case 459; + goto case 462; } } } } else { Expect(15, la); // XmlOpenEndTag - currentState = 460; + currentState = 463; break; } } - case 460: { - if (la == null) { currentState = 460; break; } - if (set[149].Get(la.kind)) { - if (set[150].Get(la.kind)) { - currentState = 460; + case 463: { + if (la == null) { currentState = 463; break; } + if (set[148].Get(la.kind)) { + if (set[149].Get(la.kind)) { + currentState = 463; break; } else { if (la.kind == 12) { - stateStack.Push(460); - goto case 461; + stateStack.Push(463); + goto case 464; } else { Error(la); - goto case 460; + goto case 463; } } } else { Expect(11, la); // XmlCloseTag - currentState = 458; + currentState = 461; break; } } - case 461: { - if (la == null) { currentState = 461; break; } + case 464: { + if (la == null) { currentState = 464; break; } Expect(12, la); // XmlStartInlineVB - currentState = 462; + currentState = 465; break; } - case 462: { - stateStack.Push(463); - goto case 56; + case 465: { + stateStack.Push(466); + goto case 55; } - case 463: { - if (la == null) { currentState = 463; break; } + case 466: { + if (la == null) { currentState = 466; break; } Expect(13, la); // XmlEndInlineVB currentState = stateStack.Pop(); break; } - case 464: { - if (la == null) { currentState = 464; break; } + case 467: { + if (la == null) { currentState = 467; break; } if (la.kind == 16) { - currentState = 465; + currentState = 468; break; } else { - goto case 465; + goto case 468; } } - case 465: { - if (la == null) { currentState = 465; break; } + case 468: { + if (la == null) { currentState = 468; break; } if (la.kind == 17 || la.kind == 19) { - currentState = 464; + currentState = 467; break; } else { if (la.kind == 10) { - stateStack.Push(466); - goto case 455; + stateStack.Push(469); + goto case 458; } else { - goto case 452; + goto case 455; } } } - case 466: { - if (la == null) { currentState = 466; break; } + case 469: { + if (la == null) { currentState = 469; break; } if (la.kind == 17) { - currentState = 467; + currentState = 470; break; } else { - goto case 452; + goto case 455; } } - case 467: { - if (la == null) { currentState = 467; break; } + case 470: { + if (la == null) { currentState = 470; break; } if (la.kind == 16) { - currentState = 466; + currentState = 469; break; } else { - goto case 466; + goto case 469; } } - case 468: { - if (la == null) { currentState = 468; break; } + case 471: { + if (la == null) { currentState = 471; break; } Expect(37, la); // "(" - currentState = 469; + currentState = 472; break; } - case 469: { + case 472: { readXmlIdentifier = true; - stateStack.Push(470); - goto case 206; + stateStack.Push(473); + goto case 205; } - case 470: { - if (la == null) { currentState = 470; break; } + case 473: { + if (la == null) { currentState = 473; break; } Expect(38, la); // ")" - currentState = 176; + currentState = 175; break; } - case 471: { - if (la == null) { currentState = 471; break; } + case 474: { + if (la == null) { currentState = 474; break; } Expect(37, la); // "(" - currentState = 472; + currentState = 475; break; } - case 472: { + case 475: { PushContext(Context.Type, la, t); - stateStack.Push(473); + stateStack.Push(476); goto case 37; } - case 473: { + case 476: { PopContext(); - goto case 470; + goto case 473; } - case 474: { + case 477: { nextTokenIsStartOfImportsOrAccessExpression = true; wasQualifierTokenAtStart = true; - goto case 475; + goto case 478; } - case 475: { - if (la == null) { currentState = 475; break; } + case 478: { + if (la == null) { currentState = 478; break; } if (la.kind == 10) { - currentState = 476; - break; - } else { - goto case 476; - } - } - case 476: { - stateStack.Push(477); - goto case 102; - } - case 477: { - if (la == null) { currentState = 477; break; } - if (la.kind == 11) { - currentState = 176; + currentState = 479; break; } else { - goto case 176; + goto case 479; } } - case 478: { - activeArgument = 0; - goto case 479; - } case 479: { stateStack.Push(480); - goto case 56; + goto case 101; } case 480: { if (la == null) { currentState = 480; break; } - if (la.kind == 22) { - currentState = 481; + if (la.kind == 11) { + currentState = 175; break; } else { - goto case 470; + goto case 175; } } case 481: { - activeArgument++; - goto case 479; + activeArgument = 0; + goto case 482; } case 482: { stateStack.Push(483); - goto case 56; + goto case 55; } case 483: { if (la == null) { currentState = 483; break; } if (la.kind == 22) { currentState = 484; break; + } else { + goto case 473; + } + } + case 484: { + activeArgument++; + goto case 482; + } + case 485: { + stateStack.Push(486); + goto case 55; + } + case 486: { + if (la == null) { currentState = 486; break; } + if (la.kind == 22) { + currentState = 487; + break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 484: { + case 487: { activeArgument++; nextTokenIsPotentialStartOfExpression = true; - goto case 485; + goto case 488; } - case 485: { - if (la == null) { currentState = 485; break; } + case 488: { + if (la == null) { currentState = 488; break; } if (set[23].Get(la.kind)) { - goto case 482; + goto case 485; } else { - goto case 483; + goto case 486; } } - case 486: { - if (la == null) { currentState = 486; break; } + case 489: { + if (la == null) { currentState = 489; break; } if (set[16].Get(la.kind)) { - stateStack.Push(487); + PushContext(Context.Type, la, t); + stateStack.Push(493); goto case 37; } else { - goto case 487; + goto case 490; } } - case 487: { - if (la == null) { currentState = 487; break; } + case 490: { + if (la == null) { currentState = 490; break; } if (la.kind == 22) { - currentState = 486; + currentState = 491; break; } else { goto case 45; } } - case 488: { + case 491: { + if (la == null) { currentState = 491; break; } + if (set[16].Get(la.kind)) { + PushContext(Context.Type, la, t); + stateStack.Push(492); + goto case 37; + } else { + goto case 490; + } + } + case 492: { + PopContext(); + goto case 490; + } + case 493: { + PopContext(); + goto case 490; + } + case 494: { SetIdentifierExpected(la); - goto case 489; + goto case 495; } - case 489: { - if (la == null) { currentState = 489; break; } - if (set[151].Get(la.kind)) { + case 495: { + if (la == null) { currentState = 495; break; } + if (set[150].Get(la.kind)) { if (la.kind == 169) { - currentState = 491; + currentState = 497; break; } else { - if (set[78].Get(la.kind)) { - stateStack.Push(490); - goto case 422; + if (set[77].Get(la.kind)) { + stateStack.Push(496); + goto case 428; } else { Error(la); - goto case 490; + goto case 496; } } } else { - goto case 490; + goto case 496; } } - case 490: { - if (la == null) { currentState = 490; break; } + case 496: { + if (la == null) { currentState = 496; break; } Expect(38, la); // ")" currentState = 34; break; } - case 491: { - stateStack.Push(490); - goto case 492; + case 497: { + stateStack.Push(496); + goto case 498; } - case 492: { + case 498: { SetIdentifierExpected(la); - goto case 493; + goto case 499; } - case 493: { - if (la == null) { currentState = 493; break; } + case 499: { + if (la == null) { currentState = 499; break; } if (la.kind == 138 || la.kind == 178) { - currentState = 494; + currentState = 500; break; } else { - goto case 494; + goto case 500; } } - case 494: { + case 500: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(495); - goto case 509; + stateStack.Push(501); + goto case 515; } - case 495: { + case 501: { PopContext(); - goto case 496; + goto case 502; } - case 496: { - if (la == null) { currentState = 496; break; } + case 502: { + if (la == null) { currentState = 502; break; } if (la.kind == 63) { - currentState = 510; + currentState = 516; break; } else { - goto case 497; + goto case 503; } } - case 497: { - if (la == null) { currentState = 497; break; } + case 503: { + if (la == null) { currentState = 503; break; } if (la.kind == 22) { - currentState = 498; + currentState = 504; break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 498: { + case 504: { SetIdentifierExpected(la); - goto case 499; + goto case 505; } - case 499: { - if (la == null) { currentState = 499; break; } + case 505: { + if (la == null) { currentState = 505; break; } if (la.kind == 138 || la.kind == 178) { - currentState = 500; + currentState = 506; break; } else { - goto case 500; + goto case 506; } } - case 500: { + case 506: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(501); - goto case 509; + stateStack.Push(507); + goto case 515; } - case 501: { + case 507: { PopContext(); - goto case 502; + goto case 508; } - case 502: { - if (la == null) { currentState = 502; break; } + case 508: { + if (la == null) { currentState = 508; break; } if (la.kind == 63) { - currentState = 503; + currentState = 509; break; } else { - goto case 497; + goto case 503; } } - case 503: { + case 509: { PushContext(Context.Type, la, t); - stateStack.Push(504); - goto case 505; + stateStack.Push(510); + goto case 511; } - case 504: { + case 510: { PopContext(); - goto case 497; + goto case 503; } - case 505: { - if (la == null) { currentState = 505; break; } - if (set[94].Get(la.kind)) { - goto case 508; + case 511: { + if (la == null) { currentState = 511; break; } + if (set[93].Get(la.kind)) { + goto case 514; } else { if (la.kind == 35) { - currentState = 506; + currentState = 512; break; } else { goto case 6; } } } - case 506: { - stateStack.Push(507); - goto case 508; + case 512: { + stateStack.Push(513); + goto case 514; } - case 507: { - if (la == null) { currentState = 507; break; } + case 513: { + if (la == null) { currentState = 513; break; } if (la.kind == 22) { - currentState = 506; + currentState = 512; break; } else { - goto case 83; + goto case 82; } } - case 508: { - if (la == null) { currentState = 508; break; } + case 514: { + if (la == null) { currentState = 514; break; } if (set[16].Get(la.kind)) { currentState = 38; break; } else { if (la.kind == 162) { - goto case 122; + goto case 121; } else { if (la.kind == 84) { - goto case 138; + goto case 137; } else { if (la.kind == 209) { - goto case 113; + goto case 112; } else { goto case 6; } @@ -6544,85 +6573,85 @@ partial class ExpressionFinder { } } } - case 509: { - if (la == null) { currentState = 509; break; } + case 515: { + if (la == null) { currentState = 515; break; } if (la.kind == 2) { - goto case 146; + goto case 145; } else { if (la.kind == 62) { - goto case 144; + goto case 143; } else { if (la.kind == 64) { - goto case 143; + goto case 142; } else { if (la.kind == 65) { - goto case 142; + goto case 141; } else { if (la.kind == 66) { - goto case 141; + goto case 140; } else { if (la.kind == 67) { - goto case 140; + goto case 139; } else { if (la.kind == 70) { - goto case 139; + goto case 138; } else { if (la.kind == 87) { - goto case 137; + goto case 136; } else { if (la.kind == 104) { - goto case 135; + goto case 134; } else { if (la.kind == 107) { - goto case 134; + goto case 133; } else { if (la.kind == 116) { - goto case 132; + goto case 131; } else { if (la.kind == 121) { - goto case 131; + goto case 130; } else { if (la.kind == 133) { - goto case 127; + goto case 126; } else { if (la.kind == 139) { - goto case 126; + goto case 125; } else { if (la.kind == 143) { - goto case 125; + goto case 124; } else { if (la.kind == 146) { - goto case 124; + goto case 123; } else { if (la.kind == 147) { - goto case 123; + goto case 122; } else { if (la.kind == 170) { - goto case 120; + goto case 119; } else { if (la.kind == 176) { - goto case 119; + goto case 118; } else { if (la.kind == 184) { - goto case 118; + goto case 117; } else { if (la.kind == 203) { - goto case 115; + goto case 114; } else { if (la.kind == 212) { - goto case 110; + goto case 109; } else { if (la.kind == 213) { - goto case 109; + goto case 108; } else { if (la.kind == 223) { - goto case 107; + goto case 106; } else { if (la.kind == 224) { - goto case 106; + goto case 105; } else { if (la.kind == 230) { - goto case 105; + goto case 104; } else { goto case 6; } @@ -6652,131 +6681,93 @@ partial class ExpressionFinder { } } } - case 510: { + case 516: { PushContext(Context.Type, la, t); - stateStack.Push(511); - goto case 505; + stateStack.Push(517); + goto case 511; } - case 511: { + case 517: { PopContext(); - goto case 497; + goto case 503; } - case 512: { + case 518: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(513); - goto case 206; + stateStack.Push(519); + goto case 205; } - case 513: { + case 519: { PopContext(); - goto case 514; + goto case 520; } - case 514: { - if (la == null) { currentState = 514; break; } + case 520: { + if (la == null) { currentState = 520; break; } if (la.kind == 37) { - currentState = 519; - break; + stateStack.Push(521); + goto case 424; } else { - goto case 515; + goto case 521; } } - case 515: { - if (la == null) { currentState = 515; break; } + case 521: { + if (la == null) { currentState = 521; break; } if (la.kind == 63) { - currentState = 516; + currentState = 522; break; } else { goto case 23; } } - case 516: { + case 522: { PushContext(Context.Type, la, t); - goto case 517; + goto case 523; } - case 517: { - if (la == null) { currentState = 517; break; } + case 523: { + if (la == null) { currentState = 523; break; } if (la.kind == 40) { - stateStack.Push(517); - goto case 435; + stateStack.Push(523); + goto case 441; } else { - stateStack.Push(518); + stateStack.Push(524); goto case 37; } } - case 518: { + case 524: { PopContext(); goto case 23; } - case 519: { - SetIdentifierExpected(la); - goto case 520; - } - case 520: { - if (la == null) { currentState = 520; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(521); - goto case 422; - } else { - goto case 521; - } - } - case 521: { - if (la == null) { currentState = 521; break; } - Expect(38, la); // ")" - currentState = 515; - break; - } - case 522: { + case 525: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(523); - goto case 206; + stateStack.Push(526); + goto case 205; } - case 523: { + case 526: { PopContext(); - goto case 524; + goto case 527; } - case 524: { - if (la == null) { currentState = 524; break; } + case 527: { + if (la == null) { currentState = 527; break; } if (la.kind == 37 || la.kind == 63) { if (la.kind == 63) { currentState = 529; break; } else { if (la.kind == 37) { - currentState = 526; - break; + stateStack.Push(23); + goto case 424; } else { - goto case 525; + goto case 528; } } } else { goto case 23; } } - case 525: { + case 528: { Error(la); goto case 23; } - case 526: { - SetIdentifierExpected(la); - goto case 527; - } - case 527: { - if (la == null) { currentState = 527; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(528); - goto case 422; - } else { - goto case 528; - } - } - case 528: { - if (la == null) { currentState = 528; break; } - Expect(38, la); // ")" - currentState = 23; - break; - } case 529: { PushContext(Context.Type, la, t); stateStack.Push(530); @@ -6800,7 +6791,7 @@ partial class ExpressionFinder { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); stateStack.Push(534); - goto case 206; + goto case 205; } case 534: { PopContext(); @@ -6825,7 +6816,7 @@ partial class ExpressionFinder { } case 538: { if (la == null) { currentState = 538; break; } - if (set[97].Get(la.kind)) { + if (set[96].Get(la.kind)) { goto case 542; } else { Expect(113, la); // "End" @@ -6856,12 +6847,12 @@ partial class ExpressionFinder { if (la == null) { currentState = 543; break; } if (la.kind == 40) { stateStack.Push(542); - goto case 435; + goto case 441; } else { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); stateStack.Push(544); - goto case 206; + goto case 205; } } case 544: { @@ -6879,7 +6870,7 @@ partial class ExpressionFinder { } case 546: { stateStack.Push(536); - goto case 56; + goto case 55; } case 547: { PushContext(Context.Type, la, t); @@ -6954,14 +6945,14 @@ partial class ExpressionFinder { } case 558: { if (la == null) { currentState = 558; break; } - if (set[151].Get(la.kind)) { + if (set[150].Get(la.kind)) { if (la.kind == 169) { currentState = 560; break; } else { - if (set[78].Get(la.kind)) { + if (set[77].Get(la.kind)) { stateStack.Push(559); - goto case 422; + goto case 428; } else { Error(la); goto case 559; @@ -6979,7 +6970,7 @@ partial class ExpressionFinder { } case 560: { stateStack.Push(559); - goto case 492; + goto case 498; } case 561: { PushContext(Context.TypeDeclaration, la, t); @@ -7009,7 +7000,7 @@ partial class ExpressionFinder { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); stateStack.Push(564); - goto case 206; + goto case 205; } case 564: { PopContext(); @@ -7018,7 +7009,7 @@ partial class ExpressionFinder { case 565: { if (la == null) { currentState = 565; break; } if (la.kind == 37) { - currentState = 729; + currentState = 715; break; } else { goto case 566; @@ -7037,7 +7028,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 568; break; } if (la.kind == 140) { isMissingModifier = false; - goto case 726; + goto case 712; } else { goto case 569; } @@ -7051,7 +7042,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 570; break; } if (la.kind == 136) { isMissingModifier = false; - goto case 720; + goto case 706; } else { goto case 571; } @@ -7063,7 +7054,7 @@ partial class ExpressionFinder { } case 572: { if (la == null) { currentState = 572; break; } - if (set[101].Get(la.kind)) { + if (set[100].Get(la.kind)) { goto case 577; } else { isMissingModifier = false; @@ -7114,7 +7105,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 578; break; } if (la.kind == 40) { stateStack.Push(577); - goto case 435; + goto case 441; } else { isMissingModifier = true; goto case 579; @@ -7126,8 +7117,8 @@ partial class ExpressionFinder { } case 580: { if (la == null) { currentState = 580; break; } - if (set[132].Get(la.kind)) { - currentState = 719; + if (set[131].Get(la.kind)) { + currentState = 705; break; } else { isMissingModifier = false; @@ -7153,7 +7144,7 @@ partial class ExpressionFinder { stateStack.Push(571); goto case 9; } else { - if (set[104].Get(la.kind)) { + if (set[103].Get(la.kind)) { stateStack.Push(571); PushContext(Context.Member, la, t); SetIdentifierExpected(la); @@ -7169,25 +7160,25 @@ partial class ExpressionFinder { } case 582: { if (la == null) { currentState = 582; break; } - if (set[122].Get(la.kind)) { + if (set[121].Get(la.kind)) { stateStack.Push(583); - goto case 704; + goto case 690; } else { if (la.kind == 127 || la.kind == 210) { stateStack.Push(583); - goto case 686; + goto case 672; } else { if (la.kind == 101) { stateStack.Push(583); - goto case 670; + goto case 659; } else { if (la.kind == 119) { stateStack.Push(583); - goto case 655; + goto case 647; } else { if (la.kind == 98) { stateStack.Push(583); - goto case 643; + goto case 635; } else { if (la.kind == 186) { stateStack.Push(583); @@ -7240,7 +7231,7 @@ partial class ExpressionFinder { } case 589: { stateStack.Push(590); - goto case 422; + goto case 428; } case 590: { if (la == null) { currentState = 590; break; } @@ -7259,7 +7250,7 @@ partial class ExpressionFinder { } case 592: { stateStack.Push(593); - goto case 263; + goto case 259; } case 593: { if (la == null) { currentState = 593; break; } @@ -7281,7 +7272,7 @@ partial class ExpressionFinder { if (la == null) { currentState = 596; break; } if (la.kind == 40) { stateStack.Push(596); - goto case 435; + goto case 441; } else { stateStack.Push(597); goto case 37; @@ -7301,7 +7292,7 @@ partial class ExpressionFinder { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); stateStack.Push(600); - goto case 206; + goto case 205; } case 600: { PopContext(); @@ -7310,8 +7301,8 @@ partial class ExpressionFinder { case 601: { if (la == null) { currentState = 601; break; } if (la.kind == 37) { - currentState = 640; - break; + stateStack.Push(602); + goto case 424; } else { goto case 602; } @@ -7319,7 +7310,7 @@ partial class ExpressionFinder { case 602: { if (la == null) { currentState = 602; break; } if (la.kind == 63) { - currentState = 638; + currentState = 632; break; } else { goto case 603; @@ -7328,7 +7319,7 @@ partial class ExpressionFinder { case 603: { if (la == null) { currentState = 603; break; } if (la.kind == 136) { - currentState = 633; + currentState = 627; break; } else { goto case 604; @@ -7337,7 +7328,7 @@ partial class ExpressionFinder { case 604: { if (la == null) { currentState = 604; break; } if (la.kind == 20) { - currentState = 632; + currentState = 626; break; } else { goto case 605; @@ -7355,15 +7346,15 @@ partial class ExpressionFinder { if (la == null) { currentState = 607; break; } if (la.kind == 40) { stateStack.Push(607); - goto case 435; + goto case 441; } else { goto case 608; } } case 608: { if (la == null) { currentState = 608; break; } - if (set[152].Get(la.kind)) { - currentState = 631; + if (set[151].Get(la.kind)) { + currentState = 625; break; } else { if (la.kind == 128 || la.kind == 198) { @@ -7393,15 +7384,15 @@ partial class ExpressionFinder { case 610: { if (la == null) { currentState = 610; break; } if (la.kind == 37) { - currentState = 628; - break; + stateStack.Push(611); + goto case 424; } else { goto case 611; } } case 611: { stateStack.Push(612); - goto case 263; + goto case 259; } case 612: { if (la == null) { currentState = 612; break; } @@ -7430,7 +7421,7 @@ partial class ExpressionFinder { } case 615: { if (la == null) { currentState = 615; break; } - if (set[110].Get(la.kind)) { + if (set[109].Get(la.kind)) { goto case 618; } else { goto case 616; @@ -7452,14 +7443,14 @@ partial class ExpressionFinder { if (la == null) { currentState = 618; break; } if (la.kind == 40) { stateStack.Push(618); - goto case 435; + goto case 441; } else { goto case 619; } } case 619: { if (la == null) { currentState = 619; break; } - if (set[152].Get(la.kind)) { + if (set[151].Get(la.kind)) { currentState = 619; break; } else { @@ -7480,15 +7471,15 @@ partial class ExpressionFinder { case 620: { if (la == null) { currentState = 620; break; } if (la.kind == 37) { - currentState = 625; - break; + stateStack.Push(621); + goto case 424; } else { goto case 621; } } case 621: { stateStack.Push(622); - goto case 263; + goto case 259; } case 622: { if (la == null) { currentState = 622; break; } @@ -7517,498 +7508,406 @@ partial class ExpressionFinder { } case 625: { SetIdentifierExpected(la); - goto case 626; + goto case 608; } case 626: { - if (la == null) { currentState = 626; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(627); - goto case 422; - } else { - goto case 627; - } + stateStack.Push(605); + goto case 55; } case 627: { - if (la == null) { currentState = 627; break; } - Expect(38, la); // ")" - currentState = 621; - break; + PushContext(Context.Type, la, t); + stateStack.Push(628); + goto case 37; } case 628: { - SetIdentifierExpected(la); + PopContext(); goto case 629; } case 629: { if (la == null) { currentState = 629; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(630); - goto case 422; - } else { - goto case 630; - } - } - case 630: { - if (la == null) { currentState = 630; break; } - Expect(38, la); // ")" - currentState = 611; - break; - } - case 631: { - SetIdentifierExpected(la); - goto case 608; - } - case 632: { - stateStack.Push(605); - goto case 56; - } - case 633: { - PushContext(Context.Type, la, t); - stateStack.Push(634); - goto case 37; - } - case 634: { - PopContext(); - goto case 635; - } - case 635: { - if (la == null) { currentState = 635; break; } if (la.kind == 22) { - currentState = 636; + currentState = 630; break; } else { goto case 604; } } - case 636: { + case 630: { PushContext(Context.Type, la, t); - stateStack.Push(637); + stateStack.Push(631); goto case 37; } - case 637: { + case 631: { PopContext(); - goto case 635; + goto case 629; } - case 638: { - if (la == null) { currentState = 638; break; } + case 632: { + PushContext(Context.Type, la, t); + goto case 633; + } + case 633: { + if (la == null) { currentState = 633; break; } if (la.kind == 40) { - stateStack.Push(638); - goto case 435; + stateStack.Push(633); + goto case 441; } else { if (la.kind == 162) { - stateStack.Push(603); - goto case 86; + stateStack.Push(634); + goto case 85; } else { if (set[16].Get(la.kind)) { - PushContext(Context.Type, la, t); - stateStack.Push(639); + stateStack.Push(634); goto case 37; } else { Error(la); - goto case 603; + goto case 634; } } } } - case 639: { + case 634: { PopContext(); goto case 603; } - case 640: { - SetIdentifierExpected(la); - goto case 641; - } - case 641: { - if (la == null) { currentState = 641; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(642); - goto case 422; - } else { - goto case 642; - } - } - case 642: { - if (la == null) { currentState = 642; break; } - Expect(38, la); // ")" - currentState = 602; - break; - } - case 643: { - if (la == null) { currentState = 643; break; } + case 635: { + if (la == null) { currentState = 635; break; } Expect(98, la); // "Custom" - currentState = 644; + currentState = 636; break; } - case 644: { - stateStack.Push(645); - goto case 655; + case 636: { + stateStack.Push(637); + goto case 647; } - case 645: { - if (la == null) { currentState = 645; break; } - if (set[115].Get(la.kind)) { - goto case 647; + case 637: { + if (la == null) { currentState = 637; break; } + if (set[114].Get(la.kind)) { + goto case 639; } else { Expect(113, la); // "End" - currentState = 646; + currentState = 638; break; } } - case 646: { - if (la == null) { currentState = 646; break; } + case 638: { + if (la == null) { currentState = 638; break; } Expect(119, la); // "Event" currentState = 23; break; } - case 647: { - if (la == null) { currentState = 647; break; } + case 639: { + if (la == null) { currentState = 639; break; } if (la.kind == 40) { - stateStack.Push(647); - goto case 435; + stateStack.Push(639); + goto case 441; } else { if (la.kind == 56) { - currentState = 648; + currentState = 640; break; } else { if (la.kind == 193) { - currentState = 648; + currentState = 640; break; } else { if (la.kind == 189) { - currentState = 648; + currentState = 640; break; } else { Error(la); - goto case 648; + goto case 640; } } } } } - case 648: { - if (la == null) { currentState = 648; break; } + case 640: { + if (la == null) { currentState = 640; break; } Expect(37, la); // "(" - currentState = 649; + currentState = 641; break; } - case 649: { - stateStack.Push(650); - goto case 422; + case 641: { + stateStack.Push(642); + goto case 428; } - case 650: { - if (la == null) { currentState = 650; break; } + case 642: { + if (la == null) { currentState = 642; break; } Expect(38, la); // ")" - currentState = 651; + currentState = 643; break; } - case 651: { - stateStack.Push(652); - goto case 263; + case 643: { + stateStack.Push(644); + goto case 259; } - case 652: { - if (la == null) { currentState = 652; break; } + case 644: { + if (la == null) { currentState = 644; break; } Expect(113, la); // "End" - currentState = 653; + currentState = 645; break; } - case 653: { - if (la == null) { currentState = 653; break; } + case 645: { + if (la == null) { currentState = 645; break; } if (la.kind == 56) { - currentState = 654; + currentState = 646; break; } else { if (la.kind == 193) { - currentState = 654; + currentState = 646; break; } else { if (la.kind == 189) { - currentState = 654; + currentState = 646; break; } else { Error(la); - goto case 654; + goto case 646; } } } } - case 654: { - stateStack.Push(645); + case 646: { + stateStack.Push(637); goto case 23; } - case 655: { - if (la == null) { currentState = 655; break; } + case 647: { + if (la == null) { currentState = 647; break; } Expect(119, la); // "Event" - currentState = 656; + currentState = 648; break; } - case 656: { + case 648: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(657); - goto case 206; + stateStack.Push(649); + goto case 205; } - case 657: { + case 649: { PopContext(); - goto case 658; + goto case 650; } - case 658: { - if (la == null) { currentState = 658; break; } + case 650: { + if (la == null) { currentState = 650; break; } if (la.kind == 63) { - currentState = 668; + currentState = 657; break; } else { - if (set[153].Get(la.kind)) { + if (set[152].Get(la.kind)) { if (la.kind == 37) { - currentState = 665; - break; + stateStack.Push(651); + goto case 424; } else { - goto case 659; + goto case 651; } } else { Error(la); - goto case 659; + goto case 651; } } } - case 659: { - if (la == null) { currentState = 659; break; } + case 651: { + if (la == null) { currentState = 651; break; } if (la.kind == 136) { - currentState = 660; + currentState = 652; break; } else { goto case 23; } } - case 660: { + case 652: { PushContext(Context.Type, la, t); - stateStack.Push(661); + stateStack.Push(653); goto case 37; } - case 661: { + case 653: { PopContext(); - goto case 662; + goto case 654; } - case 662: { - if (la == null) { currentState = 662; break; } + case 654: { + if (la == null) { currentState = 654; break; } if (la.kind == 22) { - currentState = 663; + currentState = 655; break; } else { goto case 23; } } - case 663: { + case 655: { PushContext(Context.Type, la, t); - stateStack.Push(664); + stateStack.Push(656); goto case 37; } - case 664: { + case 656: { PopContext(); - goto case 662; - } - case 665: { - SetIdentifierExpected(la); - goto case 666; + goto case 654; } - case 666: { - if (la == null) { currentState = 666; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(667); - goto case 422; - } else { - goto case 667; - } - } - case 667: { - if (la == null) { currentState = 667; break; } - Expect(38, la); // ")" - currentState = 659; - break; - } - case 668: { + case 657: { PushContext(Context.Type, la, t); - stateStack.Push(669); + stateStack.Push(658); goto case 37; } - case 669: { + case 658: { PopContext(); - goto case 659; + goto case 651; } - case 670: { - if (la == null) { currentState = 670; break; } + case 659: { + if (la == null) { currentState = 659; break; } Expect(101, la); // "Declare" - currentState = 671; + currentState = 660; break; } - case 671: { - if (la == null) { currentState = 671; break; } + case 660: { + if (la == null) { currentState = 660; break; } if (la.kind == 62 || la.kind == 66 || la.kind == 223) { - currentState = 672; + currentState = 661; break; } else { - goto case 672; + goto case 661; } } - case 672: { - if (la == null) { currentState = 672; break; } + case 661: { + if (la == null) { currentState = 661; break; } if (la.kind == 210) { - currentState = 673; + currentState = 662; break; } else { if (la.kind == 127) { - currentState = 673; + currentState = 662; break; } else { Error(la); - goto case 673; + goto case 662; } } } - case 673: { + case 662: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(674); - goto case 206; + stateStack.Push(663); + goto case 205; } - case 674: { + case 663: { PopContext(); - goto case 675; + goto case 664; } - case 675: { - if (la == null) { currentState = 675; break; } + case 664: { + if (la == null) { currentState = 664; break; } Expect(149, la); // "Lib" - currentState = 676; + currentState = 665; break; } - case 676: { - if (la == null) { currentState = 676; break; } + case 665: { + if (la == null) { currentState = 665; break; } Expect(3, la); // LiteralString - currentState = 677; + currentState = 666; break; } - case 677: { - if (la == null) { currentState = 677; break; } + case 666: { + if (la == null) { currentState = 666; break; } if (la.kind == 59) { - currentState = 685; + currentState = 671; break; } else { - goto case 678; + goto case 667; } } - case 678: { - if (la == null) { currentState = 678; break; } + case 667: { + if (la == null) { currentState = 667; break; } if (la.kind == 37) { - currentState = 682; - break; + stateStack.Push(668); + goto case 424; } else { - goto case 679; + goto case 668; } } - case 679: { - if (la == null) { currentState = 679; break; } + case 668: { + if (la == null) { currentState = 668; break; } if (la.kind == 63) { - currentState = 680; + currentState = 669; break; } else { goto case 23; } } - case 680: { + case 669: { PushContext(Context.Type, la, t); - stateStack.Push(681); + stateStack.Push(670); goto case 37; } - case 681: { + case 670: { PopContext(); goto case 23; } - case 682: { - SetIdentifierExpected(la); - goto case 683; - } - case 683: { - if (la == null) { currentState = 683; break; } - if (set[78].Get(la.kind)) { - stateStack.Push(684); - goto case 422; - } else { - goto case 684; - } - } - case 684: { - if (la == null) { currentState = 684; break; } - Expect(38, la); // ")" - currentState = 679; - break; - } - case 685: { - if (la == null) { currentState = 685; break; } + case 671: { + if (la == null) { currentState = 671; break; } Expect(3, la); // LiteralString - currentState = 678; + currentState = 667; break; } - case 686: { - if (la == null) { currentState = 686; break; } + case 672: { + if (la == null) { currentState = 672; break; } if (la.kind == 210) { - currentState = 687; + currentState = 673; break; } else { if (la.kind == 127) { - currentState = 687; + currentState = 673; break; } else { Error(la); - goto case 687; + goto case 673; } } } - case 687: { + case 673: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - goto case 688; + goto case 674; } - case 688: { - if (la == null) { currentState = 688; break; } - currentState = 689; + case 674: { + if (la == null) { currentState = 674; break; } + currentState = 675; break; } - case 689: { + case 675: { PopContext(); - goto case 690; + goto case 676; } - case 690: { - if (la == null) { currentState = 690; break; } + case 676: { + if (la == null) { currentState = 676; break; } if (la.kind == 37) { - currentState = 700; + currentState = 686; break; } else { if (la.kind == 63) { - currentState = 698; + currentState = 684; break; } else { - goto case 691; + goto case 677; } } } - case 691: { - if (la == null) { currentState = 691; break; } + case 677: { + if (la == null) { currentState = 677; break; } if (la.kind == 134 || la.kind == 136) { - currentState = 695; + currentState = 681; break; } else { - goto case 692; + goto case 678; } } - case 692: { - stateStack.Push(693); - goto case 263; + case 678: { + stateStack.Push(679); + goto case 259; } - case 693: { - if (la == null) { currentState = 693; break; } + case 679: { + if (la == null) { currentState = 679; break; } Expect(113, la); // "End" - currentState = 694; + currentState = 680; break; } - case 694: { - if (la == null) { currentState = 694; break; } + case 680: { + if (la == null) { currentState = 680; break; } if (la.kind == 210) { currentState = 23; break; @@ -8017,443 +7916,444 @@ partial class ExpressionFinder { currentState = 23; break; } else { - goto case 525; + goto case 528; } } } - case 695: { - if (la == null) { currentState = 695; break; } + case 681: { + if (la == null) { currentState = 681; break; } if (la.kind == 153 || la.kind == 158 || la.kind == 159) { - currentState = 697; + currentState = 683; break; } else { - goto case 696; + goto case 682; } } - case 696: { - stateStack.Push(692); + case 682: { + stateStack.Push(678); goto case 37; } - case 697: { - if (la == null) { currentState = 697; break; } + case 683: { + if (la == null) { currentState = 683; break; } Expect(26, la); // "." - currentState = 696; + currentState = 682; break; } - case 698: { + case 684: { PushContext(Context.Type, la, t); - stateStack.Push(699); + stateStack.Push(685); goto case 37; } - case 699: { + case 685: { PopContext(); - goto case 691; + goto case 677; } - case 700: { + case 686: { SetIdentifierExpected(la); - goto case 701; + goto case 687; } - case 701: { - if (la == null) { currentState = 701; break; } - if (set[151].Get(la.kind)) { + case 687: { + if (la == null) { currentState = 687; break; } + if (set[150].Get(la.kind)) { if (la.kind == 169) { - currentState = 703; + currentState = 689; break; } else { - if (set[78].Get(la.kind)) { - stateStack.Push(702); - goto case 422; + if (set[77].Get(la.kind)) { + stateStack.Push(688); + goto case 428; } else { Error(la); - goto case 702; + goto case 688; } } } else { - goto case 702; + goto case 688; } } - case 702: { - if (la == null) { currentState = 702; break; } + case 688: { + if (la == null) { currentState = 688; break; } Expect(38, la); // ")" - currentState = 690; + currentState = 676; break; } - case 703: { - stateStack.Push(702); - goto case 492; + case 689: { + stateStack.Push(688); + goto case 498; } - case 704: { - stateStack.Push(705); + case 690: { + stateStack.Push(691); SetIdentifierExpected(la); - goto case 706; + goto case 692; } - case 705: { - if (la == null) { currentState = 705; break; } + case 691: { + if (la == null) { currentState = 691; break; } if (la.kind == 22) { - currentState = 704; + currentState = 690; break; } else { goto case 23; } } - case 706: { - if (la == null) { currentState = 706; break; } + case 692: { + if (la == null) { currentState = 692; break; } if (la.kind == 88) { - currentState = 707; + currentState = 693; break; } else { - goto case 707; + goto case 693; } } - case 707: { + case 693: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - stateStack.Push(708); - goto case 718; + stateStack.Push(694); + goto case 704; } - case 708: { + case 694: { PopContext(); - goto case 709; + goto case 695; } - case 709: { - if (la == null) { currentState = 709; break; } + case 695: { + if (la == null) { currentState = 695; break; } if (la.kind == 33) { - currentState = 710; + currentState = 696; break; } else { - goto case 710; + goto case 696; } } - case 710: { - if (la == null) { currentState = 710; break; } + case 696: { + if (la == null) { currentState = 696; break; } if (la.kind == 37) { - currentState = 715; + currentState = 701; break; } else { if (la.kind == 63) { - currentState = 712; + currentState = 698; break; } else { - goto case 711; + goto case 697; } } } - case 711: { - if (la == null) { currentState = 711; break; } + case 697: { + if (la == null) { currentState = 697; break; } if (la.kind == 20) { - goto case 406; + currentState = 55; + break; } else { currentState = stateStack.Pop(); goto switchlbl; } } - case 712: { + case 698: { PushContext(Context.Type, la, t); - goto case 713; + goto case 699; } - case 713: { - if (la == null) { currentState = 713; break; } + case 699: { + if (la == null) { currentState = 699; break; } if (la.kind == 162) { - stateStack.Push(714); - goto case 86; + stateStack.Push(700); + goto case 85; } else { if (set[16].Get(la.kind)) { - stateStack.Push(714); + stateStack.Push(700); goto case 37; } else { Error(la); - goto case 714; + goto case 700; } } } - case 714: { + case 700: { PopContext(); - goto case 711; + goto case 697; } - case 715: { + case 701: { nextTokenIsPotentialStartOfExpression = true; - goto case 716; + goto case 702; } - case 716: { - if (la == null) { currentState = 716; break; } + case 702: { + if (la == null) { currentState = 702; break; } if (set[23].Get(la.kind)) { - stateStack.Push(717); - goto case 56; + stateStack.Push(703); + goto case 55; } else { - goto case 717; + goto case 703; } } - case 717: { - if (la == null) { currentState = 717; break; } + case 703: { + if (la == null) { currentState = 703; break; } if (la.kind == 22) { - currentState = 715; + currentState = 701; break; } else { Expect(38, la); // ")" - currentState = 710; + currentState = 696; break; } } - case 718: { - if (la == null) { currentState = 718; break; } - if (set[137].Get(la.kind)) { + case 704: { + if (la == null) { currentState = 704; break; } + if (set[136].Get(la.kind)) { currentState = stateStack.Pop(); break; } else { if (la.kind == 58) { - goto case 145; + goto case 144; } else { if (la.kind == 126) { - goto case 129; + goto case 128; } else { goto case 6; } } } } - case 719: { + case 705: { isMissingModifier = false; goto case 579; } - case 720: { - if (la == null) { currentState = 720; break; } + case 706: { + if (la == null) { currentState = 706; break; } Expect(136, la); // "Implements" - currentState = 721; + currentState = 707; break; } - case 721: { + case 707: { PushContext(Context.Type, la, t); - stateStack.Push(722); + stateStack.Push(708); goto case 37; } - case 722: { + case 708: { PopContext(); - goto case 723; + goto case 709; } - case 723: { - if (la == null) { currentState = 723; break; } + case 709: { + if (la == null) { currentState = 709; break; } if (la.kind == 22) { - currentState = 724; + currentState = 710; break; } else { stateStack.Push(571); goto case 23; } } - case 724: { + case 710: { PushContext(Context.Type, la, t); - stateStack.Push(725); + stateStack.Push(711); goto case 37; } - case 725: { + case 711: { PopContext(); - goto case 723; + goto case 709; } - case 726: { - if (la == null) { currentState = 726; break; } + case 712: { + if (la == null) { currentState = 712; break; } Expect(140, la); // "Inherits" - currentState = 727; + currentState = 713; break; } - case 727: { + case 713: { PushContext(Context.Type, la, t); - stateStack.Push(728); + stateStack.Push(714); goto case 37; } - case 728: { + case 714: { PopContext(); stateStack.Push(569); goto case 23; } - case 729: { - if (la == null) { currentState = 729; break; } + case 715: { + if (la == null) { currentState = 715; break; } Expect(169, la); // "Of" - currentState = 730; + currentState = 716; break; } - case 730: { - stateStack.Push(731); - goto case 492; + case 716: { + stateStack.Push(717); + goto case 498; } - case 731: { - if (la == null) { currentState = 731; break; } + case 717: { + if (la == null) { currentState = 717; break; } Expect(38, la); // ")" currentState = 566; break; } - case 732: { + case 718: { isMissingModifier = false; goto case 28; } - case 733: { + case 719: { PushContext(Context.Type, la, t); - stateStack.Push(734); + stateStack.Push(720); goto case 37; } - case 734: { + case 720: { PopContext(); - goto case 735; + goto case 721; } - case 735: { - if (la == null) { currentState = 735; break; } + case 721: { + if (la == null) { currentState = 721; break; } if (la.kind == 22) { - currentState = 736; + currentState = 722; break; } else { stateStack.Push(17); goto case 23; } } - case 736: { + case 722: { PushContext(Context.Type, la, t); - stateStack.Push(737); + stateStack.Push(723); goto case 37; } - case 737: { + case 723: { PopContext(); - goto case 735; + goto case 721; } - case 738: { - if (la == null) { currentState = 738; break; } + case 724: { + if (la == null) { currentState = 724; break; } Expect(169, la); // "Of" - currentState = 739; + currentState = 725; break; } - case 739: { - stateStack.Push(740); - goto case 492; + case 725: { + stateStack.Push(726); + goto case 498; } - case 740: { - if (la == null) { currentState = 740; break; } + case 726: { + if (la == null) { currentState = 726; break; } Expect(38, la); // ")" currentState = 14; break; } - case 741: { + case 727: { PushContext(Context.Identifier, la, t); SetIdentifierExpected(la); - goto case 742; + goto case 728; } - case 742: { - if (la == null) { currentState = 742; break; } - if (set[50].Get(la.kind)) { - currentState = 742; + case 728: { + if (la == null) { currentState = 728; break; } + if (set[49].Get(la.kind)) { + currentState = 728; break; } else { PopContext(); - stateStack.Push(743); + stateStack.Push(729); goto case 23; } } - case 743: { - if (la == null) { currentState = 743; break; } + case 729: { + if (la == null) { currentState = 729; break; } if (set[3].Get(la.kind)) { - stateStack.Push(743); + stateStack.Push(729); goto case 5; } else { Expect(113, la); // "End" - currentState = 744; + currentState = 730; break; } } - case 744: { - if (la == null) { currentState = 744; break; } + case 730: { + if (la == null) { currentState = 730; break; } Expect(160, la); // "Namespace" currentState = 23; break; } - case 745: { - if (la == null) { currentState = 745; break; } + case 731: { + if (la == null) { currentState = 731; break; } Expect(137, la); // "Imports" - currentState = 746; + currentState = 732; break; } - case 746: { + case 732: { PushContext(Context.Importable, la, t); nextTokenIsStartOfImportsOrAccessExpression = true; - goto case 747; + goto case 733; } - case 747: { - if (la == null) { currentState = 747; break; } - if (set[154].Get(la.kind)) { - currentState = 753; + case 733: { + if (la == null) { currentState = 733; break; } + if (set[153].Get(la.kind)) { + currentState = 739; break; } else { if (la.kind == 10) { - currentState = 749; + currentState = 735; break; } else { Error(la); - goto case 748; + goto case 734; } } } - case 748: { + case 734: { PopContext(); goto case 23; } - case 749: { - stateStack.Push(750); - goto case 206; + case 735: { + stateStack.Push(736); + goto case 205; } - case 750: { - if (la == null) { currentState = 750; break; } + case 736: { + if (la == null) { currentState = 736; break; } Expect(20, la); // "=" - currentState = 751; + currentState = 737; break; } - case 751: { - if (la == null) { currentState = 751; break; } + case 737: { + if (la == null) { currentState = 737; break; } Expect(3, la); // LiteralString - currentState = 752; + currentState = 738; break; } - case 752: { - if (la == null) { currentState = 752; break; } + case 738: { + if (la == null) { currentState = 738; break; } Expect(11, la); // XmlCloseTag - currentState = 748; + currentState = 734; break; } - case 753: { - if (la == null) { currentState = 753; break; } + case 739: { + if (la == null) { currentState = 739; break; } if (la.kind == 37) { - stateStack.Push(753); + stateStack.Push(739); goto case 42; } else { if (la.kind == 20 || la.kind == 26) { - currentState = 754; + currentState = 740; break; } else { - goto case 748; + goto case 734; } } } - case 754: { - stateStack.Push(748); + case 740: { + stateStack.Push(734); goto case 37; } - case 755: { - if (la == null) { currentState = 755; break; } + case 741: { + if (la == null) { currentState = 741; break; } Expect(173, la); // "Option" - currentState = 756; + currentState = 742; break; } - case 756: { - if (la == null) { currentState = 756; break; } + case 742: { + if (la == null) { currentState = 742; break; } if (la.kind == 121 || la.kind == 139 || la.kind == 207) { - currentState = 758; + currentState = 744; break; } else { if (la.kind == 87) { - currentState = 757; + currentState = 743; break; } else { - goto case 525; + goto case 528; } } } - case 757: { - if (la == null) { currentState = 757; break; } + case 743: { + if (la == null) { currentState = 743; break; } if (la.kind == 213) { currentState = 23; break; @@ -8462,12 +8362,12 @@ partial class ExpressionFinder { currentState = 23; break; } else { - goto case 525; + goto case 528; } } } - case 758: { - if (la == null) { currentState = 758; break; } + case 744: { + if (la == null) { currentState = 744; break; } if (la.kind == 170 || la.kind == 171) { currentState = 23; break; @@ -8517,8 +8417,8 @@ partial class ExpressionFinder { new BitArray(new int[] {-940564478, 889192413, 65, 1074825472, 72844640, 231424, 22030368, 4704}), new BitArray(new int[] {4, -16777216, -1, -1, -1, -1, -1, 16383}), new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106740, -97186288, 8259}), - new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), new BitArray(new int[] {-61995012, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), new BitArray(new int[] {-1007673342, 889192405, 65, 1074825472, 72843296, 231424, 22030368, 4160}), new BitArray(new int[] {-1013972992, 822083461, 0, 0, 71499776, 163840, 16777216, 4096}), @@ -8542,7 +8442,6 @@ partial class ExpressionFinder { new BitArray(new int[] {65140738, 973078487, 51384096, 972018404, 1030969181, -17106229, 97186287, -8260}), new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8387}), new BitArray(new int[] {0, 67108864, 0, 1073743872, 1343520, 65536, 1050656, 64}), - new BitArray(new int[] {4, 1140851008, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), new BitArray(new int[] {-64092162, -973078488, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), new BitArray(new int[] {-64092162, 1191182376, -1048865, -546062565, -1014191950, -1593504452, -21144002, 8903}), new BitArray(new int[] {0, 0, 3072, 134447104, 16777216, 8, 0, 0}), @@ -8571,9 +8470,9 @@ partial class ExpressionFinder { new BitArray(new int[] {2097154, 32, 0, 32768, 0, 0, 0, 0}), new BitArray(new int[] {7340034, -2147483614, 0, 32768, 0, 0, 0, 0}), new BitArray(new int[] {7340034, -2147483616, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {7340034, -2147483648, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {3145730, 0, 0, 32768, 0, 0, 0, 0}), + new BitArray(new int[] {7340034, 0, 0, 32768, 0, 0, 0, 0}), new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106180, -533656048, 67}), + new BitArray(new int[] {4, 1140851008, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), new BitArray(new int[] {4, 1140850944, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), new BitArray(new int[] {4, 1140850688, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), new BitArray(new int[] {5242880, -2147483584, 0, 0, 0, 0, 0, 0}), diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs b/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs index c1dd4bb18..9d244528c 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs @@ -90,7 +90,7 @@ namespace ICSharpCode.NRefactory.VB string cmd; string arg; - VB.Dom.Expression expression = Dom.Expression.Null; + Ast.Expression expression = Ast.Expression.Null; /// /// Gets the directive name, including '#'. @@ -119,9 +119,9 @@ namespace ICSharpCode.NRefactory.VB /// /// Gets/sets the expression (for directives that take an expression, e.g. #if and #elif). /// - public Dom.Expression Expression { + public Ast.Expression Expression { get { return expression; } - set { expression = value ?? Dom.Expression.Null; } + set { expression = value ?? Ast.Expression.Null; } } /// diff --git a/NRefactory/ICSharpCode.NRefactory.VB/OperatorPrecedence.cs b/NRefactory/ICSharpCode.NRefactory.VB/OperatorPrecedence.cs index eced7d595..833802ffd 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/OperatorPrecedence.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/OperatorPrecedence.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Parser/ModifierList.cs b/NRefactory/ICSharpCode.NRefactory.VB/Parser/ModifierList.cs index 4b6ba47fb..7acfedbae 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Parser/ModifierList.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Parser/ModifierList.cs @@ -1,7 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Parser { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs b/NRefactory/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs index 6e6ed55c0..f9a6c6dd9 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs @@ -1,7 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Parser { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Parser/Parser.cs b/NRefactory/ICSharpCode.NRefactory.VB/Parser/Parser.cs index 4a5f94598..88ff84b89 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Parser/Parser.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Parser/Parser.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Text; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; -using ASTAttribute = ICSharpCode.NRefactory.VB.Dom.Attribute; +using ASTAttribute = ICSharpCode.NRefactory.VB.Ast.Attribute; @@ -3677,6 +3677,7 @@ partial class VBParser EmbeddedStatement(out statement); lambda.StatementBody = statement; lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; } else if (la.kind == 1) { Get(); @@ -3685,6 +3686,7 @@ partial class VBParser Expect(210); lambda.StatementBody = statement; lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; } else SynErr(293); } @@ -3710,7 +3712,8 @@ partial class VBParser if (StartOf(24)) { Expr(out inner); lambda.ExpressionBody = inner; - lambda.EndLocation = t.EndLocation; // la.Location? + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; } else if (la.kind == 1) { Get(); @@ -3719,6 +3722,7 @@ partial class VBParser Expect(127); lambda.StatementBody = statement; lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; } else SynErr(294); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Parser/VBParser.cs b/NRefactory/ICSharpCode.NRefactory.VB/Parser/VBParser.cs index 05c7c7a98..07c67597c 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Parser/VBParser.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Parser/VBParser.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.Linq; using System.Text; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Visitors; namespace ICSharpCode.NRefactory.VB.Parser diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Parser/vb.atg b/NRefactory/ICSharpCode.NRefactory.VB/Parser/vb.atg index 3df4fad5e..fbaf98990 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Parser/vb.atg +++ b/NRefactory/ICSharpCode.NRefactory.VB/Parser/vb.atg @@ -4,9 +4,9 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Text; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; -using ASTAttribute = ICSharpCode.NRefactory.VB.Dom.Attribute; +using ASTAttribute = ICSharpCode.NRefactory.VB.Ast.Attribute; COMPILER VB @@ -2232,6 +2232,7 @@ SubLambdaExpression (. lambda.StatementBody = statement; lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; .) | EOL @@ -2240,6 +2241,7 @@ SubLambdaExpression (. lambda.StatementBody = statement; lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; .) ) . @@ -2259,7 +2261,8 @@ FunctionLambdaExpression GREEDY Expr (. lambda.ExpressionBody = inner; - lambda.EndLocation = t.EndLocation; // la.Location? + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; .) | EOL @@ -2268,6 +2271,7 @@ FunctionLambdaExpression (. lambda.StatementBody = statement; lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; .) ) . diff --git a/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs index e692fe1e9..ecac6596d 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs @@ -3,11 +3,11 @@ using System; using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.PrettyPrinter { - public interface IOutputDomVisitor : IDomVisitor + public interface IOutputDomVisitor : IAstVisitor { event Action BeforeNodeVisit; event Action AfterNodeVisit; diff --git a/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs b/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs index b1a8ee9bb..2dbc3faaa 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.PrettyPrinter { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index 86420bfc4..dbf5d2bc9 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -9,13 +9,13 @@ using System.Diagnostics; using System.Globalization; using System.Text; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; using ICSharpCode.NRefactory.VB.Visitors; namespace ICSharpCode.NRefactory.VB.PrettyPrinter { - public sealed class VBNetOutputVisitor : NodeTrackingDomVisitor, IOutputDomVisitor + public sealed class VBNetOutputVisitor : NodeTrackingAstVisitor, IOutputDomVisitor { Errors errors = new Errors(); VBNetOutputFormatter outputFormatter; @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter Error(node.GetType().Name + " is unsupported", node.StartLocation); } - #region ICSharpCode.NRefactory.Parser.IDomVisitor interface implementation + #region ICSharpCode.NRefactory.Parser.IAstVisitor interface implementation public override object TrackedVisitCompilationUnit(CompilationUnit compilationUnit, object data) { compilationUnit.AcceptChildren(this, data); @@ -200,7 +200,7 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter return null; } - public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data) + public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { outputFormatter.PrintIdentifier(attribute.Name); if (attribute.PositionalArguments.Count > 0 || attribute.NamedArguments.Count > 0) { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/SnippetParser.cs b/NRefactory/ICSharpCode.NRefactory.VB/SnippetParser.cs index d6273176e..367ce5abf 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/SnippetParser.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/SnippetParser.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using ICSharpCode.NRefactory.VB.Parser; namespace ICSharpCode.NRefactory.VB @@ -113,7 +113,7 @@ namespace ICSharpCode.NRefactory.VB public object UserData { get; set; } - public object AcceptChildren(IDomVisitor visitor, object data) + public object AcceptChildren(IAstVisitor visitor, object data) { foreach (INode n in nodes) { n.AcceptVisitor(visitor, data); @@ -121,7 +121,7 @@ namespace ICSharpCode.NRefactory.VB return null; } - public object AcceptVisitor(IDomVisitor visitor, object data) + public object AcceptVisitor(IAstVisitor visitor, object data) { return AcceptChildren(visitor, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractDomTransformer.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractAstTransformer.cs similarity index 99% rename from NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractDomTransformer.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractAstTransformer.cs index aa4a698de..350626e69 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractDomTransformer.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractAstTransformer.cs @@ -12,19 +12,19 @@ namespace ICSharpCode.NRefactory.VB.Visitors { using System; using System.Collections.Generic; using System.Diagnostics; - using ICSharpCode.NRefactory.VB.Dom; + using ICSharpCode.NRefactory.VB.Ast; /// - /// The AbstractDomTransformer will iterate through the whole Dom, - /// just like the AbstractDomVisitor. However, the AbstractDomTransformer allows - /// you to modify the Dom at the same time: It does not use 'foreach' internally, + /// The AbstractAstTransformer will iterate through the whole Ast, + /// just like the AbstractAstVisitor. However, the AbstractAstTransformer allows + /// you to modify the Ast at the same time: It does not use 'foreach' internally, /// so you can add members to collections of parents of the current node (but /// you cannot insert or delete items as that will make the index used invalid). /// You can use the methods ReplaceCurrentNode and RemoveCurrentNode to replace /// or remove the current node, totally independent from the type of the parent node. /// - public abstract class AbstractDomTransformer : IDomVisitor { + public abstract class AbstractAstTransformer : IAstVisitor { private Stack nodeStack = new Stack(); @@ -98,7 +98,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { return null; } - public virtual object VisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data) { + public virtual object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { Debug.Assert((attribute != null)); Debug.Assert((attribute.PositionalArguments != null)); Debug.Assert((attribute.NamedArguments != null)); @@ -131,11 +131,11 @@ namespace ICSharpCode.NRefactory.VB.Visitors { Debug.Assert((attributeSection != null)); Debug.Assert((attributeSection.Attributes != null)); for (int i = 0; i < attributeSection.Attributes.Count; i++) { - ICSharpCode.NRefactory.VB.Dom.Attribute o = attributeSection.Attributes[i]; + ICSharpCode.NRefactory.VB.Ast.Attribute o = attributeSection.Attributes[i]; Debug.Assert(o != null); nodeStack.Push(o); o.AcceptVisitor(this, data); - o = (ICSharpCode.NRefactory.VB.Dom.Attribute)nodeStack.Pop(); + o = (ICSharpCode.NRefactory.VB.Ast.Attribute)nodeStack.Pop(); if (o == null) attributeSection.Attributes.RemoveAt(i--); else diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractDomVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractAstVisitor.cs similarity index 99% rename from NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractDomVisitor.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractAstVisitor.cs index cd9a63afb..40673247f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractDomVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/AbstractAstVisitor.cs @@ -12,10 +12,10 @@ namespace ICSharpCode.NRefactory.VB.Visitors { using System; using System.Collections.Generic; using System.Diagnostics; - using ICSharpCode.NRefactory.VB.Dom; + using ICSharpCode.NRefactory.VB.Ast; - public abstract class AbstractDomVisitor : IDomVisitor { + public abstract class AbstractAstVisitor : IAstVisitor { public virtual object VisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data) { Debug.Assert((addHandlerStatement != null)); @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { return assignmentExpression.Right.AcceptVisitor(this, data); } - public virtual object VisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data) { + public virtual object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { Debug.Assert((attribute != null)); Debug.Assert((attribute.PositionalArguments != null)); Debug.Assert((attribute.NamedArguments != null)); @@ -70,7 +70,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { public virtual object VisitAttributeSection(AttributeSection attributeSection, object data) { Debug.Assert((attributeSection != null)); Debug.Assert((attributeSection.Attributes != null)); - foreach (ICSharpCode.NRefactory.VB.Dom.Attribute o in attributeSection.Attributes) { + foreach (ICSharpCode.NRefactory.VB.Ast.Attribute o in attributeSection.Attributes) { Debug.Assert(o != null); o.AcceptVisitor(this, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CodeDOMOutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CodeDOMOutputVisitor.cs index 965e9703b..b63a86f85 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CodeDOMOutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CodeDOMOutputVisitor.cs @@ -8,11 +8,11 @@ using System.Collections.Generic; using System.Reflection; using System.Text; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Visitors { - public class CodeDomVisitor : AbstractDomVisitor + public class CodeDomVisitor : AbstractAstVisitor { Stack namespaceDeclarations = new Stack(); Stack typeDeclarations = new Stack(); @@ -174,7 +174,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors return attr; } - #region ICSharpCode.SharpRefactory.Parser.IDomVisitor interface implementation + #region ICSharpCode.SharpRefactory.Parser.IAstVisitor interface implementation public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data) { if (compilationUnit == null) { diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/LookupTableVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/LookupTableVisitor.cs index 97e6ed6a2..f29fe7f38 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/LookupTableVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/LookupTableVisitor.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Visitors { @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors } - public sealed class LookupTableVisitor : AbstractDomVisitor + public sealed class LookupTableVisitor : AbstractAstVisitor { Dictionary> variables; @@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors } } - public override object VisitCompilationUnit (ICSharpCode.NRefactory.VB.Dom.CompilationUnit compilationUnit, object data) + public override object VisitCompilationUnit (ICSharpCode.NRefactory.VB.Ast.CompilationUnit compilationUnit, object data) { variables.Clear (); return base.VisitCompilationUnit (compilationUnit, data); diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NodeTrackingDomVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NodeTrackingAstVisitor.cs similarity index 99% rename from NRefactory/ICSharpCode.NRefactory.VB/Visitors/NodeTrackingDomVisitor.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Visitors/NodeTrackingAstVisitor.cs index 79ed02e58..609d3b266 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NodeTrackingDomVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NodeTrackingAstVisitor.cs @@ -10,12 +10,12 @@ namespace ICSharpCode.NRefactory.VB.Visitors { using System; - using ICSharpCode.NRefactory.VB.Dom; + using ICSharpCode.NRefactory.VB.Ast; /// - /// The NodeTrackingDomVisitor will iterate through the whole Dom, - /// just like the AbstractDomVisitor, and calls the virtual methods + /// The NodeTrackingAstVisitor will iterate through the whole Ast, + /// just like the AbstractAstVisitor, and calls the virtual methods /// BeginVisit and EndVisit for each node being visited. /// /// @@ -23,7 +23,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { /// you want to visit child nodes using the default visiting behaviour, /// use base.TrackedVisit(parentNode, data). /// - public abstract class NodeTrackingDomVisitor : AbstractDomVisitor { + public abstract class NodeTrackingAstVisitor : AbstractAstVisitor { protected virtual void BeginVisit(INode node) { } @@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { return result; } - public sealed override object VisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data) { + public sealed override object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { this.BeginVisit(attribute); object result = this.TrackedVisitAttribute(attribute, data); this.EndVisit(attribute); @@ -831,7 +831,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { return base.VisitAssignmentExpression(assignmentExpression, data); } - public virtual object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data) { + public virtual object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { return base.VisitAttribute(attribute, data); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NotImplementedDomVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NotImplementedAstVisitor.cs similarity index 99% rename from NRefactory/ICSharpCode.NRefactory.VB/Visitors/NotImplementedDomVisitor.cs rename to NRefactory/ICSharpCode.NRefactory.VB/Visitors/NotImplementedAstVisitor.cs index 33ca1cfc7..c9d26a55e 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NotImplementedDomVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/NotImplementedAstVisitor.cs @@ -10,13 +10,13 @@ namespace ICSharpCode.NRefactory.VB.Visitors { using System; - using ICSharpCode.NRefactory.VB.Dom; + using ICSharpCode.NRefactory.VB.Ast; /// - /// IDomVisitor implementation that always throws NotImplementedExceptions. + /// IAstVisitor implementation that always throws NotImplementedExceptions. /// - public class NotImplementedDomVisitor : IDomVisitor { + public class NotImplementedAstVisitor : IAstVisitor { public virtual object VisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data) { throw new global::System.NotImplementedException("AddHandlerStatement"); @@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors { throw new global::System.NotImplementedException("AssignmentExpression"); } - public virtual object VisitAttribute(ICSharpCode.NRefactory.VB.Dom.Attribute attribute, object data) { + public virtual object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { throw new global::System.NotImplementedException("Attribute"); } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/PrefixFieldsVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/PrefixFieldsVisitor.cs index 4b6a8f328..7bf15b034 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/PrefixFieldsVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/PrefixFieldsVisitor.cs @@ -3,14 +3,14 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Visitors { /// /// Prefixes the names of the specified fields with the prefix and replaces the use. /// - public class PrefixFieldsVisitor : AbstractDomVisitor + public class PrefixFieldsVisitor : AbstractAstVisitor { List fields; List curBlock = new List(); diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/RenameIdentifierVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/RenameIdentifierVisitor.cs index a4c9bf553..dc4ef2d33 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/RenameIdentifierVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/RenameIdentifierVisitor.cs @@ -2,11 +2,11 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Visitors { - class RenameIdentifierVisitor : AbstractDomVisitor + class RenameIdentifierVisitor : AbstractAstVisitor { protected StringComparer nameComparer; protected string from, to; diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetParentVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetParentVisitor.cs index 5835a5562..3122dedcd 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetParentVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetParentVisitor.cs @@ -2,7 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; using System.Collections.Generic; namespace ICSharpCode.NRefactory.VB.Visitors @@ -10,7 +10,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors /// /// Sets the parent property on all nodes in the tree. /// - public class SetParentVisitor : NodeTrackingDomVisitor + public class SetParentVisitor : NodeTrackingAstVisitor { Stack nodeStack = new Stack(); diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetRegionInclusionVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetRegionInclusionVisitor.cs index ad6da8f0f..50aaca96f 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetRegionInclusionVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/SetRegionInclusionVisitor.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using ICSharpCode.NRefactory.VB.Dom; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB.Visitors { @@ -13,7 +13,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors /// Parsers don't do this by default: /// e.g. "a.Foo()" is InvocationExpression, its region includes only the "()" and it has a child MemberReferenceExpression, with region ".Foo". /// - public class SetRegionInclusionVisitor : NodeTrackingDomVisitor + public class SetRegionInclusionVisitor : NodeTrackingAstVisitor { Stack parentNodes = new Stack(); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs index bd5fbcc58..ab8377685 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs @@ -591,12 +591,42 @@ namespace ICSharpCode.NRefactory.CSharp protected internal abstract bool DoMatch(AstNode other, Match match); - internal virtual bool DoMatchCollection(Role role, AstNode pos, Match match, Stack backtrackingStack) + internal virtual bool DoMatchCollection (Role role, AstNode pos, Match match, Stack backtrackingStack) { - return DoMatch(pos, match); + return DoMatch (pos, match); } #endregion + public AstNode GetNextNode () + { + if (NextSibling != null) + return NextSibling; + if (Parent != null) + return Parent.GetNextNode (); + return null; + } + + public AstNode GetPrevNode () + { + if (PrevSibling != null) + return PrevSibling; + if (Parent != null) + return Parent.GetPrevNode (); + return null; + } + + // filters all non c# nodes (comments, white spaces or pre processor directives) + public AstNode GetCSharpNodeBefore (AstNode node) + { + var n = node.PrevSibling; + while (n != null) { + if (n.Role != Roles.Comment) + return n; + n = n.GetPrevNode (); + } + return null; + } + // the Root role must be available when creating the null nodes, so we can't put it in the Roles class static readonly Role RootRole = new Role("Root"); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs index dff52990d..dc4a97905 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs @@ -130,6 +130,11 @@ namespace ICSharpCode.NRefactory.CSharp return VisitChildren (usingDeclaration, data); } + public virtual S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data) + { + return VisitChildren (externAliasDeclaration, data); + } + public virtual S VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data) { return VisitChildren (constructorDeclaration, data); @@ -160,6 +165,16 @@ namespace ICSharpCode.NRefactory.CSharp return VisitChildren (fieldDeclaration, data); } + public virtual S VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, T data) + { + return VisitChildren (fixedFieldDeclaration, data); + } + + public virtual S VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, T data) + { + return VisitChildren (fixedVariableInitializer, data); + } + public virtual S VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data) { return VisitChildren (indexerDeclaration, data); @@ -560,9 +575,14 @@ namespace ICSharpCode.NRefactory.CSharp return VisitChildren (arraySpecifier, data); } - public virtual S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data) + public virtual S VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression, T data) { return VisitChildren (namedArgumentExpression, data); } + + public virtual S VisitEmptyExpression (EmptyExpression emptyExpression, T data) + { + return VisitChildren (emptyExpression, data); + } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs new file mode 100644 index 000000000..b057acbdf --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs @@ -0,0 +1,69 @@ +// +// EmptyExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// 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; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// Type<[EMPTY]> + /// + public class EmptyExpression : Expression + { + AstLocation location; + + public override AstLocation StartLocation { + get { + return location; + } + } + + public override AstLocation EndLocation { + get { + return location; + } + } + + public EmptyExpression () + { + } + + public EmptyExpression (AstLocation location) + { + this.location = location; + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + return visitor.VisitEmptyExpression (this, data); + } + + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) + { + var o = other as EmptyExpression; + return o != null; + } + } +} diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs new file mode 100644 index 000000000..bdd8c0f04 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs @@ -0,0 +1,83 @@ +// +// ExternAliasDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// 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. + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// extern alias ; + /// + public class ExternAliasDeclaration : AstNode + { + public static readonly Role AliasRole = new Role ("Alias", CSharpTokenNode.Null); + + public override NodeType NodeType { + get { + return NodeType.Unknown; + } + } + + public CSharpTokenNode ExternToken { + get { return GetChildByRole (Roles.Keyword); } + } + + public CSharpTokenNode AliasToken { + get { return GetChildByRole (AliasRole); } + } + + public string Name { + get { + return GetChildByRole (Roles.Identifier).Name; + } + set { + SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); + } + } + + public CSharpTokenNode SemicolonToken { + get { return GetChildByRole (Roles.Semicolon); } + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + return visitor.VisitExternAliasDeclaration (this, data); + } + + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) + { + var o = other as ExternAliasDeclaration; + return o != null && MatchString (this.Name, o.Name); + } + } +} diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs index f388f856c..5f0bee4e0 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs @@ -42,6 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data); S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data); S VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data); + S VisitEmptyExpression (EmptyExpression emptyExpression, T data); S VisitQueryExpression(QueryExpression queryExpression, T data); S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data); @@ -61,6 +62,7 @@ namespace ICSharpCode.NRefactory.CSharp S VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data); S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, T data); S VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data); + S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data); S VisitBlockStatement(BlockStatement blockStatement, T data); S VisitBreakStatement(BreakStatement breakStatement, T data); @@ -107,6 +109,8 @@ namespace ICSharpCode.NRefactory.CSharp S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data); S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data); S VisitVariableInitializer(VariableInitializer variableInitializer, T data); + S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data); + S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data); S VisitCompilationUnit(CompilationUnit compilationUnit, T data); S VisitSimpleType(SimpleType simpleType, T data); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs new file mode 100644 index 000000000..2fde82260 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs @@ -0,0 +1,64 @@ +// +// FixedFieldDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// 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; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class FixedFieldDeclaration : AttributedNode + { + public static readonly Role VariableRole = new Role ("FixedVariable"); + + public override NodeType NodeType { + get { return NodeType.Member; } + } + + public CSharpTokenNode FixedToken { + get { return GetChildByRole (Roles.Keyword); } + } + + public AstType ReturnType { + get { return GetChildByRole (Roles.Type); } + set { SetChildByRole (Roles.Type, value); } + } + + public AstNodeCollection Variables { + get { return GetChildrenByRole (VariableRole); } + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + return visitor.VisitFixedFieldDeclaration (this, data); + } + + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) + { + var o = other as FixedFieldDeclaration; + return o != null && this.MatchAttributesAndModifiers (o, match) + && this.ReturnType.DoMatch (o.ReturnType, match) && this.Variables.DoMatch (o.Variables, match); + } + } +} + diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs new file mode 100644 index 000000000..75857e111 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs @@ -0,0 +1,86 @@ +// +// FixedFieldDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// 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; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// name [ ] + /// + public class FixedVariableInitializer : AstNode + { + public override NodeType NodeType { + get { + return NodeType.Unknown; + } + } + + public FixedVariableInitializer() + { + } + + public FixedVariableInitializer (string name, Expression initializer = null) + { + this.Name = name; + this.Initializer = initializer; + } + + public string Name { + get { + return GetChildByRole (Roles.Identifier).Name; + } + set { + SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + } + } + + public CSharpTokenNode LBracketToken { + get { return GetChildByRole (Roles.LBracket); } + } + + public Expression Initializer { + get { return GetChildByRole (Roles.Expression); } + set { SetChildByRole (Roles.Expression, value); } + } + + public CSharpTokenNode RBracketToken { + get { return GetChildByRole (Roles.RBracket); } + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + return visitor.VisitFixedVariableInitializer (this, data); + } + + protected internal override bool DoMatch (AstNode other, ICSharpCode.NRefactory.CSharp.PatternMatching.Match match) + { + var o = other as FixedVariableInitializer; + return o != null && MatchString (this.Name, o.Name) && this.Initializer.DoMatch (o.Initializer, match); + } + } +} + diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs new file mode 100644 index 000000000..0533d9566 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs @@ -0,0 +1,1584 @@ +// +// AstFormattingVisitor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// 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 System.Text; +using System.Collections.Generic; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class AstFormattingVisitor : DepthFirstAstVisitor + { + CSharpFormattingPolicy policy; + ITextEditorAdapter data; + List changes = new List (); + Indent curIndent = new Indent (); + + public int IndentLevel { + get { + return curIndent.Level; + } + set { + curIndent.Level = value; + } + } + + public int CurrentSpaceIndents { + get; + set; + } + + public List Changes { + get { return this.changes; } + } + + public bool CorrectBlankLines { + get; + set; + } + + public bool HadErrors { + get; + set; + } + + public AstFormattingVisitor (CSharpFormattingPolicy policy, ITextEditorAdapter data) + { + this.policy = policy; + this.data = data; + this.curIndent.TabsToSpaces = this.data.TabsToSpaces; + this.curIndent.TabSize = this.data.TabSize; + CorrectBlankLines = true; + } + + public override object VisitCompilationUnit (CompilationUnit unit, object data) + { + base.VisitCompilationUnit (unit, data); + return null; + } + + public void EnsureBlankLinesAfter (AstNode node, int blankLines) + { + if (!CorrectBlankLines) + return; + var loc = node.EndLocation; + int line = loc.Line; + do { + line++; + } while (line < data.LineCount && data.GetEditableLength (line) == data.GetIndentation (line).Length); + var start = data.GetLineEndOffset (loc.Line); + StringBuilder sb = new StringBuilder (); + for (int i = 0; i < blankLines; i++) + sb.Append (data.EolMarker); + int removedChars = line < data.LineCount ? data.GetLineOffset (line) - start : 0; + AddChange (start, removedChars, sb.ToString ()); + } + + public void EnsureBlankLinesBefore (AstNode node, int blankLines) + { + if (!CorrectBlankLines) + return; + var loc = node.StartLocation; + int line = loc.Line; + do { + line--; + } while (line > 0 && data.GetEditableLength (line) == data.GetIndentation (line).Length); + + int end = data.GetLineOffset (loc.Line); + int start = line >= 1 ? data.GetLineEndOffset (line) : 0; + StringBuilder sb = new StringBuilder (); + for (int i = 0; i < blankLines; i++) + sb.Append (data.EolMarker); + AddChange (start, end - start, sb.ToString ()); + } + + public override object VisitUsingDeclaration (UsingDeclaration usingDeclaration, object data) + { + if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) + EnsureBlankLinesAfter (usingDeclaration, policy.BlankLinesAfterUsings); + if (!(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) + EnsureBlankLinesBefore (usingDeclaration, policy.BlankLinesBeforeUsings); + + return null; + } + + public override object VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, object data) + { + if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) + EnsureBlankLinesAfter (usingDeclaration, policy.BlankLinesAfterUsings); + if (!(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) + EnsureBlankLinesBefore (usingDeclaration, policy.BlankLinesBeforeUsings); + return null; + } + + public override object VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, object data) + { + var firstNsMember = namespaceDeclaration.Members.FirstOrDefault (); + if (firstNsMember != null) + EnsureBlankLinesBefore (firstNsMember, policy.BlankLinesBeforeFirstDeclaration); + FixIndentationForceNewLine (namespaceDeclaration.StartLocation); + EnforceBraceStyle (policy.NamespaceBraceStyle, namespaceDeclaration.LBraceToken, namespaceDeclaration.RBraceToken); + if (policy.IndentNamespaceBody) + IndentLevel++; + object result = base.VisitNamespaceDeclaration (namespaceDeclaration, data); + if (policy.IndentNamespaceBody) + IndentLevel--; + FixIndentation (namespaceDeclaration.RBraceToken.StartLocation); + return result; + } + + public override object VisitTypeDeclaration (TypeDeclaration typeDeclaration, object data) + { + FixIndentationForceNewLine (typeDeclaration.StartLocation); + BraceStyle braceStyle; + bool indentBody = false; + switch (typeDeclaration.ClassType) { + case ClassType.Class: + braceStyle = policy.ClassBraceStyle; + indentBody = policy.IndentClassBody; + break; + case ClassType.Struct: + braceStyle = policy.StructBraceStyle; + indentBody = policy.IndentStructBody; + break; + case ClassType.Interface: + braceStyle = policy.InterfaceBraceStyle; + indentBody = policy.IndentInterfaceBody; + break; + case ClassType.Enum: + braceStyle = policy.EnumBraceStyle; + indentBody = policy.IndentEnumBody; + break; + default: + throw new InvalidOperationException ("unsupported class type : " + typeDeclaration.ClassType); + } + EnforceBraceStyle (braceStyle, typeDeclaration.LBraceToken, typeDeclaration.RBraceToken); + + if (indentBody) + IndentLevel++; + object result = base.VisitTypeDeclaration (typeDeclaration, data); + if (indentBody) + IndentLevel--; + + if (typeDeclaration.NextSibling is TypeDeclaration || typeDeclaration.NextSibling is DelegateDeclaration) + EnsureBlankLinesAfter (typeDeclaration, policy.BlankLinesBetweenTypes); + return result; + } + + bool IsSimpleAccessor (Accessor accessor) + { + if (accessor.IsNull || accessor.Body.IsNull || accessor.Body.FirstChild == null) + return true; + if (accessor.Body.Statements.Count () != 1) + return false; + return !(accessor.Body.Statements.FirstOrDefault () is BlockStatement); + + } + + bool IsSpacing (char ch) + { + return ch == ' ' || ch == '\t'; + } + + int SearchLastNonWsChar (int startOffset, int endOffset) + { + startOffset = System.Math.Max (0, startOffset); + endOffset = System.Math.Max (startOffset, endOffset); + if (startOffset >= endOffset) + return startOffset; + int result = -1; + bool inComment = false; + + for (int i = startOffset; i < endOffset && i < data.Length; i++) { + char ch = data.GetCharAt (i); + if (IsSpacing (ch)) + continue; + if (ch == '/' && i + 1 < data.Length && data.GetCharAt (i + 1) == '/') + return result; + if (ch == '/' && i + 1 < data.Length && data.GetCharAt (i + 1) == '*') { + inComment = true; + i++; + continue; + } + if (inComment && ch == '*' && i + 1 < data.Length && data.GetCharAt (i + 1) == '/') { + inComment = false; + i++; + continue; + } + if (!inComment) + result = i; + } + return result; + } + + void ForceSpace (int startOffset, int endOffset, bool forceSpace) + { + int lastNonWs = SearchLastNonWsChar (startOffset, endOffset); + AddChange (lastNonWs + 1, System.Math.Max (0, endOffset - lastNonWs - 1), forceSpace ? " " : ""); + } +// void ForceSpacesAfter (AstNode n, bool forceSpaces) +// { +// if (n == null) +// return; +// AstLocation location = n.EndLocation; +// int offset = data.LocationToOffset (location.Line, location.Column); +// int i = offset; +// while (i < data.Length && IsSpacing (data.GetCharAt (i))) { +// i++; +// } +// ForceSpace (offset - 1, i, forceSpaces); +// } + + void ForceSpacesAfter (AstNode n, bool forceSpaces) + { + if (n == null) + return; + AstLocation location = n.EndLocation; + int offset = data.LocationToOffset (location.Line, location.Column); + if (location.Column > data.GetEditableLength (location.Line)) + return; + int i = offset; + while (i < data.Length && IsSpacing (data.GetCharAt (i))) { + i++; + } + ForceSpace (offset - 1, i, forceSpaces); + } + +// int ForceSpacesBefore (AstNode n, bool forceSpaces) +// { +// if (n == null || n.IsNull) +// return 0; +// AstLocation location = n.StartLocation; +// +// int offset = data.LocationToOffset (location.Line, location.Column); +// int i = offset - 1; +// +// while (i >= 0 && IsSpacing (data.GetCharAt (i))) { +// i--; +// } +// ForceSpace (i, offset, forceSpaces); +// return i; +// } + + int ForceSpacesBefore (AstNode n, bool forceSpaces) + { + if (n == null || n.IsNull) + return 0; + AstLocation location = n.StartLocation; + // respect manual line breaks. + if (location.Column <= 1 || data.GetIndentation (location.Line).Length == location.Column - 1) + return 0; + + int offset = data.LocationToOffset (location.Line, location.Column); + int i = offset - 1; + while (i >= 0 && IsSpacing (data.GetCharAt (i))) { + i--; + } + ForceSpace (i, offset, forceSpaces); + return i; + } + + public override object VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, object data) + { + FixIndentationForceNewLine (propertyDeclaration.StartLocation); + bool oneLine = false; + switch (policy.PropertyFormatting) { + case PropertyFormatting.AllowOneLine: + bool isSimple = IsSimpleAccessor (propertyDeclaration.Getter) && IsSimpleAccessor (propertyDeclaration.Setter); + if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != propertyDeclaration.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); + } else { + ForceSpacesBefore (propertyDeclaration.Getter, true); + ForceSpacesBefore (propertyDeclaration.Setter, true); + ForceSpacesBefore (propertyDeclaration.RBraceToken, true); + oneLine = true; + } + break; + case PropertyFormatting.ForceNewLine: + EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); + break; + case PropertyFormatting.ForceOneLine: + isSimple = IsSimpleAccessor (propertyDeclaration.Getter) && IsSimpleAccessor (propertyDeclaration.Setter); + if (isSimple) { + int offset = this.data.LocationToOffset (propertyDeclaration.LBraceToken.StartLocation.Line, propertyDeclaration.LBraceToken.StartLocation.Column); + + int start = SearchWhitespaceStart (offset); + int end = SearchWhitespaceEnd (offset); + AddChange (start, offset - start, " "); + AddChange (offset + 1, end - offset - 2, " "); + + offset = this.data.LocationToOffset (propertyDeclaration.RBraceToken.StartLocation.Line, propertyDeclaration.RBraceToken.StartLocation.Column); + start = SearchWhitespaceStart (offset); + AddChange (start, offset - start, " "); + oneLine = true; + + } else { + EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); + } + break; + } + if (policy.IndentPropertyBody) + IndentLevel++; + ///System.Console.WriteLine ("one line: " + oneLine); + if (!propertyDeclaration.Getter.IsNull) { + if (!oneLine) { + if (!IsLineIsEmptyUpToEol (propertyDeclaration.Getter.StartLocation)) { + int offset = this.data.LocationToOffset (propertyDeclaration.Getter.StartLocation.Line, propertyDeclaration.Getter.StartLocation.Column); + int start = SearchWhitespaceStart (offset); + string indentString = this.curIndent.IndentString; + AddChange (start, offset - start, this.data.EolMarker + indentString); + } else { + FixIndentation (propertyDeclaration.Getter.StartLocation); + } + } else { + int offset = this.data.LocationToOffset (propertyDeclaration.Getter.StartLocation.Line, propertyDeclaration.Getter.StartLocation.Column); + int start = SearchWhitespaceStart (offset); + AddChange (start, offset - start, " "); + + ForceSpacesBefore (propertyDeclaration.Getter.Body.LBraceToken, true); + ForceSpacesBefore (propertyDeclaration.Getter.Body.RBraceToken, true); + } + if (!propertyDeclaration.Getter.Body.IsNull) { + if (!policy.AllowPropertyGetBlockInline || propertyDeclaration.Getter.Body.LBraceToken.StartLocation.Line != propertyDeclaration.Getter.Body.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.PropertyGetBraceStyle, propertyDeclaration.Getter.Body.LBraceToken, propertyDeclaration.Getter.Body.RBraceToken); + } else { + nextStatementIndent = " "; + } + VisitBlockWithoutFixIndentation (propertyDeclaration.Getter.Body, policy.IndentBlocks, data); + } + } + + if (!propertyDeclaration.Setter.IsNull) { + if (!oneLine) { + if (!IsLineIsEmptyUpToEol (propertyDeclaration.Setter.StartLocation)) { + int offset = this.data.LocationToOffset (propertyDeclaration.Setter.StartLocation.Line, propertyDeclaration.Setter.StartLocation.Column); + int start = SearchWhitespaceStart (offset); + string indentString = this.curIndent.IndentString; + AddChange (start, offset - start, this.data.EolMarker + indentString); + } else { + FixIndentation (propertyDeclaration.Setter.StartLocation); + } + } else { + int offset = this.data.LocationToOffset (propertyDeclaration.Setter.StartLocation.Line, propertyDeclaration.Setter.StartLocation.Column); + int start = SearchWhitespaceStart (offset); + AddChange (start, offset - start, " "); + + ForceSpacesBefore (propertyDeclaration.Setter.Body.LBraceToken, true); + ForceSpacesBefore (propertyDeclaration.Setter.Body.RBraceToken, true); + } + if (!propertyDeclaration.Setter.Body.IsNull) { + if (!policy.AllowPropertySetBlockInline || propertyDeclaration.Setter.Body.LBraceToken.StartLocation.Line != propertyDeclaration.Setter.Body.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.PropertySetBraceStyle, propertyDeclaration.Setter.Body.LBraceToken, propertyDeclaration.Setter.Body.RBraceToken); + } else { + nextStatementIndent = " "; + } + VisitBlockWithoutFixIndentation (propertyDeclaration.Setter.Body, policy.IndentBlocks, data); + } + } + + if (policy.IndentPropertyBody) + IndentLevel--; + if (IsMember (propertyDeclaration.NextSibling)) + EnsureBlankLinesAfter (propertyDeclaration, policy.BlankLinesBetweenMembers); + return null; + } + + public override object VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, object data) + { + ForceSpacesBefore (indexerDeclaration.LBracketToken, policy.SpaceBeforeIndexerDeclarationBracket); + ForceSpacesAfter (indexerDeclaration.LBracketToken, policy.SpaceWithinIndexerDeclarationBracket); + ForceSpacesBefore (indexerDeclaration.RBracketToken, policy.SpaceWithinIndexerDeclarationBracket); + + FormatCommas (indexerDeclaration, policy.SpaceBeforeIndexerDeclarationParameterComma, policy.SpaceAfterIndexerDeclarationParameterComma); + + + FixIndentationForceNewLine (indexerDeclaration.StartLocation); + EnforceBraceStyle (policy.PropertyBraceStyle, indexerDeclaration.LBraceToken, indexerDeclaration.RBraceToken); + if (policy.IndentPropertyBody) + IndentLevel++; + + if (!indexerDeclaration.Getter.IsNull) { + FixIndentation (indexerDeclaration.Getter.StartLocation); + if (!indexerDeclaration.Getter.Body.IsNull) { + if (!policy.AllowPropertyGetBlockInline || indexerDeclaration.Getter.Body.LBraceToken.StartLocation.Line != indexerDeclaration.Getter.Body.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.PropertyGetBraceStyle, indexerDeclaration.Getter.Body.LBraceToken, indexerDeclaration.Getter.Body.RBraceToken); + } else { + nextStatementIndent = " "; + } + VisitBlockWithoutFixIndentation (indexerDeclaration.Getter.Body, policy.IndentBlocks, data); + } + } + + if (!indexerDeclaration.Setter.IsNull) { + FixIndentation (indexerDeclaration.Setter.StartLocation); + if (!indexerDeclaration.Setter.Body.IsNull) { + if (!policy.AllowPropertySetBlockInline || indexerDeclaration.Setter.Body.LBraceToken.StartLocation.Line != indexerDeclaration.Setter.Body.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.PropertySetBraceStyle, indexerDeclaration.Setter.Body.LBraceToken, indexerDeclaration.Setter.Body.RBraceToken); + } else { + nextStatementIndent = " "; + } + VisitBlockWithoutFixIndentation (indexerDeclaration.Setter.Body, policy.IndentBlocks, data); + } + } + if (policy.IndentPropertyBody) + IndentLevel--; + if (IsMember (indexerDeclaration.NextSibling)) + EnsureBlankLinesAfter (indexerDeclaration, policy.BlankLinesBetweenMembers); + return null; + } + + static bool IsSimpleEvent (AstNode node) + { + return node is EventDeclaration; + } + + public override object VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration, object data) + { + FixIndentationForceNewLine (eventDeclaration.StartLocation); + EnforceBraceStyle (policy.EventBraceStyle, eventDeclaration.LBraceToken, eventDeclaration.RBraceToken); + if (policy.IndentEventBody) + IndentLevel++; + + if (!eventDeclaration.AddAccessor.IsNull) { + FixIndentation (eventDeclaration.AddAccessor.StartLocation); + if (!eventDeclaration.AddAccessor.Body.IsNull) { + if (!policy.AllowEventAddBlockInline || eventDeclaration.AddAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.AddAccessor.Body.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.LBraceToken, eventDeclaration.AddAccessor.Body.RBraceToken); + } else { + nextStatementIndent = " "; + } + + VisitBlockWithoutFixIndentation (eventDeclaration.AddAccessor.Body, policy.IndentBlocks, data); + } + } + + if (!eventDeclaration.RemoveAccessor.IsNull) { + FixIndentation (eventDeclaration.RemoveAccessor.StartLocation); + if (!eventDeclaration.RemoveAccessor.Body.IsNull) { + if (!policy.AllowEventRemoveBlockInline || eventDeclaration.RemoveAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.RemoveAccessor.Body.RBraceToken.StartLocation.Line) { + EnforceBraceStyle (policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.LBraceToken, eventDeclaration.RemoveAccessor.Body.RBraceToken); + } else { + nextStatementIndent = " "; + } + VisitBlockWithoutFixIndentation (eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks, data); + } + } + + if (policy.IndentEventBody) + IndentLevel--; + + if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent (eventDeclaration) && IsSimpleEvent (eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenEventFields); + } else if (IsMember (eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenMembers); + } + return null; + } + + public override object VisitEventDeclaration (EventDeclaration eventDeclaration, object data) + { + FixIndentationForceNewLine (eventDeclaration.StartLocation); + if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent (eventDeclaration) && IsSimpleEvent (eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenEventFields); + } else if (IsMember (eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenMembers); + } + return null; + } + + public override object VisitAccessor (Accessor accessor, object data) + { + FixIndentationForceNewLine (accessor.StartLocation); + object result = base.VisitAccessor (accessor, data); + return result; + } + + public override object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) + { + FixIndentationForceNewLine (fieldDeclaration.StartLocation); + FormatCommas (fieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma); + if (fieldDeclaration.NextSibling is FieldDeclaration) { + EnsureBlankLinesAfter (fieldDeclaration, policy.BlankLinesBetweenFields); + } else if (IsMember (fieldDeclaration.NextSibling)) { + EnsureBlankLinesAfter (fieldDeclaration, policy.BlankLinesBetweenMembers); + } + return base.VisitFieldDeclaration (fieldDeclaration, data); + } + + public override object VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, object data) + { + FixIndentationForceNewLine (enumMemberDeclaration.StartLocation); + return base.VisitEnumMemberDeclaration (enumMemberDeclaration, data); + } + + public override object VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, object data) + { + FixIndentation (delegateDeclaration.StartLocation); + + ForceSpacesBefore (delegateDeclaration.LParToken, policy.SpaceBeforeDelegateDeclarationParentheses); + if (delegateDeclaration.Parameters.Any ()) { + ForceSpacesAfter (delegateDeclaration.LParToken, policy.SpaceWithinDelegateDeclarationParentheses); + ForceSpacesBefore (delegateDeclaration.RParToken, policy.SpaceWithinDelegateDeclarationParentheses); + } else { + ForceSpacesAfter (delegateDeclaration.LParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses); + ForceSpacesBefore (delegateDeclaration.RParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses); + } + FormatCommas (delegateDeclaration, policy.SpaceBeforeDelegateDeclarationParameterComma, policy.SpaceAfterDelegateDeclarationParameterComma); + + if (delegateDeclaration.NextSibling is TypeDeclaration || delegateDeclaration.NextSibling is DelegateDeclaration) { + EnsureBlankLinesAfter (delegateDeclaration, policy.BlankLinesBetweenTypes); + } else if (IsMember (delegateDeclaration.NextSibling)) { + EnsureBlankLinesAfter (delegateDeclaration, policy.BlankLinesBetweenMembers); + } + + return base.VisitDelegateDeclaration (delegateDeclaration, data); + } + + static bool IsMember (AstNode nextSibling) + { + return nextSibling != null && nextSibling.NodeType == NodeType.Member; + } + + public override object VisitMethodDeclaration (MethodDeclaration methodDeclaration, object data) + { + FixIndentationForceNewLine (methodDeclaration.StartLocation); + + ForceSpacesBefore (methodDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); + if (methodDeclaration.Parameters.Any ()) { + ForceSpacesAfter (methodDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); + ForceSpacesBefore (methodDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); + } else { + ForceSpacesAfter (methodDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + ForceSpacesBefore (methodDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + } + FormatCommas (methodDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); + + if (!methodDeclaration.Body.IsNull) { + EnforceBraceStyle (policy.MethodBraceStyle, methodDeclaration.Body.LBraceToken, methodDeclaration.Body.RBraceToken); + if (policy.IndentMethodBody) + IndentLevel++; + base.VisitBlockStatement (methodDeclaration.Body, data); + if (policy.IndentMethodBody) + IndentLevel--; + } + if (IsMember (methodDeclaration.NextSibling)) + EnsureBlankLinesAfter (methodDeclaration, policy.BlankLinesBetweenMembers); + + return null; + } + + public override object VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, object data) + { + FixIndentationForceNewLine (operatorDeclaration.StartLocation); + + ForceSpacesBefore (operatorDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); + if (operatorDeclaration.Parameters.Any ()) { + ForceSpacesAfter (operatorDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); + ForceSpacesBefore (operatorDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); + } else { + ForceSpacesAfter (operatorDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + ForceSpacesBefore (operatorDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + } + FormatCommas (operatorDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); + + if (!operatorDeclaration.Body.IsNull) { + EnforceBraceStyle (policy.MethodBraceStyle, operatorDeclaration.Body.LBraceToken, operatorDeclaration.Body.RBraceToken); + if (policy.IndentMethodBody) + IndentLevel++; + base.VisitBlockStatement (operatorDeclaration.Body, data); + if (policy.IndentMethodBody) + IndentLevel--; + } + if (IsMember (operatorDeclaration.NextSibling)) + EnsureBlankLinesAfter (operatorDeclaration, policy.BlankLinesBetweenMembers); + + return null; + } + + public override object VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, object data) + { + FixIndentationForceNewLine (constructorDeclaration.StartLocation); + + ForceSpacesBefore (constructorDeclaration.LParToken, policy.SpaceBeforeConstructorDeclarationParentheses); + if (constructorDeclaration.Parameters.Any ()) { + ForceSpacesAfter (constructorDeclaration.LParToken, policy.SpaceWithinConstructorDeclarationParentheses); + ForceSpacesBefore (constructorDeclaration.RParToken, policy.SpaceWithinConstructorDeclarationParentheses); + } else { + ForceSpacesAfter (constructorDeclaration.LParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); + ForceSpacesBefore (constructorDeclaration.RParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); + } + FormatCommas (constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma); + + object result = null; + if (!constructorDeclaration.Body.IsNull) { + EnforceBraceStyle (policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken); + if (policy.IndentMethodBody) + IndentLevel++; + result = base.VisitBlockStatement (constructorDeclaration.Body, data); + if (policy.IndentMethodBody) + IndentLevel--; + } + if (IsMember (constructorDeclaration.NextSibling)) + EnsureBlankLinesAfter (constructorDeclaration, policy.BlankLinesBetweenMembers); + return result; + } + + public override object VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, object data) + { + FixIndentationForceNewLine (destructorDeclaration.StartLocation); + + CSharpTokenNode lParen = destructorDeclaration.LParToken; + int offset = this.data.LocationToOffset (lParen.StartLocation.Line, lParen.StartLocation.Column); + ForceSpaceBefore (offset, policy.SpaceBeforeConstructorDeclarationParentheses); + + object result = null; + if (!destructorDeclaration.Body.IsNull) { + EnforceBraceStyle (policy.DestructorBraceStyle, destructorDeclaration.Body.LBraceToken, destructorDeclaration.Body.RBraceToken); + if (policy.IndentMethodBody) + IndentLevel++; + result = base.VisitBlockStatement (destructorDeclaration.Body, data); + if (policy.IndentMethodBody) + IndentLevel--; + } + if (IsMember (destructorDeclaration.NextSibling)) + EnsureBlankLinesAfter (destructorDeclaration, policy.BlankLinesBetweenMembers); + return result; + } + + #region Statements + public override object VisitExpressionStatement (ExpressionStatement expressionStatement, object data) + { + FixStatementIndentation (expressionStatement.StartLocation); + FixSemicolon (expressionStatement.SemicolonToken); + return base.VisitExpressionStatement (expressionStatement, data); + } + + object VisitBlockWithoutFixIndentation (BlockStatement blockStatement, bool indent, object data) + { + if (indent) + IndentLevel++; + object result = base.VisitBlockStatement (blockStatement, data); + if (indent) + IndentLevel--; + return result; + } + + public override object VisitBlockStatement (BlockStatement blockStatement, object data) + { + FixIndentation (blockStatement.StartLocation); + object result = VisitBlockWithoutFixIndentation (blockStatement, policy.IndentBlocks, data); + FixIndentation (blockStatement.EndLocation, -1); + return result; + } + + public override object VisitComment (Comment comment, object data) + { + if (comment.StartsLine && !HadErrors && comment.StartLocation.Column > 1) + FixIndentation (comment.StartLocation); + return null; + } + + public override object VisitBreakStatement (BreakStatement breakStatement, object data) + { + FixStatementIndentation (breakStatement.StartLocation); + return null; + } + + public override object VisitCheckedStatement (CheckedStatement checkedStatement, object data) + { + FixStatementIndentation (checkedStatement.StartLocation); + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, checkedStatement.Body); + } + + public override object VisitContinueStatement (ContinueStatement continueStatement, object data) + { + FixStatementIndentation (continueStatement.StartLocation); + return null; + } + + public override object VisitEmptyStatement (EmptyStatement emptyStatement, object data) + { + FixStatementIndentation (emptyStatement.StartLocation); + return null; + } + + public override object VisitFixedStatement (FixedStatement fixedStatement, object data) + { + FixStatementIndentation (fixedStatement.StartLocation); + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, fixedStatement.EmbeddedStatement); + } + + public override object VisitForeachStatement (ForeachStatement foreachStatement, object data) + { + FixStatementIndentation (foreachStatement.StartLocation); + ForceSpacesBefore (foreachStatement.LParToken, policy.SpaceBeforeForeachParentheses); + + ForceSpacesAfter (foreachStatement.LParToken, policy.SpacesWithinForeachParentheses); + ForceSpacesBefore (foreachStatement.RParToken, policy.SpacesWithinForeachParentheses); + + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.ForEachBraceForcement, foreachStatement.EmbeddedStatement); + } + + object FixEmbeddedStatment (BraceStyle braceStyle, BraceForcement braceForcement, AstNode node) + { + return FixEmbeddedStatment (braceStyle, braceForcement, null, false, node); + } + + object FixEmbeddedStatment (BraceStyle braceStyle, BraceForcement braceForcement, CSharpTokenNode token, bool allowInLine, AstNode node) + { + if (node == null) + return null; + int originalLevel = curIndent.Level; + bool isBlock = node is BlockStatement; + switch (braceForcement) { + case BraceForcement.DoNotChange: + //nothing + break; + case BraceForcement.AddBraces: + if (!isBlock) { + AstNode n = node.Parent.GetCSharpNodeBefore (node); + int start = data.LocationToOffset (n.EndLocation.Line, n.EndLocation.Column); + var next = n.GetNextNode (); + int offset = data.LocationToOffset (next.StartLocation.Line, next.StartLocation.Column); + string startBrace = ""; + switch (braceStyle) { + case BraceStyle.EndOfLineWithoutSpace: + startBrace = "{"; + break; + case BraceStyle.EndOfLine: + startBrace = " {"; + break; + case BraceStyle.NextLine: + startBrace = data.EolMarker + curIndent.IndentString + "{"; + break; + case BraceStyle.NextLineShifted2: + case BraceStyle.NextLineShifted: + startBrace = data.EolMarker + curIndent.IndentString + curIndent.SingleIndent + "{"; + break; + } + if (IsLineIsEmptyUpToEol (data.LocationToOffset (node.StartLocation.Line, node.StartLocation.Column))) + startBrace += data.EolMarker + data.GetIndentation (node.StartLocation.Line); + AddChange (start, offset - start, startBrace); + } + break; + case BraceForcement.RemoveBraces: + if (isBlock) { + BlockStatement block = node as BlockStatement; + if (block.Statements.Count () == 1) { + int offset1 = data.LocationToOffset (node.StartLocation.Line, node.StartLocation.Column); + int start = SearchWhitespaceStart (offset1); + + int offset2 = data.LocationToOffset (node.EndLocation.Line, node.EndLocation.Column); + int end = SearchWhitespaceStart (offset2 - 1); + + AddChange (start, offset1 - start + 1, null); + AddChange (end + 1, offset2 - end, null); + node = block.FirstChild; + isBlock = false; + } + } + break; + } + if (isBlock) { + BlockStatement block = node as BlockStatement; + if (allowInLine && block.StartLocation.Line == block.EndLocation.Line && block.Statements.Count () <= 1) { + if (block.Statements.Count () == 1) + nextStatementIndent = " "; + } else { + EnforceBraceStyle (braceStyle, block.LBraceToken, block.RBraceToken); + } + if (braceStyle == BraceStyle.NextLineShifted2) + curIndent.Level++; + } else { + if (allowInLine && token.StartLocation.Line == node.EndLocation.Line) { + nextStatementIndent = " "; + } + } + if (!(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || + policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) + curIndent.Level++; + object result = isBlock ? base.VisitBlockStatement ((BlockStatement)node, null) : node.AcceptVisitor (this, null); + curIndent.Level = originalLevel; + switch (braceForcement) { + case BraceForcement.DoNotChange: + break; + case BraceForcement.AddBraces: + if (!isBlock) { + int offset = data.LocationToOffset (node.EndLocation.Line, node.EndLocation.Column); + if (!char.IsWhiteSpace (data.GetCharAt (offset))) + offset++; + string startBrace = ""; + switch (braceStyle) { + case BraceStyle.DoNotChange: + startBrace = null; + break; + case BraceStyle.EndOfLineWithoutSpace: + startBrace = data.EolMarker + curIndent.IndentString + "}"; + break; + case BraceStyle.EndOfLine: + startBrace = data.EolMarker + curIndent.IndentString + "}"; + break; + case BraceStyle.NextLine: + startBrace = data.EolMarker + curIndent.IndentString + "}"; + break; + case BraceStyle.NextLineShifted2: + case BraceStyle.NextLineShifted: + startBrace = data.EolMarker + curIndent.IndentString + curIndent.SingleIndent + "}"; + break; + } + if (startBrace != null) + AddChange (offset, 0, startBrace); + } + break; + } + return result; + } + + void EnforceBraceStyle (BraceStyle braceStyle, AstNode lbrace, AstNode rbrace) + { + if (lbrace.IsNull || rbrace.IsNull) + return; + +// LineSegment lbraceLineSegment = data.Document.GetLine (lbrace.StartLocation.Line); + int lbraceOffset = data.LocationToOffset (lbrace.StartLocation.Line, lbrace.StartLocation.Column); + +// LineSegment rbraceLineSegment = data.Document.GetLine (rbrace.StartLocation.Line); + int rbraceOffset = data.LocationToOffset (rbrace.StartLocation.Line, rbrace.StartLocation.Column); + int whitespaceStart = SearchWhitespaceStart (lbraceOffset); + int whitespaceEnd = SearchWhitespaceLineStart (rbraceOffset); + string startIndent = ""; + string endIndent = ""; + switch (braceStyle) { + case BraceStyle.DoNotChange: + startIndent = endIndent = null; + break; + case BraceStyle.EndOfLineWithoutSpace: + startIndent = ""; + endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString : data.EolMarker + curIndent.IndentString; + break; + case BraceStyle.EndOfLine: + var prevNode = lbrace.GetPrevNode (); + if (prevNode is Comment) { + // delete old bracket + AddChange (whitespaceStart, lbraceOffset - whitespaceStart + 1, ""); + + while (prevNode is Comment) { + prevNode = prevNode.GetPrevNode (); + } + whitespaceStart = data.LocationToOffset (prevNode.EndLocation.Line, prevNode.EndLocation.Column); + lbraceOffset = whitespaceStart; + startIndent = " {"; + } else { + startIndent = " "; + } + endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString : data.EolMarker + curIndent.IndentString; + break; + case BraceStyle.NextLine: + startIndent = data.EolMarker + curIndent.IndentString; + endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString : data.EolMarker + curIndent.IndentString; + break; + case BraceStyle.NextLineShifted2: + case BraceStyle.NextLineShifted: + startIndent = data.EolMarker + curIndent.IndentString + curIndent.SingleIndent; + endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString + curIndent.SingleIndent : data.EolMarker + curIndent.IndentString + curIndent.SingleIndent; + break; + } + + if (lbraceOffset > 0 && startIndent != null) + AddChange (whitespaceStart, lbraceOffset - whitespaceStart, startIndent); + if (rbraceOffset > 0 && endIndent != null) + AddChange (whitespaceEnd, rbraceOffset - whitespaceEnd, endIndent); + } + + void AddChange (int offset, int removedChars, string insertedText) + { + if (changes.Any (c => c.Offset == offset && c.RemovedChars == removedChars + && c.InsertedText == insertedText)) + return; + string currentText = data.GetTextAt (offset, removedChars); + if (currentText == insertedText) + return; + if (currentText.Any (c => !(char.IsWhiteSpace (c) || c == '\r' || c == '\t' || c == '{' || c == '}'))) + throw new InvalidOperationException ("Tried to remove non ws chars: '" + currentText + "'"); + foreach (var change in changes) { + if (change.Offset == offset) { + if (removedChars > 0 && insertedText == change.InsertedText) { + change.RemovedChars = removedChars; +// change.InsertedText = insertedText; + return; + } + if (!string.IsNullOrEmpty (change.InsertedText)) { + change.InsertedText += insertedText; + } else { + change.InsertedText = insertedText; + } + change.RemovedChars = System.Math.Max (removedChars, change.RemovedChars); + return; + } + } +// Console.WriteLine ("offset={0}, removedChars={1}, insertedText={2}", offset, removedChars , insertedText == null ? "" : insertedText.Replace("\n", "\\n").Replace("\t", "\\t").Replace(" ", ".")); +// Console.WriteLine (Environment.StackTrace); + + changes.Add (new Change (offset, removedChars, insertedText)); + } + + public bool IsLineIsEmptyUpToEol (AstLocation startLocation) + { + return IsLineIsEmptyUpToEol (data.LocationToOffset (startLocation.Line, startLocation.Column) - 1); + } + + bool IsLineIsEmptyUpToEol (int startOffset) + { + for (int offset = startOffset - 1; offset >= 0; offset--) { + char ch = data.GetCharAt (offset); + if (ch != ' ' && ch != '\t') + return ch == '\n' || ch == '\r'; + } + return true; + } + + int SearchWhitespaceStart (int startOffset) + { + if (startOffset < 0) + throw new ArgumentOutOfRangeException ("startoffset", "value : " + startOffset); + for (int offset = startOffset - 1; offset >= 0; offset--) { + char ch = data.GetCharAt (offset); + if (!Char.IsWhiteSpace (ch)) { + return offset + 1; + } + } + return 0; + } + + int SearchWhitespaceEnd (int startOffset) + { + if (startOffset > data.Length) + throw new ArgumentOutOfRangeException ("startoffset", "value : " + startOffset); + for (int offset = startOffset + 1; offset < data.Length; offset++) { + char ch = data.GetCharAt (offset); + if (!Char.IsWhiteSpace (ch)) { + return offset + 1; + } + } + return data.Length - 1; + } + + int SearchWhitespaceLineStart (int startOffset) + { + if (startOffset < 0) + throw new ArgumentOutOfRangeException ("startoffset", "value : " + startOffset); + for (int offset = startOffset - 1; offset >= 0; offset--) { + char ch = data.GetCharAt (offset); + if (ch != ' ' && ch != '\t') { + return offset + 1; + } + } + return 0; + } + + public override object VisitForStatement (ForStatement forStatement, object data) + { + FixStatementIndentation (forStatement.StartLocation); + foreach (AstNode node in forStatement.Children) { + if (node.Role == ForStatement.Roles.Semicolon) { + if (node.NextSibling is CSharpTokenNode || node.NextSibling is EmptyStatement) + continue; + ForceSpacesBefore (node, policy.SpaceBeforeForSemicolon); + ForceSpacesAfter (node, policy.SpaceAfterForSemicolon); + } + } + + ForceSpacesBefore (forStatement.LParToken, policy.SpaceBeforeForParentheses); + + ForceSpacesAfter (forStatement.LParToken, policy.SpacesWithinForParentheses); + ForceSpacesBefore (forStatement.RParToken, policy.SpacesWithinForParentheses); + + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.ForBraceForcement, forStatement.EmbeddedStatement); + } + + public override object VisitGotoStatement (GotoStatement gotoStatement, object data) + { + FixStatementIndentation (gotoStatement.StartLocation); + return VisitChildren (gotoStatement, data); + } + + public override object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) + { + ForceSpacesBefore (ifElseStatement.LParToken, policy.SpaceBeforeIfParentheses); + + ForceSpacesAfter (ifElseStatement.LParToken, policy.SpacesWithinIfParentheses); + ForceSpacesBefore (ifElseStatement.RParToken, policy.SpacesWithinIfParentheses); + + if (!(ifElseStatement.Parent is IfElseStatement && ((IfElseStatement)ifElseStatement.Parent).FalseStatement == ifElseStatement)) + FixStatementIndentation (ifElseStatement.StartLocation); + + if (!ifElseStatement.Condition.IsNull) + ifElseStatement.Condition.AcceptVisitor (this, data); + + if (!ifElseStatement.TrueStatement.IsNull) + FixEmbeddedStatment (policy.StatementBraceStyle, policy.IfElseBraceForcement, ifElseStatement.IfToken, policy.AllowIfBlockInline, ifElseStatement.TrueStatement); + + if (!ifElseStatement.FalseStatement.IsNull) { + PlaceOnNewLine (policy.PlaceElseOnNewLine || !(ifElseStatement.TrueStatement is BlockStatement) && policy.IfElseBraceForcement != BraceForcement.AddBraces, ifElseStatement.ElseToken); + var forcement = policy.IfElseBraceForcement; + if (ifElseStatement.FalseStatement is IfElseStatement) { + forcement = BraceForcement.DoNotChange; + PlaceOnNewLine (policy.PlaceElseIfOnNewLine, ((IfElseStatement)ifElseStatement.FalseStatement).IfToken); + } + FixEmbeddedStatment (policy.StatementBraceStyle, forcement, ifElseStatement.ElseToken, policy.AllowIfBlockInline, ifElseStatement.FalseStatement); + } + + return null; + } + + public override object VisitLabelStatement (LabelStatement labelStatement, object data) + { + // TODO + return VisitChildren (labelStatement, data); + } + + public override object VisitLockStatement (LockStatement lockStatement, object data) + { + FixStatementIndentation (lockStatement.StartLocation); + ForceSpacesBefore (lockStatement.LParToken, policy.SpaceBeforeLockParentheses); + + ForceSpacesAfter (lockStatement.LParToken, policy.SpacesWithinLockParentheses); + ForceSpacesBefore (lockStatement.RParToken, policy.SpacesWithinLockParentheses); + + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, lockStatement.EmbeddedStatement); + } + + public override object VisitReturnStatement (ReturnStatement returnStatement, object data) + { + FixStatementIndentation (returnStatement.StartLocation); + return VisitChildren (returnStatement, data); + } + + public override object VisitSwitchStatement (SwitchStatement switchStatement, object data) + { + FixStatementIndentation (switchStatement.StartLocation); + ForceSpacesBefore (switchStatement.LParToken, policy.SpaceBeforeSwitchParentheses); + + ForceSpacesAfter (switchStatement.LParToken, policy.SpacesWithinSwitchParentheses); + ForceSpacesBefore (switchStatement.RParToken, policy.SpacesWithinSwitchParentheses); + + EnforceBraceStyle (policy.StatementBraceStyle, switchStatement.LBraceToken, switchStatement.RBraceToken); + object result = VisitChildren (switchStatement, data); + return result; + } + + public override object VisitSwitchSection (SwitchSection switchSection, object data) + { + if (policy.IndentSwitchBody) + curIndent.Level++; + + foreach (CaseLabel label in switchSection.CaseLabels) { + FixStatementIndentation (label.StartLocation); + } + if (policy.IndentCaseBody) + curIndent.Level++; + + foreach (var stmt in switchSection.Statements) { + stmt.AcceptVisitor (this, null); + } + if (policy.IndentCaseBody) + curIndent.Level--; + + if (policy.IndentSwitchBody) + curIndent.Level--; + return null; + } + + public override object VisitCaseLabel (CaseLabel caseLabel, object data) + { + // handled in switchsection + return null; + } + + public override object VisitThrowStatement (ThrowStatement throwStatement, object data) + { + FixStatementIndentation (throwStatement.StartLocation); + return VisitChildren (throwStatement, data); + } + + public override object VisitTryCatchStatement (TryCatchStatement tryCatchStatement, object data) + { + FixStatementIndentation (tryCatchStatement.StartLocation); + + if (!tryCatchStatement.TryBlock.IsNull) + FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.TryBlock); + + foreach (CatchClause clause in tryCatchStatement.CatchClauses) { + PlaceOnNewLine (policy.PlaceCatchOnNewLine, clause.CatchToken); + if (!clause.LParToken.IsNull) { + ForceSpacesBefore (clause.LParToken, policy.SpaceBeforeCatchParentheses); + + ForceSpacesAfter (clause.LParToken, policy.SpacesWithinCatchParentheses); + ForceSpacesBefore (clause.RParToken, policy.SpacesWithinCatchParentheses); + } + FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, clause.Body); + } + + if (!tryCatchStatement.FinallyBlock.IsNull) { + PlaceOnNewLine (policy.PlaceFinallyOnNewLine, tryCatchStatement.FinallyToken); + + FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.FinallyBlock); + } + + return VisitChildren (tryCatchStatement, data); + } + + public override object VisitCatchClause (CatchClause catchClause, object data) + { + // Handled in TryCatchStatement + return null; + } + + public override object VisitUncheckedStatement (UncheckedStatement uncheckedStatement, object data) + { + FixStatementIndentation (uncheckedStatement.StartLocation); + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, uncheckedStatement.Body); + } + + public override object VisitUnsafeStatement (UnsafeStatement unsafeStatement, object data) + { + FixStatementIndentation (unsafeStatement.StartLocation); + return FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, unsafeStatement.Body); + } + + public override object VisitUsingStatement (UsingStatement usingStatement, object data) + { + FixStatementIndentation (usingStatement.StartLocation); + ForceSpacesBefore (usingStatement.LParToken, policy.SpaceBeforeUsingParentheses); + + ForceSpacesAfter (usingStatement.LParToken, policy.SpacesWithinUsingParentheses); + ForceSpacesBefore (usingStatement.RParToken, policy.SpacesWithinUsingParentheses); + + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.UsingBraceForcement, usingStatement.EmbeddedStatement); + } + + public override object VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, object data) + { + if (!variableDeclarationStatement.SemicolonToken.IsNull) + FixStatementIndentation (variableDeclarationStatement.StartLocation); + + if ((variableDeclarationStatement.Modifiers & Modifiers.Const) == Modifiers.Const) { + ForceSpacesAround (variableDeclarationStatement.Type, true); + } else { + ForceSpacesAfter (variableDeclarationStatement.Type, true); + } + foreach (var initializer in variableDeclarationStatement.Variables) { + initializer.AcceptVisitor (this, data); + } + FormatCommas (variableDeclarationStatement, policy.SpaceBeforeLocalVariableDeclarationComma, policy.SpaceAfterLocalVariableDeclarationComma); + FixSemicolon (variableDeclarationStatement.SemicolonToken); + return null; + } + + public override object VisitDoWhileStatement (DoWhileStatement doWhileStatement, object data) + { + FixStatementIndentation (doWhileStatement.StartLocation); + PlaceOnNewLine (policy.PlaceWhileOnNewLine, doWhileStatement.WhileToken); + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.WhileBraceForcement, doWhileStatement.EmbeddedStatement); + } + + public override object VisitWhileStatement (WhileStatement whileStatement, object data) + { + FixStatementIndentation (whileStatement.StartLocation); + ForceSpacesBefore (whileStatement.LParToken, policy.SpaceBeforeWhileParentheses); + + ForceSpacesAfter (whileStatement.LParToken, policy.SpacesWithinWhileParentheses); + ForceSpacesBefore (whileStatement.RParToken, policy.SpacesWithinWhileParentheses); + + return FixEmbeddedStatment (policy.StatementBraceStyle, policy.WhileBraceForcement, whileStatement.EmbeddedStatement); + } + + public override object VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, object data) + { + FixStatementIndentation (yieldBreakStatement.StartLocation); + return null; + } + + public override object VisitYieldStatement (YieldStatement yieldStatement, object data) + { + FixStatementIndentation (yieldStatement.StartLocation); + return null; + } + + public override object VisitVariableInitializer (VariableInitializer variableInitializer, object data) + { + if (!variableInitializer.AssignToken.IsNull) + ForceSpacesAround (variableInitializer.AssignToken, policy.SpaceAroundAssignment); + if (!variableInitializer.Initializer.IsNull) + variableInitializer.Initializer.AcceptVisitor (this, data); + return data; + } + + #endregion + + #region Expressions + public override object VisitComposedType (ComposedType composedType, object data) + { + var spec = composedType.ArraySpecifiers.FirstOrDefault (); + if (spec != null) + ForceSpacesBefore (spec.LBracketToken, policy.SpaceBeforeArrayDeclarationBrackets); + + return base.VisitComposedType (composedType, data); + } + + public override object VisitAssignmentExpression (AssignmentExpression assignmentExpression, object data) + { + ForceSpacesAround (assignmentExpression.OperatorToken, policy.SpaceAroundAssignment); + return base.VisitAssignmentExpression (assignmentExpression, data); + } + + public override object VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, object data) + { + bool forceSpaces = false; + switch (binaryOperatorExpression.Operator) { + case BinaryOperatorType.Equality: + case BinaryOperatorType.InEquality: + forceSpaces = policy.SpaceAroundEqualityOperator; + break; + case BinaryOperatorType.GreaterThan: + case BinaryOperatorType.GreaterThanOrEqual: + case BinaryOperatorType.LessThan: + case BinaryOperatorType.LessThanOrEqual: + forceSpaces = policy.SpaceAroundRelationalOperator; + break; + case BinaryOperatorType.ConditionalAnd: + case BinaryOperatorType.ConditionalOr: + forceSpaces = policy.SpaceAroundLogicalOperator; + break; + case BinaryOperatorType.BitwiseAnd: + case BinaryOperatorType.BitwiseOr: + case BinaryOperatorType.ExclusiveOr: + forceSpaces = policy.SpaceAroundBitwiseOperator; + break; + case BinaryOperatorType.Add: + case BinaryOperatorType.Subtract: + forceSpaces = policy.SpaceAroundAdditiveOperator; + break; + case BinaryOperatorType.Multiply: + case BinaryOperatorType.Divide: + case BinaryOperatorType.Modulus: + forceSpaces = policy.SpaceAroundMultiplicativeOperator; + break; + case BinaryOperatorType.ShiftLeft: + case BinaryOperatorType.ShiftRight: + forceSpaces = policy.SpaceAroundShiftOperator; + break; + case BinaryOperatorType.NullCoalescing: + forceSpaces = policy.SpaceAroundNullCoalescingOperator; + break; + } + ForceSpacesAround (binaryOperatorExpression.OperatorToken, forceSpaces); + + return base.VisitBinaryOperatorExpression (binaryOperatorExpression, data); + } + + public override object VisitConditionalExpression (ConditionalExpression conditionalExpression, object data) + { + ForceSpacesBefore (conditionalExpression.QuestionMarkToken, policy.SpaceBeforeConditionalOperatorCondition); + ForceSpacesAfter (conditionalExpression.QuestionMarkToken, policy.SpaceAfterConditionalOperatorCondition); + ForceSpacesBefore (conditionalExpression.ColonToken, policy.SpaceBeforeConditionalOperatorSeparator); + ForceSpacesAfter (conditionalExpression.ColonToken, policy.SpaceAfterConditionalOperatorSeparator); + return base.VisitConditionalExpression (conditionalExpression, data); + } + + public override object VisitCastExpression (CastExpression castExpression, object data) + { + if (castExpression.RParToken != null) { + ForceSpacesAfter (castExpression.LParToken, policy.SpacesWithinCastParentheses); + ForceSpacesBefore (castExpression.RParToken, policy.SpacesWithinCastParentheses); + + ForceSpacesAfter (castExpression.RParToken, policy.SpaceAfterTypecast); + } + return base.VisitCastExpression (castExpression, data); + } + + void ForceSpacesAround (AstNode node, bool forceSpaces) + { + if (node.IsNull) + return; + ForceSpacesBefore (node, forceSpaces); + ForceSpacesAfter (node, forceSpaces); + } + + void FormatCommas (AstNode parent, bool before, bool after) + { + if (parent.IsNull) + return; + foreach (CSharpTokenNode comma in parent.Children.Where (node => node.Role == FieldDeclaration.Roles.Comma)) { + ForceSpacesAfter (comma, after); + ForceSpacesBefore (comma, before); + } + } + + public override object VisitInvocationExpression (InvocationExpression invocationExpression, object data) + { + ForceSpacesBefore (invocationExpression.LParToken, policy.SpaceBeforeMethodCallParentheses); + if (invocationExpression.Arguments.Any ()) { + ForceSpacesAfter (invocationExpression.LParToken, policy.SpaceWithinMethodCallParentheses); + ForceSpacesBefore (invocationExpression.RParToken, policy.SpaceWithinMethodCallParentheses); + } else { + ForceSpacesAfter (invocationExpression.LParToken, policy.SpaceBetweenEmptyMethodCallParentheses); + ForceSpacesBefore (invocationExpression.RParToken, policy.SpaceBetweenEmptyMethodCallParentheses); + } + FormatCommas (invocationExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); + + return base.VisitInvocationExpression (invocationExpression, data); + } + + public override object VisitIndexerExpression (IndexerExpression indexerExpression, object data) + { + ForceSpacesBefore (indexerExpression.LBracketToken, policy.SpacesBeforeBrackets); + ForceSpacesAfter (indexerExpression.LBracketToken, policy.SpacesWithinBrackets); + ForceSpacesBefore (indexerExpression.RBracketToken, policy.SpacesWithinBrackets); + FormatCommas (indexerExpression, policy.SpaceBeforeBracketComma, policy.SpaceAfterBracketComma); + + return base.VisitIndexerExpression (indexerExpression, data); + } + + public override object VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, object data) + { + ForceSpacesAfter (parenthesizedExpression.LParToken, policy.SpacesWithinParentheses); + ForceSpacesBefore (parenthesizedExpression.RParToken, policy.SpacesWithinParentheses); + return base.VisitParenthesizedExpression (parenthesizedExpression, data); + } + + public override object VisitSizeOfExpression (SizeOfExpression sizeOfExpression, object data) + { + ForceSpacesBefore (sizeOfExpression.LParToken, policy.SpaceBeforeSizeOfParentheses); + ForceSpacesAfter (sizeOfExpression.LParToken, policy.SpacesWithinSizeOfParentheses); + ForceSpacesBefore (sizeOfExpression.RParToken, policy.SpacesWithinSizeOfParentheses); + return base.VisitSizeOfExpression (sizeOfExpression, data); + } + + public override object VisitTypeOfExpression (TypeOfExpression typeOfExpression, object data) + { + ForceSpacesBefore (typeOfExpression.LParToken, policy.SpaceBeforeTypeOfParentheses); + ForceSpacesAfter (typeOfExpression.LParToken, policy.SpacesWithinTypeOfParentheses); + ForceSpacesBefore (typeOfExpression.RParToken, policy.SpacesWithinTypeOfParentheses); + return base.VisitTypeOfExpression (typeOfExpression, data); + } + + public override object VisitCheckedExpression (CheckedExpression checkedExpression, object data) + { + ForceSpacesAfter (checkedExpression.LParToken, policy.SpacesWithinCheckedExpressionParantheses); + ForceSpacesBefore (checkedExpression.RParToken, policy.SpacesWithinCheckedExpressionParantheses); + return base.VisitCheckedExpression (checkedExpression, data); + } + + public override object VisitUncheckedExpression (UncheckedExpression uncheckedExpression, object data) + { + ForceSpacesAfter (uncheckedExpression.LParToken, policy.SpacesWithinCheckedExpressionParantheses); + ForceSpacesBefore (uncheckedExpression.RParToken, policy.SpacesWithinCheckedExpressionParantheses); + return base.VisitUncheckedExpression (uncheckedExpression, data); + } + + public override object VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, object data) + { + ForceSpacesBefore (objectCreateExpression.LParToken, policy.SpaceBeforeNewParentheses); + + if (objectCreateExpression.Arguments.Any ()) { + if (!objectCreateExpression.LParToken.IsNull) + ForceSpacesAfter (objectCreateExpression.LParToken, policy.SpacesWithinNewParentheses); + if (!objectCreateExpression.RParToken.IsNull) + ForceSpacesBefore (objectCreateExpression.RParToken, policy.SpacesWithinNewParentheses); + } else { + if (!objectCreateExpression.LParToken.IsNull) + ForceSpacesAfter (objectCreateExpression.LParToken, policy.SpacesBetweenEmptyNewParentheses); + if (!objectCreateExpression.RParToken.IsNull) + ForceSpacesBefore (objectCreateExpression.RParToken, policy.SpacesBetweenEmptyNewParentheses); + } + FormatCommas (objectCreateExpression, policy.SpaceBeforeNewParameterComma, policy.SpaceAfterNewParameterComma); + + return base.VisitObjectCreateExpression (objectCreateExpression, data); + } + + public override object VisitArrayCreateExpression (ArrayCreateExpression arrayObjectCreateExpression, object data) + { + FormatCommas (arrayObjectCreateExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); + return base.VisitArrayCreateExpression (arrayObjectCreateExpression, data); + } + + public override object VisitLambdaExpression (LambdaExpression lambdaExpression, object data) + { + ForceSpacesAfter (lambdaExpression.ArrowToken, true); + ForceSpacesBefore (lambdaExpression.ArrowToken, true); + + return base.VisitLambdaExpression (lambdaExpression, data); + } + + #endregion + + void ForceSpaceBefore (int offset, bool forceSpace) + { + bool insertedSpace = false; + do { + char ch = data.GetCharAt (offset); + //Console.WriteLine (ch); + if (!IsSpacing (ch) && (insertedSpace || !forceSpace)) + break; + if (ch == ' ' && forceSpace) { + if (insertedSpace) { + AddChange (offset, 1, null); + } else { + insertedSpace = true; + } + } else if (forceSpace) { + if (!insertedSpace) { + AddChange (offset, IsSpacing (ch) ? 1 : 0, " "); + insertedSpace = true; + } else if (IsSpacing (ch)) { + AddChange (offset, 1, null); + } + } + + offset--; + } while (offset >= 0); + } + + + + /* + int GetLastNonWsChar (LineSegment line, int lastColumn) + { + int result = -1; + bool inComment = false; + for (int i = 0; i < lastColumn; i++) { + char ch = data.GetCharAt (line.Offset + i); + if (Char.IsWhiteSpace (ch)) + continue; + if (ch == '/' && i + 1 < line.EditableLength && data.GetCharAt (line.Offset + i + 1) == '/') + return result; + if (ch == '/' && i + 1 < line.EditableLength && data.GetCharAt (line.Offset + i + 1) == '*') { + inComment = true; + i++; + continue; + } + if (inComment && ch == '*' && i + 1 < line.EditableLength && data.GetCharAt (line.Offset + i + 1) == '/') { + inComment = false; + i++; + continue; + } + if (!inComment) + result = i; + } + return result; + } + */ + + + public void FixSemicolon (CSharpTokenNode semicolon) + { + if (semicolon.IsNull) + return; + int endOffset = data.LocationToOffset (semicolon.StartLocation.Line, semicolon.StartLocation.Column); + int offset = endOffset; + while (offset - 1 > 0 && char.IsWhiteSpace (data.GetCharAt (offset - 1))) { + offset--; + } + if (offset < endOffset) { + AddChange (offset, endOffset - offset, null); + } + } + + void PlaceOnNewLine (bool newLine, AstNode keywordNode) + { + if (keywordNode == null) + return; + int offset = data.LocationToOffset (keywordNode.StartLocation.Line, keywordNode.StartLocation.Column); + + int whitespaceStart = SearchWhitespaceStart (offset); + string indentString = newLine ? data.EolMarker + this.curIndent.IndentString : " "; + AddChange (whitespaceStart, offset - whitespaceStart, indentString); + } + + string nextStatementIndent = null; + + void FixStatementIndentation (AstLocation location) + { + int offset = data.LocationToOffset (location.Line, location.Column); + if (offset <= 0) { + Console.WriteLine ("possible wrong offset"); + Console.WriteLine (Environment.StackTrace); + return; + } + bool isEmpty = IsLineIsEmptyUpToEol (offset); + int lineStart = SearchWhitespaceLineStart (offset); + string indentString = nextStatementIndent == null ? (isEmpty ? "" : data.EolMarker) + this.curIndent.IndentString : nextStatementIndent; + nextStatementIndent = null; + AddChange (lineStart, offset - lineStart, indentString); + } + + void FixIndentation (AstLocation location) + { + FixIndentation (location, 0); + } + + void FixIndentation (AstLocation location, int relOffset) + { + if (location.Line < 0 || location.Line >= data.LineCount) { + Console.WriteLine ("Invalid location " + location); + Console.WriteLine (Environment.StackTrace); + return; + } + + string lineIndent = data.GetIndentation (location.Line); + string indentString = this.curIndent.IndentString; + if (indentString != lineIndent && location.Column - 1 + relOffset == lineIndent.Length) { + AddChange (data.GetLineOffset (location.Line), lineIndent.Length, indentString); + } + } + + void FixIndentationForceNewLine (AstLocation location) + { + string lineIndent = data.GetIndentation (location.Line); + string indentString = this.curIndent.IndentString; + if (indentString != lineIndent && location.Column - 1 == lineIndent.Length) { + AddChange (data.GetLineOffset (location.Line), lineIndent.Length, indentString); + } else { + int offset = data.LocationToOffset (location.Line, location.Column); + int start = SearchWhitespaceLineStart (offset); + if (start > 0) { + char ch = data.GetCharAt (start - 1); + if (ch == '\n') { + start--; + if (start > 1 && data.GetCharAt (start - 1) == '\r') + start--; + } else if (ch == '\r') { + start--; + } + AddChange (start, offset - start, data.EolMarker + indentString); + } + } + } + } +} + diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingPolicy.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingPolicy.cs index e311deee7..ceb666d1e 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingPolicy.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingPolicy.cs @@ -26,10 +26,12 @@ using System; using System.Reflection; +using System.Linq; namespace ICSharpCode.NRefactory.CSharp { - public enum BraceStyle { + public enum BraceStyle + { DoNotChange, EndOfLine, EndOfLineWithoutSpace, @@ -37,303 +39,289 @@ namespace ICSharpCode.NRefactory.CSharp NextLineShifted, NextLineShifted2 } - - public enum BraceForcement { + + public enum BraceForcement + { DoNotChange, RemoveBraces, AddBraces } - - public enum ArrayInitializerPlacement { + + public enum ArrayInitializerPlacement + { AlwaysNewLine, AlwaysSameLine } - // HACK: Monodevelop internal attribute - public class ItemPropertyAttribute : System.Attribute + public enum PropertyFormatting { + AllowOneLine, + ForceOneLine, + ForceNewLine } - public class CSharpFormattingPolicy : IEquatable + public class CSharpFormattingPolicy { + public string Name { + get; + set; + } + + public bool IsBuiltIn { + get; + set; + } + public CSharpFormattingPolicy Clone () { - return (CSharpFormattingPolicy) MemberwiseClone (); + return (CSharpFormattingPolicy)MemberwiseClone (); } - + #region Indentation - [ItemProperty] public bool IndentNamespaceBody { // tested get; set; } - - [ItemProperty] + public bool IndentClassBody { // tested get; set; } - - [ItemProperty] + public bool IndentInterfaceBody { // tested get; set; } - - [ItemProperty] + public bool IndentStructBody { // tested get; set; } - - [ItemProperty] + public bool IndentEnumBody { // tested get; set; } - - [ItemProperty] + public bool IndentMethodBody { // tested get; set; } - - [ItemProperty] + public bool IndentPropertyBody { // tested get; set; } - - [ItemProperty] + public bool IndentEventBody { // tested get; set; } - - [ItemProperty] + public bool IndentBlocks { // tested get; set; } - - [ItemProperty] + public bool IndentSwitchBody { // tested get; set; } - - [ItemProperty] + public bool IndentCaseBody { // tested get; set; } - - [ItemProperty] + public bool IndentBreakStatements { // tested get; set; } + + public bool AlignEmbeddedUsingStatements { // tested + get; + set; + } + + public bool AlignEmbeddedIfStatements { // tested + get; + set; + } + + public PropertyFormatting PropertyFormatting { // tested + get; + set; + } + #endregion #region Braces - [ItemProperty] public BraceStyle NamespaceBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle ClassBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle InterfaceBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle StructBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle EnumBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle MethodBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle AnonymousMethodBraceStyle { get; set; } - - [ItemProperty] + public BraceStyle ConstructorBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle DestructorBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle PropertyBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle PropertyGetBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle PropertySetBraceStyle { // tested get; set; } - - [ItemProperty] + public bool AllowPropertyGetBlockInline { // tested get; set; } - - [ItemProperty] + public bool AllowPropertySetBlockInline { // tested get; set; } - - [ItemProperty] + public BraceStyle EventBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle EventAddBraceStyle { // tested get; set; } - - [ItemProperty] + public BraceStyle EventRemoveBraceStyle { // tested get; set; } - - [ItemProperty] + public bool AllowEventAddBlockInline { // tested get; set; } - - [ItemProperty] + public bool AllowEventRemoveBlockInline { // tested get; set; } - - [ItemProperty] + public BraceStyle StatementBraceStyle { // tested get; set; } - - [ItemProperty] + public bool AllowIfBlockInline { get; set; } - + #endregion #region Force Braces - [ItemProperty] public BraceForcement IfElseBraceForcement { // tested get; set; } - - [ItemProperty] + public BraceForcement ForBraceForcement { // tested get; set; } - - [ItemProperty] + public BraceForcement ForEachBraceForcement { // tested get; set; } - - [ItemProperty] + public BraceForcement WhileBraceForcement { // tested get; set; } - - [ItemProperty] + public BraceForcement UsingBraceForcement { // tested get; set; } - - [ItemProperty] + public BraceForcement FixedBraceForcement { // tested get; set; } + #endregion #region NewLines - [ItemProperty] public bool PlaceElseOnNewLine { // tested get; set; } - - [ItemProperty] + public bool PlaceElseIfOnNewLine { // tested get; set; } - - [ItemProperty] + public bool PlaceCatchOnNewLine { // tested get; set; } - - [ItemProperty] + public bool PlaceFinallyOnNewLine { // tested get; set; } - - [ItemProperty] + public bool PlaceWhileOnNewLine { // tested get; set; } - - [ItemProperty] + public ArrayInitializerPlacement PlaceArrayInitializersOnNewLine { get; set; @@ -341,275 +329,441 @@ namespace ICSharpCode.NRefactory.CSharp #endregion #region Spaces - [ItemProperty] - public bool BeforeMethodCallParentheses { // tested + // Methods + public bool SpaceBeforeMethodDeclarationParentheses { // tested get; set; } - - [ItemProperty] - public bool BeforeMethodDeclarationParentheses { // tested + + public bool SpaceBetweenEmptyMethodDeclarationParentheses { get; set; } - - [ItemProperty] - public bool BeforeConstructorDeclarationParentheses { // tested + + public bool SpaceBeforeMethodDeclarationParameterComma { // tested get; set; } - - [ItemProperty] - public bool BeforeDelegateDeclarationParentheses { // tested + + public bool SpaceAfterMethodDeclarationParameterComma { // tested get; set; } - - [ItemProperty] - public bool NewParentheses { // tested + + public bool SpaceWithinMethodDeclarationParentheses { // tested get; set; } - [ItemProperty] - public bool IfParentheses { // tested + // Method calls + public bool SpaceBeforeMethodCallParentheses { // tested get; set; } - - [ItemProperty] - public bool WhileParentheses { // tested + + public bool SpaceBetweenEmptyMethodCallParentheses { // tested get; set; } - - [ItemProperty] - public bool ForParentheses { // tested + + public bool SpaceBeforeMethodCallParameterComma { // tested get; set; } - - [ItemProperty] - public bool ForeachParentheses { // tested + + public bool SpaceAfterMethodCallParameterComma { // tested get; set; } - - [ItemProperty] - public bool CatchParentheses { // tested + + public bool SpaceWithinMethodCallParentheses { // tested get; set; } - [ItemProperty] - public bool SwitchParentheses { // tested + // fields + + public bool SpaceBeforeFieldDeclarationComma { // tested get; set; } - - [ItemProperty] - public bool LockParentheses { // tested + + public bool SpaceAfterFieldDeclarationComma { // tested get; set; } - [ItemProperty] - public bool UsingParentheses { // tested + // local variables + + public bool SpaceBeforeLocalVariableDeclarationComma { // tested get; set; } - - [ItemProperty] - public bool AroundAssignmentParentheses { // tested + + public bool SpaceAfterLocalVariableDeclarationComma { // tested get; set; } - [ItemProperty] - public bool AroundLogicalOperatorParentheses { // tested + // constructors + + public bool SpaceBeforeConstructorDeclarationParentheses { // tested get; set; } - - [ItemProperty] - public bool AroundEqualityOperatorParentheses { // tested + + public bool SpaceBetweenEmptyConstructorDeclarationParentheses { // tested get; set; } - - [ItemProperty] - public bool AroundRelationalOperatorParentheses { // tested + + public bool SpaceBeforeConstructorDeclarationParameterComma { // tested get; set; } - - [ItemProperty] - public bool AroundBitwiseOperatorParentheses { // tested + + public bool SpaceAfterConstructorDeclarationParameterComma { // tested get; set; } - - [ItemProperty] - public bool AroundAdditiveOperatorParentheses { // tested + + public bool SpaceWithinConstructorDeclarationParentheses { // tested get; set; } - [ItemProperty] - public bool AroundMultiplicativeOperatorParentheses { // tested + // indexer + public bool SpaceBeforeIndexerDeclarationBracket { // tested get; set; } - - [ItemProperty] - public bool AroundShiftOperatorParentheses { // tested + + public bool SpaceWithinIndexerDeclarationBracket { // tested get; set; } - - [ItemProperty] - public bool WithinParentheses { // tested + + public bool SpaceBeforeIndexerDeclarationParameterComma { get; set; } - - [ItemProperty] - public bool WithinMethodCallParentheses { // tested + + public bool SpaceAfterIndexerDeclarationParameterComma { get; set; } - [ItemProperty] - public bool WithinMethodDeclarationParentheses { // tested + // delegates + + public bool SpaceBeforeDelegateDeclarationParentheses { get; set; } - - [ItemProperty] - public bool WithinIfParentheses { // tested + + public bool SpaceBetweenEmptyDelegateDeclarationParentheses { get; set; } - - [ItemProperty] - public bool WithinWhileParentheses { // tested + + public bool SpaceBeforeDelegateDeclarationParameterComma { get; set; } - - [ItemProperty] - public bool WithinForParentheses { // tested + + public bool SpaceAfterDelegateDeclarationParameterComma { get; set; } - - [ItemProperty] - public bool WithinForEachParentheses { // tested + + public bool SpaceWithinDelegateDeclarationParentheses { get; set; } - - [ItemProperty] - public bool WithinCatchParentheses { // tested + + public bool SpaceBeforeNewParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinSwitchParentheses { // tested + + public bool SpaceBeforeIfParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinLockParentheses { // tested + + public bool SpaceBeforeWhileParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinUsingParentheses { // tested + + public bool SpaceBeforeForParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinCastParentheses { // tested + + public bool SpaceBeforeForeachParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinSizeOfParentheses { // tested + + public bool SpaceBeforeCatchParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinTypeOfParentheses { // tested + + public bool SpaceBeforeSwitchParentheses { // tested get; set; } - - [ItemProperty] - public bool WithinCheckedExpressionParantheses { // tested + + public bool SpaceBeforeLockParentheses { // tested get; set; } - - [ItemProperty] - public bool ConditionalOperatorBeforeConditionSpace { // tested + + public bool SpaceBeforeUsingParentheses { // tested get; set; } - - [ItemProperty] - public bool ConditionalOperatorAfterConditionSpace { // tested + + public bool SpaceAroundAssignment { // tested get; set; } - - [ItemProperty] - public bool ConditionalOperatorBeforeSeparatorSpace { // tested + + public bool SpaceAroundLogicalOperator { // tested get; set; } - - [ItemProperty] - public bool ConditionalOperatorAfterSeparatorSpace { // tested + + public bool SpaceAroundEqualityOperator { // tested + get; + set; + } + + public bool SpaceAroundRelationalOperator { // tested + get; + set; + } + + public bool SpaceAroundBitwiseOperator { // tested + get; + set; + } + + public bool SpaceAroundAdditiveOperator { // tested + get; + set; + } + + public bool SpaceAroundMultiplicativeOperator { // tested + get; + set; + } + + public bool SpaceAroundShiftOperator { // tested + get; + set; + } + + public bool SpaceAroundNullCoalescingOperator { + get; + set; + } + + public bool SpacesWithinParentheses { // tested + get; + set; + } + + public bool SpacesWithinIfParentheses { // tested + get; + set; + } + + public bool SpacesWithinWhileParentheses { // tested + get; + set; + } + + public bool SpacesWithinForParentheses { // tested + get; + set; + } + + public bool SpacesWithinForeachParentheses { // tested + get; + set; + } + + public bool SpacesWithinCatchParentheses { // tested + get; + set; + } + + public bool SpacesWithinSwitchParentheses { // tested + get; + set; + } + + public bool SpacesWithinLockParentheses { // tested + get; + set; + } + + public bool SpacesWithinUsingParentheses { // tested + get; + set; + } + + public bool SpacesWithinCastParentheses { // tested + get; + set; + } + + public bool SpacesWithinSizeOfParentheses { // tested + get; + set; + } + + public bool SpaceBeforeSizeOfParentheses { // tested + get; + set; + } + + public bool SpacesWithinTypeOfParentheses { // tested + get; + set; + } + + public bool SpacesWithinNewParentheses { // tested + get; + set; + } + + public bool SpacesBetweenEmptyNewParentheses { // tested + get; + set; + } + + public bool SpaceBeforeNewParameterComma { // tested + get; + set; + } + + public bool SpaceAfterNewParameterComma { // tested + get; + set; + } + + public bool SpaceBeforeTypeOfParentheses { // tested + get; + set; + } + + public bool SpacesWithinCheckedExpressionParantheses { // tested + get; + set; + } + + public bool SpaceBeforeConditionalOperatorCondition { // tested + get; + set; + } + + public bool SpaceAfterConditionalOperatorCondition { // tested + get; + set; + } + + public bool SpaceBeforeConditionalOperatorSeparator { // tested + get; + set; + } + + public bool SpaceAfterConditionalOperatorSeparator { // tested get; set; } - [ItemProperty] + // brackets public bool SpacesWithinBrackets { // tested get; set; } - - [ItemProperty] - public bool SpacesAfterComma { // tested + + public bool SpacesBeforeBrackets { // tested get; set; } - - [ItemProperty] - public bool SpacesBeforeComma { // tested + + public bool SpaceBeforeBracketComma { // tested get; set; } - - [ItemProperty] - public bool SpacesAfterSemicolon { // tested + + public bool SpaceAfterBracketComma { // tested + get; + set; + } + + public bool SpaceBeforeForSemicolon { // tested get; set; } + + public bool SpaceAfterForSemicolon { // tested + get; + set; + } + + public bool SpaceAfterTypecast { // tested + get; + set; + } + + public bool SpaceBeforeArrayDeclarationBrackets { // tested + get; + set; + } + + #endregion - [ItemProperty] - public bool SpacesAfterTypecast { // tested + #region Blank Lines + public int BlankLinesBeforeUsings { + get; + set; + } + + public int BlankLinesAfterUsings { + get; + set; + } + + public int BlankLinesBeforeFirstDeclaration { + get; + set; + } + + public int BlankLinesBetweenTypes { + get; + set; + } + + public int BlankLinesBetweenFields { + get; + set; + } + + public int BlankLinesBetweenEventFields { get; set; } + + public int BlankLinesBetweenMembers { + get; + set; + } + #endregion public CSharpFormattingPolicy () @@ -639,67 +793,170 @@ namespace ICSharpCode.NRefactory.CSharp PlaceWhileOnNewLine = false; PlaceArrayInitializersOnNewLine = ArrayInitializerPlacement.AlwaysSameLine; - BeforeMethodCallParentheses = true; - BeforeMethodDeclarationParentheses = true; - BeforeConstructorDeclarationParentheses = true; - BeforeDelegateDeclarationParentheses = true; - - NewParentheses = true; - IfParentheses = true; - WhileParentheses = true; - ForParentheses = true; - ForeachParentheses = true; - CatchParentheses = true; - SwitchParentheses = true; - LockParentheses = true; - UsingParentheses = true; - AroundAssignmentParentheses = true; - AroundLogicalOperatorParentheses = true; - AroundEqualityOperatorParentheses = true; - AroundRelationalOperatorParentheses = true; - AroundBitwiseOperatorParentheses = true; - AroundAdditiveOperatorParentheses = true; - AroundMultiplicativeOperatorParentheses = true; - AroundShiftOperatorParentheses = true; - WithinParentheses = false; - WithinMethodCallParentheses = false; - WithinMethodDeclarationParentheses = false; - WithinIfParentheses = false; - WithinWhileParentheses = false; - WithinForParentheses = false; - WithinForEachParentheses = false; - WithinCatchParentheses = false; - WithinSwitchParentheses = false; - WithinLockParentheses = false; - WithinUsingParentheses = false; - WithinCastParentheses = false; - WithinSizeOfParentheses = false; - WithinTypeOfParentheses = false; - WithinCheckedExpressionParantheses = false; - ConditionalOperatorBeforeConditionSpace = true; - ConditionalOperatorAfterConditionSpace = true; - ConditionalOperatorBeforeSeparatorSpace = true; - ConditionalOperatorAfterSeparatorSpace = true; + SpaceBeforeMethodCallParentheses = true; + SpaceBeforeMethodDeclarationParentheses = true; + SpaceBeforeConstructorDeclarationParentheses = true; + SpaceBeforeDelegateDeclarationParentheses = true; + SpaceAfterMethodCallParameterComma = true; + SpaceAfterConstructorDeclarationParameterComma = true; + + SpaceBeforeNewParentheses = true; + SpacesWithinNewParentheses = false; + SpacesBetweenEmptyNewParentheses = false; + SpaceBeforeNewParameterComma = false; + SpaceAfterNewParameterComma = true; + + SpaceBeforeIfParentheses = true; + SpaceBeforeWhileParentheses = true; + SpaceBeforeForParentheses = true; + SpaceBeforeForeachParentheses = true; + SpaceBeforeCatchParentheses = true; + SpaceBeforeSwitchParentheses = true; + SpaceBeforeLockParentheses = true; + SpaceBeforeUsingParentheses = true; + SpaceAroundAssignment = true; + SpaceAroundLogicalOperator = true; + SpaceAroundEqualityOperator = true; + SpaceAroundRelationalOperator = true; + SpaceAroundBitwiseOperator = true; + SpaceAroundAdditiveOperator = true; + SpaceAroundMultiplicativeOperator = true; + SpaceAroundShiftOperator = true; + SpaceAroundNullCoalescingOperator = true; + SpacesWithinParentheses = false; + SpaceWithinMethodCallParentheses = false; + SpaceWithinMethodDeclarationParentheses = false; + SpacesWithinIfParentheses = false; + SpacesWithinWhileParentheses = false; + SpacesWithinForParentheses = false; + SpacesWithinForeachParentheses = false; + SpacesWithinCatchParentheses = false; + SpacesWithinSwitchParentheses = false; + SpacesWithinLockParentheses = false; + SpacesWithinUsingParentheses = false; + SpacesWithinCastParentheses = false; + SpacesWithinSizeOfParentheses = false; + SpacesWithinTypeOfParentheses = false; + SpacesWithinCheckedExpressionParantheses = false; + SpaceBeforeConditionalOperatorCondition = true; + SpaceAfterConditionalOperatorCondition = true; + SpaceBeforeConditionalOperatorSeparator = true; + SpaceAfterConditionalOperatorSeparator = true; SpacesWithinBrackets = false; - SpacesAfterComma = true; - SpacesBeforeComma = false; - SpacesAfterSemicolon = true; - SpacesAfterTypecast = false; + SpacesBeforeBrackets = true; + SpaceBeforeBracketComma = false; + SpaceAfterBracketComma = true; + + SpaceBeforeForSemicolon = false; + SpaceAfterForSemicolon = true; + SpaceAfterTypecast = false; + + AlignEmbeddedIfStatements = true; + AlignEmbeddedUsingStatements = true; + PropertyFormatting = PropertyFormatting.AllowOneLine; + SpaceBeforeMethodDeclarationParameterComma = false; + SpaceAfterMethodDeclarationParameterComma = true; + SpaceBeforeFieldDeclarationComma = false; + SpaceAfterFieldDeclarationComma = true; + SpaceBeforeLocalVariableDeclarationComma = false; + SpaceAfterLocalVariableDeclarationComma = true; + + SpaceBeforeIndexerDeclarationBracket = true; + SpaceWithinIndexerDeclarationBracket = false; + SpaceBeforeIndexerDeclarationParameterComma = false; + + + SpaceAfterIndexerDeclarationParameterComma = true; + + BlankLinesBeforeUsings = 0; + BlankLinesAfterUsings = 1; + + + BlankLinesBeforeFirstDeclaration = 0; + BlankLinesBetweenTypes = 1; + BlankLinesBetweenFields = 0; + BlankLinesBetweenEventFields = 0; + BlankLinesBetweenMembers = 1; } - + + /*public static CSharpFormattingPolicy Load (FilePath selectedFile) + { + using (var stream = System.IO.File.OpenRead (selectedFile)) { + return Load (stream); + } + } + + public static CSharpFormattingPolicy Load (System.IO.Stream input) + { + CSharpFormattingPolicy result = new CSharpFormattingPolicy (); + result.Name = "noname"; + using (XmlTextReader reader = new XmlTextReader (input)) { + while (reader.Read ()) { + if (reader.NodeType == XmlNodeType.Element) { + if (reader.LocalName == "Property") { + var info = typeof(CSharpFormattingPolicy).GetProperty (reader.GetAttribute ("name")); + string valString = reader.GetAttribute ("value"); + object value; + if (info.PropertyType == typeof(bool)) { + value = Boolean.Parse (valString); + } else if (info.PropertyType == typeof(int)) { + value = Int32.Parse (valString); + } else { + value = Enum.Parse (info.PropertyType, valString); + } + info.SetValue (result, value, null); + } else if (reader.LocalName == "FormattingProfile") { + result.Name = reader.GetAttribute ("name"); + } + } else if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "FormattingProfile") { + //Console.WriteLine ("result:" + result.Name); + return result; + } + } + } + return result; + } + + public void Save (string fileName) + { + using (var writer = new XmlTextWriter (fileName, Encoding.Default)) { + writer.Formatting = System.Xml.Formatting.Indented; + writer.Indentation = 1; + writer.IndentChar = '\t'; + writer.WriteStartElement ("FormattingProfile"); + writer.WriteAttributeString ("name", Name); + foreach (PropertyInfo info in typeof (CSharpFormattingPolicy).GetProperties ()) { + if (info.GetCustomAttributes (false).Any (o => o.GetType () == typeof(ItemPropertyAttribute))) { + writer.WriteStartElement ("Property"); + writer.WriteAttributeString ("name", info.Name); + writer.WriteAttributeString ("value", info.GetValue (this, null).ToString ()); + writer.WriteEndElement (); + } + } + writer.WriteEndElement (); + } + } + public bool Equals (CSharpFormattingPolicy other) { foreach (PropertyInfo info in typeof (CSharpFormattingPolicy).GetProperties ()) { - object val = info.GetValue (this, null); - object otherVal = info.GetValue (other, null); - if (!val.Equals (otherVal)) { - //Console.WriteLine ("!equal"); - return false; + if (info.GetCustomAttributes (false).Any (o => o.GetType () == typeof(ItemPropertyAttribute))) { + object val = info.GetValue (this, null); + object otherVal = info.GetValue (other, null); + if (val == null) { + if (otherVal == null) + continue; + return false; + } + if (!val.Equals (otherVal)) { + //Console.WriteLine ("!equal"); + return false; + } } } //Console.WriteLine ("== equal"); return true; - } + }*/ } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Change.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Change.cs new file mode 100644 index 000000000..f2a241c1d --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Change.cs @@ -0,0 +1,72 @@ +// +// Change.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// 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; + +namespace ICSharpCode.NRefactory +{ + public class Change + { + public int Offset { + get; + set; + } + + int removedChars; + public int RemovedChars { + get { + return removedChars; + } + set { + if (value < 0) + throw new ArgumentOutOfRangeException ("RemovedChars", "needs to be >= 0"); + removedChars = value; + } + } + + public string InsertedText { + get; + set; + } + + public Change (int offset, int removedChars, string insertedText) + { + if (removedChars < 0) + throw new ArgumentOutOfRangeException ("removedChars", "removedChars needs to be >= 0"); + if (offset < 0) + throw new ArgumentOutOfRangeException ("offset", "offset needs to be >= 0"); + this.removedChars = removedChars; + this.Offset = offset; + this.InsertedText = insertedText; + } + + public override string ToString () + { + return string.Format ("[Change: Offset={0}, RemovedChars={1}, InsertedText={2}]", Offset, RemovedChars, InsertedText); + } + } + +} + diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/DomIndentationVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/DomIndentationVisitor.cs deleted file mode 100644 index 62eb44dd8..000000000 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/DomIndentationVisitor.cs +++ /dev/null @@ -1,758 +0,0 @@ -// -// DomIndentationVisitor.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2010 Novell, Inc (http://www.novell.com) -// -// 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.CSharp; -using System.Text; -using MonoDevelop.Projects.Dom; -using Mono.TextEditor; -using MonoDevelop.Refactoring; -using System.Collections.Generic; -using System.Linq; - -namespace ICSharpCode.NRefactory.CSharp -{ - public class DomIndentationVisitor : AbtractCSharpDomVisitor - { - CSharpFormattingPolicy policy; - TextEditorData data; - List changes = new List (); - Indent curIndent = new Indent (); - - public int IndentLevel { - get { - return curIndent.Level; - } - set { - curIndent.Level = value; - } - } - - public int CurrentSpaceIndents { - get; - set; - } - - public List Changes { - get { return this.changes; } - } - - public bool AutoAcceptChanges { get; set; } - - - public DomIndentationVisitor (CSharpFormattingPolicy policy, TextEditorData data) - { - this.policy = policy; - this.data = data; - AutoAcceptChanges = true; - } - - public override object VisitCompilatioICSharpCode.NRefactory.CSharparp.Dom.CompilationUnit unit, object data) - { - base.VisitCompilationUnit (unit, data); - if (AutoAcceptChanges) - RefactoringService.AcceptChanges (null, null, changes); - return null; - } - - public override object VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, object data) - { - FixIndentation (namespaceDeclaration.StartLocation); - IndentLevel++; - object result = base.VisitNamespaceDeclaration (namespaceDeclaration, data); - IndentLevel--; - FixIndentation (namespaceDeclaration.EndLocation); - return result; - } - - public override object VisitTypeDeclaration (TypeDeclaration typeDeclaration, object data) - { - FixIndentation (typeDeclaration.StartLocation); - BraceStyle braceStyle; - bool indentBody = false; - switch (typeDeclaration.ClassType) { - case ClassType.Class: - braceStyle = policy.ClassBraceStyle; - indentBody = policy.IndentClassBody; - break; - case ClassType.Struct: - braceStyle = policy.StructBraceStyle; - indentBody = policy.IndentStructBody; - break; - case ClassType.Interface: - braceStyle = policy.InterfaceBraceStyle; - indentBody = policy.IndentInterfaceBody; - break; - case ClassType.Enum: - braceStyle = policy.EnumBraceStyle; - indentBody = policy.IndentEnumBody; - break; - default: - throw new InvalidOperationException ("unsupported class type : " + typeDeclaration.ClassType); - } - EnforceBraceStyle (braceStyle, typeDeclaration.LBrace, typeDeclaration.RBrace); - - if (indentBody) - IndentLevel++; - object result = base.VisitTypeDeclaration (typeDeclaration, data); - if (indentBody) - IndentLevel--; - return result; - } - - public override object VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, object data) - { - FixIndentation (propertyDeclaration.StartLocation); - EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBrace, propertyDeclaration.RBrace); - if (policy.IndentPropertyBody) - IndentLevel++; - - if (propertyDeclaration.GetAccessor != null) { - FixIndentation (propertyDeclaration.GetAccessor.StartLocation); - if (propertyDeclaration.GetAccessor.Body != null) { - if (!policy.AllowPropertyGetBlockInline || propertyDeclaration.GetAccessor.Body.LBrace.StartLocation.Line != propertyDeclaration.GetAccessor.Body.RBrace.StartLocation.Line) { - EnforceBraceStyle (policy.PropertyGetBraceStyle, propertyDeclaration.GetAccessor.Body.LBrace, propertyDeclaration.GetAccessor.Body.RBrace); - } else { - nextStatementIndent = " "; - } - VisitBlockWithoutFixIndentation (propertyDeclaration.GetAccessor.Body, policy.IndentBlocks, data); - } - } - - if (propertyDeclaration.SetAccessor != null) { - FixIndentation (propertyDeclaration.SetAccessor.StartLocation); - if (propertyDeclaration.SetAccessor.Body != null) { - if (!policy.AllowPropertySetBlockInline || propertyDeclaration.SetAccessor.Body.LBrace.StartLocation.Line != propertyDeclaration.SetAccessor.Body.RBrace.StartLocation.Line) { - EnforceBraceStyle (policy.PropertySetBraceStyle, propertyDeclaration.SetAccessor.Body.LBrace, propertyDeclaration.SetAccessor.Body.RBrace); - } else { - nextStatementIndent = " "; - } - VisitBlockWithoutFixIndentation (propertyDeclaration.SetAccessor.Body, policy.IndentBlocks, data); - } - } - - if (policy.IndentPropertyBody) - IndentLevel--; - return null; - } - - public override object VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, object data) - { - FixIndentation (indexerDeclaration.StartLocation); - EnforceBraceStyle (policy.PropertyBraceStyle, indexerDeclaration.LBrace, indexerDeclaration.RBrace); - if (policy.IndentPropertyBody) - IndentLevel++; - - if (indexerDeclaration.GetAccessor != null) { - FixIndentation (indexerDeclaration.GetAccessor.StartLocation); - if (indexerDeclaration.GetAccessor.Body != null) { - if (!policy.AllowPropertyGetBlockInline || indexerDeclaration.GetAccessor.Body.LBrace.StartLocation.Line != indexerDeclaration.GetAccessor.Body.RBrace.StartLocation.Line) { - EnforceBraceStyle (policy.PropertyGetBraceStyle, indexerDeclaration.GetAccessor.Body.LBrace, indexerDeclaration.GetAccessor.Body.RBrace); - } else { - nextStatementIndent = " "; - } - VisitBlockWithoutFixIndentation (indexerDeclaration.GetAccessor.Body, policy.IndentBlocks, data); - } - } - - if (indexerDeclaration.SetAccessor != null) { - FixIndentation (indexerDeclaration.SetAccessor.StartLocation); - if (indexerDeclaration.SetAccessor.Body != null) { - if (!policy.AllowPropertySetBlockInline || indexerDeclaration.SetAccessor.Body.LBrace.StartLocation.Line != indexerDeclaration.SetAccessor.Body.RBrace.StartLocation.Line) { - EnforceBraceStyle (policy.PropertySetBraceStyle, indexerDeclaration.SetAccessor.Body.LBrace, indexerDeclaration.SetAccessor.Body.RBrace); - } else { - nextStatementIndent = " "; - } - VisitBlockWithoutFixIndentation (indexerDeclaration.SetAccessor.Body, policy.IndentBlocks, data); - } - } - if (policy.IndentPropertyBody) - IndentLevel--; - return null; - } - - - public override object VisitEventDeclaration (EventDeclaration eventDeclaration, object data) - { - FixIndentation (eventDeclaration.StartLocation); - EnforceBraceStyle (policy.EventBraceStyle, eventDeclaration.LBrace, eventDeclaration.RBrace); - if (policy.IndentEventBody) - IndentLevel++; - - if (eventDeclaration.AddAccessor != null) { - FixIndentation (eventDeclaration.AddAccessor.StartLocation); - if (eventDeclaration.AddAccessor.Body != null) { - if (!policy.AllowEventAddBlockInline || eventDeclaration.AddAccessor.Body.LBrace.StartLocation.Line != eventDeclaration.AddAccessor.Body.RBrace.StartLocation.Line) { - EnforceBraceStyle (policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.LBrace, eventDeclaration.AddAccessor.Body.RBrace); - } else { - nextStatementIndent = " "; - } - - VisitBlockWithoutFixIndentation (eventDeclaration.AddAccessor.Body, policy.IndentBlocks, data); - } - } - - if (eventDeclaration.RemoveAccessor != null) { - FixIndentation (eventDeclaration.RemoveAccessor.StartLocation); - if (eventDeclaration.RemoveAccessor.Body != null) { - if (!policy.AllowEventRemoveBlockInline || eventDeclaration.RemoveAccessor.Body.LBrace.StartLocation.Line != eventDeclaration.RemoveAccessor.Body.RBrace.StartLocation.Line) { - EnforceBraceStyle (policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.LBrace, eventDeclaration.RemoveAccessor.Body.RBrace); - } else { - nextStatementIndent = " "; - } - VisitBlockWithoutFixIndentation (eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks, data); - } - } - - if (policy.IndentEventBody) - IndentLevel--; - return null; - } - - - public override object VisitAccessorDeclaration (Accessor accessorDeclaration, object data) - { - FixIndentation (accessorDeclaration.StartLocation); - object result = base.VisitAccessorDeclaration (accessorDeclaration, data); - return result; - } - - public override object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) - { - Console.WriteLine ("VISIT FIELD:" + fieldDeclaration.StartLocation); - FixIndentation (fieldDeclaration.StartLocation); - return base.VisitFieldDeclaration (fieldDeclaration, data); - } - - public override object VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, object data) - { - FixIndentation (delegateDeclaration.StartLocation); - return base.VisitDelegateDeclaration (delegateDeclaration, data); - } - - public override object VisitMethodDeclaration (MethodDeclaration methodDeclaration, object data) - { - FixIndentation (methodDeclaration.StartLocation); - if (methodDeclaration.Body != null) { - EnforceBraceStyle (policy.MethodBraceStyle, methodDeclaration.Body.LBrace, methodDeclaration.Body.RBrace); - if (policy.IndentMethodBody) - IndentLevel++; - base.VisitBlockStatement (methodDeclaration.Body, data); - if (policy.IndentMethodBody) - IndentLevel--; - } - - return null; - } - - public override object VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, object data) - { - FixIndentation (operatorDeclaration.StartLocation); - if (operatorDeclaration.Body != null) { - EnforceBraceStyle (policy.MethodBraceStyle, operatorDeclaration.Body.LBrace, operatorDeclaration.Body.RBrace); - if (policy.IndentMethodBody) - IndentLevel++; - base.VisitBlockStatement (operatorDeclaration.Body, data); - if (policy.IndentMethodBody) - IndentLevel--; - } - - return null; - } - - public override object VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, object data) - { - FixIndentation (constructorDeclaration.StartLocation); - if (constructorDeclaration.Body != null) - EnforceBraceStyle (policy.ConstructorBraceStyle, constructorDeclaration.Body.LBrace, constructorDeclaration.Body.RBrace); - object result = base.VisitConstructorDeclaration (constructorDeclaration, data); - return result; - } - - public override object VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, object data) - { - FixIndentation (destructorDeclaration.StartLocation); - if (destructorDeclaration.Body != null) - EnforceBraceStyle (policy.DestructorBraceStyle, destructorDeclaration.Body.LBrace, destructorDeclaration.Body.RBrace); - object result = base.VisitDestructorDeclaration (destructorDeclaration, data); - return result; - } - - #region Statements - public override object VisitExpressionStatement (ExpressionStatement expressionStatement, object data) - { - FixStatementIndentation (expressionStatement.StartLocation); - return null; - } - - object VisitBlockWithoutFixIndentation (BlockStatement blockStatement, bool indent, object data) - { - if (indent) - IndentLevel++; - object result = base.VisitBlockStatement (blockStatement, data); - if (indent) - IndentLevel--; - return result; - } - - public override object VisitBlockStatement (BlockStatement blockStatement, object data) - { - FixIndentation (blockStatement.StartLocation); - object result = VisitBlockWithoutFixIndentation (blockStatement, policy.IndentBlocks, data); - FixIndentation (blockStatement.EndLocation, -1); - return result; - } - - public override object VisitBreakStatement (BreakStatement breakStatement, object data) - { - FixStatementIndentation (breakStatement.StartLocation); - return null; - } - - public override object VisitCheckedStatement (CheckedStatement checkedStatement, object data) - { - FixStatementIndentation (checkedStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement , checkedStatement.EmbeddedStatement); - } - - public override object VisitContinueStatement (ContinueStatement continueStatement, object data) - { - FixStatementIndentation (continueStatement.StartLocation); - return null; - } - - public override object VisitEmptyStatement (EmptyStatement emptyStatement, object data) - { - FixStatementIndentation (emptyStatement.StartLocation); - return null; - } - - public override object VisitFixedStatement (FixedStatement fixedStatement, object data) - { - FixStatementIndentation (fixedStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, fixedStatement.EmbeddedStatement); - } - - public override object VisitForeachStatement (ForeachStatement foreachStatement, object data) - { - FixStatementIndentation (foreachStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.ForEachBraceForcement , foreachStatement.EmbeddedStatement); - } - - object FixEmbeddedStatment (MonoDevelop.CSharp.Formatting.BraceStyle braceStyle, MonoDevelop.CSharp.Formatting.BraceForcement braceForcement, ICSharpNode node) - { - return FixEmbeddedStatment (braceStyle, braceForcement, null, false, node); - } - - object FixEmbeddedStatment (MonoDevelop.CSharp.Formatting.BraceStyle braceStyle, MonoDevelop.CSharp.Formatting.BraceForcement braceForcement, CSharpTokenNode token, bool allowInLine, ICSharpNode node) - { - if (node == null) - return null; - bool isBlock = node is BlockStatement; - switch (braceForcement) { - case BraceForcement.DoNotChange: - //nothing - break; - case BraceForcement.AddBraces: - if (!isBlock) { - int offset = data.Document.LocationToOffset (node.StartLocation.Line, node.StartLocation.Column); - int start = SearchWhitespaceStart (offset); - string startBrace = ""; - switch (braceStyle) { - case BraceStyle.EndOfLineWithoutSpace: - startBrace = "{"; - break; - case BraceStyle.EndOfLine: - startBrace = " {"; - break; - case BraceStyle.NextLine: - startBrace = data.EolMarker + curIndent.IndentString + "{"; - break; - case BraceStyle.NextLineShifted2: - case BraceStyle.NextLineShifted: - startBrace = data.EolMarker + curIndent.IndentString + curIndent.SingleIndent + "{"; - break; - } - AddChange (start, offset - start, startBrace); - } - break; - case BraceForcement.RemoveBraces: - if (isBlock) { - BlockStatement block = node as BlockStatement; - if (block.Statements.Count () == 1) { - int offset1 = data.Document.LocationToOffset (node.StartLocation.Line, node.StartLocation.Column); - int start = SearchWhitespaceStart (offset1); - - int offset2 = data.Document.LocationToOffset (node.EndLocation.Line, node.EndLocation.Column); - int end = SearchWhitespaceStart (offset2 - 1); - - AddChange (start, offset1 - start + 1, null); - AddChange (end + 1, offset2 - end, null); - node = (ICSharpNode)block.FirstChild; - isBlock = false; - } - } - break; - } - int originalLevel = curIndent.Level; - if (isBlock) { - BlockStatement block = node as BlockStatement; - if (allowInLine && block.StartLocation.Line == block.EndLocation.Line && block.Statements.Count () <= 1) { - if (block.Statements.Count () == 1) - nextStatementIndent = " "; - } else { - EnforceBraceStyle (braceStyle, block.LBrace, block.RBrace); - } - if (braceStyle == BraceStyle.NextLineShifted2) - curIndent.Level++; - } else { - if (allowInLine && token.StartLocation.Line == node.EndLocation.Line) { - nextStatementIndent = " "; - } - } - if (!(node is IfElseStatement && node.Parent is IfElseStatement || node is UsingStatement && node.Parent is UsingStatement)) - curIndent.Level++; - object result = isBlock ? base.VisitBlockStatement ((BlockStatement)node, null) : node.AcceptVisitor (this, null); - curIndent.Level = originalLevel; - switch (braceForcement) { - case BraceForcement.DoNotChange: - break; - case BraceForcement.AddBraces: - if (!isBlock) { - int offset = data.Document.LocationToOffset (node.EndLocation.Line, node.EndLocation.Column); - string startBrace = ""; - switch (braceStyle) { - case BraceStyle.DoNotChange: - startBrace = null; - break; - case BraceStyle.EndOfLineWithoutSpace: - startBrace = data.EolMarker + curIndent.IndentString + "}"; - break; - case BraceStyle.EndOfLine: - startBrace = data.EolMarker + curIndent.IndentString + "}"; - break; - case BraceStyle.NextLine: - startBrace = data.EolMarker + curIndent.IndentString + "}"; - break; - case BraceStyle.NextLineShifted2: - case BraceStyle.NextLineShifted: - startBrace = data.EolMarker + curIndent.IndentString + curIndent.SingleIndent + "}"; - break; - } - if (startBrace != null) - AddChange (offset, 0, startBrace); - } - break; - } - return result; - } - - void EnforceBraceStyle (MonoDevelop.CSharp.Formatting.BraceStyle braceStyle, ICSharpNode lbrace, ICSharpNode rbrace) - { - if (lbrace == null || rbrace == null) - return; - -// LineSegment lbraceLineSegment = data.Document.GetLine (lbrace.StartLocation.Line); - int lbraceOffset = data.Document.LocationToOffset (lbrace.StartLocation.Line, lbrace.StartLocation.Column); - -// LineSegment rbraceLineSegment = data.Document.GetLine (rbrace.StartLocation.Line); - int rbraceOffset = data.Document.LocationToOffset (rbrace.StartLocation.Line, rbrace.StartLocation.Column); - int whitespaceStart = SearchWhitespaceStart (lbraceOffset); - int whitespaceEnd = SearchWhitespaceStart (rbraceOffset); - string startIndent = ""; - string endIndent = ""; - switch (braceStyle) { - case BraceStyle.DoNotChange: - startIndent = endIndent = null; - break; - case BraceStyle.EndOfLineWithoutSpace: - startIndent = ""; - endIndent = data.EolMarker + curIndent.IndentString; - break; - case BraceStyle.EndOfLine: - startIndent = " "; - endIndent = data.EolMarker + curIndent.IndentString; - break; - case BraceStyle.NextLine: - startIndent = data.EolMarker + curIndent.IndentString; - endIndent = data.EolMarker + curIndent.IndentString; - break; - case BraceStyle.NextLineShifted2: - case BraceStyle.NextLineShifted: - endIndent = startIndent = data.EolMarker + curIndent.IndentString + curIndent.SingleIndent; - break; - } - - if (lbraceOffset > 0 && startIndent != null) - AddChange (whitespaceStart, lbraceOffset - whitespaceStart, startIndent); - if (rbraceOffset > 0 && endIndent != null) - AddChange (whitespaceEnd, rbraceOffset - whitespaceEnd, endIndent); - } - - void AddChange (int offset, int removedChars, string insertedText) - { - if (changes.Cast ().Any (c => c.Offset == offset && c.RemovedChars == removedChars && c.InsertedText == insertedText)) - return; - string currentText = data.Document.GetTextAt (offset, removedChars); - if (currentText == insertedText) - return; - foreach (DomSpacingVisitor.MyTextReplaceChange change in changes) { - if (change.Offset == offset) { - if (removedChars > 0 && insertedText == change.InsertedText) { - change.RemovedChars = removedChars; -// change.InsertedText = insertedText; - return; - } - } - } -// Console.WriteLine ("offset={0}, removedChars={1}, insertedText={2}", offset, removedChars, insertedText.Replace("\n", "\\n").Replace("\t", "\\t").Replace(" ", ".")); -// Console.WriteLine (Environment.StackTrace); - changes.Add (new DomSpacingVisitor.MyTextReplaceChange (data, offset, removedChars, insertedText)); - } - - int SearchWhitespaceStart (int startOffset) - { - for (int offset = startOffset - 1; offset >= 0; offset--) { - char ch = data.Document.GetCharAt (offset); - if (!Char.IsWhiteSpace (ch)) { - return offset + 1; - } - } - return startOffset - 1; - } - - - public override object VisitForStatement (ForStatement forStatement, object data) - { - FixStatementIndentation (forStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.ForBraceForcement, forStatement.EmbeddedStatement); - } - - public override object VisitGotoStatement (GotoStatement gotoStatement, object data) - { - FixStatementIndentation (gotoStatement.StartLocation); - return VisitChildren (gotoStatement, data); - } - - public override object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) - { - if (!(ifElseStatement.Parent is IfElseStatement)) - FixStatementIndentation (ifElseStatement.StartLocation); - - if (ifElseStatement.Condition != null) - ifElseStatement.Condition.AcceptVisitor (this, data); - - if (ifElseStatement.TrueEmbeddedStatement != null) - FixEmbeddedStatment (policy.StatementBraceStyle, policy.IfElseBraceForcement, ifElseStatement.IfKeyword, policy.AllowIfBlockInline, ifElseStatement.TrueEmbeddedStatement); - - if (ifElseStatement.FalseEmbeddedStatement != null) { - PlaceOnNewLine (policy.PlaceElseOnNewLine, ifElseStatement.ElseKeyword); - if (ifElseStatement.FalseEmbeddedStatement is IfElseStatement) { - PlaceOnNewLine (policy.PlaceElseIfOnNewLine, ((IfElseStatement)ifElseStatement.FalseEmbeddedStatement).IfKeyword); - } - FixEmbeddedStatment (policy.StatementBraceStyle, policy.IfElseBraceForcement, ifElseStatement.ElseKeyword, policy.AllowIfBlockInline, ifElseStatement.FalseEmbeddedStatement); - } - - return null; - } - - - public override object VisitLabelStatement (LabelStatement labelStatement, object data) - { - // TODO - return VisitChildren (labelStatement, data); - } - - public override object VisitLockStatement (LockStatement lockStatement, object data) - { - FixStatementIndentation (lockStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement , lockStatement.EmbeddedStatement); - } - - public override object VisitReturnStatement (ReturnStatement returnStatement, object data) - { - FixStatementIndentation (returnStatement.StartLocation); - return VisitChildren (returnStatement, data); - } - - public override object VisitSwitchStatement (SwitchStatement switchStatement, object data) - { - FixStatementIndentation (switchStatement.StartLocation); - EnforceBraceStyle (policy.StatementBraceStyle, switchStatement.LBrace, switchStatement.RBrace); - object result = VisitChildren (switchStatement, data); - return result; - } - - public override object VisitSwitchSection (SwitchSection switchSection, object data) - { - - if (policy.IndentCaseBody) - curIndent.Level++; - - foreach (CaseLabel label in switchSection.CaseLabels) { - FixStatementIndentation (label.StartLocation); - } - if (policy.IndentSwitchBody) - curIndent.Level++; - - foreach (ICSharpNode stmt in switchSection.Statements) { - stmt.AcceptVisitor (this, null); - } - if (policy.IndentSwitchBody) - curIndent.Level--; - - if (policy.IndentCaseBody) - curIndent.Level--; - return null; - } - - public override object VisitCaseLabel (CaseLabel caseLabel, object data) - { - // handled in switchsection - return null; - } - - public override object VisitThrowStatement (ThrowStatement throwStatement, object data) - { - FixStatementIndentation (throwStatement.StartLocation); - return VisitChildren (throwStatement, data); - } - - public override object VisitTryCatchStatement (TryCatchStatement tryCatchStatement, object data) - { - FixStatementIndentation (tryCatchStatement.StartLocation); - - if (tryCatchStatement.TryBlock != null) - FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.TryBlock); - - foreach (CatchClause clause in tryCatchStatement.CatchClauses) { - PlaceOnNewLine (policy.PlaceCatchOnNewLine, clause.CatchKeyword); - - FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, clause.Block); - } - - if (tryCatchStatement.FinallyBlock != null) { - PlaceOnNewLine (policy.PlaceFinallyOnNewLine, tryCatchStatement.FinallyKeyword); - - FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.FinallyBlock); - } - - return VisitChildren (tryCatchStatement, data); - } - - public override object VisitCatchClause (CatchClause catchClause, object data) - { - // Handled in TryCatchStatement - return null; - } - - public override object VisitUncheckedStatement (UncheckedStatement uncheckedStatement, object data) - { - FixStatementIndentation (uncheckedStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement , uncheckedStatement.EmbeddedStatement); - } - - public override object VisitUnsafeStatement (UnsafeStatement unsafeStatement, object data) - { - FixStatementIndentation (unsafeStatement.StartLocation); - Console.WriteLine (unsafeStatement.Block); - return FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, unsafeStatement.Block); - } - - public override object VisitUsingStatement (UsingStatement usingStatement, object data) - { - FixStatementIndentation (usingStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.UsingBraceForcement , usingStatement.EmbeddedStatement); - } - - public override object VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, object data) - { - FixStatementIndentation (variableDeclarationStatement.StartLocation); - return null; - } - - public override object VisitWhileStatement (WhileStatement whileStatement, object data) - { - FixStatementIndentation (whileStatement.StartLocation); - if (whileStatement.WhilePosition == WhilePosition.End) { - PlaceOnNewLine (policy.PlaceWhileOnNewLine, whileStatement.WhileKeyword); - } - - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.WhileBraceForcement , whileStatement.EmbeddedStatement); - } - - public override object VisitYieldStatement (YieldStatement yieldStatement, object data) - { - FixStatementIndentation (yieldStatement.StartLocation); - return null; - } - - #endregion - - void PlaceOnNewLine (bool newLine, ICSharpNode keywordNode) - { - if (keywordNode == null) - return; - int offset = data.Document.LocationToOffset (keywordNode.StartLocation.Line, keywordNode.StartLocation.Column); - - int whitespaceStart = SearchWhitespaceStart (offset); - string indentString = newLine ? data.EolMarker + this.curIndent.IndentString : " "; - AddChange (whitespaceStart, offset - whitespaceStart, indentString); - } - - string nextStatementIndent = null; - void FixStatementIndentation (MonoDevelop.Projects.Dom.DomLocation location) - { - int offset = data.Document.LocationToOffset (location.Line, location.Column); - if (offset == 0) { - Console.WriteLine ("possible wrong offset"); - Console.WriteLine (Environment.StackTrace); - return; - } - int whitespaceStart = SearchWhitespaceStart (offset); - string indentString = nextStatementIndent == null ? data.EolMarker + this.curIndent.IndentString : nextStatementIndent; - nextStatementIndent = null; - AddChange (whitespaceStart, offset - whitespaceStart, indentString); - } - - void FixIndentation (MonoDevelop.Projects.Dom.DomLocation location) - { - FixIndentation (location, 0); - } - - void FixIndentation (MonoDevelop.Projects.Dom.DomLocation location, int relOffset) - { - LineSegment lineSegment = data.Document.GetLine (location.Line); - string lineIndent = lineSegment.GetIndentation (data.Document); - string indentString = this.curIndent.IndentString; - if (indentString != lineIndent && location.Column + relOffset == lineIndent.Length) { - AddChange (lineSegment.Offset, lineIndent.Length, indentString); - } - } - } -} - -*/ \ No newline at end of file diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/DomSpacingVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/DomSpacingVisitor.cs deleted file mode 100644 index 6ee49cfd3..000000000 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/DomSpacingVisitor.cs +++ /dev/null @@ -1,513 +0,0 @@ -// -// DomFormattingVisitor.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2010 Novell, Inc (http://www.novell.com) -// -// 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.CSharp; -using System.Text; -using MonoDevelop.Projects.Dom; -using Mono.TextEditor; -using MonoDevelop.Refactoring; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.CSharp -{ - public class DomSpacingVisitor : AbtractCSharpDomVisitor - { - CSharpFormattingPolicy policy; - TextEditorData data; - List changes = new List (); - - public List Changes { - get { return this.changes; } - } - - public bool AutoAcceptChanges { get; set; } - - public DomSpacingVisitor (CSharpFormattingPolicy policy, TextEditorData data) - { - this.policy = policy; - this.data = data; - AutoAcceptChanges = true; - } - - internal class MyTextReplaceChange : TextReplaceChange - { - TextEditorData data; - protected override TextEditorData TextEditorData { - get { - return data; - } - } - - public MyTextReplaceChange (TextEditorData data, int offset, int count, string replaceWith) - { - this.data = data; - this.FileName = data.Document.FileName; - this.Offset = offset; - this.RemovedChars = count; - this.InsertedText = replaceWith; - } - } - - public override object VisitCompilatioICSharpCode.NRefactory.CSharparp.Dom.CompilationUnit unit, object data) - { - base.VisitCompilationUnit (unit, data); - if (AutoAcceptChanges) - RefactoringService.AcceptChanges (null, null, changes); - return null; - } - - public override object VisitTypeDeclaration (TypeDeclaration typeDeclaration, object data) - { - - return base.VisitTypeDeclaration (typeDeclaration, data); - } - - public override object VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, object data) - { - return base.VisitPropertyDeclaration (propertyDeclaration, data); - } - - public override object VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, object data) - { - ForceSpacesAfter (indexerDeclaration.LBracket, policy.SpacesWithinBrackets); - ForceSpacesBefore (indexerDeclaration.RBracket, policy.SpacesWithinBrackets); - return base.VisitIndexerDeclaration (indexerDeclaration, data); - } - public override object VisitBlockStatement (BlockStatement blockStatement, object data) - { - return base.VisitBlockStatement (blockStatement, data); - } - - public override object VisitAssignmentExpression (AssignmentExpression assignmentExpression, object data) - { - ForceSpacesAround (assignmentExpression.Operator, policy.AroundAssignmentParentheses); - return base.VisitAssignmentExpression (assignmentExpression, data); - } - - public override object VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, object data) - { - bool forceSpaces = false; - switch (binaryOperatorExpression.BinaryOperatorType) { - case BinaryOperatorType.Equality: - case BinaryOperatorType.InEquality: - forceSpaces = policy.AroundEqualityOperatorParentheses; - break; - case BinaryOperatorType.GreaterThan: - case BinaryOperatorType.GreaterThanOrEqual: - case BinaryOperatorType.LessThan: - case BinaryOperatorType.LessThanOrEqual: - forceSpaces = policy.AroundRelationalOperatorParentheses; - break; - case BinaryOperatorType.LogicalAnd: - case BinaryOperatorType.LogicalOr: - forceSpaces = policy.AroundLogicalOperatorParentheses; - break; - case BinaryOperatorType.BitwiseAnd: - case BinaryOperatorType.BitwiseOr: - case BinaryOperatorType.ExclusiveOr: - forceSpaces = policy.AroundBitwiseOperatorParentheses; - break; - case BinaryOperatorType.Add: - case BinaryOperatorType.Subtract: - forceSpaces = policy.AroundAdditiveOperatorParentheses; - break; - case BinaryOperatorType.Multiply: - case BinaryOperatorType.Divide: - case BinaryOperatorType.Modulus: - forceSpaces = policy.AroundMultiplicativeOperatorParentheses; - break; - case BinaryOperatorType.ShiftLeft: - case BinaryOperatorType.ShiftRight: - forceSpaces = policy.AroundShiftOperatorParentheses; - break; - } - ForceSpacesAround (binaryOperatorExpression.Operator, forceSpaces); - - return base.VisitBinaryOperatorExpression (binaryOperatorExpression, data); - } - - public override object VisitConditionalExpression (ConditionalExpression conditionalExpression, object data) - { - ForceSpacesBefore (conditionalExpression.QuestionMark, policy.ConditionalOperatorBeforeConditionSpace); - ForceSpacesAfter (conditionalExpression.QuestionMark, policy.ConditionalOperatorAfterConditionSpace); - ForceSpacesBefore (conditionalExpression.Colon, policy.ConditionalOperatorBeforeSeparatorSpace); - ForceSpacesAfter (conditionalExpression.Colon, policy.ConditionalOperatorAfterSeparatorSpace); - return base.VisitConditionalExpression (conditionalExpression, data); - } - - public override object VisitCastExpression (CastExpression castExpression, object data) - { - if (castExpression.RPar != null) { - ForceSpacesAfter (castExpression.LPar, policy.WithinCastParentheses); - ForceSpacesBefore (castExpression.RPar, policy.WithinCastParentheses); - - ForceSpacesAfter (castExpression.RPar, 1, policy.SpacesAfterTypecast); - } - return base.VisitCastExpression (castExpression, data); - } - - void ForceSpacesAround (INode node, bool forceSpaces) - { - ForceSpacesBefore (node, forceSpaces); - ForceSpacesAfter (node, forceSpaces); - } - - void ForceSpacesAfter (INode node, bool forceSpaces) - { - DomLocation location = ((ICSharpNode)node).EndLocation; - - int offset = data.Document.LocationToOffset (location.Line, location.Column) - 1; - int i = offset + 1; - while (i < data.Document.Length && Char.IsWhiteSpace (data.Document.GetCharAt (i))) { - i++; - } - ForceSpace (offset, i, forceSpaces); - } - - void ForceSpacesAfter (INode node, int tokenLength, bool forceSpaces) - { - DomLocation location = ((ICSharpNode)node).StartLocation; - int offset = data.Document.LocationToOffset (location.Line, location.Column) + 1; - int i = offset; - while (i < data.Document.Length && Char.IsWhiteSpace (data.Document.GetCharAt (i))) { - i++; - } - ForceSpace (offset - 1, i, forceSpaces); - } - - int ForceSpacesBefore (INode node, bool forceSpaces) - { - DomLocation location = ((ICSharpNode)node).StartLocation; - - int offset = data.Document.LocationToOffset (location.Line, location.Column); - int i = offset - 1; - - while (i >= 0 && Char.IsWhiteSpace (data.Document.GetCharAt (i))) { - i--; - } - ForceSpace (i, offset, forceSpaces); - return i; - } - - public override object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) - { - foreach (INode node in fieldDeclaration.Children) { - if (node is VariableInitializer && node.NextSibling != null && node.NextSibling.Role == FieldDeclaration.Roles.Comma) { - VariableInitializer initializer = node as VariableInitializer; - CSharpTokenNode commaToken = (CSharpTokenNode)node.NextSibling; - int offset = this.data.Document.LocationToOffset (initializer.NameIdentifier.StartLocation.Line, initializer.NameIdentifier.StartLocation.Column); - int commaOffset = this.data.Document.LocationToOffset (commaToken.StartLocation.Line, commaToken.StartLocation.Column); - ForceSpace (offset, commaOffset, policy.SpacesAfterComma); - //Console.WriteLine (initializer.Name +"/" + initializer.NameIdentifier + "/" + commaToken); - - if (node.NextSibling.NextSibling is VariableInitializer) { - DomLocation location = ((VariableInitializer)node.NextSibling.NextSibling).NameIdentifier.StartLocation; - int nextOffset = this.data.Document.LocationToOffset (location.Line, location.Column); - ForceSpace (commaOffset, nextOffset, policy.SpacesAfterComma); - } - } - } - return base.VisitFieldDeclaration (fieldDeclaration, data); - } - - public override object VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, object data) - { - CSharpTokenNode lParen = (CSharpTokenNode)delegateDeclaration.GetChildByRole (DelegateDeclaration.Roles.LPar); - int offset = this.data.Document.LocationToOffset (lParen.StartLocation.Line, lParen.StartLocation.Column); - ForceSpaceBefore (offset, policy.BeforeDelegateDeclarationParentheses); - return base.VisitDelegateDeclaration (delegateDeclaration, data); - } - - public override object VisitMethodDeclaration (MethodDeclaration methodDeclaration, object data) - { - ForceSpacesBefore (methodDeclaration.LPar, policy.BeforeMethodDeclarationParentheses); - - ForceSpacesAfter (methodDeclaration.LPar, policy.WithinMethodDeclarationParentheses); - ForceSpacesBefore (methodDeclaration.RPar, policy.WithinMethodDeclarationParentheses); - - return base.VisitMethodDeclaration (methodDeclaration, data); - } - - public override object VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, object data) - { - CSharpTokenNode lParen = (CSharpTokenNode)constructorDeclaration.GetChildByRole (ConstructorDeclaration.Roles.LPar); - int offset = this.data.Document.LocationToOffset (lParen.StartLocation.Line, lParen.StartLocation.Column); - ForceSpaceBefore (offset, policy.BeforeConstructorDeclarationParentheses); - - return base.VisitConstructorDeclaration (constructorDeclaration, data); - } - - public override object VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, object data) - { - CSharpTokenNode lParen = (CSharpTokenNode)destructorDeclaration.GetChildByRole (DestructorDeclaration.Roles.LPar); - int offset = this.data.Document.LocationToOffset (lParen.StartLocation.Line, lParen.StartLocation.Column); - ForceSpaceBefore (offset, policy.BeforeConstructorDeclarationParentheses); - return base.VisitDestructorDeclaration (destructorDeclaration, data); - } - - void ForceSpaceBefore (int offset, bool forceSpace) - { - bool insertedSpace = false; - do { - char ch = data.Document.GetCharAt (offset); - //Console.WriteLine (ch); - if (!Char.IsWhiteSpace (ch) && (insertedSpace || !forceSpace)) - break; - if (ch == ' ' && forceSpace) { - if (insertedSpace) { - changes.Add (new MyTextReplaceChange (data, offset, 1, null)); - } else { - insertedSpace = true; - } - } else if (forceSpace) { - if (!insertedSpace) { - changes.Add (new MyTextReplaceChange (data, offset, Char.IsWhiteSpace (ch) ? 1 : 0, " ")); - insertedSpace = true; - } else if (Char.IsWhiteSpace (ch)) { - changes.Add (new MyTextReplaceChange (data, offset, 1, null)); - } - } - - offset--; - } while (offset >= 0); - } - - void ForceSpace (int startOffset, int endOffset, bool forceSpace) - { - int lastNonWs = SearchLastNonWsChar (startOffset, endOffset); - changes.Add (new MyTextReplaceChange (data, lastNonWs + 1, System.Math.Max (0, endOffset - lastNonWs - 1), forceSpace ? " " : "")); - } - - int SearchLastNonWsChar (int startOffset, int endOffset) - { - startOffset = System.Math.Max (0, startOffset); - endOffset = System.Math.Max (startOffset, endOffset); - if (startOffset >= endOffset) - return startOffset; - int result = -1; - bool inComment = false; - - for (int i = startOffset; i < endOffset && i < data.Document.Length; i++) { - char ch = data.Document.GetCharAt (i); - //Console.WriteLine (ch); - if (Char.IsWhiteSpace (ch)) - continue; - if (ch == '/' && i + 1 < data.Document.Length && data.Document.GetCharAt (i + 1) == '/') - return result; - if (ch == '/' && i + 1 < data.Document.Length && data.Document.GetCharAt (i + 1) == '*') { - inComment = true; - i++; - continue; - } - if (inComment && ch == '*' && i + 1 < data.Document.Length && data.Document.GetCharAt (i + 1) == '/') { - inComment = false; - i++; - continue; - } - if (!inComment) - result = i; - } - return result; - } - - public override object VisitInvocationExpression (InvocationExpression invocationExpression, object data) - { - ForceSpacesBefore (invocationExpression.LPar, policy.BeforeMethodCallParentheses); - - ForceSpacesAfter (invocationExpression.LPar, policy.WithinMethodCallParentheses); - ForceSpacesBefore (invocationExpression.RPar, policy.WithinMethodCallParentheses); - - return base.VisitInvocationExpression (invocationExpression, data); - } - - public override object VisitIndexerExpression (IndexerExpression indexerExpression, object data) - { - ForceSpacesAfter (indexerExpression.LBracket, policy.SpacesWithinBrackets); - ForceSpacesBefore (indexerExpression.RBracket, policy.SpacesWithinBrackets); - return base.VisitIndexerExpression (indexerExpression, data); - } - - public override object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) - { - ForceSpacesBefore (ifElseStatement.LPar, policy.IfParentheses); - - ForceSpacesAfter (ifElseStatement.LPar, policy.WithinIfParentheses); - ForceSpacesBefore (ifElseStatement.RPar, policy.WithinIfParentheses); - - - return base.VisitIfElseStatement (ifElseStatement, data); - } - - public override object VisitWhileStatement (WhileStatement whileStatement, object data) - { - ForceSpacesBefore (whileStatement.LPar, policy.WhileParentheses); - - ForceSpacesAfter (whileStatement.LPar, policy.WithinWhileParentheses); - ForceSpacesBefore (whileStatement.RPar, policy.WithinWhileParentheses); - - return base.VisitWhileStatement (whileStatement, data); - } - - public override object VisitForStatement (ForStatement forStatement, object data) - { - foreach (INode node in forStatement.Children) { - if (node.Role == ForStatement.Roles.Semicolon) { - if (node.NextSibling is CSharpTokenNode || node.NextSibling is EmptyStatement) - continue; - ForceSpacesAfter (node, policy.SpacesAfterSemicolon); - } - } - - ForceSpacesBefore (forStatement.LPar, policy.ForParentheses); - - ForceSpacesAfter (forStatement.LPar, policy.WithinForParentheses); - ForceSpacesBefore (forStatement.RPar, policy.WithinForParentheses); - - if (forStatement.EmbeddedStatement != null) - forStatement.EmbeddedStatement.AcceptVisitor (this, data); - - return null; - } - - public override object VisitForeachStatement (ForeachStatement foreachStatement, object data) - { - ForceSpacesBefore (foreachStatement.LPar, policy.ForeachParentheses); - - ForceSpacesAfter (foreachStatement.LPar, policy.WithinForEachParentheses); - ForceSpacesBefore (foreachStatement.RPar, policy.WithinForEachParentheses); - - return base.VisitForeachStatement (foreachStatement, data); - } - - public override object VisitCatchClause (CatchClause catchClause, object data) - { - if (catchClause.LPar != null) { - ForceSpacesBefore (catchClause.LPar, policy.CatchParentheses); - - ForceSpacesAfter (catchClause.LPar, policy.WithinCatchParentheses); - ForceSpacesBefore (catchClause.RPar, policy.WithinCatchParentheses); - } - - return base.VisitCatchClause (catchClause, data); - } - - public override object VisitLockStatement (LockStatement lockStatement, object data) - { - ForceSpacesBefore (lockStatement.LPar, policy.LockParentheses); - - ForceSpacesAfter (lockStatement.LPar, policy.WithinLockParentheses); - ForceSpacesBefore (lockStatement.RPar, policy.WithinLockParentheses); - - - return base.VisitLockStatement (lockStatement, data); - } - - public override object VisitUsingStatement (UsingStatement usingStatement, object data) - { - ForceSpacesBefore (usingStatement.LPar, policy.UsingParentheses); - - ForceSpacesAfter (usingStatement.LPar, policy.WithinUsingParentheses); - ForceSpacesBefore (usingStatement.RPar, policy.WithinUsingParentheses); - - return base.VisitUsingStatement (usingStatement, data); - } - - public override object VisitSwiICSharpCode.NRefactory.CSharplop.CSharp.Dom.SwitchStatement switchStatement, object data) - { - ForceSpacesBefore (switchStatement.LPar, policy.SwitchParentheses); - - ForceSpacesAfter (switchStatement.LPar, policy.WithinSwitchParentheses); - ForceSpacesBefore (switchStatement.RPar, policy.WithinSwitchParentheses); - - return base.VisitSwitchStatement (switchStatement, data); - } - - public override object VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, object data) - { - ForceSpacesAfter (parenthesizedExpression.LPar, policy.WithinParentheses); - ForceSpacesBefore (parenthesizedExpression.RPar, policy.WithinParentheses); - return base.VisitParenthesizedExpression (parenthesizedExpression, data); - } - - public override object VisitSizeOfExpression (SizeOfExpression sizeOfExpression, object data) - { - ForceSpacesAfter (sizeOfExpression.LPar, policy.WithinSizeOfParentheses); - ForceSpacesBefore (sizeOfExpression.RPar, policy.WithinSizeOfParentheses); - return base.VisitSizeOfExpression (sizeOfExpression, data); - } - - public override object VisitTypeOfExpression (TypeOfExpression typeOfExpression, object data) - { - ForceSpacesAfter (typeOfExpression.LPar, policy.WithinTypeOfParentheses); - ForceSpacesBefore (typeOfExpression.RPar, policy.WithinTypeOfParentheses); - return base.VisitTypeOfExpression (typeOfExpression, data); - } - - public override object VisitCheckedExpression (CheckedExpression checkedExpression, object data) - { - ForceSpacesAfter (checkedExpression.LPar, policy.WithinCheckedExpressionParantheses); - ForceSpacesBefore (checkedExpression.RPar, policy.WithinCheckedExpressionParantheses); - return base.VisitCheckedExpression (checkedExpression, data); - } - - public override object VisitUncheckedExpression (UncheckedExpression uncheckedExpression, object data) - { - ForceSpacesAfter (uncheckedExpression.LPar, policy.WithinCheckedExpressionParantheses); - ForceSpacesBefore (uncheckedExpression.RPar, policy.WithinCheckedExpressionParantheses); - return base.VisitUncheckedExpression (uncheckedExpression, data); - } - - public override object VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, object data) - { - ForceSpacesBefore (objectCreateExpression.LPar, policy.NewParentheses); - - return base.VisitObjectCreateExpression (objectCreateExpression, data); - } - - public override object VisitArrayObjectCreateExpression (ArrayObjectCreateExpression arrayObjectCreateExpression, object data) - { - foreach (INode node in arrayObjectCreateExpression.Children) { - if (node.Role == ArrayObjectCreateExpression.Roles.Comma) { - ForceSpacesBefore (node, policy.SpacesBeforeComma); - ForceSpacesAfter (node, policy.SpacesAfterComma); - } - } - return base.VisitArrayObjectCreateExpression (arrayObjectCreateExpression, data); - } - - public override object VisitLambdaExpression (LambdaExpression lambdaExpression, object data) - { - ForceSpacesAfter (lambdaExpression.Arrow, true); - ForceSpacesBefore (lambdaExpression.Arrow, true); - - return base.VisitLambdaExpression (lambdaExpression, data); - } - - - } -} -*/ \ No newline at end of file diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs new file mode 100644 index 000000000..b6acd11bf --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs @@ -0,0 +1,52 @@ +// +// ITextEditorAdapter.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// 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; + +namespace ICSharpCode.NRefactory +{ + public interface ITextEditorAdapter + { + bool TabsToSpaces { get; } + int TabSize { get; } + string EolMarker { get; } + + string Text { get; } + int Length { get; } + int LocationToOffset (int line, int col); + char GetCharAt (int offset); + string GetTextAt (int offset, int length); + + int LineCount { get; } + int GetEditableLength (int lineNumber); + string GetIndentation (int lineNumber); + int GetLineOffset (int lineNumber); + int GetLineLength (int lineNumber); + int GetLineEndOffset (int lineNumber); + + } +} + diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Indent.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Indent.cs index 8703b41c8..017d8c9b4 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Indent.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Formatter/Indent.cs @@ -33,44 +33,54 @@ namespace ICSharpCode.NRefactory.CSharp get; set; } - + public int ExtraSpaces { get; set; } - + + public bool TabsToSpaces { + get; + set; + } + + public int TabSize { + get; + set; + } + public Indent () { } - + public Indent (int level, int extraSpaces) { this.Level = level; this.ExtraSpaces = extraSpaces; } - - public static Indent operator+(Indent left, Indent right) + + public static Indent operator+ (Indent left, Indent right) { return new Indent (left.Level + right.Level, left.ExtraSpaces + right.ExtraSpaces); } - - public static Indent operator-(Indent left, Indent right) + + public static Indent operator- (Indent left, Indent right) { return new Indent (left.Level - right.Level, left.ExtraSpaces - right.ExtraSpaces); } - + public string IndentString { get { - return new string ('\t', Level) + new string (' ', ExtraSpaces); + return (TabsToSpaces ? new string (' ', Level * TabSize) : new string ('\t', Level)) + new string (' ', ExtraSpaces); } } - + public string SingleIndent { get { - return "\t"; + return TabsToSpaces ? new string (' ', TabSize) : "\t"; } } - + public override string ToString () { return string.Format ("[Indent: Level={0}, ExtraSpaces={1}]", Level, ExtraSpaces); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs index 947028699..e8a9f408f 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs @@ -152,10 +152,10 @@ namespace ICSharpCode.NRefactory.CSharp void Comma(AstNode nextNode, bool noSpaceAfterComma = false) { WriteSpecialsUpToRole(AstNode.Roles.Comma, nextNode); - Space(policy.SpacesBeforeComma); + Space(policy.SpaceBeforeBracketComma); // TODO: Comma policy has changed. formatter.WriteToken(","); lastWritten = LastWritten.Other; - Space(!noSpaceAfterComma && policy.SpacesAfterComma); + Space(!noSpaceAfterComma && policy.SpaceAfterBracketComma); // TODO: Comma policy has changed. } void WriteCommaSeparatedList(IEnumerable list) @@ -218,13 +218,13 @@ namespace ICSharpCode.NRefactory.CSharp void WriteCommaSeparatedListInBrackets(IEnumerable list) { - WriteToken("[", AstNode.Roles.LBracket); - if (list.Any()) { - Space(policy.SpacesWithinBrackets); - WriteCommaSeparatedList(list.SafeCast()); - Space(policy.SpacesWithinBrackets); + WriteToken ("[", AstNode.Roles.LBracket); + if (list.Any ()) { + Space (policy.SpacesWithinBrackets); + WriteCommaSeparatedList (list.SafeCast ()); + Space (policy.SpacesWithinBrackets); } - WriteToken("]", AstNode.Roles.RBracket); + WriteToken ("]", AstNode.Roles.RBracket); } #endregion @@ -461,8 +461,8 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(anonymousMethodExpression); WriteKeyword("delegate"); if (anonymousMethodExpression.HasParameterList) { - Space(policy.BeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(anonymousMethodExpression.Parameters, policy.WithinMethodDeclarationParentheses); + Space(policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(anonymousMethodExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); } anonymousMethodExpression.Body.AcceptVisitor(this, data); return EndNode(anonymousMethodExpression); @@ -473,8 +473,8 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(argListExpression); WriteKeyword("__arglist"); if (!argListExpression.IsAccess) { - Space(policy.BeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(argListExpression.Arguments, policy.WithinMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(argListExpression.Arguments, policy.SpaceWithinMethodCallParentheses); } return EndNode(argListExpression); } @@ -530,9 +530,9 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(assignmentExpression); assignmentExpression.Left.AcceptVisitor(this, data); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); WriteToken(AssignmentExpression.GetOperatorSymbol(assignmentExpression.Operator), AssignmentExpression.OperatorRole); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); assignmentExpression.Right.AcceptVisitor(this, data); return EndNode(assignmentExpression); } @@ -553,34 +553,34 @@ namespace ICSharpCode.NRefactory.CSharp case BinaryOperatorType.BitwiseAnd: case BinaryOperatorType.BitwiseOr: case BinaryOperatorType.ExclusiveOr: - spacePolicy = policy.AroundBitwiseOperatorParentheses; + spacePolicy = policy.SpaceAroundBitwiseOperator; break; case BinaryOperatorType.ConditionalAnd: case BinaryOperatorType.ConditionalOr: - spacePolicy = policy.AroundLogicalOperatorParentheses; + spacePolicy = policy.SpaceAroundLogicalOperator; break; case BinaryOperatorType.GreaterThan: case BinaryOperatorType.GreaterThanOrEqual: case BinaryOperatorType.LessThanOrEqual: case BinaryOperatorType.LessThan: - spacePolicy = policy.AroundRelationalOperatorParentheses; + spacePolicy = policy.SpaceAroundRelationalOperator; break; case BinaryOperatorType.Equality: case BinaryOperatorType.InEquality: - spacePolicy = policy.AroundEqualityOperatorParentheses; + spacePolicy = policy.SpaceAroundEqualityOperator; break; case BinaryOperatorType.Add: case BinaryOperatorType.Subtract: - spacePolicy = policy.AroundAdditiveOperatorParentheses; + spacePolicy = policy.SpaceAroundAdditiveOperator; break; case BinaryOperatorType.Multiply: case BinaryOperatorType.Divide: case BinaryOperatorType.Modulus: - spacePolicy = policy.AroundMultiplicativeOperatorParentheses; + spacePolicy = policy.SpaceAroundMultiplicativeOperator; break; case BinaryOperatorType.ShiftLeft: case BinaryOperatorType.ShiftRight: - spacePolicy = policy.AroundShiftOperatorParentheses; + spacePolicy = policy.SpaceAroundShiftOperator; break; case BinaryOperatorType.NullCoalescing: spacePolicy = true; @@ -599,11 +599,11 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(castExpression); LPar(); - Space(policy.WithinCastParentheses); + Space(policy.SpacesWithinCastParentheses); castExpression.Type.AcceptVisitor(this, data); - Space(policy.WithinCastParentheses); + Space(policy.SpacesWithinCastParentheses); RPar(); - Space(policy.SpacesAfterTypecast); + Space(policy.SpaceAfterTypecast); castExpression.Expression.AcceptVisitor(this, data); return EndNode(castExpression); } @@ -613,9 +613,9 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(checkedExpression); WriteKeyword("checked"); LPar(); - Space(policy.WithinCheckedExpressionParantheses); + Space(policy.SpacesWithinCheckedExpressionParantheses); checkedExpression.Expression.AcceptVisitor(this, data); - Space(policy.WithinCheckedExpressionParantheses); + Space(policy.SpacesWithinCheckedExpressionParantheses); RPar(); return EndNode(checkedExpression); } @@ -625,15 +625,15 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(conditionalExpression); conditionalExpression.Condition.AcceptVisitor(this, data); - Space(policy.ConditionalOperatorBeforeConditionSpace); + Space(policy.SpaceBeforeConditionalOperatorCondition); WriteToken("?", ConditionalExpression.QuestionMarkRole); - Space(policy.ConditionalOperatorAfterConditionSpace); + Space(policy.SpaceAfterConditionalOperatorCondition); conditionalExpression.TrueExpression.AcceptVisitor(this, data); - Space(policy.ConditionalOperatorBeforeSeparatorSpace); + Space(policy.SpaceBeforeConditionalOperatorSeparator); WriteToken(":", ConditionalExpression.ColonRole); - Space(policy.ConditionalOperatorAfterSeparatorSpace); + Space(policy.SpaceAfterConditionalOperatorSeparator); conditionalExpression.FalseExpression.AcceptVisitor(this, data); @@ -646,9 +646,9 @@ namespace ICSharpCode.NRefactory.CSharp WriteKeyword("default"); LPar(); - Space(policy.WithinTypeOfParentheses); + Space(policy.SpacesWithinTypeOfParentheses); defaultValueExpression.Type.AcceptVisitor(this, data); - Space(policy.WithinTypeOfParentheses); + Space(policy.SpacesWithinTypeOfParentheses); RPar(); return EndNode(defaultValueExpression); @@ -686,7 +686,7 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(indexerExpression); indexerExpression.Target.AcceptVisitor(this, data); - Space(policy.BeforeMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); WriteCommaSeparatedListInBrackets(indexerExpression.Arguments); return EndNode(indexerExpression); } @@ -695,8 +695,8 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(invocationExpression); invocationExpression.Target.AcceptVisitor(this, data); - Space(policy.BeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(invocationExpression.Arguments, policy.WithinMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(invocationExpression.Arguments, policy.SpaceWithinMethodCallParentheses); return EndNode(invocationExpression); } @@ -714,7 +714,7 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(lambdaExpression); if (LambdaNeedsParenthesis(lambdaExpression)) { - WriteCommaSeparatedListInParenthesis(lambdaExpression.Parameters, policy.WithinMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(lambdaExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); } else { lambdaExpression.Parameters.Single().AcceptVisitor(this, data); } @@ -765,8 +765,8 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(objectCreateExpression); WriteKeyword("new"); objectCreateExpression.Type.AcceptVisitor(this, data); - Space(policy.BeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(objectCreateExpression.Arguments, policy.WithinMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(objectCreateExpression.Arguments, policy.SpaceWithinMethodCallParentheses); objectCreateExpression.Initializer.AcceptVisitor(this, data); return EndNode(objectCreateExpression); } @@ -775,23 +775,27 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(parenthesizedExpression); LPar(); - Space(policy.WithinParentheses); + Space(policy.SpacesWithinParentheses); parenthesizedExpression.Expression.AcceptVisitor(this, data); - Space(policy.WithinParentheses); + Space(policy.SpacesWithinParentheses); RPar(); return EndNode(parenthesizedExpression); } - public object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) + public object VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, object data) { - StartNode(pointerReferenceExpression); - pointerReferenceExpression.Target.AcceptVisitor(this, data); - WriteToken("->", PointerReferenceExpression.ArrowRole); - WriteIdentifier(pointerReferenceExpression.MemberName); - WriteTypeArguments(pointerReferenceExpression.TypeArguments); - return EndNode(pointerReferenceExpression); + StartNode (pointerReferenceExpression); + pointerReferenceExpression.Target.AcceptVisitor (this, data); + WriteToken ("->", PointerReferenceExpression.ArrowRole); + WriteIdentifier (pointerReferenceExpression.MemberName); + WriteTypeArguments (pointerReferenceExpression.TypeArguments); + return EndNode (pointerReferenceExpression); } + public object VisitEmptyExpression (EmptyExpression emptyExpression, object data) + { + return EndNode (emptyExpression); + } #region VisitPrimitiveExpression public object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) { @@ -942,9 +946,9 @@ namespace ICSharpCode.NRefactory.CSharp WriteKeyword("sizeof"); LPar(); - Space(policy.WithinSizeOfParentheses); + Space(policy.SpacesWithinSizeOfParentheses); sizeOfExpression.Type.AcceptVisitor(this, data); - Space(policy.WithinSizeOfParentheses); + Space(policy.SpacesWithinSizeOfParentheses); RPar(); return EndNode(sizeOfExpression); @@ -972,9 +976,9 @@ namespace ICSharpCode.NRefactory.CSharp WriteKeyword("typeof"); LPar(); - Space(policy.WithinTypeOfParentheses); + Space(policy.SpacesWithinTypeOfParentheses); typeOfExpression.Type.AcceptVisitor(this, data); - Space(policy.WithinTypeOfParentheses); + Space(policy.SpacesWithinTypeOfParentheses); RPar(); return EndNode(typeOfExpression); @@ -1005,9 +1009,9 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(uncheckedExpression); WriteKeyword("unchecked"); LPar(); - Space(policy.WithinCheckedExpressionParantheses); + Space(policy.SpacesWithinCheckedExpressionParantheses); uncheckedExpression.Expression.AcceptVisitor(this, data); - Space(policy.WithinCheckedExpressionParantheses); + Space(policy.SpacesWithinCheckedExpressionParantheses); RPar(); return EndNode(uncheckedExpression); } @@ -1058,9 +1062,9 @@ namespace ICSharpCode.NRefactory.CSharp WriteKeyword("let"); Space(); WriteIdentifier(queryLetClause.Identifier); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); WriteToken("=", QueryLetClause.Roles.Assign); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); queryLetClause.Expression.AcceptVisitor(this, data); return EndNode(queryLetClause); } @@ -1155,9 +1159,9 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(attribute); attribute.Type.AcceptVisitor(this, data); - Space(policy.BeforeMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); if (attribute.Arguments.Count != 0 || !attribute.GetChildByRole(AstNode.Roles.LPar).IsNull) - WriteCommaSeparatedListInParenthesis(attribute.Arguments, policy.WithinMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(attribute.Arguments, policy.SpaceWithinMethodCallParentheses); return EndNode(attribute); } @@ -1189,8 +1193,8 @@ namespace ICSharpCode.NRefactory.CSharp Space(); WriteIdentifier(delegateDeclaration.Name); WriteTypeParameters(delegateDeclaration.TypeParameters); - Space(policy.BeforeDelegateDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(delegateDeclaration.Parameters, policy.WithinMethodDeclarationParentheses); + Space(policy.SpaceBeforeDelegateDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(delegateDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); foreach (Constraint constraint in delegateDeclaration.Constraints) { constraint.AcceptVisitor(this, data); } @@ -1274,9 +1278,9 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(usingAliasDeclaration); WriteKeyword("using"); WriteIdentifier(usingAliasDeclaration.Alias, UsingAliasDeclaration.AliasRole); - Space(policy.AroundEqualityOperatorParentheses); + Space(policy.SpaceAroundEqualityOperator); WriteToken("=", AstNode.Roles.Assign); - Space(policy.AroundEqualityOperatorParentheses); + Space(policy.SpaceAroundEqualityOperator); usingAliasDeclaration.Import.AcceptVisitor(this, data); Semicolon(); return EndNode(usingAliasDeclaration); @@ -1290,6 +1294,20 @@ namespace ICSharpCode.NRefactory.CSharp Semicolon(); return EndNode(usingDeclaration); } + + public object VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, object data) + { + StartNode(externAliasDeclaration); + WriteKeyword("extern"); + Space (); + WriteKeyword("alias"); + Space (); + externAliasDeclaration.NameToken.AcceptVisitor(this, data); + Semicolon(); + return EndNode(externAliasDeclaration); + } + + #endregion #region Statements @@ -1358,11 +1376,11 @@ namespace ICSharpCode.NRefactory.CSharp WriteKeyword("do", DoWhileStatement.DoKeywordRole); WriteEmbeddedStatement(doWhileStatement.EmbeddedStatement); WriteKeyword("while", DoWhileStatement.WhileKeywordRole); - Space(policy.WhileParentheses); + Space(policy.SpaceBeforeWhileParentheses); LPar(); - Space(policy.WithinWhileParentheses); + Space(policy.SpacesWithinWhileParentheses); doWhileStatement.Condition.AcceptVisitor(this, data); - Space(policy.WithinWhileParentheses); + Space(policy.SpacesWithinWhileParentheses); RPar(); Semicolon(); return EndNode(doWhileStatement); @@ -1387,13 +1405,13 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(fixedStatement); WriteKeyword("fixed"); - Space(policy.UsingParentheses); + Space(policy.SpaceBeforeUsingParentheses); LPar(); - Space(policy.WithinUsingParentheses); + Space(policy.SpacesWithinUsingParentheses); fixedStatement.Type.AcceptVisitor(this, data); Space(); WriteCommaSeparatedList(fixedStatement.Variables); - Space(policy.WithinUsingParentheses); + Space(policy.SpacesWithinUsingParentheses); RPar(); WriteEmbeddedStatement(fixedStatement.EmbeddedStatement); return EndNode(fixedStatement); @@ -1403,16 +1421,16 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(foreachStatement); WriteKeyword("foreach"); - Space(policy.ForeachParentheses); + Space(policy.SpaceBeforeForeachParentheses); LPar(); - Space(policy.WithinForEachParentheses); + Space(policy.SpacesWithinForeachParentheses); foreachStatement.VariableType.AcceptVisitor(this, data); Space(); WriteIdentifier(foreachStatement.VariableName); WriteKeyword("in", ForeachStatement.Roles.InKeyword); Space(); foreachStatement.InExpression.AcceptVisitor(this, data); - Space(policy.WithinForEachParentheses); + Space(policy.SpacesWithinForeachParentheses); RPar(); WriteEmbeddedStatement(foreachStatement.EmbeddedStatement); return EndNode(foreachStatement); @@ -1422,21 +1440,23 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(forStatement); WriteKeyword("for"); - Space(policy.ForParentheses); + Space(policy.SpaceBeforeForParentheses); LPar(); - Space(policy.WithinForParentheses); + Space(policy.SpacesWithinForParentheses); WriteCommaSeparatedList(forStatement.Initializers.SafeCast()); + Space (policy.SpaceBeforeForSemicolon); WriteToken(";", AstNode.Roles.Semicolon); - Space(policy.SpacesAfterSemicolon); + Space (policy.SpaceAfterForSemicolon); forStatement.Condition.AcceptVisitor(this, data); + Space (policy.SpaceBeforeForSemicolon); WriteToken(";", AstNode.Roles.Semicolon); - Space(policy.SpacesAfterSemicolon); + Space(policy.SpaceAfterForSemicolon); WriteCommaSeparatedList(forStatement.Iterators.SafeCast()); - Space(policy.WithinForParentheses); + Space(policy.SpacesWithinForParentheses); RPar(); WriteEmbeddedStatement(forStatement.EmbeddedStatement); return EndNode(forStatement); @@ -1475,11 +1495,11 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(ifElseStatement); WriteKeyword("if", IfElseStatement.IfKeywordRole); - Space(policy.IfParentheses); + Space(policy.SpaceBeforeIfParentheses); LPar(); - Space(policy.WithinIfParentheses); + Space(policy.SpacesWithinIfParentheses); ifElseStatement.Condition.AcceptVisitor(this, data); - Space(policy.WithinIfParentheses); + Space(policy.SpacesWithinIfParentheses); RPar(); WriteEmbeddedStatement(ifElseStatement.TrueStatement); if (!ifElseStatement.FalseStatement.IsNull) { @@ -1502,11 +1522,11 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(lockStatement); WriteKeyword("lock"); - Space(policy.LockParentheses); + Space(policy.SpaceBeforeLockParentheses); LPar(); - Space(policy.WithinLockParentheses); + Space(policy.SpacesWithinLockParentheses); lockStatement.Expression.AcceptVisitor(this, data); - Space(policy.WithinLockParentheses); + Space(policy.SpacesWithinLockParentheses); RPar(); WriteEmbeddedStatement(lockStatement.EmbeddedStatement); return EndNode(lockStatement); @@ -1528,11 +1548,11 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(switchStatement); WriteKeyword("switch"); - Space(policy.SwitchParentheses); + Space(policy.SpaceBeforeSwitchParentheses); LPar(); - Space(policy.WithinSwitchParentheses); + Space(policy.SpacesWithinSwitchParentheses); switchStatement.Expression.AcceptVisitor(this, data); - Space(policy.WithinSwitchParentheses); + Space(policy.SpacesWithinSwitchParentheses); RPar(); OpenBrace(policy.StatementBraceStyle); foreach (var section in switchStatement.SwitchSections) @@ -1602,13 +1622,13 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(catchClause); WriteKeyword("catch"); if (!catchClause.Type.IsNull) { - Space(policy.CatchParentheses); + Space(policy.SpaceBeforeCatchParentheses); LPar(); - Space(policy.WithinCatchParentheses); + Space(policy.SpacesWithinCatchParentheses); catchClause.Type.AcceptVisitor(this, data); Space(); WriteIdentifier(catchClause.VariableName); - Space(policy.WithinCatchParentheses); + Space(policy.SpacesWithinCatchParentheses); RPar(); } catchClause.Body.AcceptVisitor(this, data); @@ -1635,13 +1655,13 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(usingStatement); WriteKeyword("using"); - Space(policy.UsingParentheses); + Space(policy.SpaceBeforeUsingParentheses); LPar(); - Space(policy.WithinUsingParentheses); + Space(policy.SpacesWithinUsingParentheses); usingStatement.ResourceAcquisition.AcceptVisitor(this, data); - Space(policy.WithinUsingParentheses); + Space(policy.SpacesWithinUsingParentheses); RPar(); WriteEmbeddedStatement(usingStatement.EmbeddedStatement); @@ -1663,11 +1683,11 @@ namespace ICSharpCode.NRefactory.CSharp { StartNode(whileStatement); WriteKeyword("while", WhileStatement.WhileKeywordRole); - Space(policy.WhileParentheses); + Space(policy.SpaceBeforeWhileParentheses); LPar(); - Space(policy.WithinWhileParentheses); + Space(policy.SpacesWithinWhileParentheses); whileStatement.Condition.AcceptVisitor(this, data); - Space(policy.WithinWhileParentheses); + Space(policy.SpacesWithinWhileParentheses); RPar(); WriteEmbeddedStatement(whileStatement.EmbeddedStatement); return EndNode(whileStatement); @@ -1720,8 +1740,8 @@ namespace ICSharpCode.NRefactory.CSharp WriteModifiers(constructorDeclaration.ModifierTokens); TypeDeclaration type = constructorDeclaration.Parent as TypeDeclaration; WriteIdentifier(type != null ? type.Name : constructorDeclaration.Name); - Space(policy.BeforeConstructorDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, policy.WithinMethodDeclarationParentheses); + Space(policy.SpaceBeforeConstructorDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); if (!constructorDeclaration.Initializer.IsNull) { Space(); constructorDeclaration.Initializer.AcceptVisitor(this, data); @@ -1740,8 +1760,8 @@ namespace ICSharpCode.NRefactory.CSharp } else { WriteKeyword("base"); } - Space(policy.BeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(constructorInitializer.Arguments, policy.WithinMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(constructorInitializer.Arguments, policy.SpaceWithinMethodCallParentheses); return EndNode(constructorInitializer); } @@ -1753,7 +1773,7 @@ namespace ICSharpCode.NRefactory.CSharp WriteToken("~", DestructorDeclaration.TildeRole); TypeDeclaration type = destructorDeclaration.Parent as TypeDeclaration; WriteIdentifier(type != null ? type.Name : destructorDeclaration.Name); - Space(policy.BeforeConstructorDeclarationParentheses); + Space(policy.SpaceBeforeConstructorDeclarationParentheses); LPar(); RPar(); WriteMethodBody(destructorDeclaration.Body); @@ -1767,9 +1787,9 @@ namespace ICSharpCode.NRefactory.CSharp WriteModifiers(enumMemberDeclaration.ModifierTokens); WriteIdentifier(enumMemberDeclaration.Name); if (!enumMemberDeclaration.Initializer.IsNull) { - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); WriteToken("=", EnumMemberDeclaration.Roles.Assign); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); enumMemberDeclaration.Initializer.AcceptVisitor(this, data); } return EndNode(enumMemberDeclaration); @@ -1810,16 +1830,45 @@ namespace ICSharpCode.NRefactory.CSharp return EndNode(customEventDeclaration); } - public object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) + public object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) { - StartNode(fieldDeclaration); - WriteAttributes(fieldDeclaration.Attributes); - WriteModifiers(fieldDeclaration.ModifierTokens); - fieldDeclaration.ReturnType.AcceptVisitor(this, data); + StartNode (fieldDeclaration); + WriteAttributes (fieldDeclaration.Attributes); + WriteModifiers (fieldDeclaration.ModifierTokens); + fieldDeclaration.ReturnType.AcceptVisitor (this, data); + Space (); + WriteCommaSeparatedList (fieldDeclaration.Variables); + Semicolon (); + return EndNode (fieldDeclaration); + } + + public object VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, object data) + { + StartNode(fixedFieldDeclaration); + WriteAttributes(fixedFieldDeclaration.Attributes); + WriteModifiers(fixedFieldDeclaration.ModifierTokens); Space(); - WriteCommaSeparatedList(fieldDeclaration.Variables); + WriteKeyword("fixed"); + Space(); + fixedFieldDeclaration.ReturnType.AcceptVisitor (this, data); + Space(); + WriteCommaSeparatedList(fixedFieldDeclaration.Variables); Semicolon(); - return EndNode(fieldDeclaration); + return EndNode(fixedFieldDeclaration); + } + + public object VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, object data) + { + StartNode(fixedVariableInitializer); + WriteIdentifier(fixedVariableInitializer.Name); + if (!fixedVariableInitializer.Initializer.IsNull) { + WriteToken("[", AstNode.Roles.LBracket); + Space(policy.SpacesWithinBrackets); + fixedVariableInitializer.Initializer.AcceptVisitor(this, data); + Space(policy.SpacesWithinBrackets); + WriteToken("]", AstNode.Roles.RBracket); + } + return EndNode(fixedVariableInitializer); } public object VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, object data) @@ -1829,9 +1878,9 @@ namespace ICSharpCode.NRefactory.CSharp WriteModifiers(indexerDeclaration.ModifierTokens); indexerDeclaration.ReturnType.AcceptVisitor(this, data); WritePrivateImplementationType(indexerDeclaration.PrivateImplementationType); - WriteKeyword("this"); - Space(policy.BeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInBrackets(indexerDeclaration.Parameters, policy.WithinMethodDeclarationParentheses); + WriteKeyword ("this"); + Space(policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInBrackets(indexerDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); OpenBrace(policy.PropertyBraceStyle); // output get/set in their original order foreach (AstNode node in indexerDeclaration.Children) { @@ -1854,8 +1903,8 @@ namespace ICSharpCode.NRefactory.CSharp WritePrivateImplementationType(methodDeclaration.PrivateImplementationType); WriteIdentifier(methodDeclaration.Name); WriteTypeParameters(methodDeclaration.TypeParameters); - Space(policy.BeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(methodDeclaration.Parameters, policy.WithinMethodDeclarationParentheses); + Space(policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(methodDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); foreach (Constraint constraint in methodDeclaration.Constraints) { constraint.AcceptVisitor(this, data); } @@ -1884,8 +1933,8 @@ namespace ICSharpCode.NRefactory.CSharp } else { WriteToken(OperatorDeclaration.GetToken(operatorDeclaration.OperatorType), OperatorDeclaration.OperatorTypeRole); } - Space(policy.BeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(operatorDeclaration.Parameters, policy.WithinMethodDeclarationParentheses); + Space(policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(operatorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); WriteMethodBody(operatorDeclaration.Body); return EndNode(operatorDeclaration); } @@ -1914,9 +1963,9 @@ namespace ICSharpCode.NRefactory.CSharp if (!string.IsNullOrEmpty(parameterDeclaration.Name)) WriteIdentifier(parameterDeclaration.Name); if (!parameterDeclaration.DefaultExpression.IsNull) { - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); WriteToken("=", ParameterDeclaration.Roles.Assign); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); parameterDeclaration.DefaultExpression.AcceptVisitor(this, data); } return EndNode(parameterDeclaration); @@ -1950,9 +1999,9 @@ namespace ICSharpCode.NRefactory.CSharp StartNode(variableInitializer); WriteIdentifier(variableInitializer.Name); if (!variableInitializer.Initializer.IsNull) { - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); WriteToken("=", VariableInitializer.Roles.Assign); - Space(policy.AroundAssignmentParentheses); + Space(policy.SpaceAroundAssignment); variableInitializer.Initializer.AcceptVisitor(this, data); } return EndNode(variableInitializer); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs index a056c8ba1..f9a20b45b 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs @@ -1,4 +1,4 @@ -// +// // CSharpParser.cs // // Author: @@ -85,6 +85,8 @@ namespace ICSharpCode.NRefactory.CSharp if (typeName is Mono.CSharp.QualifiedAliasMember) { var qam = (Mono.CSharp.QualifiedAliasMember)typeName; + // TODO: Overwork the return type model - atm we don't have a good representation + // for qualified alias members. return new SimpleType (qam.Name, Convert (qam.Location)); } @@ -120,14 +122,15 @@ namespace ICSharpCode.NRefactory.CSharp var spec = new ArraySpecifier () { Dimensions = cc.Spec.Dimension - 1 }; spec.AddChild (new CSharpTokenNode (Convert (cc.Spec.Location), 1), FieldDeclaration.Roles.LBracket); if (location != null) - spec.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.RBracket); + spec.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FieldDeclaration.Roles.RBracket); - result.ArraySpecifiers.Add(spec); + result.ArraySpecifiers.Add (spec); } return result; } System.Console.WriteLine ("Error while converting :" + typeName + " - unknown type name"); + System.Console.WriteLine (Environment.StackTrace); return new SimpleType ("unknown"); } @@ -185,12 +188,22 @@ namespace ICSharpCode.NRefactory.CSharp ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingAliasDeclaration.Roles.Semicolon); AddToNamespace (ud); } - + + public override void Visit (UsingsBag.ExternAlias u) + { + var ud = new ExternAliasDeclaration (); + ud.AddChild (new CSharpTokenNode (Convert (u.ExternLocation), "extern".Length), ExternAliasDeclaration.Roles.Keyword); + ud.AddChild (new CSharpTokenNode (Convert (u.AliasLocation), "alias".Length), ExternAliasDeclaration.AliasRole); + ud.AddChild (new Identifier (u.Identifier.Value, Convert (u.Identifier.Location)), ExternAliasDeclaration.Roles.Identifier); + ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingAliasDeclaration.Roles.Semicolon); + AddToNamespace (ud); + } + AstType ConvertImport (MemberName memberName) { if (memberName.Left != null) { // left.name - MemberType t = new MemberType(); + var t = new MemberType(); t.IsDoubleColon = memberName.IsDoubleColon; t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole); t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier); @@ -369,53 +382,61 @@ namespace ICSharpCode.NRefactory.CSharp public override void Visit (EnumMember em) { EnumMemberDeclaration newField = new EnumMemberDeclaration (); - VariableInitializer variable = new VariableInitializer (); - - variable.AddChild (new Identifier (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); + // TODO: attributes, 'new' modifier + newField.AddChild (new Identifier (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); if (em.Initializer != null) { - var initializer = (Expression)em.Initializer.Accept (this); - if (initializer != null) - variable.AddChild (initializer, EnumMemberDeclaration.InitializerRole); + newField.AddChild ((Expression)em.Initializer.Accept (this), EnumMemberDeclaration.InitializerRole); } - newField.AddChild (variable, AstNode.Roles.Variable); typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); } #endregion #region Type members + public override void Visit (FixedField f) { var location = LocationsBag.GetMemberLocation (f); - FieldDeclaration newField = new FieldDeclaration (); + var newField = new FixedFieldDeclaration (); AddModifiers (newField, location); if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location[0]), "fixed".Length), FieldDeclaration.Roles.Keyword); - newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); + newField.AddChild (new CSharpTokenNode (Convert (location [0]), "fixed".Length), FixedFieldDeclaration.Roles.Keyword); + newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type); - VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); + var variable = new FixedVariableInitializer (); + variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); if (!f.Initializer.IsNull) { + var bracketLocations = LocationsBag.GetLocations (f.Initializer); + if (bracketLocations != null && bracketLocations.Count > 1) + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket); + variable.AddChild ((Expression)f.Initializer.Accept (this), FieldDeclaration.Roles.Expression); + if (bracketLocations != null && bracketLocations.Count > 1) + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket); } + newField.AddChild (variable, FixedFieldDeclaration.VariableRole); - newField.AddChild (variable, FieldDeclaration.Roles.Variable); if (f.Declarators != null) { foreach (var decl in f.Declarators) { var declLoc = LocationsBag.GetLocations (decl); if (declLoc != null) - newField.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Comma); + newField.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma); - variable = new VariableInitializer (); + variable = new FixedVariableInitializer (); variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); if (!decl.Initializer.IsNull) { + var bracketLocations = LocationsBag.GetLocations (f.Initializer); + if (bracketLocations != null && bracketLocations.Count > 1) + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket); variable.AddChild ((Expression)decl.Initializer.Accept (this), FieldDeclaration.Roles.Expression); + if (bracketLocations != null && bracketLocations.Count > 1) + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket); } - newField.AddChild (variable, FieldDeclaration.Roles.Variable); + newField.AddChild (variable, FixedFieldDeclaration.VariableRole); } } if (location != null) @@ -656,25 +677,46 @@ namespace ICSharpCode.NRefactory.CSharp typeStack.Peek ().AddChild (newMethod, TypeDeclaration.MemberRole); } - static Dictionary modifierTable = new Dictionary (); + static Dictionary modifierTable = new Dictionary (); + static string[] keywordTable; + static ConversionVisitor () { - modifierTable[Mono.CSharp.Modifiers.NEW] = Modifiers.New; - modifierTable[Mono.CSharp.Modifiers.PUBLIC] = Modifiers.Public; - modifierTable[Mono.CSharp.Modifiers.PROTECTED] = Modifiers.Protected; - modifierTable[Mono.CSharp.Modifiers.PRIVATE] = Modifiers.Private; - modifierTable[Mono.CSharp.Modifiers.INTERNAL] = Modifiers.Internal; - modifierTable[Mono.CSharp.Modifiers.ABSTRACT] = Modifiers.Abstract; - modifierTable[Mono.CSharp.Modifiers.VIRTUAL] = Modifiers.Virtual; - modifierTable[Mono.CSharp.Modifiers.SEALED] = Modifiers.Sealed; - modifierTable[Mono.CSharp.Modifiers.STATIC] = Modifiers.Static; - modifierTable[Mono.CSharp.Modifiers.OVERRIDE] = Modifiers.Override; - modifierTable[Mono.CSharp.Modifiers.READONLY] = Modifiers.Readonly; -// modifierTable[Mono.CSharp.Modifiers.] = Modifiers.Const; - modifierTable[Mono.CSharp.Modifiers.PARTIAL] = Modifiers.Partial; - modifierTable[Mono.CSharp.Modifiers.EXTERN] = Modifiers.Extern; - modifierTable[Mono.CSharp.Modifiers.VOLATILE] = Modifiers.Volatile; - modifierTable[Mono.CSharp.Modifiers.UNSAFE] = Modifiers.Unsafe; + modifierTable [Mono.CSharp.Modifiers.NEW] = ICSharpCode.NRefactory.CSharp.Modifiers.New; + modifierTable [Mono.CSharp.Modifiers.PUBLIC] = ICSharpCode.NRefactory.CSharp.Modifiers.Public; + modifierTable [Mono.CSharp.Modifiers.PROTECTED] = ICSharpCode.NRefactory.CSharp.Modifiers.Protected; + modifierTable [Mono.CSharp.Modifiers.PRIVATE] = ICSharpCode.NRefactory.CSharp.Modifiers.Private; + modifierTable [Mono.CSharp.Modifiers.INTERNAL] = ICSharpCode.NRefactory.CSharp.Modifiers.Internal; + modifierTable [Mono.CSharp.Modifiers.ABSTRACT] = ICSharpCode.NRefactory.CSharp.Modifiers.Abstract; + modifierTable [Mono.CSharp.Modifiers.VIRTUAL] = ICSharpCode.NRefactory.CSharp.Modifiers.Virtual; + modifierTable [Mono.CSharp.Modifiers.SEALED] = ICSharpCode.NRefactory.CSharp.Modifiers.Sealed; + modifierTable [Mono.CSharp.Modifiers.STATIC] = ICSharpCode.NRefactory.CSharp.Modifiers.Static; + modifierTable [Mono.CSharp.Modifiers.OVERRIDE] = ICSharpCode.NRefactory.CSharp.Modifiers.Override; + modifierTable [Mono.CSharp.Modifiers.READONLY] = ICSharpCode.NRefactory.CSharp.Modifiers.Readonly; + modifierTable [Mono.CSharp.Modifiers.PARTIAL] = ICSharpCode.NRefactory.CSharp.Modifiers.Partial; + modifierTable [Mono.CSharp.Modifiers.EXTERN] = ICSharpCode.NRefactory.CSharp.Modifiers.Extern; + modifierTable [Mono.CSharp.Modifiers.VOLATILE] = ICSharpCode.NRefactory.CSharp.Modifiers.Volatile; + modifierTable [Mono.CSharp.Modifiers.UNSAFE] = ICSharpCode.NRefactory.CSharp.Modifiers.Unsafe; + + keywordTable = new string[255]; + for (int i = 0; i< keywordTable.Length; i++) + keywordTable [i] = "unknown"; + + keywordTable [(int)BuiltinTypeSpec.Type.Other] = "void"; + keywordTable [(int)BuiltinTypeSpec.Type.String] = "string"; + keywordTable [(int)BuiltinTypeSpec.Type.Int] = "int"; + keywordTable [(int)BuiltinTypeSpec.Type.Object] = "object"; + keywordTable [(int)BuiltinTypeSpec.Type.Float] = "float"; + keywordTable [(int)BuiltinTypeSpec.Type.Double] = "double"; + keywordTable [(int)BuiltinTypeSpec.Type.Long] = "long"; + keywordTable [(int)BuiltinTypeSpec.Type.Byte] = "byte"; + keywordTable [(int)BuiltinTypeSpec.Type.UInt] = "uint"; + keywordTable [(int)BuiltinTypeSpec.Type.ULong] = "ulong"; + keywordTable [(int)BuiltinTypeSpec.Type.Short] = "short"; + keywordTable [(int)BuiltinTypeSpec.Type.UShort] = "ushort"; + keywordTable [(int)BuiltinTypeSpec.Type.SByte] = "sbyte"; + keywordTable [(int)BuiltinTypeSpec.Type.Decimal] = "decimal"; + keywordTable [(int)BuiltinTypeSpec.Type.Char] = "char"; } void AddModifiers (AttributedNode parent, LocationsBag.MemberLocations location) @@ -692,7 +734,6 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (p); AddModifiers (newProperty, location); - newProperty.AddChild (ConvertToType (p.TypeName), AstNode.Roles.Type); newProperty.AddChild (new Identifier (p.MemberName.Name, Convert (p.MemberName.Location)), AstNode.Roles.Identifier); if (location != null) @@ -858,16 +899,14 @@ namespace ICSharpCode.NRefactory.CSharp foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); + if (loc != null && loc.Count > 0) + result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), VariableInitializer.Roles.Comma); init.AddChild (new Identifier (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { - if (loc != null) - init.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), VariableInitializer.Roles.Assign); - init.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); if (loc != null && loc.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), VariableInitializer.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); + init.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); } else { - if (loc != null && loc.Count > 0) - result.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), VariableInitializer.Roles.Comma); } result.AddChild (init, VariableDeclarationStatement.Roles.Variable); } @@ -880,12 +919,14 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (BlockConstantDeclaration blockVariableDeclaration) { var result = new VariableDeclarationStatement (); - result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), VariableDeclarationStatement.Roles.Type); - var varInit = new VariableInitializer (); var location = LocationsBag.GetLocations (blockVariableDeclaration); if (location != null) - varInit.AddChild (new CSharpModifierToken (Convert (location[0]), Modifiers.Const), VariableDeclarationStatement.ModifierRole); + result.AddChild (new CSharpModifierToken (Convert (location [0]), ICSharpCode.NRefactory.CSharp.Modifiers.Const), VariableDeclarationStatement.ModifierRole); + + result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), VariableDeclarationStatement.Roles.Type); + + var varInit = new VariableInitializer (); varInit.AddChild (new Identifier (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (location != null) @@ -927,11 +968,9 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (EmptyExpressionStatement emptyExpressionStatement) { - // indicates an error - return new EmptyStatement (); + return new EmptyExpression (Convert (emptyExpressionStatement.Location)); } - public override object Visit (If ifStatement) { var result = new IfElseStatement (); @@ -1037,7 +1076,8 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (StatementExpression statementExpression) { var result = new ExpressionStatement (); - result.AddChild ((Expression)statementExpression.Expr.Accept (this), ExpressionStatement.Roles.Expression); + object expr = statementExpression.Expr.Accept (this); + result.AddChild ((Expression)expr, ExpressionStatement.Roles.Expression); var location = LocationsBag.GetLocations (statementExpression); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ExpressionStatement.Roles.Semicolon); @@ -1159,7 +1199,7 @@ namespace ICSharpCode.NRefactory.CSharp if (loc != null) usingResult.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), ContinueStatement.Roles.Assign); if (u.Variables.Initializer != null) - usingResult.AddChild (ConvertToType (u.Variables.Initializer), UsingStatement.ResourceAcquisitionRole); + usingResult.AddChild ((AstNode)u.Variables.Initializer.Accept (this), UsingStatement.ResourceAcquisitionRole); } cur = u.Statement; @@ -1188,7 +1228,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (Block blockStatement) { - if (blockStatement.IsCompilerGenerated) { + if (blockStatement.IsCompilerGenerated && blockStatement.Statements.Any ()) { if (blockStatement.Statements.First () is Using) return CreateUsingStatement (blockStatement); return blockStatement.Statements.Last ().Accept (this); @@ -1294,22 +1334,20 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar); - /* if (fixedStatement.Variables != null) { - result.AddChild (ConvertToType (fixedStatement.Variables.TypeExpression.Accept (this), UsingStatement.Roles.Type); +// result.AddChild (ConvertToType (fixedStatement.Variables), UsingStatement.Roles.Type); result.AddChild (new Identifier (fixedStatement.Variables.Variable.Name, Convert (fixedStatement.Variables.Variable.Location)), UsingStatement.Roles.Identifier); var loc = LocationsBag.GetLocations (fixedStatement.Variables); if (loc != null) result.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), ContinueStatement.Roles.Assign); - if (fixedStatement.Variables.Initializer != null) - result.AddChild ((AstNode)fixedStatement.Variables.Initializer.Accept (this), UsingStatement.Roles.Variable); +// if (fixedStatement.Variables.Initializer != null) +// result.AddChild (fixedStatement.Variables.Initializer.Accept (this), UsingStatement.Roles.Variable); } if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar); - result.AddChild ((AstNode)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement); - return result;*/ - throw new NotImplementedException(); + result.AddChild ((Statement)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement); + return result; } public override object Visit (TryFinally tryFinallyStatement) @@ -1450,41 +1488,14 @@ namespace ICSharpCode.NRefactory.CSharp return null; } + public override object Visit (Mono.CSharp.DefaultParameterValueExpression defaultParameterValueExpression) + { + return defaultParameterValueExpression.Child.Accept (this); + } + public override object Visit (TypeExpression typeExpression) { - string keyword; - if (typeExpression.Type == TypeManager.void_type) { - keyword = "void"; - } else if (typeExpression.Type == TypeManager.string_type) { - keyword = "string"; - } else if (typeExpression.Type == TypeManager.int32_type) { - keyword = "int"; - } else if (typeExpression.Type == TypeManager.object_type) { - keyword = "object"; - } else if (typeExpression.Type == TypeManager.float_type) { - keyword = "float"; - } else if (typeExpression.Type == TypeManager.double_type) { - keyword = "double"; - } else if (typeExpression.Type == TypeManager.int64_type) { - keyword = "long"; - } else if (typeExpression.Type == TypeManager.byte_type) { - keyword = "byte"; - } else if (typeExpression.Type == TypeManager.uint32_type) { - keyword = "uint"; - } else if (typeExpression.Type == TypeManager.uint64_type) { - keyword = "ulong"; - } else if (typeExpression.Type == TypeManager.short_type) { - keyword = "short"; - } else if (typeExpression.Type == TypeManager.ushort_type) { - keyword = "ushort"; - } else if (typeExpression.Type == TypeManager.sbyte_type) { - keyword = "sbyte"; - } else if (typeExpression.Type == TypeManager.decimal_type) { - keyword = "decimal"; - } else { - keyword = "unknown"; - } - return new IdentifierExpression (keyword, Convert (typeExpression.Location)); + return new IdentifierExpression (keywordTable [(int)typeExpression.Type.BuiltinType], Convert (typeExpression.Location)); } public override object Visit (LocalVariableReference localVariableReference) @@ -1495,8 +1506,10 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (MemberAccess memberAccess) { var result = new MemberReferenceExpression (); - if (memberAccess.LeftExpression != null) - result.AddChild ((Expression)memberAccess.LeftExpression.Accept (this), MemberReferenceExpression.Roles.TargetExpression); + if (memberAccess.LeftExpression != null) { + var leftExpr = memberAccess.LeftExpression.Accept (this); + result.AddChild ((Expression)leftExpr, MemberReferenceExpression.Roles.TargetExpression); + } result.AddChild (new Identifier (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier); if (memberAccess.TypeArguments != null) { var location = LocationsBag.GetLocations (memberAccess); @@ -1755,6 +1768,7 @@ namespace ICSharpCode.NRefactory.CSharp opLength = 2; break; } + result.AddChild ((Expression)binaryExpression.Left.Accept (this), BinaryOperatorExpression.LeftRole); result.AddChild (new CSharpTokenNode (Convert (binaryExpression.Location), opLength), BinaryOperatorExpression.OperatorRole); result.AddChild ((Expression)binaryExpression.Right.Accept (this), BinaryOperatorExpression.RightRole); @@ -1794,41 +1808,41 @@ namespace ICSharpCode.NRefactory.CSharp for (int i = 0; i < parameters.Count; i++) { if (paramLocation != null && i > 0 && i - 1 < paramLocation.Count) - parent.AddChild (new CSharpTokenNode (Convert (paramLocation[i - 1]), 1), ParameterDeclaration.Roles.Comma); - var p = (Parameter)parameters.FixedParameters[i]; + parent.AddChild (new CSharpTokenNode (Convert (paramLocation [i - 1]), 1), ParameterDeclaration.Roles.Comma); + var p = (Parameter)parameters.FixedParameters [i]; var location = LocationsBag.GetLocations (p); ParameterDeclaration parameterDeclarationExpression = new ParameterDeclaration (); switch (p.ModFlags) { - case Parameter.Modifier.OUT: - parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out; - if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "out".Length), ParameterDeclaration.Roles.Keyword); - break; - case Parameter.Modifier.REF: - parameterDeclarationExpression.ParameterModifier = ParameterModifier.Ref; - if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "ref".Length), ParameterDeclaration.Roles.Keyword); - break; - case Parameter.Modifier.PARAMS: - parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params; + case Parameter.Modifier.OUT: + parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out; + if (location != null) + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "out".Length), ParameterDeclaration.Roles.Keyword); + break; + case Parameter.Modifier.REF: + parameterDeclarationExpression.ParameterModifier = ParameterModifier.Ref; + if (location != null) + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "ref".Length), ParameterDeclaration.Roles.Keyword); + break; + case Parameter.Modifier.PARAMS: + parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params; + if (location != null) + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "params".Length), ParameterDeclaration.Roles.Keyword); + break; + default: + if (p.HasExtensionMethodModifier) { + parameterDeclarationExpression.ParameterModifier = ParameterModifier.This; if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "params".Length), ParameterDeclaration.Roles.Keyword); - break; - default: - if (p.HasExtensionMethodModifier) { - parameterDeclarationExpression.ParameterModifier = ParameterModifier.This; - if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "this".Length), ParameterDeclaration.Roles.Keyword); - } - break; + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "this".Length), ParameterDeclaration.Roles.Keyword); + } + break; } if (p.TypeExpression != null) // lambdas may have no types (a, b) => ... parameterDeclarationExpression.AddChild (ConvertToType (p.TypeExpression), ParameterDeclaration.Roles.Type); parameterDeclarationExpression.AddChild (new Identifier (p.Name, Convert (p.Location)), ParameterDeclaration.Roles.Identifier); if (p.HasDefaultValue) { if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ParameterDeclaration.Roles.Assign); + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ParameterDeclaration.Roles.Assign); parameterDeclarationExpression.AddChild ((Expression)p.DefaultValue.Accept (this), ParameterDeclaration.Roles.Expression); } parent.AddChild (parameterDeclarationExpression, InvocationExpression.Roles.Parameter); @@ -1854,6 +1868,20 @@ namespace ICSharpCode.NRefactory.CSharp } } + void AddTypeArguments (AstNode parent, LocationsBag.MemberLocations location, Mono.CSharp.TypeArguments typeArguments) + { + if (typeArguments == null || typeArguments.IsEmpty) + return; + for (int i = 0; i < typeArguments.Count; i++) { + if (location != null && i > 0 && i - 1 < location.Count) + parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma); + var arg = typeArguments.Args[i]; + if (arg == null) + continue; + parent.AddChild (ConvertToType (arg), InvocationExpression.Roles.TypeArgument); + } + } + void AddTypeArguments (AstNode parent, List location, Mono.CSharp.TypeArguments typeArguments) { if (typeArguments == null || typeArguments.IsEmpty) @@ -1873,12 +1901,12 @@ namespace ICSharpCode.NRefactory.CSharp if (d == null || d.Constraints == null) return; for (int i = 0; i < d.Constraints.Count; i++) { - Constraints c = d.Constraints[i]; + Constraints c = d.Constraints [i]; var location = LocationsBag.GetLocations (c); var constraint = new Constraint (); - constraint.AddChild (new CSharpTokenNode (Convert (location[0]), "where".Length), InvocationExpression.Roles.Keyword); + constraint.AddChild (new CSharpTokenNode (Convert (location [0]), "where".Length), InvocationExpression.Roles.Keyword); constraint.AddChild (new Identifier (c.TypeParameter.Value, Convert (c.TypeParameter.Location)), InvocationExpression.Roles.Identifier); - constraint.AddChild (new CSharpTokenNode (Convert (location[1]), 1), Constraint.ColonRole); + constraint.AddChild (new CSharpTokenNode (Convert (location [1]), 1), Constraint.ColonRole); foreach (var expr in c.ConstraintExpressions) constraint.AddChild (ConvertToType (expr), Constraint.BaseTypeRole); parent.AddChild (constraint, AstNode.Roles.Constraint); @@ -1994,7 +2022,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayCreateExpression.Roles.RBracket); if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) { - throw new NotImplementedException(); + //throw new NotImplementedException(); /* TODO: use ArrayInitializerExpression var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers); result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayCreateExpression.Roles.LBrace); @@ -2216,17 +2244,17 @@ namespace ICSharpCode.NRefactory.CSharp if (location == null || location.Count == 1) { AddParameter (result, lambdaExpression.Parameters); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "=>".Length), LambdaExpression.ArrowRole); + result.AddChild (new CSharpTokenNode (Convert (location [0]), "=>".Length), LambdaExpression.ArrowRole); } else { result.AddChild (new CSharpTokenNode (Convert (lambdaExpression.Location), 1), LambdaExpression.Roles.LPar); AddParameter (result, lambdaExpression.Parameters); if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), LambdaExpression.Roles.RPar); - result.AddChild (new CSharpTokenNode (Convert (location[1]), "=>".Length), LambdaExpression.ArrowRole); + result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), LambdaExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1]), "=>".Length), LambdaExpression.ArrowRole); } } if (lambdaExpression.Block.IsCompilerGenerated) { - ContextualReturn generatedReturn = (ContextualReturn)lambdaExpression.Block.Statements[0]; + ContextualReturn generatedReturn = (ContextualReturn)lambdaExpression.Block.Statements [0]; result.AddChild ((AstNode)generatedReturn.Expr.Accept (this), LambdaExpression.BodyRole); } else { result.AddChild ((AstNode)lambdaExpression.Block.Accept (this), LambdaExpression.BodyRole); @@ -2263,212 +2291,194 @@ namespace ICSharpCode.NRefactory.CSharp #endregion #region LINQ expressions - public override object Visit (Mono.CSharp.Linq.QueryExpression queryExpression) +/* public override object Visit (Mono.CSharp.Linq.Query queryExpression) { - throw new NotImplementedException(); - /*var result = new QueryExpressionFromClause (); + var result = new QueryFromClause (); var location = LocationsBag.GetLocations (queryExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryExpressionFromClause.FromKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryFromClause.FromKeywordRole); // TODO: select identifier if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryExpressionFromClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryFromClause.InKeywordRole); var query = queryExpression.Expr as Mono.CSharp.Linq.AQueryClause; - if (query != null && query.Expr != null) - result.AddChild ((AstNode)query.Expr.Accept (this), QueryExpressionFromClause.Roles.Expression); - return result;*/ - } +// if (query != null && query.Expr != null) +// result.AddChild ((AstNode)query.Expr.Accept (this), QueryFromClause.Roles.Expression); + return result; + } */ public override object Visit (Mono.CSharp.Linq.SelectMany selectMany) { - throw new NotImplementedException(); - /*var result = new QueryExpressionFromClause (); + var result = new QueryFromClause (); // TODO: // Mono.CSharp.Linq.Cast cast = selectMany.Expr as Mono.CSharp.Linq.Cast; var location = LocationsBag.GetLocations (selectMany); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryExpressionFromClause.FromKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryFromClause.FromKeywordRole); - // result.AddChild ((AstNode)cast.TypeExpr.Accept (this), QueryExpressionFromClause.Roles.ReturnType); + // result.AddChild ((AstNode)cast.TypeExpr.Accept (this), QueryFromClause.Roles.ReturnType); // if (cast != null) -// result.AddChild (new Identifier (selectMany.SelectIdentifier.Value, Convert (selectMany.SelectIdentifier.Location)), QueryExpressionFromClause.Roles.Identifier); - // result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryExpressionFromClause.InKeywordRole); +// result.AddChild (new Identifier (selectMany.SelectIdentifier.Value, Convert (selectMany.SelectIdentifier.Location)), QueryFromClause.Roles.Identifier); + // result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryFromClause.InKeywordRole); - // result.AddChild ((AstNode)(cast != null ? cast.Expr : selectMany.Expr).Accept (this), QueryExpressionFromClause.Roles.Expression); + // result.AddChild ((AstNode)(cast != null ? cast.Expr : selectMany.Expr).Accept (this), QueryFromClause.Roles.Expression); - return result;*/ + return result; } public override object Visit (Mono.CSharp.Linq.Select sel) { - throw new NotImplementedException(); - /*var result = new QueryExpressionSelectClause (); + var result = new QuerySelectClause (); var location = LocationsBag.GetLocations (sel); - result.AddChild (new CSharpTokenNode (Convert (location[0]), "select".Length), QueryExpressionWhereClause.Roles.Keyword); - result.AddChild ((AstNode)sel.Expr.Accept (this), QueryExpressionWhereClause.Roles.Expression); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "select".Length), QueryWhereClause.Roles.Keyword); + result.AddChild ((Expression)sel.Expr.Accept (this), QueryWhereClause.Roles.Expression); + return result; } public override object Visit (Mono.CSharp.Linq.GroupBy groupBy) { - throw new NotImplementedException(); - /*var result = new QueryExpressionGroupClause (); + var result = new QueryGroupClause (); var location = LocationsBag.GetLocations (groupBy); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "group".Length), QueryExpressionGroupClause.GroupKeywordRole); - result.AddChild ((AstNode)groupBy.ElementSelector.Accept (this), QueryExpressionGroupClause.GroupByExpressionRole); - if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[1]), "by".Length), QueryExpressionGroupClause.ByKeywordRole); - result.AddChild ((AstNode)groupBy.Expr.Accept (this), QueryExpressionGroupClause.ProjectionExpressionRole); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "group".Length), QueryGroupClause.GroupKeywordRole); +// result.AddChild ((AstNode)groupBy.ElementSelector.Accept (this), QueryGroupClause.GroupByExpressionRole); +// if (location != null) +// result.AddChild (new CSharpTokenNode (Convert (location[1]), "by".Length), QueryGroupClause.ByKeywordRole); +// result.AddChild ((AstNode)groupBy.Expr.Accept (this), QueryGroupClause.ProjectionExpressionRole); + return result; } public override object Visit (Mono.CSharp.Linq.Let l) { - throw new NotImplementedException(); - /*var result = new QueryExpressionLetClause (); + var result = new QueryLetClause (); var location = LocationsBag.GetLocations (l); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "let".Length), QueryExpressionWhereClause.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "let".Length), QueryWhereClause.Roles.Keyword); NewAnonymousType aType = l.Expr as NewAnonymousType; AnonymousTypeParameter param = ((AnonymousTypeParameter)aType.Parameters[1]); result.AddChild (new Identifier (param.Name, Convert (param.Location)), Identifier.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), QueryExpressionWhereClause.Roles.Assign); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), QueryWhereClause.Roles.Assign); - result.AddChild ((AstNode)param.Expr.Accept (this), QueryExpressionWhereClause.Roles.Condition); - return result;*/ + result.AddChild ((Expression)param.Expr.Accept (this), QueryWhereClause.Roles.Condition); + return result; } public override object Visit (Mono.CSharp.Linq.Where w) { - throw new NotImplementedException(); - /*var result = new QueryExpressionWhereClause (); + var result = new QueryWhereClause (); var location = LocationsBag.GetLocations (w); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "where".Length), QueryExpressionWhereClause.Roles.Keyword); - result.AddChild ((AstNode)w.Expr.Accept (this), QueryExpressionWhereClause.Roles.Condition); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "where".Length), QueryWhereClause.Roles.Keyword); + result.AddChild ((Expression)w.Expr.Accept (this), QueryWhereClause.Roles.Condition); + return result; } public override object Visit (Mono.CSharp.Linq.Join join) { - throw new NotImplementedException(); - /*var result = new QueryExpressionJoinClause (); - var location = LocationsBag.GetLocations (join); + var result = new QueryJoinClause (); + /* var location = LocationsBag.GetLocations (join); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "join".Length), QueryExpressionJoinClause.JoinKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "join".Length), QueryJoinClause.JoinKeywordRole); result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryExpressionJoinClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryJoinClause.InKeywordRole); - result.AddChild ((AstNode)join.Expr.Accept (this), QueryExpressionJoinClause.Roles.Expression); + result.AddChild ((AstNode)join.Expr.Accept (this), QueryJoinClause.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[2]), "on".Length), QueryExpressionJoinClause.OnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[2]), "on".Length), QueryJoinClause.OnKeywordRole); // TODO: on expression if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[3]), "equals".Length), QueryExpressionJoinClause.EqualsKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[3]), "equals".Length), QueryJoinClause.EqualsKeywordRole); // TODO: equals expression - - return result;*/ + */ + return result; } public override object Visit (Mono.CSharp.Linq.GroupJoin groupJoin) { - throw new NotImplementedException(); - /*var result = new QueryExpressionJoinClause (); - var location = LocationsBag.GetLocations (groupJoin); + var result = new QueryJoinClause (); +/* var location = LocationsBag.GetLocations (groupJoin); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "join".Length), QueryExpressionJoinClause.JoinKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "join".Length), QueryJoinClause.JoinKeywordRole); result.AddChild (new Identifier (groupJoin.JoinVariable.Name, Convert (groupJoin.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryExpressionJoinClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryJoinClause.InKeywordRole); - result.AddChild ((AstNode)groupJoin.Expr.Accept (this), QueryExpressionJoinClause.Roles.Expression); + result.AddChild ((AstNode)groupJoin.Expr.Accept (this), QueryJoinClause.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[2]), "on".Length), QueryExpressionJoinClause.OnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[2]), "on".Length), QueryJoinClause.OnKeywordRole); // TODO: on expression if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[3]), "equals".Length), QueryExpressionJoinClause.EqualsKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[3]), "equals".Length), QueryJoinClause.EqualsKeywordRole); // TODO: equals expression if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[4]), "into".Length), QueryExpressionJoinClause.IntoKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[4]), "into".Length), QueryJoinClause.IntoKeywordRole); - result.AddChild (new Identifier (groupJoin.JoinVariable.Name, Convert (groupJoin.JoinVariable.Location)), Identifier.Roles.Identifier); - return result;*/ + result.AddChild (new Identifier (groupJoin.JoinVariable.Name, Convert (groupJoin.JoinVariable.Location)), Identifier.Roles.Identifier);*/ + return result; } public override object Visit (Mono.CSharp.Linq.OrderByAscending orderByAscending) { - throw new NotImplementedException(); - /*var result = new QueryExpressionOrderClause (); - result.OrderAscending = true; - result.AddChild ((AstNode)orderByAscending.Expr.Accept (this), QueryExpressionWhereClause.Roles.Expression); + var result = new QueryOrderClause (); + /* result.OrderAscending = true; + result.AddChild ((AstNode)orderByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var location = LocationsBag.GetLocations (orderByAscending); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryExpressionWhereClause.Roles.Keyword); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);*/ + return result; } public override object Visit (Mono.CSharp.Linq.OrderByDescending orderByDescending) { - throw new NotImplementedException(); - /*var result = new QueryExpressionOrderClause (); - result.OrderAscending = false; - result.AddChild ((AstNode)orderByDescending.Expr.Accept (this), QueryExpressionWhereClause.Roles.Expression); + var result = new QueryOrderClause (); + /* result.OrderAscending = false; + result.AddChild ((AstNode)orderByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var location = LocationsBag.GetLocations (orderByDescending); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "descending".Length), QueryExpressionWhereClause.Roles.Keyword); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "descending".Length), QueryWhereClause.Roles.Keyword);*/ + return result; } public override object Visit (Mono.CSharp.Linq.ThenByAscending thenByAscending) { - throw new NotImplementedException(); - /*var result = new QueryExpressionOrderClause (); - result.OrderAscending = true; - result.AddChild ((AstNode)thenByAscending.Expr.Accept (this), QueryExpressionWhereClause.Roles.Expression); + var result = new QueryOrderClause (); + /* result.OrderAscending = true; + result.AddChild ((AstNode)thenByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var location = LocationsBag.GetLocations (thenByAscending); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryExpressionWhereClause.Roles.Keyword); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);*/ + return result; } public override object Visit (Mono.CSharp.Linq.ThenByDescending thenByDescending) { - throw new NotImplementedException(); - /*var result = new QueryExpressionOrderClause (); - result.OrderAscending = false; - result.AddChild ((AstNode)thenByDescending.Expr.Accept (this), QueryExpressionWhereClause.Roles.Expression); + var result = new QueryOrderClause (); +/* result.OrderAscending = false; + result.AddChild ((AstNode)thenByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var location = LocationsBag.GetLocations (thenByDescending); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "descending".Length), QueryExpressionWhereClause.Roles.Keyword); - return result;*/ + result.AddChild (new CSharpTokenNode (Convert (location[0]), "descending".Length), QueryWhereClause.Roles.Keyword);*/ + return result; } #endregion } - - public AstLocation StartLocation { - get { return new AstLocation(1, 1); } - // TODO: add support for setting the start location when parsing parts of files (e.g. for ASP.NET) - set { throw new NotImplementedException(); } - } - - void InsertComment (AstNode node, Comment comment) + + public static void InsertComment (AstNode node, Comment comment) { if (node.EndLocation < comment.StartLocation) { node.AddChild (comment, AstNode.Roles.Comment); @@ -2489,15 +2499,15 @@ namespace ICSharpCode.NRefactory.CSharp node.AddChild (comment, AstNode.Roles.Comment); } - void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor) + static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor) { foreach (var special in top.SpecialsBag.Specials) { var comment = special as SpecialsBag.Comment; if (comment != null) { - var type = (CommentType)comment.CommentType; - var start = new AstLocation (comment.Line, comment.Col); - var end = new AstLocation (comment.EndLine, comment.EndCol); + var type = (CommentType)comment.CommentType; + var start = new AstLocation (comment.Line, comment.Col); + var end = new AstLocation (comment.EndLine, comment.EndCol); var domComment = new Comment (type, start, end); domComment.StartsLine = comment.StartsLine; domComment.Content = comment.Content; @@ -2506,6 +2516,47 @@ namespace ICSharpCode.NRefactory.CSharp } } + internal static CompilationUnit Parse (CompilerCompilationUnit top) + { + if (top == null) + return null; + CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag); + top.UsingsBag.Global.Accept (conversionVisitor); + InsertComments (top, conversionVisitor); + return conversionVisitor.Unit; + } + + public class ErrorReportPrinter : ReportPrinter + { +// public readonly List Errors = new List (); + + public override void Print (AbstractMessage msg) + { + base.Print (msg); +// Error newError = new Error (msg.IsWarning ? ErrorType.Warning : ErrorType.Error, msg.Location.Row, msg.Location.Column, msg.Text); +// Errors.Add (newError); + } + } + ErrorReportPrinter errorReportPrinter = new ErrorReportPrinter (); + + public ErrorReportPrinter ErrorPrinter { + get { + return errorReportPrinter; + } + } + + public bool HasErrors { + get { + return errorReportPrinter.ErrorsCount + errorReportPrinter.FatalCounter > 0; + } + } + + public bool HasWarnings { + get { + return errorReportPrinter.WarningsCount > 0; + } + } + public CompilationUnit Parse (TextReader reader) { // TODO: can we optimize this to avoid the text->stream->text roundtrip? @@ -2542,8 +2593,7 @@ namespace ICSharpCode.NRefactory.CSharp var td = cu.Children.FirstOrDefault() as TypeDeclaration; if (td != null) return td.Members; - else - return EmptyList.Instance; + return Enumerable.Empty (); } public IEnumerable ParseStatements(TextReader reader) @@ -2553,8 +2603,7 @@ namespace ICSharpCode.NRefactory.CSharp var method = members.FirstOrDefault() as MethodDeclaration; if (method != null && method.Body != null) return method.Body.Statements; - else - return EmptyList.Instance; + return Enumerable.Empty (); } public AstType ParseTypeReference(TextReader reader) @@ -2582,10 +2631,5 @@ namespace ICSharpCode.NRefactory.CSharp // TODO: add support for parsing a part of a file throw new NotImplementedException(); } - - // TODO: add API for retrieving parser errors/warning - public bool HasErrors { - get { return false; } - } } -} \ No newline at end of file +} diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs index 3079be2e9..fd9bfab20 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem.Implementation; -using Mono.Collections.Generic; namespace ICSharpCode.NRefactory.CSharp { diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs index a18d5ad87..c92e95a13 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs @@ -24,7 +24,7 @@ namespace Mono.CSharp { public abstract class CompilerGeneratedClass : Class { - protected CompilerGeneratedClass (DeclSpace parent, MemberName name, Modifiers mod) + protected CompilerGeneratedClass (TypeContainer parent, MemberName name, Modifiers mod) : base (parent.NamespaceEntry, parent, name, mod | Modifiers.COMPILER_GENERATED, null) { } @@ -80,7 +80,7 @@ namespace Mono.CSharp { protected TypeParameterMutator mutator; - public HoistedStoreyClass (DeclSpace parent, MemberName name, TypeParameter[] tparams, Modifiers mod) + public HoistedStoreyClass (TypeContainer parent, MemberName name, TypeParameter[] tparams, Modifiers mod) : base (parent, name, mod | Modifiers.PRIVATE) { if (tparams != null) { @@ -97,10 +97,12 @@ namespace Mono.CSharp { // A copy is not enough, inflate any type parameter constraints // using a new type parameters - var inflator = new TypeParameterInflator (null, src, dst); + var inflator = new TypeParameterInflator (this, null, src, dst); for (int i = 0; i < type_params.Length; ++i) { src[i].InflateConstraints (inflator, dst[i]); } + + mutator = new TypeParameterMutator (tparams, type_params); } } @@ -197,7 +199,6 @@ namespace Mono.CSharp { : base (parent, MakeMemberName (host, name, unique_id, tparams, block.StartLocation), tparams, Modifiers.SEALED) { - Parent = parent; OriginalSourceBlock = block; ID = unique_id++; } @@ -211,10 +212,10 @@ namespace Mono.CSharp { // Inflated type instance has to be updated manually if (Instance.Type is InflatedTypeSpec) { - var inflator = new TypeParameterInflator (Instance.Type, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); + var inflator = new TypeParameterInflator (this, Instance.Type, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); Instance.Type.MemberCache.AddMember (f.Spec.InflateMember (inflator)); - inflator = new TypeParameterInflator (f.Parent.CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); + inflator = new TypeParameterInflator (this, f.Parent.CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); f.Parent.CurrentType.MemberCache.AddMember (f.Spec.InflateMember (inflator)); } } @@ -872,7 +873,7 @@ namespace Mono.CSharp { if (delegate_type.IsDelegate) return delegate_type; - if (delegate_type.IsGeneric && delegate_type.GetDefinition () == TypeManager.expression_type) { + if (delegate_type.IsExpressionTreeType) { delegate_type = delegate_type.TypeArguments [0]; if (delegate_type.IsDelegate) return delegate_type; @@ -965,7 +966,7 @@ namespace Mono.CSharp { return false; if (!delegate_type.IsDelegate) { - if (delegate_type.GetDefinition () != TypeManager.expression_type) + if (!delegate_type.IsExpressionTreeType) return false; delegate_type = TypeManager.GetTypeArguments (delegate_type) [0]; @@ -973,7 +974,7 @@ namespace Mono.CSharp { return false; } - AParametersCollection d_params = Delegate.GetParameters (ec.Compiler, delegate_type); + AParametersCollection d_params = Delegate.GetParameters (delegate_type); if (d_params.Count != Parameters.Count) return false; @@ -1033,7 +1034,7 @@ namespace Mono.CSharp { // needed for the anonymous method. We create the method here. // - var invoke_mb = Delegate.GetInvokeMethod (ec.Compiler, delegate_type); + var invoke_mb = Delegate.GetInvokeMethod (delegate_type); TypeSpec return_type = invoke_mb.ReturnType; // @@ -1106,7 +1107,7 @@ namespace Mono.CSharp { protected virtual ParametersCompiled ResolveParameters (ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type) { - var delegate_parameters = Delegate.GetParameters (ec.Compiler, delegate_type); + var delegate_parameters = Delegate.GetParameters (delegate_type); if (Parameters == ParametersCompiled.Undefined) { // @@ -1495,7 +1496,7 @@ namespace Mono.CSharp { var hoisted_tparams = ec.CurrentTypeParameters; var type_params = new TypeParameter[hoisted_tparams.Length]; for (int i = 0; i < type_params.Length; ++i) { - type_params[i] = hoisted_tparams[i].CreateHoistedCopy (null, null); + type_params[i] = hoisted_tparams[i].CreateHoistedCopy (parent, null); } generic_method = new GenericMethod (parent.NamespaceEntry, parent, member_name, type_params, @@ -1613,12 +1614,12 @@ namespace Mono.CSharp { ec.Emit (OpCodes.Ldftn, TypeBuilder.GetMethod (t.GetMetaInfo (), (MethodInfo) delegate_method.GetMetaInfo ())); } else { if (delegate_method.IsGeneric) - delegate_method = delegate_method.MakeGenericMethod (method.TypeParameters); + delegate_method = delegate_method.MakeGenericMethod (ec.MemberContext, method.TypeParameters); ec.Emit (OpCodes.Ldftn, delegate_method); } - var constructor_method = Delegate.GetConstructor (ec.MemberContext.Compiler, ec.CurrentType, type); + var constructor_method = Delegate.GetConstructor (type); ec.Emit (OpCodes.Newobj, constructor_method); if (am_cache != null) { @@ -1676,13 +1677,13 @@ namespace Mono.CSharp { readonly IList parameters; - private AnonymousTypeClass (DeclSpace parent, MemberName name, IList parameters, Location loc) - : base (parent, name, (RootContext.EvalMode ? Modifiers.PUBLIC : 0) | Modifiers.SEALED) + private AnonymousTypeClass (TypeContainer parent, MemberName name, IList parameters, Location loc) + : base (parent, name, (parent.Module.Evaluator != null ? Modifiers.PUBLIC : 0) | Modifiers.SEALED) { this.parameters = parameters; } - public static AnonymousTypeClass Create (CompilerContext ctx, TypeContainer parent, IList parameters, Location loc) + public static AnonymousTypeClass Create (TypeContainer parent, IList parameters, Location loc) { string name = ClassNamePrefix + types_counter++; @@ -1721,7 +1722,7 @@ namespace Mono.CSharp { Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, null, all_parameters, null, loc); - c.Block = new ToplevelBlock (ctx, c.ParameterInfo, loc); + c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc); // // Create fields and contructor body with field initialization @@ -1742,7 +1743,7 @@ namespace Mono.CSharp { new SimpleAssign (new MemberAccess (new This (p.Location), f.Name), c.Block.GetParameterReference (i, p.Location)))); - ToplevelBlock get_block = new ToplevelBlock (ctx, p.Location); + ToplevelBlock get_block = new ToplevelBlock (parent.Module.Compiler, p.Location); get_block.AddStatement (new Return ( new MemberAccess (new This (p.Location), f.Name), p.Location)); @@ -1792,15 +1793,15 @@ namespace Mono.CSharp { Location loc = Location; var equals_parameters = ParametersCompiled.CreateFullyResolved ( - new Parameter (new TypeExpression (TypeManager.object_type, loc), "obj", 0, null, loc), TypeManager.object_type); + new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc), Compiler.BuiltinTypes.Object); - Method equals = new Method (this, null, new TypeExpression (TypeManager.bool_type, loc), + Method equals = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Bool, loc), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc), equals_parameters, null); equals_parameters[0].Resolve (equals, 0); - Method tostring = new Method (this, null, new TypeExpression (TypeManager.string_type, loc), + Method tostring = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.String, loc), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc), Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null); @@ -1825,8 +1826,8 @@ namespace Mono.CSharp { new QualifiedAliasMember ("global", "System", loc), "Collections", loc), "Generic", loc); Expression rs_equals = null; - Expression string_concat = new StringConstant ("{", loc); - Expression rs_hashcode = new IntConstant (-2128831035, loc); + Expression string_concat = new StringConstant (Compiler.BuiltinTypes, "{", loc); + Expression rs_hashcode = new IntConstant (Compiler.BuiltinTypes, -2128831035, loc); for (int i = 0; i < parameters.Count; ++i) { var p = parameters [i]; var f = Fields [i]; @@ -1848,7 +1849,7 @@ namespace Mono.CSharp { Expression field_hashcode = new Invocation (new MemberAccess (equality_comparer, "GetHashCode", loc), arguments_hashcode); - IntConstant FNV_prime = new IntConstant (16777619, loc); + IntConstant FNV_prime = new IntConstant (Compiler.BuiltinTypes, 16777619, loc); rs_hashcode = new Binary (Binary.Operator.Multiply, new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode, loc), FNV_prime, loc); @@ -1857,14 +1858,14 @@ namespace Mono.CSharp { new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc), loc)), new Invocation (new MemberAccess ( new MemberAccess (new This (f.Location), f.Name), "ToString"), null), - new StringConstant (string.Empty, loc), loc); + new StringConstant (Compiler.BuiltinTypes, string.Empty, loc), loc); if (rs_equals == null) { rs_equals = field_equal; string_concat = new Binary (Binary.Operator.Addition, string_concat, new Binary (Binary.Operator.Addition, - new StringConstant (" " + p.Name + " = ", loc), + new StringConstant (Compiler.BuiltinTypes, " " + p.Name + " = ", loc), field_to_string, loc), loc); @@ -1877,7 +1878,7 @@ namespace Mono.CSharp { string_concat = new Binary (Binary.Operator.Addition, new Binary (Binary.Operator.Addition, string_concat, - new StringConstant (", " + p.Name + " = ", loc), + new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc), loc), field_to_string, loc); @@ -1887,7 +1888,7 @@ namespace Mono.CSharp { string_concat = new Binary (Binary.Operator.Addition, string_concat, - new StringConstant (" }", loc), + new StringConstant (Compiler.BuiltinTypes, " }", loc), loc); // @@ -1911,7 +1912,7 @@ namespace Mono.CSharp { // // GetHashCode () override // - Method hashcode = new Method (this, null, new TypeExpression (TypeManager.int32_type, loc), + Method hashcode = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Int, loc), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("GetHashCode", loc), Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null); @@ -1934,7 +1935,7 @@ namespace Mono.CSharp { Block hashcode_block = new Block (hashcode_top, loc, loc); hashcode_top.AddStatement (new Unchecked (hashcode_block, loc)); - var li_hash = LocalVariable.CreateCompilerGenerated (TypeManager.int32_type, hashcode_top, loc); + var li_hash = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Int, hashcode_top, loc); hashcode_block.AddStatement (new BlockVariableDeclaration (new TypeExpression (li_hash.Type, loc), li_hash)); LocalVariableReference hash_variable_assign = new LocalVariableReference (li_hash, loc); hashcode_block.AddStatement (new StatementExpression ( @@ -1943,19 +1944,19 @@ namespace Mono.CSharp { var hash_variable = new LocalVariableReference (li_hash, loc); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (13, loc), loc), loc))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 13, loc), loc), loc))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable, - new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (7, loc), loc), loc))); + new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 7, loc), loc), loc))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (3, loc), loc), loc))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 3, loc), loc), loc))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable, - new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (17, loc), loc), loc))); + new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 17, loc), loc), loc))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (5, loc), loc), loc))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 5, loc), loc), loc))); hashcode_block.AddStatement (new Return (hash_variable, loc)); hashcode.Block = hashcode_top; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs index a5e08f48d..4acd366f7 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs @@ -138,7 +138,7 @@ namespace Mono.CSharp // Verify that the argument is writeable if (Expr != null && IsByRef) - Expr = Expr.ResolveLValue (ec, EmptyExpression.OutAccess.Instance); + Expr = Expr.ResolveLValue (ec, EmptyExpression.OutAccess); if (Expr == null) Expr = EmptyExpression.Null; @@ -201,7 +201,7 @@ namespace Mono.CSharp if (IsByRef) { var ml = (IMemoryLocation) Expr; ml.AddressOf (ec, AddressOp.Load); - type = ReferenceContainer.MakeType (type); + type = ReferenceContainer.MakeType (ec.Module, type); } else { Expr.Emit (ec); } @@ -274,7 +274,7 @@ namespace Mono.CSharp // CSharpArgumentInfoFlags.None = 0 const string info_flags_enum = "CSharpArgumentInfoFlags"; - Expression info_flags = new IntLiteral (0, loc); + Expression info_flags = new IntLiteral (rc.BuiltinTypes, 0, loc); if (a.Expr is Constant) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, @@ -296,7 +296,7 @@ namespace Mono.CSharp var arg_type = a.Expr.Type; - if (arg_type != InternalType.Dynamic && arg_type != InternalType.Null) { + if (arg_type.BuiltinType != BuiltinTypeSpec.Type.Dynamic && arg_type != InternalType.NullLiteral) { MethodGroupExpr mg = a.Expr as MethodGroupExpr; if (mg != null) { rc.Report.Error (1976, a.Expr.Location, @@ -305,7 +305,7 @@ namespace Mono.CSharp } else if (arg_type == InternalType.AnonymousMethod) { rc.Report.Error (1977, a.Expr.Location, "An anonymous method or lambda expression cannot be used as an argument of dynamic operation. Consider using a cast"); - } else if (arg_type == TypeManager.void_type || arg_type == InternalType.Arglist || arg_type.IsPointer) { + } else if (arg_type.Kind == MemberKind.Void || arg_type == InternalType.Arglist || arg_type.IsPointer) { rc.Report.Error (1978, a.Expr.Location, "An expression of type `{0}' cannot be used as an argument of dynamic operation", TypeManager.CSharpName (arg_type)); @@ -327,7 +327,7 @@ namespace Mono.CSharp } dargs.Add (new Argument (info_flags)); - dargs.Add (new Argument (new StringLiteral (named_value, loc))); + dargs.Add (new Argument (new StringLiteral (rc.BuiltinTypes, named_value, loc))); all.Add (new Invocation (new MemberAccess (new MemberAccess (binder, "CSharpArgumentInfo", loc), "Create", loc), dargs)); } @@ -436,7 +436,7 @@ namespace Mono.CSharp public bool HasDynamic { get { foreach (Argument a in args) { - if (a.Type == InternalType.Dynamic && !a.IsByRef) + if (a.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && !a.IsByRef) return true; } @@ -506,7 +506,7 @@ namespace Mono.CSharp dynamic = false; foreach (Argument a in args) { a.Resolve (ec); - if (a.Type == InternalType.Dynamic && !a.IsByRef) + if (a.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && !a.IsByRef) dynamic = true; } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assembly.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assembly.cs index 3d35de630..704f5c1f9 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assembly.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assembly.cs @@ -81,15 +81,15 @@ namespace Mono.CSharp wrap_non_exception_throws = true; - delay_sign = RootContext.StrongNameDelaySign; + delay_sign = Compiler.Settings.StrongNameDelaySign; // // Load strong name key early enough for assembly importer to be able to // use the keys for InternalsVisibleTo // This should go somewhere close to ReferencesLoading but don't have the place yet // - if (RootContext.StrongNameKeyFile != null || RootContext.StrongNameKeyContainer != null) { - LoadPublicKey (RootContext.StrongNameKeyFile, RootContext.StrongNameKeyContainer); + if (Compiler.Settings.HasKeyFileOrContainer) { + LoadPublicKey (Compiler.Settings.StrongNameKeyFile, Compiler.Settings.StrongNameKeyContainer); } } @@ -200,7 +200,7 @@ namespace Mono.CSharp if (value == null || value.Length == 0) return; - if (RootContext.Target == Target.Exe) { + if (Compiler.Settings.Target == Target.Exe) { a.Error_AttributeEmitError ("The executables cannot be satelite assemblies, remove the attribute or keep it empty"); return; } @@ -208,7 +208,7 @@ namespace Mono.CSharp if (value == "neutral") value = ""; - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute (ctor, cdata); } else { builder_extra.SetCulture (value, a.Location); @@ -228,7 +228,7 @@ namespace Mono.CSharp return; } - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute (ctor, cdata); } else { builder_extra.SetVersion (vinfo, a.Location); @@ -244,7 +244,7 @@ namespace Mono.CSharp alg |= ((uint) cdata [pos + 2]) << 16; alg |= ((uint) cdata [pos + 3]) << 24; - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute (ctor, cdata); } else { builder_extra.SetAlgorithmId (alg, a.Location); @@ -264,7 +264,7 @@ namespace Mono.CSharp if ((flags & (uint) AssemblyNameFlags.PublicKey) != 0 && public_key == null) flags &= ~(uint) AssemblyNameFlags.PublicKey; - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute (ctor, cdata); } else { builder_extra.SetFlags (flags, a.Location); @@ -396,7 +396,7 @@ namespace Mono.CSharp { var an = new AssemblyName (name); - if (public_key != null && RootContext.Target != Target.Module) { + if (public_key != null && Compiler.Settings.Target != Target.Module) { if (delay_sign) { an.SetPublicKey (public_key); } else { @@ -429,7 +429,7 @@ namespace Mono.CSharp public virtual void Emit () { - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Target == Target.Module) { module_target_attrs = new AssemblyAttributesPlaceholder (module, name); module_target_attrs.CreateType (); module_target_attrs.DefineType (); @@ -439,11 +439,15 @@ namespace Mono.CSharp ReadModulesAssemblyAttributes (); } - if (RootContext.GenerateDebugInfo) { + if (Compiler.Settings.GenerateDebugInfo) { symbol_writer = new MonoSymbolWriter (file_name); + // Register all source files with symbol writer + foreach (var source in Compiler.SourceFiles) { + source.DefineSymbolInfo (symbol_writer); + } + // TODO: global variables - Location.DefineSymbolDocuments (symbol_writer); SymbolWriter.symwriter = symbol_writer; } @@ -459,10 +463,10 @@ namespace Mono.CSharp if (!wrap_non_exception_throws_custom) { PredefinedAttribute pa = module.PredefinedAttributes.RuntimeCompatibility; if (pa.IsDefined && pa.ResolveBuilder ()) { - var prop = pa.GetProperty ("WrapNonExceptionThrows", TypeManager.bool_type, Location.Null); + var prop = module.PredefinedMembers.RuntimeCompatibilityWrapNonExceptionThrows.Get (); if (prop != null) { AttributeEncoder encoder = new AttributeEncoder (); - encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (true, Location.Null)); + encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (Compiler.BuiltinTypes, true, Location.Null)); SetCustomAttribute (pa.Constructor, encoder.ToArray ()); } } @@ -523,7 +527,7 @@ namespace Mono.CSharp // For attribute based KeyFile do additional lookup // in output assembly path // - if (!key_file_exists && RootContext.StrongNameKeyFile == null) { + if (!key_file_exists && Compiler.Settings.StrongNameKeyFile == null) { // // The key file can be relative to output assembly // @@ -598,7 +602,7 @@ namespace Mono.CSharp public void Resolve () { - if (RootContext.Unsafe && module.PredefinedTypes.SecurityAction.Define ()) { + if (Compiler.Settings.Unsafe && module.PredefinedTypes.SecurityAction.Define ()) { // // Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)] // when -unsafe option was specified @@ -608,15 +612,15 @@ namespace Mono.CSharp MemberAccess system_security_permissions = new MemberAccess (new MemberAccess ( new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc); - var req_min = (ConstSpec) module.PredefinedTypes.SecurityAction.GetField ("RequestMinimum", module.PredefinedTypes.SecurityAction.TypeSpec, loc); + var req_min = module.PredefinedMembers.SecurityActionRequestMinimum.Resolve (loc); Arguments pos = new Arguments (1); pos.Add (new Argument (req_min.GetConstant (null))); Arguments named = new Arguments (1); - named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (true, loc))); + named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (Compiler.BuiltinTypes, true, loc))); - GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (module, null, null, null), "assembly", + Attribute g = new Attribute ("assembly", new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"), new Arguments[] { pos, named }, loc, false); g.AttachTo (module, module); @@ -639,7 +643,7 @@ namespace Mono.CSharp is_cls_compliant = cls_attribute.GetClsCompliantAttributeValue (); } - if (added_modules != null && RootContext.VerifyClsCompliance && is_cls_compliant) { + if (added_modules != null && Compiler.Settings.VerifyClsCompliance && is_cls_compliant) { foreach (var m in added_modules) { if (!m.IsCLSCompliant) { Report.Error (3013, @@ -676,7 +680,7 @@ namespace Mono.CSharp case "AssemblyKeyFile": case "AssemblyKeyFileAttribute": case "System.Reflection.AssemblyKeyFileAttribute": - if (RootContext.StrongNameKeyFile != null) { + if (Compiler.Settings.StrongNameKeyFile != null) { Report.SymbolRelatedToPreviousError (a.Location, a.GetSignatureForError ()); Report.Warning (1616, 1, "Option `{0}' overrides attribute `{1}' given in a source file or added module", "keyfile", "System.Reflection.AssemblyKeyFileAttribute"); @@ -691,7 +695,7 @@ namespace Mono.CSharp case "AssemblyKeyName": case "AssemblyKeyNameAttribute": case "System.Reflection.AssemblyKeyNameAttribute": - if (RootContext.StrongNameKeyContainer != null) { + if (Compiler.Settings.StrongNameKeyContainer != null) { Report.SymbolRelatedToPreviousError (a.Location, a.GetSignatureForError ()); Report.Warning (1616, 1, "Option `{0}' overrides attribute `{1}' given in a source file or added module", "keycontainer", "System.Reflection.AssemblyKeyNameAttribute"); @@ -737,22 +741,22 @@ namespace Mono.CSharp // // Add Win32 resources // - if (RootContext.Win32ResourceFile != null) { - Builder.DefineUnmanagedResource (RootContext.Win32ResourceFile); + if (Compiler.Settings.Win32ResourceFile != null) { + Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile); } else { Builder.DefineVersionInfoResource (); } - if (RootContext.Win32IconFile != null) { - builder_extra.DefineWin32IconResource (RootContext.Win32IconFile); + if (Compiler.Settings.Win32IconFile != null) { + builder_extra.DefineWin32IconResource (Compiler.Settings.Win32IconFile); } - if (RootContext.Resources != null) { - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Resources != null) { + if (Compiler.Settings.Target == Target.Module) { Report.Error (1507, "Cannot link resource file when building a module"); } else { int counter = 0; - foreach (var res in RootContext.Resources) { + foreach (var res in Compiler.Settings.Resources) { if (!File.Exists (res.FileName)) { Report.Error (1566, "Error reading resource file `{0}'", res.FileName); continue; @@ -783,7 +787,7 @@ namespace Mono.CSharp PortableExecutableKinds pekind; ImageFileMachine machine; - switch (RootContext.Platform) { + switch (Compiler.Settings.Platform) { case Platform.X86: pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly; machine = ImageFileMachine.I386; @@ -805,7 +809,7 @@ namespace Mono.CSharp Compiler.TimeReporter.Start (TimeReporter.TimerType.OutputSave); try { - if (RootContext.Target == Target.Module) { + if (Compiler.Settings.Target == Target.Module) { SaveModule (pekind, machine); } else { Builder.Save (module.Builder.ScopeName, pekind, machine); @@ -839,8 +843,8 @@ namespace Mono.CSharp void SetEntryPoint () { - if (!RootContext.NeedsEntryPoint) { - if (RootContext.MainClass != null) + if (!Compiler.Settings.NeedsEntryPoint) { + if (Compiler.Settings.MainClass != null) Report.Error (2017, "Cannot specify -main if building a module or library"); return; @@ -848,7 +852,7 @@ namespace Mono.CSharp PEFileKinds file_kind; - switch (RootContext.Target) { + switch (Compiler.Settings.Target) { case Target.Library: case Target.Module: file_kind = PEFileKinds.Dll; @@ -862,16 +866,16 @@ namespace Mono.CSharp } if (entry_point == null) { - if (RootContext.MainClass != null) { + if (Compiler.Settings.MainClass != null) { // TODO: Should use MemberCache - DeclSpace main_cont = module.GetDefinition (RootContext.MainClass) as DeclSpace; + DeclSpace main_cont = module.GetDefinition (Compiler.Settings.MainClass) as DeclSpace; if (main_cont == null) { - Report.Error (1555, "Could not find `{0}' specified for Main method", RootContext.MainClass); + Report.Error (1555, "Could not find `{0}' specified for Main method", Compiler.Settings.MainClass); return; } if (!(main_cont is ClassOrStruct)) { - Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", RootContext.MainClass); + Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", Compiler.Settings.MainClass); return; } @@ -991,7 +995,7 @@ namespace Mono.CSharp public AssemblyAttributesPlaceholder (ModuleContainer parent, string outputName) : base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC) { - assembly = new Field (this, new TypeExpression (TypeManager.object_type, Location), Modifiers.PUBLIC | Modifiers.STATIC, + assembly = new Field (this, new TypeExpression (parent.Compiler.BuiltinTypes.Object, Location), Modifiers.PUBLIC | Modifiers.STATIC, new MemberName (AssemblyFieldName), null); AddField (assembly); @@ -1069,19 +1073,13 @@ namespace Mono.CSharp protected readonly CompilerContext compiler; protected readonly List paths; - readonly string[] default_references; public AssemblyReferencesLoader (CompilerContext compiler) { this.compiler = compiler; - if (RootContext.LoadDefaultReferences) - default_references = GetDefaultReferences (); - else - default_references = new string[0]; - paths = new List (); - paths.AddRange (RootContext.ReferencesLookupPaths); + paths.AddRange (compiler.Settings.ReferencesLookupPaths); paths.Add (Directory.GetCurrentDirectory ()); } @@ -1124,20 +1122,14 @@ namespace Mono.CSharp // // Load mscorlib.dll as the first // - if (RootContext.StdLib) { + if (module.Compiler.Settings.StdLib) { corlib_assembly = LoadAssemblyDefault ("mscorlib.dll"); } else { corlib_assembly = default (T); } T a; - foreach (string r in default_references) { - a = LoadAssemblyDefault (r); - if (a != null) - loaded.Add (Tuple.Create (module.GlobalRootNamespace, a)); - } - - foreach (string r in RootContext.AssemblyReferences) { + foreach (string r in module.Compiler.Settings.AssemblyReferences) { a = LoadAssemblyFile (r); if (a == null || EqualityComparer.Default.Equals (a, corlib_assembly)) continue; @@ -1155,7 +1147,7 @@ namespace Mono.CSharp loaded.Add (key); } - foreach (var entry in RootContext.AssemblyReferencesAliases) { + foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) { a = LoadAssemblyFile (entry.Item2); if (a == null) continue; @@ -1167,6 +1159,20 @@ namespace Mono.CSharp loaded.Add (key); } + if (compiler.Settings.LoadDefaultReferences) { + foreach (string r in GetDefaultReferences ()) { + a = LoadAssemblyDefault (r); + if (a == null) + continue; + + var key = Tuple.Create (module.GlobalRootNamespace, a); + if (loaded.Contains (key)) + continue; + + loaded.Add (key); + } + } + compiler.TimeReporter.Stop (TimeReporter.TimerType.ReferencesLoading); } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assign.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assign.cs index b12afbf43..1c7d0ec3f 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assign.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/assign.cs @@ -518,7 +518,7 @@ namespace Mono.CSharp { { this.mc = mc; if (!spec.IsStatic) - ((FieldExpr)target).InstanceExpression = CompilerGeneratedThis.Instance; + ((FieldExpr)target).InstanceExpression = new CompilerGeneratedThis (mc.CurrentType, expression.Location); } protected override Expression DoResolve (ResolveContext ec) @@ -760,7 +760,7 @@ namespace Mono.CSharp { } } - if (source.Type == InternalType.Dynamic) { + if (source.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments arg = new Arguments (1); arg.Add (new Argument (source)); return new SimpleAssign (target, new DynamicConversion (target_type, CSharpBinderFlags.ConvertExplicit, arg, loc), loc).Resolve (ec); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs index 8833e292b..c994e2141 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs @@ -48,9 +48,9 @@ namespace Mono.CSharp { if (attributes == null) attributes = attrs; else - throw new NotImplementedException (); + attributes.AddAttributes (attrs.Attrs); - attributes.AttachTo (this, context); + attrs.AttachTo (this, context); } public Attributes OptAttributes { @@ -97,7 +97,7 @@ namespace Mono.CSharp { // // An attribute can be attached to multiple targets (e.g. multiple fields) // - protected Attributable[] targets; + Attributable[] targets; // // A member context for the attribute, it's much easier to hold it here @@ -106,20 +106,16 @@ namespace Mono.CSharp { IMemberContext context; public static readonly AttributeUsageAttribute DefaultUsageAttribute = new AttributeUsageAttribute (AttributeTargets.All); - static Assembly orig_sec_assembly; public static readonly object[] EmptyObject = new object [0]; List> named_values; - // Cache for parameter-less attributes - static Dictionary att_cache; - public Attribute (string target, ATypeNameExpression expr, Arguments[] args, Location loc, bool nameEscaped) { this.expression = expr; if (args != null) { - PosArguments = args [0]; - NamedArguments = args [1]; + PosArguments = args[0]; + NamedArguments = args[1]; } this.loc = loc; ExplicitTarget = target; @@ -136,14 +132,14 @@ namespace Mono.CSharp { if (HasField (dll_import_char_set)) return; - if (!rc.Module.PredefinedTypes.CharSet.IsDefined) { + if (!rc.Module.PredefinedTypes.CharSet.Define ()) { return; } if (NamedArguments == null) NamedArguments = new Arguments (1); - var value = Constant.CreateConstant (rc, rc.Module.PredefinedTypes.CharSet.TypeSpec, rc.Module.DefaultCharSet, Location); + var value = Constant.CreateConstant (rc.Module.PredefinedTypes.CharSet.TypeSpec, rc.Module.DefaultCharSet, Location); NamedArguments.Add (new NamedArgument (dll_import_char_set, loc, value)); } @@ -155,16 +151,6 @@ namespace Mono.CSharp { return a; } - static Attribute () - { - Reset (); - } - - public static void Reset () - { - att_cache = new Dictionary (); - } - // // When the same attribute is attached to multiple fiels // we use @target field as a list of targets. The attribute @@ -178,6 +164,13 @@ namespace Mono.CSharp { return; } + // When re-attaching global attributes + if (context is NamespaceEntry) { + this.targets[0] = target; + this.context = context; + return; + } + // Resize target array Attributable[] new_array = new Attributable [this.targets.Length + 1]; targets.CopyTo (new_array, 0); @@ -213,7 +206,7 @@ namespace Mono.CSharp { public static void Error_AttributeArgumentIsDynamic (IMemberContext context, Location loc) { - context.Compiler.Report.Error (1982, loc, "An attribute argument cannot be dynamic expression"); + context.Module.Compiler.Report.Error (1982, loc, "An attribute argument cannot be dynamic expression"); } public void Error_MissingGuidAttribute () @@ -252,14 +245,9 @@ namespace Mono.CSharp { } } - protected virtual TypeExpr ResolveAsTypeTerminal (Expression expr, IMemberContext ec) - { - return expr.ResolveAsTypeTerminal (ec, false); - } - TypeSpec ResolvePossibleAttributeType (ATypeNameExpression expr, ref bool is_attr) { - TypeExpr te = ResolveAsTypeTerminal (expr, context); + TypeExpr te = expr.ResolveAsTypeTerminal (context, false); if (te == null) return null; @@ -279,7 +267,7 @@ namespace Mono.CSharp { void ResolveAttributeType () { SessionReportPrinter resolve_printer = new SessionReportPrinter (); - ReportPrinter prev_recorder = context.Compiler.Report.SetPrinter (resolve_printer); + ReportPrinter prev_recorder = context.Module.Compiler.Report.SetPrinter (resolve_printer); bool t1_is_attr = false; bool t2_is_attr = false; @@ -300,7 +288,7 @@ namespace Mono.CSharp { resolve_printer.EndSession (); } finally { - context.Compiler.Report.SetPrinter (prev_recorder); + context.Module.Compiler.Report.SetPrinter (prev_recorder); } if (t1_is_attr && t2_is_attr) { @@ -324,7 +312,7 @@ namespace Mono.CSharp { resolve_error = true; } - public virtual TypeSpec ResolveType () + public TypeSpec ResolveType () { if (Type == null && !resolve_error) ResolveAttributeType (); @@ -348,19 +336,41 @@ namespace Mono.CSharp { public bool IsValidSecurityAttribute () { - return HasSecurityAttribute && IsSecurityActionValid (false); + return HasSecurityAttribute && IsSecurityActionValid (); } static bool IsValidArgumentType (TypeSpec t) { - if (t.IsArray) - t = TypeManager.GetElementType (t); + if (t.IsArray) { + var ac = (ArrayContainer) t; + if (ac.Rank > 1) + return false; - return t == TypeManager.string_type || - TypeManager.IsPrimitiveType (t) || - TypeManager.IsEnumType (t) || - t == TypeManager.object_type || - t == TypeManager.type_type; + t = ac.Element; + } + + switch (t.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.Double: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.Bool: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.UShort: + + case BuiltinTypeSpec.Type.String: + case BuiltinTypeSpec.Type.Object: + case BuiltinTypeSpec.Type.Dynamic: + case BuiltinTypeSpec.Type.Type: + return true; + } + + return t.IsEnum; } // TODO: Don't use this ambiguous value @@ -368,8 +378,14 @@ namespace Mono.CSharp { get { return expression.Name; } } + public ATypeNameExpression TypeNameExpression { + get { + return expression; + } + } + public Report Report { - get { return context.Compiler.Report; } + get { return context.Module.Compiler.Report; } } public MethodSpec Resolve () @@ -396,19 +412,19 @@ namespace Mono.CSharp { AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (Type), Location, Report); } + ResolveContext rc = null; + MethodSpec ctor; - // Try if the attribute is simple has been resolved before - if (PosArguments == null && NamedArguments == null) { - if (att_cache.TryGetValue (Type, out ctor)) { - resolve_error = false; - return ctor; + // Try if the attribute is simple and has been resolved before + if (PosArguments != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) { + rc = CreateResolveContext (); + ctor = ResolveConstructor (rc); + if (ctor == null) { + return null; } - } - ResolveContext rc = CreateResolveContext (); - ctor = ResolveConstructor (rc); - if (ctor == null) { - return null; + if (PosArguments == null && ctor.Parameters.IsEmpty) + context.Module.AttributeConstructorCache.Add (Type, ctor); } // @@ -416,18 +432,25 @@ namespace Mono.CSharp { // var module = context.Module; if (Type == module.PredefinedAttributes.DllImport && module.HasDefaultCharSet) { + if (rc == null) + rc = CreateResolveContext (); + AddModuleCharSet (rc); } - if (NamedArguments != null && !ResolveNamedArguments (rc)) { - return null; + if (NamedArguments != null) { + if (rc == null) + rc = CreateResolveContext (); + + if (!ResolveNamedArguments (rc)) + return null; } resolve_error = false; return ctor; } - protected virtual MethodSpec ResolveConstructor (ResolveContext ec) + MethodSpec ResolveConstructor (ResolveContext ec) { if (PosArguments != null) { bool dynamic; @@ -441,7 +464,7 @@ namespace Mono.CSharp { return ConstructorLookup (ec, Type, ref PosArguments, loc); } - protected virtual bool ResolveNamedArguments (ResolveContext ec) + bool ResolveNamedArguments (ResolveContext ec) { int named_arg_count = NamedArguments.Count; var seen_names = new List (named_arg_count); @@ -459,10 +482,10 @@ namespace Mono.CSharp { a.Resolve (ec); - Expression member = Expression.MemberLookup (ec, ec.CurrentType, Type, name, 0, MemberLookupRestrictions.ExactArity, loc); + Expression member = Expression.MemberLookup (ec, false, Type, name, 0, MemberLookupRestrictions.ExactArity, loc); if (member == null) { - member = Expression.MemberLookup (null, ec.CurrentType, Type, name, 0, MemberLookupRestrictions.ExactArity, loc); + member = Expression.MemberLookup (ec, true, Type, name, 0, MemberLookupRestrictions.ExactArity, loc); if (member != null) { // TODO: ec.Report.SymbolRelatedToPreviousError (member); @@ -728,17 +751,19 @@ namespace Mono.CSharp { sb.Append (", "); } sb.Remove (sb.Length - 2, 2); - Report.Error (657, Location, "`{0}' is not a valid attribute location for this declaration. " + - "Valid attribute locations for this declaration are `{1}'", ExplicitTarget, sb.ToString ()); + Report.Warning (657, 1, Location, + "`{0}' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are `{1}'. All attributes in this section will be ignored", + ExplicitTarget, sb.ToString ()); return false; } /// /// Tests permitted SecurityAction for assembly or other types /// - protected virtual bool IsSecurityActionValid (bool for_assembly) + bool IsSecurityActionValid () { SecurityAction action = GetSecurityActionValue (); + bool for_assembly = Target == AttributeTargets.Assembly || Target == AttributeTargets.Module; switch (action) { #pragma warning disable 618 @@ -805,103 +830,7 @@ namespace Mono.CSharp { var cab = new CustomAttributeBuilder ((ConstructorInfo) ctor.GetMetaInfo (), values, prop, prop_values); permissions.Add (cab); #else - Type orig_assembly_type = null; - - if (Type.MemberDefinition is TypeContainer) { - if (!RootContext.StdLib) { - orig_assembly_type = System.Type.GetType (Type.GetMetaInfo ().FullName); - } else { - string orig_version_path = Environment.GetEnvironmentVariable ("__SECURITY_BOOTSTRAP_DB"); - if (orig_version_path == null) { - Error_AttributeEmitError ("security custom attributes can not be referenced from defining assembly"); - return; - } - - if (orig_sec_assembly == null) { - string file = Path.Combine (orig_version_path, Path.GetFileName (RootContext.OutputFile)); - orig_sec_assembly = Assembly.LoadFile (file); - } - - orig_assembly_type = orig_sec_assembly.GetType (Type.GetMetaInfo ().FullName, true); - if (orig_assembly_type == null) { - Report.Warning (-112, 1, Location, "Self-referenced security attribute `{0}' " + - "was not found in previous version of assembly"); - return; - } - } - } - - SecurityAttribute sa; - object[] args; - - // For all non-selfreferencing security attributes we can avoid all hacks - if (orig_assembly_type == null) { - args = new object[PosArguments.Count]; - for (int j = 0; j < args.Length; ++j) { - args[j] = ((Constant) PosArguments[j].Expr).GetValue (); - } - - sa = (SecurityAttribute) Activator.CreateInstance (Type.GetMetaInfo (), args); - - if (named_values != null) { - for (int i = 0; i < named_values.Count; ++i) { - PropertyInfo pi = ((PropertyExpr) named_values[i].Key).PropertyInfo.MetaInfo; - pi.SetValue (sa, ((Constant) named_values [i].Value.Expr).GetValue (), null); - } - } - } else { - // HACK: All security attributes have same ctor syntax - args = new object[] { GetSecurityActionValue () }; - sa = (SecurityAttribute) Activator.CreateInstance (orig_assembly_type, args); - - // All types are from newly created assembly but for invocation with old one we need to convert them - if (named_values != null) { - for (int i = 0; i < named_values.Count; ++i) { - PropertyInfo emited_pi = ((PropertyExpr) named_values[i].Key).PropertyInfo.MetaInfo; - // FIXME: We are missing return type filter - // TODO: pi can be null - PropertyInfo pi = orig_assembly_type.GetProperty (emited_pi.Name); - - pi.SetValue (sa, ((Constant) named_values[i].Value.Expr).GetValue (), null); - } - } - } - - IPermission perm; - perm = sa.CreatePermission (); - SecurityAction action = (SecurityAction) args [0]; - - // IS is correct because for corlib we are using an instance from old corlib - if (!(perm is System.Security.CodeAccessPermission)) { - switch (action) { - case SecurityAction.Demand: - action = (SecurityAction)13; - break; - case SecurityAction.LinkDemand: - action = (SecurityAction)14; - break; - case SecurityAction.InheritanceDemand: - action = (SecurityAction)15; - break; - } - } - - if (permissions == null) - permissions = new SecurityType (); - - PermissionSet ps; - if (!permissions.TryGetValue (action, out ps)) { - if (sa is PermissionSetAttribute) - ps = new PermissionSet (sa.Unrestricted ? PermissionState.Unrestricted : PermissionState.None); - else - ps = new PermissionSet (PermissionState.None); - - permissions.Add (action, ps); - } else if (!ps.IsUnrestricted () && (sa is PermissionSetAttribute) && sa.Unrestricted) { - ps = ps.Union (new PermissionSet (PermissionState.Unrestricted)); - permissions [action] = ps; - } - ps.AddPermission (perm); + throw new NotSupportedException (); #endif } @@ -1020,7 +949,7 @@ namespace Mono.CSharp { if (Type == predefined.IndexerName || Type == predefined.Conditional) { string v = ((StringConstant) arg_expr).Value; if (!Tokenizer.IsValidIdentifier (v) || Tokenizer.IsKeyword (v)) { - context.Compiler.Report.Error (633, arg_expr.Location, + context.Module.Compiler.Report.Error (633, arg_expr.Location, "The argument to the `{0}' attribute must be a valid identifier", GetSignatureForError ()); } } else if (Type == predefined.Guid) { @@ -1034,7 +963,7 @@ namespace Mono.CSharp { } else if (Type == predefined.AttributeUsage) { int v = ((IntConstant) ((EnumConstant) arg_expr).Child).Value; if (v == 0) { - context.Compiler.Report.Error (591, Location, "Invalid value for argument to `{0}' attribute", + context.Module.Compiler.Report.Error (591, Location, "Invalid value for argument to `{0}' attribute", "System.AttributeUsage"); } } else if (Type == predefined.MarshalAs) { @@ -1050,7 +979,7 @@ namespace Mono.CSharp { if (string.IsNullOrEmpty (value)) Error_AttributeEmitError ("DllName cannot be empty"); } - } else if (Type == predefined.MethodImpl && pt == TypeManager.short_type && + } else if (Type == predefined.MethodImpl && pt.BuiltinType == BuiltinTypeSpec.Type.Short && !System.Enum.IsDefined (typeof (MethodImplOptions), ((Constant) arg_expr).GetValue ().ToString ())) { Error_AttributeEmitError ("Incorrect argument value."); return; @@ -1101,18 +1030,18 @@ namespace Mono.CSharp { } } - if (!RootContext.VerifyClsCompliance) + if (!context.Module.Compiler.Settings.VerifyClsCompliance) return; // Here we are testing attribute arguments for array usage (error 3016) if (Owner.IsClsComplianceRequired ()) { if (PosArguments != null) - PosArguments.CheckArrayAsAttribute (context.Compiler); + PosArguments.CheckArrayAsAttribute (context.Module.Compiler); if (NamedArguments == null) return; - NamedArguments.CheckArrayAsAttribute (context.Compiler); + NamedArguments.CheckArrayAsAttribute (context.Module.Compiler); } } @@ -1164,82 +1093,8 @@ namespace Mono.CSharp { } } - - /// - /// For global attributes (assembly, module) we need special handling. - /// Attributes can be located in the several files - /// - public class GlobalAttribute : Attribute + public class Attributes { - public readonly NamespaceEntry ns; - - public GlobalAttribute (NamespaceEntry ns, string target, ATypeNameExpression expression, - Arguments[] args, Location loc, bool nameEscaped): - base (target, expression, args, loc, nameEscaped) - { - this.ns = ns; - } - - void Enter () - { - // RootContext.ToplevelTypes has a single NamespaceEntry which gets overwritten - // each time a new file is parsed. However, we need to use the NamespaceEntry - // in effect where the attribute was used. Since code elsewhere cannot assume - // that the NamespaceEntry is right, just overwrite it. - // - // Precondition: RootContext.ToplevelTypes == null - - if (RootContext.ToplevelTypes.NamespaceEntry != null) - throw new InternalErrorException (Location + " non-null NamespaceEntry"); - - RootContext.ToplevelTypes.NamespaceEntry = ns; - } - - protected override bool IsSecurityActionValid (bool for_assembly) - { - return base.IsSecurityActionValid (true); - } - - void Leave () - { - RootContext.ToplevelTypes.NamespaceEntry = null; - } - - protected override TypeExpr ResolveAsTypeTerminal (Expression expr, IMemberContext ec) - { - try { - Enter (); - return base.ResolveAsTypeTerminal (expr, ec); - } - finally { - Leave (); - } - } - - protected override MethodSpec ResolveConstructor (ResolveContext ec) - { - try { - Enter (); - return base.ResolveConstructor (ec); - } - finally { - Leave (); - } - } - - protected override bool ResolveNamedArguments (ResolveContext ec) - { - try { - Enter (); - return base.ResolveNamedArguments (ec); - } - finally { - Leave (); - } - } - } - - public class Attributes { public readonly List Attrs; public Attributes (Attribute a) @@ -1253,6 +1108,11 @@ namespace Mono.CSharp { Attrs = attrs; } + public void AddAttribute (Attribute attr) + { + Attrs.Add (attr); + } + public void AddAttributes (List attrs) { Attrs.AddRange (attrs); @@ -1278,13 +1138,39 @@ namespace Mono.CSharp { /// public bool CheckTargets () { - foreach (Attribute a in Attrs) { - if (!a.CheckTarget ()) - return false; + for (int i = 0; i < Attrs.Count; ++i) { + if (!Attrs [i].CheckTarget ()) + Attrs.RemoveAt (i--); } + return true; } + public void ConvertGlobalAttributes (TypeContainer member, NamespaceEntry currentNamespace, bool isGlobal) + { + var member_explicit_targets = member.ValidAttributeTargets; + for (int i = 0; i < Attrs.Count; ++i) { + var attr = Attrs[0]; + if (attr.ExplicitTarget == null) + continue; + + int ii; + for (ii = 0; ii < member_explicit_targets.Length; ++ii) { + if (attr.ExplicitTarget == member_explicit_targets[ii]) { + ii = -1; + break; + } + } + + if (ii < 0 || !isGlobal) + continue; + + member.Module.AddAttribute (attr, currentNamespace); + Attrs.RemoveAt (i); + --i; + } + } + public Attribute Search (PredefinedAttribute t) { return Search (null, t); @@ -1477,45 +1363,67 @@ namespace Mono.CSharp { public EncodedTypeProperties Encode (TypeSpec type) { - if (type == TypeManager.bool_type) { + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Bool: Encode ((byte) 0x02); - } else if (type == TypeManager.char_type) { + break; + case BuiltinTypeSpec.Type.Char: Encode ((byte) 0x03); - } else if (type == TypeManager.sbyte_type) { + break; + case BuiltinTypeSpec.Type.SByte: Encode ((byte) 0x04); - } else if (type == TypeManager.byte_type) { + break; + case BuiltinTypeSpec.Type.Byte: Encode ((byte) 0x05); - } else if (type == TypeManager.short_type) { + break; + case BuiltinTypeSpec.Type.Short: Encode ((byte) 0x06); - } else if (type == TypeManager.ushort_type) { + break; + case BuiltinTypeSpec.Type.UShort: Encode ((byte) 0x07); - } else if (type == TypeManager.int32_type) { + break; + case BuiltinTypeSpec.Type.Int: Encode ((byte) 0x08); - } else if (type == TypeManager.uint32_type) { + break; + case BuiltinTypeSpec.Type.UInt: Encode ((byte) 0x09); - } else if (type == TypeManager.int64_type) { + break; + case BuiltinTypeSpec.Type.Long: Encode ((byte) 0x0A); - } else if (type == TypeManager.uint64_type) { + break; + case BuiltinTypeSpec.Type.ULong: Encode ((byte) 0x0B); - } else if (type == TypeManager.float_type) { + break; + case BuiltinTypeSpec.Type.Float: Encode ((byte) 0x0C); - } else if (type == TypeManager.double_type) { + break; + case BuiltinTypeSpec.Type.Double: Encode ((byte) 0x0D); - } else if (type == TypeManager.string_type) { + break; + case BuiltinTypeSpec.Type.String: Encode ((byte) 0x0E); - } else if (type == TypeManager.type_type) { + break; + case BuiltinTypeSpec.Type.Type: Encode ((byte) 0x50); - } else if (type == TypeManager.object_type) { + break; + case BuiltinTypeSpec.Type.Object: Encode ((byte) 0x51); - } else if (TypeManager.IsEnumType (type)) { - Encode ((byte) 0x55); - EncodeTypeName (type); - } else if (type.IsArray) { - Encode ((byte) 0x1D); - return Encode (TypeManager.GetElementType (type)); - } else if (type == InternalType.Dynamic) { + break; + case BuiltinTypeSpec.Type.Dynamic: Encode ((byte) 0x51); return EncodedTypeProperties.DynamicType; + default: + if (type.IsArray) { + Encode ((byte) 0x1D); + return Encode (TypeManager.GetElementType (type)); + } + + if (type.Kind == MemberKind.Enum) { + Encode ((byte) 0x55); + EncodeTypeName (type); + } + + break; } return EncodedTypeProperties.None; @@ -1799,7 +1707,6 @@ namespace Mono.CSharp { public class PredefinedAttribute : PredefinedType { protected MethodSpec ctor; - List properties; public PredefinedAttribute (ModuleContainer module, string ns, string name) : base (module, MemberKind.Class, ns, name) @@ -1904,31 +1811,6 @@ namespace Mono.CSharp { return (ConstructorInfo) ctor.GetMetaInfo (); } - public PropertySpec GetProperty (string name, TypeSpec memberType, Location loc) - { - PropertySpec spec; - - if (properties != null) { - spec = properties.Find (l => l.Name == name); - } else { - spec = null; - } - - if (spec == null) { - spec = TypeManager.GetPredefinedProperty (type, name, loc, memberType); - - if (spec != null) { - if (properties == null) { - properties = new List (); - } - - properties.Add (spec); - } - } - - return spec; - } - public bool ResolveBuilder () { if (ctor != null) @@ -1940,19 +1822,7 @@ namespace Mono.CSharp { if (!IsDefined) return false; - ctor = TypeManager.GetPredefinedConstructor (type, Location.Null, TypeSpec.EmptyTypes); - return ctor != null; - } - - public bool ResolveConstructor (Location loc, params TypeSpec[] argType) - { - if (ctor != null) - throw new InternalErrorException ("Predefined ctor redefined"); - - if (Resolve (loc) == null) - return false; - - ctor = TypeManager.GetPredefinedConstructor (type, loc, argType); + ctor = (MethodSpec) MemberCache.FindMember (type, MemberFilter.Constructor (ParametersCompiled.EmptyReadOnlyParameters), BindingRestriction.DeclaredOnly); return ctor != null; } } @@ -1966,10 +1836,8 @@ namespace Mono.CSharp { public void EmitAttribute (ParameterBuilder builder, decimal value, Location loc) { - if (Resolve (loc) == null) - return; - - if (ctor == null && !ResolveConstructor (loc, TypeManager.byte_type, TypeManager.byte_type, TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type)) + var ctor = module.PredefinedMembers.DecimalConstantAttributeCtor.Resolve (loc); + if (ctor == null) return; int[] bits = decimal.GetBits (value); @@ -1981,15 +1849,13 @@ namespace Mono.CSharp { encoder.Encode ((uint) bits[0]); encoder.EncodeEmptyNamedArguments (); - EmitAttribute (builder, encoder); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); } public void EmitAttribute (FieldBuilder builder, decimal value, Location loc) { - if (Resolve (loc) == null) - return; - - if (ctor == null && !ResolveConstructor (loc, TypeManager.byte_type, TypeManager.byte_type, TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type)) + var ctor = module.PredefinedMembers.DecimalConstantAttributeCtor.Resolve (loc); + if (ctor == null) return; int[] bits = decimal.GetBits (value); @@ -2001,7 +1867,7 @@ namespace Mono.CSharp { encoder.Encode ((uint) bits[0]); encoder.EncodeEmptyNamedArguments (); - EmitAttribute (builder, encoder); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); } } @@ -2099,7 +1965,7 @@ namespace Mono.CSharp { return transform.ToArray (); } - if (t == InternalType.Dynamic) + if (t.BuiltinType == BuiltinTypeSpec.Type.Dynamic) return new bool[] { true }; return null; @@ -2110,10 +1976,7 @@ namespace Mono.CSharp { if (tctor != null) return true; - if (Resolve (loc) == null) - return false; - - tctor = TypeManager.GetPredefinedConstructor (type, Location.Null, ArrayContainer.MakeType (TypeManager.bool_type)); + tctor = module.PredefinedMembers.DynamicAttributeCtor.Resolve (loc); return tctor != null; } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cfold.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cfold.cs index 36211cd12..ada59bc66 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cfold.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cfold.cs @@ -12,25 +12,14 @@ using System; namespace Mono.CSharp { - public class ConstantFold { - - static TypeSpec[] binary_promotions; - - public static TypeSpec[] BinaryPromotionsTypes { - get { - if (binary_promotions == null) { - binary_promotions = new TypeSpec[] { - TypeManager.decimal_type, TypeManager.double_type, TypeManager.float_type, - TypeManager.uint64_type, TypeManager.int64_type, TypeManager.uint32_type }; - } - - return binary_promotions; - } - } - - public static void Reset () + public static class ConstantFold + { + public static TypeSpec[] CreateBinaryPromotionsTypes (BuiltinTypes types) { - binary_promotions = null; + return new TypeSpec[] { + types.Decimal, types.Double, types.Float, + types.ULong, types.Long, types.UInt + }; } // @@ -48,7 +37,7 @@ namespace Mono.CSharp { TypeSpec ltype = left.Type; TypeSpec rtype = right.Type; - foreach (TypeSpec t in BinaryPromotionsTypes) { + foreach (TypeSpec t in rc.BuiltinTypes.BinaryPromotionsTypes) { if (t == ltype) return t == rtype || ConvertPromotion (rc, ref right, ref left, t); @@ -56,23 +45,23 @@ namespace Mono.CSharp { return t == ltype || ConvertPromotion (rc, ref left, ref right, t); } - left = left.ConvertImplicitly (rc, TypeManager.int32_type); - right = right.ConvertImplicitly (rc, TypeManager.int32_type); + left = left.ConvertImplicitly (rc.BuiltinTypes.Int); + right = right.ConvertImplicitly (rc.BuiltinTypes.Int); return left != null && right != null; } static bool ConvertPromotion (ResolveContext rc, ref Constant prim, ref Constant second, TypeSpec type) { - Constant c = prim.ConvertImplicitly (rc, type); + Constant c = prim.ConvertImplicitly (type); if (c != null) { prim = c; return true; } - if (type == TypeManager.uint32_type) { - type = TypeManager.int64_type; - prim = prim.ConvertImplicitly (rc, type); - second = second.ConvertImplicitly (rc, type); + if (type.BuiltinType == BuiltinTypeSpec.Type.UInt) { + type = rc.BuiltinTypes.Long; + prim = prim.ConvertImplicitly (type); + second = second.ConvertImplicitly (type); return prim != null && second != null; } @@ -118,22 +107,22 @@ namespace Mono.CSharp { TypeSpec rt = right.Type; bool bool_res; - if (lt == TypeManager.bool_type && lt == rt) { + if (lt.BuiltinType == BuiltinTypeSpec.Type.Bool && lt == rt) { bool lv = (bool) left.GetValue (); bool rv = (bool) right.GetValue (); switch (oper) { case Binary.Operator.BitwiseAnd: case Binary.Operator.LogicalAnd: - return new BoolConstant (lv && rv, left.Location); + return new BoolConstant (ec.BuiltinTypes, lv && rv, left.Location); case Binary.Operator.BitwiseOr: case Binary.Operator.LogicalOr: - return new BoolConstant (lv || rv, left.Location); + return new BoolConstant (ec.BuiltinTypes, lv || rv, left.Location); case Binary.Operator.ExclusiveOr: - return new BoolConstant (lv ^ rv, left.Location); + return new BoolConstant (ec.BuiltinTypes, lv ^ rv, left.Location); case Binary.Operator.Equality: - return new BoolConstant (lv == rv, left.Location); + return new BoolConstant (ec.BuiltinTypes, lv == rv, left.Location); case Binary.Operator.Inequality: - return new BoolConstant (lv != rv, left.Location); + return new BoolConstant (ec.BuiltinTypes, lv != rv, left.Location); } return null; } @@ -160,7 +149,7 @@ namespace Mono.CSharp { case Binary.Operator.ExclusiveOr: result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); if (result != null) - result = result.Resolve (ec).TryReduce (ec, lt, loc); + result = result.TryReduce (ec, lt, loc); return result; /// @@ -169,7 +158,7 @@ namespace Mono.CSharp { case Binary.Operator.Subtraction: result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); if (result != null) - result = result.Resolve (ec).TryReduce (ec, EnumSpec.GetUnderlyingType (lt), loc); + result = result.TryReduce (ec, EnumSpec.GetUnderlyingType (lt), loc); return result; /// @@ -196,8 +185,8 @@ namespace Mono.CSharp { // // bool? operator &(bool? x, bool? y); // - if ((lt == TypeManager.bool_type && right is NullLiteral) || - (rt == TypeManager.bool_type && left is NullLiteral)) { + if ((lt.BuiltinType == BuiltinTypeSpec.Type.Bool && right is NullLiteral) || + (rt.BuiltinType == BuiltinTypeSpec.Type.Bool && left is NullLiteral)) { var b = new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); // false | null => null @@ -207,7 +196,7 @@ namespace Mono.CSharp { // true | null => true // null | true => true - return ReducedExpression.Create (new BoolConstant (true, loc).Resolve (ec), b); + return ReducedExpression.Create (new BoolConstant (ec.BuiltinTypes, true, loc), b); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -215,24 +204,24 @@ namespace Mono.CSharp { if (left is IntConstant){ int res = ((IntConstant) left).Value | ((IntConstant) right).Value; - - return new IntConstant (res, left.Location); + + return new IntConstant (ec.BuiltinTypes, res, left.Location); } if (left is UIntConstant){ uint res = ((UIntConstant)left).Value | ((UIntConstant)right).Value; - - return new UIntConstant (res, left.Location); + + return new UIntConstant (ec.BuiltinTypes, res, left.Location); } if (left is LongConstant){ long res = ((LongConstant)left).Value | ((LongConstant)right).Value; - - return new LongConstant (res, left.Location); + + return new LongConstant (ec.BuiltinTypes, res, left.Location); } if (left is ULongConstant){ ulong res = ((ULongConstant)left).Value | ((ULongConstant)right).Value; - - return new ULongConstant (res, left.Location); + + return new ULongConstant (ec.BuiltinTypes, res, left.Location); } break; @@ -240,14 +229,14 @@ namespace Mono.CSharp { // // bool? operator &(bool? x, bool? y); // - if ((lt == TypeManager.bool_type && right is NullLiteral) || - (rt == TypeManager.bool_type && left is NullLiteral)) { + if ((lt.BuiltinType == BuiltinTypeSpec.Type.Bool && right is NullLiteral) || + (rt.BuiltinType == BuiltinTypeSpec.Type.Bool && left is NullLiteral)) { var b = new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); // false & null => false // null & false => false if ((right is NullLiteral && left.IsDefaultValue) || (left is NullLiteral && right.IsDefaultValue)) - return ReducedExpression.Create (new BoolConstant (false, loc).Resolve (ec), b); + return ReducedExpression.Create (new BoolConstant (ec.BuiltinTypes, false, loc), b); // true & null => null // null & true => null @@ -265,21 +254,21 @@ namespace Mono.CSharp { /// if (left is IntConstant){ int res = ((IntConstant) left).Value & ((IntConstant) right).Value; - return new IntConstant (res, left.Location); + return new IntConstant (ec.BuiltinTypes, res, left.Location); } if (left is UIntConstant){ uint res = ((UIntConstant)left).Value & ((UIntConstant)right).Value; - return new UIntConstant (res, left.Location); + return new UIntConstant (ec.BuiltinTypes, res, left.Location); } if (left is LongConstant){ long res = ((LongConstant)left).Value & ((LongConstant)right).Value; - return new LongConstant (res, left.Location); + return new LongConstant (ec.BuiltinTypes, res, left.Location); } if (left is ULongConstant){ ulong res = ((ULongConstant)left).Value & ((ULongConstant)right).Value; - - return new ULongConstant (res, left.Location); + + return new ULongConstant (ec.BuiltinTypes, res, left.Location); } break; @@ -289,31 +278,31 @@ namespace Mono.CSharp { if (left is IntConstant){ int res = ((IntConstant) left).Value ^ ((IntConstant) right).Value; - return new IntConstant (res, left.Location); + return new IntConstant (ec.BuiltinTypes, res, left.Location); } if (left is UIntConstant){ uint res = ((UIntConstant)left).Value ^ ((UIntConstant)right).Value; - - return new UIntConstant (res, left.Location); + + return new UIntConstant (ec.BuiltinTypes, res, left.Location); } if (left is LongConstant){ long res = ((LongConstant)left).Value ^ ((LongConstant)right).Value; - - return new LongConstant (res, left.Location); + + return new LongConstant (ec.BuiltinTypes, res, left.Location); } if (left is ULongConstant){ ulong res = ((ULongConstant)left).Value ^ ((ULongConstant)right).Value; - - return new ULongConstant (res, left.Location); + + return new ULongConstant (ec.BuiltinTypes, res, left.Location); } break; case Binary.Operator.Addition: - if (lt == InternalType.Null) + if (lt == InternalType.NullLiteral) return right; - if (rt == InternalType.Null) + if (rt == InternalType.NullLiteral) return left; // @@ -321,9 +310,9 @@ namespace Mono.CSharp { // one is a string, and the other is not, then defer // to runtime concatenation // - if (lt == TypeManager.string_type || rt == TypeManager.string_type){ + if (lt.BuiltinType == BuiltinTypeSpec.Type.String || rt.BuiltinType == BuiltinTypeSpec.Type.String){ if (lt == rt) - return new StringConstant ((string)left.GetValue () + (string)right.GetValue (), + return new StringConstant (ec.BuiltinTypes, (string)left.GetValue () + (string)right.GetValue (), left.Location); return null; @@ -343,7 +332,7 @@ namespace Mono.CSharp { } // U has to be implicitly convetible to E.base - right = right.ConvertImplicitly (ec, lc.Child.Type); + right = right.ConvertImplicitly (lc.Child.Type); if (right == null) return null; @@ -351,7 +340,7 @@ namespace Mono.CSharp { if (result == null) return null; - result = result.Resolve (ec).TryReduce (ec, lt, loc); + result = result.TryReduce (ec, lt, loc); if (result == null) return null; @@ -371,8 +360,8 @@ namespace Mono.CSharp { else res = unchecked (((DoubleConstant) left).Value + ((DoubleConstant) right).Value); - - return new DoubleConstant (res, left.Location); + + return new DoubleConstant (ec.BuiltinTypes, res, left.Location); } if (left is FloatConstant){ float res; @@ -383,8 +372,8 @@ namespace Mono.CSharp { else res = unchecked (((FloatConstant) left).Value + ((FloatConstant) right).Value); - - result = new FloatConstant (res, left.Location); + + result = new FloatConstant (ec.BuiltinTypes, res, left.Location); } else if (left is ULongConstant){ ulong res; @@ -395,7 +384,7 @@ namespace Mono.CSharp { res = unchecked (((ULongConstant) left).Value + ((ULongConstant) right).Value); - result = new ULongConstant (res, left.Location); + result = new ULongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is LongConstant){ long res; @@ -405,8 +394,8 @@ namespace Mono.CSharp { else res = unchecked (((LongConstant) left).Value + ((LongConstant) right).Value); - - result = new LongConstant (res, left.Location); + + result = new LongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is UIntConstant){ uint res; @@ -416,8 +405,8 @@ namespace Mono.CSharp { else res = unchecked (((UIntConstant) left).Value + ((UIntConstant) right).Value); - - result = new UIntConstant (res, left.Location); + + result = new UIntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is IntConstant){ int res; @@ -428,7 +417,7 @@ namespace Mono.CSharp { res = unchecked (((IntConstant) left).Value + ((IntConstant) right).Value); - result = new IntConstant (res, left.Location); + result = new IntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is DecimalConstant) { decimal res; @@ -439,7 +428,7 @@ namespace Mono.CSharp { res = unchecked (((DecimalConstant) left).Value + ((DecimalConstant) right).Value); - result = new DecimalConstant (res, left.Location); + result = new DecimalConstant (ec.BuiltinTypes, res, left.Location); } } catch (OverflowException){ Error_CompileTimeOverflow (ec, loc); @@ -462,7 +451,7 @@ namespace Mono.CSharp { } // U has to be implicitly convetible to E.base - right = right.ConvertImplicitly (ec, lc.Child.Type); + right = right.ConvertImplicitly (lc.Child.Type); if (right == null) return null; @@ -470,7 +459,7 @@ namespace Mono.CSharp { if (result == null) return null; - result = result.Resolve (ec).TryReduce (ec, lt, loc); + result = result.TryReduce (ec, lt, loc); if (result == null) return null; @@ -478,7 +467,7 @@ namespace Mono.CSharp { } if (left is NullLiteral && right is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -495,8 +484,8 @@ namespace Mono.CSharp { else res = unchecked (((DoubleConstant) left).Value - ((DoubleConstant) right).Value); - - result = new DoubleConstant (res, left.Location); + + result = new DoubleConstant (ec.BuiltinTypes, res, left.Location); } else if (left is FloatConstant){ float res; @@ -506,8 +495,8 @@ namespace Mono.CSharp { else res = unchecked (((FloatConstant) left).Value - ((FloatConstant) right).Value); - - result = new FloatConstant (res, left.Location); + + result = new FloatConstant (ec.BuiltinTypes, res, left.Location); } else if (left is ULongConstant){ ulong res; @@ -517,8 +506,8 @@ namespace Mono.CSharp { else res = unchecked (((ULongConstant) left).Value - ((ULongConstant) right).Value); - - result = new ULongConstant (res, left.Location); + + result = new ULongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is LongConstant){ long res; @@ -528,8 +517,8 @@ namespace Mono.CSharp { else res = unchecked (((LongConstant) left).Value - ((LongConstant) right).Value); - - result = new LongConstant (res, left.Location); + + result = new LongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is UIntConstant){ uint res; @@ -539,8 +528,8 @@ namespace Mono.CSharp { else res = unchecked (((UIntConstant) left).Value - ((UIntConstant) right).Value); - - result = new UIntConstant (res, left.Location); + + result = new UIntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is IntConstant){ int res; @@ -551,7 +540,7 @@ namespace Mono.CSharp { res = unchecked (((IntConstant) left).Value - ((IntConstant) right).Value); - result = new IntConstant (res, left.Location); + result = new IntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is DecimalConstant) { decimal res; @@ -562,7 +551,7 @@ namespace Mono.CSharp { res = unchecked (((DecimalConstant) left).Value - ((DecimalConstant) right).Value); - return new DecimalConstant (res, left.Location); + return new DecimalConstant (ec.BuiltinTypes, res, left.Location); } else { throw new Exception ( "Unexepected subtraction input: " + left); } @@ -574,7 +563,7 @@ namespace Mono.CSharp { case Binary.Operator.Multiply: if (left is NullLiteral && right is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -591,8 +580,8 @@ namespace Mono.CSharp { else res = unchecked (((DoubleConstant) left).Value * ((DoubleConstant) right).Value); - - return new DoubleConstant (res, left.Location); + + return new DoubleConstant (ec.BuiltinTypes, res, left.Location); } else if (left is FloatConstant){ float res; @@ -602,8 +591,8 @@ namespace Mono.CSharp { else res = unchecked (((FloatConstant) left).Value * ((FloatConstant) right).Value); - - return new FloatConstant (res, left.Location); + + return new FloatConstant (ec.BuiltinTypes, res, left.Location); } else if (left is ULongConstant){ ulong res; @@ -613,8 +602,8 @@ namespace Mono.CSharp { else res = unchecked (((ULongConstant) left).Value * ((ULongConstant) right).Value); - - return new ULongConstant (res, left.Location); + + return new ULongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is LongConstant){ long res; @@ -624,8 +613,8 @@ namespace Mono.CSharp { else res = unchecked (((LongConstant) left).Value * ((LongConstant) right).Value); - - return new LongConstant (res, left.Location); + + return new LongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is UIntConstant){ uint res; @@ -635,8 +624,8 @@ namespace Mono.CSharp { else res = unchecked (((UIntConstant) left).Value * ((UIntConstant) right).Value); - - return new UIntConstant (res, left.Location); + + return new UIntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is IntConstant){ int res; @@ -647,7 +636,7 @@ namespace Mono.CSharp { res = unchecked (((IntConstant) left).Value * ((IntConstant) right).Value); - return new IntConstant (res, left.Location); + return new IntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is DecimalConstant) { decimal res; @@ -658,7 +647,7 @@ namespace Mono.CSharp { res = unchecked (((DecimalConstant) left).Value * ((DecimalConstant) right).Value); - return new DecimalConstant (res, left.Location); + return new DecimalConstant (ec.BuiltinTypes, res, left.Location); } else { throw new Exception ( "Unexepected multiply input: " + left); } @@ -669,7 +658,7 @@ namespace Mono.CSharp { case Binary.Operator.Division: if (left is NullLiteral && right is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -686,8 +675,8 @@ namespace Mono.CSharp { else res = unchecked (((DoubleConstant) left).Value / ((DoubleConstant) right).Value); - - return new DoubleConstant (res, left.Location); + + return new DoubleConstant (ec.BuiltinTypes, res, left.Location); } else if (left is FloatConstant){ float res; @@ -697,8 +686,8 @@ namespace Mono.CSharp { else res = unchecked (((FloatConstant) left).Value / ((FloatConstant) right).Value); - - return new FloatConstant (res, left.Location); + + return new FloatConstant (ec.BuiltinTypes, res, left.Location); } else if (left is ULongConstant){ ulong res; @@ -708,8 +697,8 @@ namespace Mono.CSharp { else res = unchecked (((ULongConstant) left).Value / ((ULongConstant) right).Value); - - return new ULongConstant (res, left.Location); + + return new ULongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is LongConstant){ long res; @@ -719,8 +708,8 @@ namespace Mono.CSharp { else res = unchecked (((LongConstant) left).Value / ((LongConstant) right).Value); - - return new LongConstant (res, left.Location); + + return new LongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is UIntConstant){ uint res; @@ -730,8 +719,8 @@ namespace Mono.CSharp { else res = unchecked (((UIntConstant) left).Value / ((UIntConstant) right).Value); - - return new UIntConstant (res, left.Location); + + return new UIntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is IntConstant){ int res; @@ -742,7 +731,7 @@ namespace Mono.CSharp { res = unchecked (((IntConstant) left).Value / ((IntConstant) right).Value); - return new IntConstant (res, left.Location); + return new IntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is DecimalConstant) { decimal res; @@ -753,7 +742,7 @@ namespace Mono.CSharp { res = unchecked (((DecimalConstant) left).Value / ((DecimalConstant) right).Value); - return new DecimalConstant (res, left.Location); + return new DecimalConstant (ec.BuiltinTypes, res, left.Location); } else { throw new Exception ( "Unexepected division input: " + left); } @@ -768,7 +757,7 @@ namespace Mono.CSharp { case Binary.Operator.Modulus: if (left is NullLiteral && right is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -785,8 +774,8 @@ namespace Mono.CSharp { else res = unchecked (((DoubleConstant) left).Value % ((DoubleConstant) right).Value); - - return new DoubleConstant (res, left.Location); + + return new DoubleConstant (ec.BuiltinTypes, res, left.Location); } else if (left is FloatConstant){ float res; @@ -796,8 +785,8 @@ namespace Mono.CSharp { else res = unchecked (((FloatConstant) left).Value % ((FloatConstant) right).Value); - - return new FloatConstant (res, left.Location); + + return new FloatConstant (ec.BuiltinTypes, res, left.Location); } else if (left is ULongConstant){ ulong res; @@ -807,8 +796,8 @@ namespace Mono.CSharp { else res = unchecked (((ULongConstant) left).Value % ((ULongConstant) right).Value); - - return new ULongConstant (res, left.Location); + + return new ULongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is LongConstant){ long res; @@ -818,8 +807,8 @@ namespace Mono.CSharp { else res = unchecked (((LongConstant) left).Value % ((LongConstant) right).Value); - - return new LongConstant (res, left.Location); + + return new LongConstant (ec.BuiltinTypes, res, left.Location); } else if (left is UIntConstant){ uint res; @@ -829,8 +818,8 @@ namespace Mono.CSharp { else res = unchecked (((UIntConstant) left).Value % ((UIntConstant) right).Value); - - return new UIntConstant (res, left.Location); + + return new UIntConstant (ec.BuiltinTypes, res, left.Location); } else if (left is IntConstant){ int res; @@ -841,7 +830,7 @@ namespace Mono.CSharp { res = unchecked (((IntConstant) left).Value % ((IntConstant) right).Value); - return new IntConstant (res, left.Location); + return new IntConstant (ec.BuiltinTypes, res, left.Location); } else { throw new Exception ( "Unexepected modulus input: " + left); } @@ -857,31 +846,33 @@ namespace Mono.CSharp { // case Binary.Operator.LeftShift: if (left is NullLiteral && right is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } - IntConstant ic = right.ConvertImplicitly (ec, TypeManager.int32_type) as IntConstant; + IntConstant ic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant; if (ic == null){ Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc); return null; } int lshift_val = ic.Value; - if (left.Type == TypeManager.uint64_type) - return new ULongConstant (((ULongConstant)left).Value << lshift_val, left.Location); - if (left.Type == TypeManager.int64_type) - return new LongConstant (((LongConstant)left).Value << lshift_val, left.Location); - if (left.Type == TypeManager.uint32_type) - return new UIntConstant (((UIntConstant)left).Value << lshift_val, left.Location); + switch (left.Type.BuiltinType) { + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (ec.BuiltinTypes, ((ULongConstant) left).Value << lshift_val, left.Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (ec.BuiltinTypes, ((LongConstant) left).Value << lshift_val, left.Location); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (ec.BuiltinTypes, ((UIntConstant) left).Value << lshift_val, left.Location); + } // null << value => null if (left is NullLiteral) return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); - left = left.ConvertImplicitly (ec, TypeManager.int32_type); - if (left.Type == TypeManager.int32_type) - return new IntConstant (((IntConstant)left).Value << lshift_val, left.Location); + left = left.ConvertImplicitly (ec.BuiltinTypes.Int); + if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) + return new IntConstant (ec.BuiltinTypes, ((IntConstant) left).Value << lshift_val, left.Location); Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc); break; @@ -891,30 +882,32 @@ namespace Mono.CSharp { // case Binary.Operator.RightShift: if (left is NullLiteral && right is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } - IntConstant sic = right.ConvertImplicitly (ec, TypeManager.int32_type) as IntConstant; + IntConstant sic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant; if (sic == null){ Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc); ; return null; } int rshift_val = sic.Value; - if (left.Type == TypeManager.uint64_type) - return new ULongConstant (((ULongConstant)left).Value >> rshift_val, left.Location); - if (left.Type == TypeManager.int64_type) - return new LongConstant (((LongConstant)left).Value >> rshift_val, left.Location); - if (left.Type == TypeManager.uint32_type) - return new UIntConstant (((UIntConstant)left).Value >> rshift_val, left.Location); + switch (left.Type.BuiltinType) { + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (ec.BuiltinTypes, ((ULongConstant) left).Value >> rshift_val, left.Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (ec.BuiltinTypes, ((LongConstant) left).Value >> rshift_val, left.Location); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (ec.BuiltinTypes, ((UIntConstant) left).Value >> rshift_val, left.Location); + } // null >> value => null if (left is NullLiteral) return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); - left = left.ConvertImplicitly (ec, TypeManager.int32_type); - if (left.Type == TypeManager.int32_type) - return new IntConstant (((IntConstant)left).Value >> rshift_val, left.Location); + left = left.ConvertImplicitly (ec.BuiltinTypes.Int); + if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) + return new IntConstant (ec.BuiltinTypes, ((IntConstant) left).Value >> rshift_val, left.Location); Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc); break; @@ -925,12 +918,12 @@ namespace Mono.CSharp { (right is Nullable.LiftedNull && left.IsNull)) { if (left.IsNull || right.IsNull) { return ReducedExpression.Create ( - new BoolConstant (left.IsNull == right.IsNull, left.Location).Resolve (ec), + new BoolConstant (ec.BuiltinTypes, left.IsNull == right.IsNull, left.Location), new Binary (oper, left, right, loc)); } if (left is StringConstant && right is StringConstant) - return new BoolConstant ( + return new BoolConstant (ec.BuiltinTypes, ((StringConstant) left).Value == ((StringConstant) right).Value, left.Location); return null; @@ -961,7 +954,7 @@ namespace Mono.CSharp { else return null; - return new BoolConstant (bool_res, left.Location); + return new BoolConstant (ec.BuiltinTypes, bool_res, left.Location); case Binary.Operator.Inequality: if (TypeManager.IsReferenceType (lt) && TypeManager.IsReferenceType (rt) || @@ -969,12 +962,12 @@ namespace Mono.CSharp { (right is Nullable.LiftedNull && left.IsNull)) { if (left.IsNull || right.IsNull) { return ReducedExpression.Create ( - new BoolConstant (left.IsNull != right.IsNull, left.Location).Resolve (ec), + new BoolConstant (ec.BuiltinTypes, left.IsNull != right.IsNull, left.Location), new Binary (oper, left, right, loc)); } if (left is StringConstant && right is StringConstant) - return new BoolConstant ( + return new BoolConstant (ec.BuiltinTypes, ((StringConstant) left).Value != ((StringConstant) right).Value, left.Location); return null; @@ -1005,12 +998,12 @@ namespace Mono.CSharp { else return null; - return new BoolConstant (bool_res, left.Location); + return new BoolConstant (ec.BuiltinTypes, bool_res, left.Location); case Binary.Operator.LessThan: if (right is NullLiteral) { if (left is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -1044,12 +1037,12 @@ namespace Mono.CSharp { else return null; - return new BoolConstant (bool_res, left.Location); + return new BoolConstant (ec.BuiltinTypes, bool_res, left.Location); case Binary.Operator.GreaterThan: if (right is NullLiteral) { if (left is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -1083,12 +1076,12 @@ namespace Mono.CSharp { else return null; - return new BoolConstant (bool_res, left.Location); + return new BoolConstant (ec.BuiltinTypes, bool_res, left.Location); case Binary.Operator.GreaterThanOrEqual: if (right is NullLiteral) { if (left is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -1122,12 +1115,12 @@ namespace Mono.CSharp { else return null; - return new BoolConstant (bool_res, left.Location); + return new BoolConstant (ec.BuiltinTypes, bool_res, left.Location); case Binary.Operator.LessThanOrEqual: if (right is NullLiteral) { if (left is NullLiteral) { - var lifted_int = new Nullable.NullableType (TypeManager.int32_type, loc).ResolveAsTypeTerminal (ec, false); + var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc).ResolveAsTypeTerminal (ec, false); return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); } @@ -1161,7 +1154,7 @@ namespace Mono.CSharp { else return null; - return new BoolConstant (bool_res, left.Location); + return new BoolConstant (ec.BuiltinTypes, bool_res, left.Location); } return null; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/class.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/class.cs index f0ffc5497..969fe84b2 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/class.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/class.cs @@ -243,11 +243,6 @@ namespace Mono.CSharp { this.PartialContainer = this; } - public override void Accept (StructuralVisitor visitor) - { - base.Accept (visitor); - } - List orderedAllMembers = new List (); public List OrderedAllMembers { get { @@ -265,7 +260,7 @@ namespace Mono.CSharp { // Switch to inflated version as it's used by all expressions // var targs = CurrentTypeParameters == null ? TypeSpec.EmptyTypes : CurrentTypeParameters.Select (l => l.Type).ToArray (); - current_type = spec.MakeGenericType (targs); + current_type = spec.MakeGenericType (this, targs); } else { current_type = spec; } @@ -323,6 +318,11 @@ namespace Mono.CSharp { #endregion + public override void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); + } + public bool AddMember (MemberCore symbol) { return AddToContainer (symbol, symbol.MemberName.Basename); @@ -338,7 +338,7 @@ namespace Mono.CSharp { return AddToContainer (ds, ds.Basename); } - protected virtual void RemoveMemberType (DeclSpace ds) + protected virtual void RemoveMemberType (TypeContainer ds) { RemoveFromContainer (ds.Basename); } @@ -430,13 +430,14 @@ namespace Mono.CSharp { { if (types != null) types.Remove (next_part); + + Cache.Remove (next_part.Basename); RemoveMemberType (next_part); } - public virtual TypeSpec AddDelegate (Delegate d) + public void AddDelegate (Delegate d) { AddTypeContainer (d); - return null; } private void AddMemberToList (MemberCore mc, List alist, bool isexplicit) @@ -583,8 +584,6 @@ namespace Mono.CSharp { public void AddCompilerGeneratedClass (CompilerGeneratedClass c) { - Report.Debug (64, "ADD COMPILER GENERATED CLASS", this, c); - if (compiler_generated == null) compiler_generated = new List (); @@ -746,7 +745,7 @@ namespace Mono.CSharp { if (initialized_static_fields == null) return; - bool has_complex_initializer = !RootContext.Optimize; + bool has_complex_initializer = !ec.Module.Compiler.Settings.Optimize; int i; ExpressionStatement [] init = new ExpressionStatement [initialized_static_fields.Count]; for (i = 0; i < initialized_static_fields.Count; ++i) { @@ -789,7 +788,7 @@ namespace Mono.CSharp { // // Field is re-initialized to its default value => removed // - if (fi.IsDefaultInitializer && RootContext.Optimize) + if (fi.IsDefaultInitializer && ec.Module.Compiler.Settings.Optimize) continue; ec.CurrentBlock.AddScopeStatement (new StatementExpression (s)); @@ -812,6 +811,50 @@ namespace Mono.CSharp { get { return pending; } } + internal override void GenerateDocComment (DocumentationBuilder builder) + { + base.GenerateDocComment (builder); + + if (DefaultStaticConstructor != null) + DefaultStaticConstructor.GenerateDocComment (builder); + + if (InstanceConstructors != null) + foreach (Constructor c in InstanceConstructors) + c.GenerateDocComment (builder); + + if (Types != null) + foreach (TypeContainer tc in Types) + tc.GenerateDocComment (builder); + + if (Constants != null) + foreach (Const c in Constants) + c.GenerateDocComment (builder); + + if (Fields != null) + foreach (FieldBase f in Fields) + f.GenerateDocComment (builder); + + if (Events != null) + foreach (Event e in Events) + e.GenerateDocComment (builder); + + if (Indexers != null) + foreach (Indexer ix in Indexers) + ix.GenerateDocComment (builder); + + if (Properties != null) + foreach (Property p in Properties) + p.GenerateDocComment (builder); + + if (Methods != null) + foreach (MethodOrOperator m in Methods) + m.GenerateDocComment (builder); + + if (Operators != null) + foreach (Operator o in Operators) + o.GenerateDocComment (builder); + } + public TypeSpec GetAttributeCoClass () { if (OptAttributes == null) @@ -871,7 +914,7 @@ namespace Mono.CSharp { continue; if (i == 0 && Kind == MemberKind.Class && !fne_resolved.Type.IsInterface) { - if (fne_resolved.Type == InternalType.Dynamic) { + if (fne_resolved.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Report.Error (1965, Location, "Class `{0}' cannot derive from the dynamic type", GetSignatureForError ()); @@ -1117,7 +1160,7 @@ namespace Mono.CSharp { for (int i = 0; i < type_params.Length; ++i) { var tp = hoisted_tparams[i]; targs.Add (new TypeParameterName (tp.Name, null, Location)); - type_params[i] = new TypeParameter (tp, null, null, new MemberName (tp.Name), null); + type_params[i] = new TypeParameter (tp, this, null, new MemberName (tp.Name), null); } member_name = new MemberName (name, targs, Location); @@ -1141,7 +1184,7 @@ namespace Mono.CSharp { // Get all the method parameters and pass them as arguments var real_base_call = new Invocation (mg, block.GetAllParametersArguments ()); Statement statement; - if (method.ReturnType == TypeManager.void_type) + if (method.ReturnType.Kind == MemberKind.Void) statement = new StatementExpression (real_base_call); else statement = new Return (real_base_call, Location); @@ -1233,7 +1276,7 @@ namespace Mono.CSharp { } if (Kind == MemberKind.Interface) { - spec.BaseType = TypeManager.object_type; + spec.BaseType = Compiler.BuiltinTypes.Object; return true; } @@ -1329,6 +1372,11 @@ namespace Mono.CSharp { type_defined = true; + // TODO: Driver resolves only first level of namespace, do the rest here for now + if (IsTopLevel && (ModFlags & Modifiers.COMPILER_GENERATED) == 0) { + NamespaceEntry.Resolve (); + } + if (!DefineBaseTypes ()) { error = true; return; @@ -1369,15 +1417,15 @@ namespace Mono.CSharp { // Replaces normal spec with predefined one when compiling corlib // and this type container defines predefined type // - public void SetPredefinedSpec (BuildinTypeSpec spec) + public void SetPredefinedSpec (BuiltinTypeSpec spec) { // When compiling build-in types we start with two - // version of same type. One is of BuildinTypeSpec and + // version of same type. One is of BuiltinTypeSpec and // second one is ordinary TypeSpec. The unification // happens at later stage when we know which type - // really matches the buildin type signature. However + // really matches the builtin type signature. However // that means TypeSpec create during CreateType of this - // type has to be replaced with buildin one + // type has to be replaced with builtin one // spec.SetMetaInfo (TypeBuilder); spec.MemberCache = this.spec.MemberCache; @@ -1585,7 +1633,7 @@ namespace Mono.CSharp { requires_delayed_unmanagedtype_check = false; foreach (FieldBase f in fields) { if (f.MemberType != null && f.MemberType.IsPointer) - TypeManager.VerifyUnmanaged (Compiler, f.MemberType, f.Location); + TypeManager.VerifyUnmanaged (Module, f.MemberType, f.Location); } } } @@ -1669,16 +1717,15 @@ namespace Mono.CSharp { if (!seen_normal_indexers) return; - PredefinedAttribute pa = Module.PredefinedAttributes.DefaultMember; - if (pa.Constructor == null && - !pa.ResolveConstructor (Location, TypeManager.string_type)) + var ctor = Module.PredefinedMembers.DefaultMemberAttributeCtor.Get (); + if (ctor == null) return; var encoder = new AttributeEncoder (); encoder.Encode (GetAttributeDefaultMember ()); encoder.EncodeEmptyNamedArguments (); - pa.EmitAttribute (TypeBuilder, encoder); + TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); } protected virtual void CheckEqualsAndGetHashCode () @@ -1729,7 +1776,7 @@ namespace Mono.CSharp { // Check for internal or private fields that were never assigned // if (Report.WarningLevel >= 3) { - if (RootContext.EnhancedWarnings) { + if (Compiler.Settings.EnhancedWarnings) { CheckMemberUsage (properties, "property"); CheckMemberUsage (methods, "method"); CheckMemberUsage (constants, "constant"); @@ -1827,7 +1874,7 @@ namespace Mono.CSharp { if (instance_constructors == null) return; - if (spec.IsAttribute && IsExposedFromAssembly () && RootContext.VerifyClsCompliance && IsClsComplianceRequired ()) { + if (spec.IsAttribute && IsExposedFromAssembly () && Compiler.Settings.VerifyClsCompliance && IsClsComplianceRequired ()) { bool has_compliant_args = false; foreach (Constructor c in instance_constructors) { @@ -1863,6 +1910,9 @@ namespace Mono.CSharp { /// public virtual void EmitType () { + if ((caching_flags & Flags.CloseTypeCreated) != 0) + return; + if (OptAttributes != null) OptAttributes.Emit (); @@ -1961,7 +2011,6 @@ namespace Mono.CSharp { c.CloseType (); types = null; - fields = null; initialized_fields = null; initialized_static_fields = null; constants = null; @@ -2194,7 +2243,7 @@ namespace Mono.CSharp { return null; // FIXME: Breaks error reporting - if (!t.IsAccessible (CurrentType)) + if (!t.IsAccessible (this)) return null; return t; @@ -2240,15 +2289,6 @@ namespace Mono.CSharp { } } - // - // Generates xml doc comments (if any), and if required, - // handle warning report. - // - internal override void GenerateDocComment (DeclSpace ds) - { - DocUtil.GenerateTypeDocComment (this, ds, Report); - } - public override string DocCommentHeader { get { return "T:"; } } @@ -2387,10 +2427,7 @@ namespace Mono.CSharp { { DeclSpace top_level = Parent; if (top_level != null) { - while (top_level.Parent != null) - top_level = top_level.Parent; - - var candidates = NamespaceEntry.NS.LookupExtensionMethod (extensionType, this, name, arity); + var candidates = NamespaceEntry.NS.LookupExtensionMethod (this, extensionType, name, arity); if (candidates != null) { scope = NamespaceEntry; return candidates; @@ -2433,10 +2470,11 @@ namespace Mono.CSharp { var accmods = (Parent == null || Parent.Parent == null) ? Modifiers.INTERNAL : Modifiers.PRIVATE; this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, Location, Report); spec = new TypeSpec (Kind, null, this, null, ModFlags); + } - if (IsStatic && RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (Location, "static classes"); - } + public override void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); } public override void AddBasesForPart (DeclSpace part, List bases) @@ -2450,7 +2488,7 @@ namespace Mono.CSharp { public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.AttributeUsage) { - if (!BaseType.IsAttribute && spec != TypeManager.attribute_type) { + if (!BaseType.IsAttribute && spec.BuiltinType != BuiltinTypeSpec.Type.Attribute) { Report.Error (641, a.Location, "Attribute `{0}' is only valid on classes derived from System.Attribute", a.GetSignatureForError ()); } } @@ -2470,7 +2508,7 @@ namespace Mono.CSharp { return; } - if (a.Type.IsConditionallyExcluded (Location)) + if (a.Type.IsConditionallyExcluded (Compiler, Location)) return; base.ApplyAttributeBuilder (a, ctor, cdata, pa); @@ -2481,12 +2519,7 @@ namespace Mono.CSharp { return AttributeTargets.Class; } } - - public override void Accept (StructuralVisitor visitor) - { - visitor.Visit (this); - } - + protected override void DefineContainerMembers (System.Collections.IList list) { if (list == null) @@ -2566,8 +2599,8 @@ namespace Mono.CSharp { TypeExpr[] ifaces = base.ResolveBaseTypes (out base_class); if (base_class == null) { - if (spec != TypeManager.object_type) - base_type = TypeManager.object_type; + if (spec.BuiltinType != BuiltinTypeSpec.Type.Object) + base_type = Compiler.BuiltinTypes.Object; } else { if (base_type.IsGenericParameter){ Report.Error (689, base_class.Location, "`{0}': Cannot derive from type parameter `{1}'", @@ -2584,18 +2617,24 @@ namespace Mono.CSharp { Report.SymbolRelatedToPreviousError (base_class.Type); Report.Error (509, Location, "`{0}': cannot derive from sealed type `{1}'", GetSignatureForError (), base_type.GetSignatureForError ()); - } else if (PartialContainer.IsStatic && base_class.Type != TypeManager.object_type) { + } else if (PartialContainer.IsStatic && base_class.Type.BuiltinType != BuiltinTypeSpec.Type.Object) { Report.Error (713, Location, "Static class `{0}' cannot derive from type `{1}'. Static classes must derive from object", GetSignatureForError (), base_class.GetSignatureForError ()); } - if (base_type is BuildinTypeSpec && !(spec is BuildinTypeSpec) && - (base_type == TypeManager.enum_type || base_type == TypeManager.value_type || base_type == TypeManager.multicast_delegate_type || - base_type == TypeManager.delegate_type || base_type == TypeManager.array_type)) { - Report.Error (644, Location, "`{0}' cannot derive from special class `{1}'", - GetSignatureForError (), base_type.GetSignatureForError ()); + switch (base_type.BuiltinType) { + case BuiltinTypeSpec.Type.Enum: + case BuiltinTypeSpec.Type.ValueType: + case BuiltinTypeSpec.Type.MulticastDelegate: + case BuiltinTypeSpec.Type.Delegate: + case BuiltinTypeSpec.Type.Array: + if (!(spec is BuiltinTypeSpec)) { + Report.Error (644, Location, "`{0}' cannot derive from special class `{1}'", + GetSignatureForError (), base_type.GetSignatureForError ()); - base_type = TypeManager.object_type; + base_type = Compiler.BuiltinTypes.Object; + } + break; } if (!IsAccessibleAs (base_type)) { @@ -2683,6 +2722,11 @@ namespace Mono.CSharp { } } + public override void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); + } + public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { base.ApplyAttributeBuilder (a, ctor, cdata, pa); @@ -2721,7 +2765,7 @@ namespace Mono.CSharp { if (!ftype.IsStruct) continue; - if (ftype is BuildinTypeSpec) + if (ftype is BuiltinTypeSpec) continue; foreach (var targ in ftype.TypeArguments) { @@ -2811,24 +2855,21 @@ namespace Mono.CSharp { protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class) { TypeExpr[] ifaces = base.ResolveBaseTypes (out base_class); - base_type = TypeManager.value_type; + base_type = Compiler.BuiltinTypes.ValueType; return ifaces; } protected override TypeAttributes TypeAttr { get { - const TypeAttributes DefaultTypeAttributes = - TypeAttributes.SequentialLayout | - TypeAttributes.Sealed; + const + TypeAttributes DefaultTypeAttributes = + TypeAttributes.SequentialLayout | + TypeAttributes.Sealed ; return base.TypeAttr | DefaultTypeAttributes; } } - public override void Accept (StructuralVisitor visitor) - { - visitor.Visit (this); - } - + public override void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression) { if ((field.ModFlags & Modifiers.STATIC) == 0) { @@ -2867,16 +2908,7 @@ namespace Mono.CSharp { spec = new TypeSpec (Kind, null, this, null, ModFlags); } - public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) - { - if (a.Type == pa.ComImport && !attributes.Contains (pa.Guid)) { - a.Error_MissingGuidAttribute (); - return; - } - - base.ApplyAttributeBuilder (a, ctor, cdata, pa); - } - + #region Properties public override AttributeTargets AttributeTargets { get { @@ -2894,12 +2926,24 @@ namespace Mono.CSharp { return base.TypeAttr | DefaultTypeAttributes; } } - + + #endregion + public override void Accept (StructuralVisitor visitor) { visitor.Visit (this); } - + + public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) + { + if (a.Type == pa.ComImport && !attributes.Contains (pa.Guid)) { + a.Error_MissingGuidAttribute (); + return; + } + + base.ApplyAttributeBuilder (a, ctor, cdata, pa); + } + protected override bool VerifyClsCompliance () { if (!base.VerifyClsCompliance ()) @@ -2995,6 +3039,8 @@ namespace Mono.CSharp { IsExplicitImpl = (MemberName.Left != null); explicit_mod_flags = mod; } + + public abstract Variance ExpectedMemberTypeVariance { get; } protected override bool CheckBase () { @@ -3255,6 +3301,13 @@ namespace Mono.CSharp { return !error; } + protected override void DoMemberTypeDependentChecks () + { + base.DoMemberTypeDependentChecks (); + + TypeManager.CheckTypeVariance (MemberType, ExpectedMemberTypeVariance, this); + } + public override void Emit() { // for extern static method must be specified either DllImport attribute or MethodImplAttribute. @@ -3482,14 +3535,11 @@ namespace Mono.CSharp { "accessible than field `" + GetSignatureForError () + "'"); } } - - Variance variance = this is Event ? Variance.Contravariant : Variance.Covariant; - TypeManager.CheckTypeVariance (MemberType, variance, this); } protected bool IsTypePermitted () { - if (TypeManager.IsSpecialType (MemberType)) { + if (MemberType.IsSpecialRuntimeType) { Report.Error (610, Location, "Field or property cannot be of type `{0}'", TypeManager.CSharpName (MemberType)); return false; } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/codegen.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/codegen.cs index 662c07ecd..e8900de8b 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/codegen.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/codegen.cs @@ -31,13 +31,13 @@ namespace Mono.CSharp public class EmitContext : BuilderContext { // TODO: Has to be private - public ILGenerator ig; + public readonly ILGenerator ig; /// /// The value that is allowed to be returned or NULL if there is no /// return type. /// - TypeSpec return_type; + readonly TypeSpec return_type; /// /// Keeps track of the Type to LocalBuilder temporary storage created @@ -83,14 +83,13 @@ namespace Mono.CSharp /// public AnonymousExpression CurrentAnonymousMethod; - public readonly IMemberContext MemberContext; + readonly IMemberContext member_context; DynamicSiteClass dynamic_site_container; - // TODO: Replace IMemberContext with MemberCore public EmitContext (IMemberContext rc, ILGenerator ig, TypeSpec return_type) { - this.MemberContext = rc; + this.member_context = rc; this.ig = ig; this.return_type = return_type; @@ -102,23 +101,29 @@ namespace Mono.CSharp #region Properties + public BuiltinTypes BuiltinTypes { + get { + return MemberContext.Module.Compiler.BuiltinTypes; + } + } + public TypeSpec CurrentType { - get { return MemberContext.CurrentType; } + get { return member_context.CurrentType; } } public TypeParameter[] CurrentTypeParameters { - get { return MemberContext.CurrentTypeParameters; } + get { return member_context.CurrentTypeParameters; } } public MemberCore CurrentTypeDefinition { - get { return MemberContext.CurrentMemberDefinition; } + get { return member_context.CurrentMemberDefinition; } } public bool IsStatic { - get { return MemberContext.IsStatic; } + get { return member_context.IsStatic; } } - bool IsAnonymousStoreyMutateRequired { + public bool IsAnonymousStoreyMutateRequired { get { return CurrentAnonymousMethod != null && CurrentAnonymousMethod.Storey != null && @@ -126,9 +131,24 @@ namespace Mono.CSharp } } - // Has to be used for emitter errors only + public IMemberContext MemberContext { + get { + return member_context; + } + } + + public ModuleContainer Module { + get { + return member_context.Module; + } + } + + // Has to be used for specific emitter errors only any + // possible resolver errors have to be reported during Resolve public Report Report { - get { return MemberContext.Compiler.Report; } + get { + return member_context.Module.Compiler.Report; + } } public TypeSpec ReturnType { @@ -188,10 +208,10 @@ namespace Mono.CSharp // // Creates a nested container in this context for all dynamic compiler generated stuff // - public DynamicSiteClass CreateDynamicSite () + internal DynamicSiteClass CreateDynamicSite () { if (dynamic_site_container == null) { - var mc = MemberContext.CurrentMemberDefinition as MemberBase; + var mc = member_context.CurrentMemberDefinition as MemberBase; dynamic_site_container = new DynamicSiteClass (CurrentTypeDefinition.Parent.PartialContainer, mc, CurrentTypeParameters); CurrentTypeDefinition.Module.AddCompilerGeneratedClass (dynamic_site_container); @@ -199,6 +219,10 @@ namespace Mono.CSharp dynamic_site_container.DefineType (); dynamic_site_container.ResolveTypeParameters (); dynamic_site_container.Define (); + + var inflator = new TypeParameterInflator (Module, CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); + var inflated = dynamic_site_container.CurrentType.InflateMember (inflator); + CurrentType.MemberCache.AddMember (inflated); } return dynamic_site_container; @@ -347,40 +371,60 @@ namespace Mono.CSharp } var type = ac.Element; - if (TypeManager.IsEnumType (type)) + if (type.Kind == MemberKind.Enum) type = EnumSpec.GetUnderlyingType (type); - if (type == TypeManager.byte_type || type == TypeManager.bool_type) + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.Bool: Emit (OpCodes.Ldelem_U1); - else if (type == TypeManager.sbyte_type) + return; + case BuiltinTypeSpec.Type.SByte: Emit (OpCodes.Ldelem_I1); - else if (type == TypeManager.short_type) + return; + case BuiltinTypeSpec.Type.Short: Emit (OpCodes.Ldelem_I2); - else if (type == TypeManager.ushort_type || type == TypeManager.char_type) + return; + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Char: Emit (OpCodes.Ldelem_U2); - else if (type == TypeManager.int32_type) + return; + case BuiltinTypeSpec.Type.Int: Emit (OpCodes.Ldelem_I4); - else if (type == TypeManager.uint32_type) + return; + case BuiltinTypeSpec.Type.UInt: Emit (OpCodes.Ldelem_U4); - else if (type == TypeManager.uint64_type) - Emit (OpCodes.Ldelem_I8); - else if (type == TypeManager.int64_type) + return; + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Long: Emit (OpCodes.Ldelem_I8); - else if (type == TypeManager.float_type) + return; + case BuiltinTypeSpec.Type.Float: Emit (OpCodes.Ldelem_R4); - else if (type == TypeManager.double_type) + return; + case BuiltinTypeSpec.Type.Double: Emit (OpCodes.Ldelem_R8); - else if (type == TypeManager.intptr_type) + return; + case BuiltinTypeSpec.Type.IntPtr: Emit (OpCodes.Ldelem_I); - else if (TypeManager.IsStruct (type)) { + return; + } + + switch (type.Kind) { + case MemberKind.Struct: Emit (OpCodes.Ldelema, type); Emit (OpCodes.Ldobj, type); - } else if (type.IsGenericParameter) { + break; + case MemberKind.TypeParameter: Emit (OpCodes.Ldelem, type); - } else if (type.IsPointer) + break; + case MemberKind.PointerType: Emit (OpCodes.Ldelem_I); - else + break; + default: Emit (OpCodes.Ldelem_Ref); + break; + } } // @@ -398,31 +442,50 @@ namespace Mono.CSharp var type = ac.Element; - if (type.IsEnum) + if (type.Kind == MemberKind.Enum) type = EnumSpec.GetUnderlyingType (type); - if (type == TypeManager.byte_type || type == TypeManager.sbyte_type || type == TypeManager.bool_type) + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Bool: Emit (OpCodes.Stelem_I1); - else if (type == TypeManager.short_type || type == TypeManager.ushort_type || type == TypeManager.char_type) + return; + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Char: Emit (OpCodes.Stelem_I2); - else if (type == TypeManager.int32_type || type == TypeManager.uint32_type) + return; + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: Emit (OpCodes.Stelem_I4); - else if (type == TypeManager.int64_type || type == TypeManager.uint64_type) + return; + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: Emit (OpCodes.Stelem_I8); - else if (type == TypeManager.float_type) + return; + case BuiltinTypeSpec.Type.Float: Emit (OpCodes.Stelem_R4); - else if (type == TypeManager.double_type) + return; + case BuiltinTypeSpec.Type.Double: Emit (OpCodes.Stelem_R8); - else if (type == TypeManager.intptr_type) - Emit (OpCodes.Stobj, type); - else if (TypeManager.IsStruct (type)) + return; + } + + switch (type.Kind) { + case MemberKind.Struct: Emit (OpCodes.Stobj, type); - else if (type.IsGenericParameter) + break; + case MemberKind.TypeParameter: Emit (OpCodes.Stelem, type); - else if (type.IsPointer) + break; + case MemberKind.PointerType: Emit (OpCodes.Stelem_I); - else + break; + default: Emit (OpCodes.Stelem_Ref); + break; + } } public void EmitInt (int i) @@ -497,45 +560,59 @@ namespace Mono.CSharp // // Load the object from the pointer. // - public void EmitLoadFromPtr (TypeSpec t) + public void EmitLoadFromPtr (TypeSpec type) { - if (t == TypeManager.int32_type) + if (type.Kind == MemberKind.Enum) + type = EnumSpec.GetUnderlyingType (type); + + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: ig.Emit (OpCodes.Ldind_I4); - else if (t == TypeManager.uint32_type) + return; + case BuiltinTypeSpec.Type.UInt: ig.Emit (OpCodes.Ldind_U4); - else if (t == TypeManager.short_type) + return; + case BuiltinTypeSpec.Type.Short: ig.Emit (OpCodes.Ldind_I2); - else if (t == TypeManager.ushort_type) - ig.Emit (OpCodes.Ldind_U2); - else if (t == TypeManager.char_type) + return; + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Char: ig.Emit (OpCodes.Ldind_U2); - else if (t == TypeManager.byte_type) + return; + case BuiltinTypeSpec.Type.Byte: ig.Emit (OpCodes.Ldind_U1); - else if (t == TypeManager.sbyte_type) + return; + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Bool: ig.Emit (OpCodes.Ldind_I1); - else if (t == TypeManager.uint64_type) - ig.Emit (OpCodes.Ldind_I8); - else if (t == TypeManager.int64_type) + return; + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Long: ig.Emit (OpCodes.Ldind_I8); - else if (t == TypeManager.float_type) + return; + case BuiltinTypeSpec.Type.Float: ig.Emit (OpCodes.Ldind_R4); - else if (t == TypeManager.double_type) + return; + case BuiltinTypeSpec.Type.Double: ig.Emit (OpCodes.Ldind_R8); - else if (t == TypeManager.bool_type) - ig.Emit (OpCodes.Ldind_I1); - else if (t == TypeManager.intptr_type) + return; + case BuiltinTypeSpec.Type.IntPtr: ig.Emit (OpCodes.Ldind_I); - else if (t.IsEnum) { - if (t == TypeManager.enum_type) - ig.Emit (OpCodes.Ldind_Ref); - else - EmitLoadFromPtr (EnumSpec.GetUnderlyingType (t)); - } else if (TypeManager.IsStruct (t) || TypeManager.IsGenericParameter (t)) - Emit (OpCodes.Ldobj, t); - else if (t.IsPointer) + return; + } + + switch (type.Kind) { + case MemberKind.Struct: + case MemberKind.TypeParameter: + Emit (OpCodes.Ldobj, type); + break; + case MemberKind.PointerType: ig.Emit (OpCodes.Ldind_I); - else + break; + default: ig.Emit (OpCodes.Ldind_Ref); + break; + } } // @@ -546,24 +623,38 @@ namespace Mono.CSharp if (type.IsEnum) type = EnumSpec.GetUnderlyingType (type); - if (type == TypeManager.int32_type || type == TypeManager.uint32_type) + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: ig.Emit (OpCodes.Stind_I4); - else if (type == TypeManager.int64_type || type == TypeManager.uint64_type) + return; + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: ig.Emit (OpCodes.Stind_I8); - else if (type == TypeManager.char_type || type == TypeManager.short_type || - type == TypeManager.ushort_type) + return; + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: ig.Emit (OpCodes.Stind_I2); - else if (type == TypeManager.float_type) + return; + case BuiltinTypeSpec.Type.Float: ig.Emit (OpCodes.Stind_R4); - else if (type == TypeManager.double_type) + return; + case BuiltinTypeSpec.Type.Double: ig.Emit (OpCodes.Stind_R8); - else if (type == TypeManager.byte_type || type == TypeManager.sbyte_type || - type == TypeManager.bool_type) + return; + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Bool: ig.Emit (OpCodes.Stind_I1); - else if (type == TypeManager.intptr_type) + return; + case BuiltinTypeSpec.Type.IntPtr: ig.Emit (OpCodes.Stind_I); - else if (TypeManager.IsStruct (type) || TypeManager.IsGenericParameter (type)) - ig.Emit (OpCodes.Stobj, type.GetMetaInfo ()); + return; + } + + if (type.IsStruct || TypeManager.IsGenericParameter (type)) + Emit (OpCodes.Stobj, type); else ig.Emit (OpCodes.Stind_Ref); } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/complete.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/complete.cs index 43cc8fad7..965416e79 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/complete.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/complete.cs @@ -72,9 +72,9 @@ namespace Mono.CSharp { { var results = new List (); - AppendResults (results, Prefix, Evaluator.GetVarNames ()); + AppendResults (results, Prefix, ec.Module.Evaluator.GetVarNames ()); AppendResults (results, Prefix, ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith (Prefix)); - AppendResults (results, Prefix, Evaluator.GetUsingList ()); + AppendResults (results, Prefix, ec.Module.Evaluator.GetUsingList ()); throw new CompletionResult (Prefix, results.ToArray ()); } @@ -114,7 +114,7 @@ namespace Mono.CSharp { return null; TypeSpec expr_type = expr_resolved.Type; - if (expr_type.IsPointer || expr_type == TypeManager.void_type || expr_type == InternalType.Null || expr_type == InternalType.AnonymousMethod) { + if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod) { Unary.Error_OperatorCannotBeApplied (ec, loc, ".", expr_type); return null; } @@ -146,7 +146,7 @@ namespace Mono.CSharp { partial_name, ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith (namespaced_partial)); } else { - var r = MemberCache.GetCompletitionMembers (expr_type, partial_name).Select (l => l.Name); + var r = MemberCache.GetCompletitionMembers (ec, expr_type, partial_name).Select (l => l.Name); AppendResults (results, partial_name, r); } @@ -175,7 +175,7 @@ namespace Mono.CSharp { protected override Expression DoResolve (ResolveContext ec) { - var members = MemberCache.GetCompletitionMembers (ec.CurrentInitializerVariable.Type, partial_name); + var members = MemberCache.GetCompletitionMembers (ec, ec.CurrentInitializerVariable.Type, partial_name); // TODO: Does this mean exact match only ? // if (partial_name != null && results.Count > 0 && result [0] == "") diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/const.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/const.cs index ebce80d6c..a66ebdd82 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/const.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/const.cs @@ -46,7 +46,7 @@ namespace Mono.CSharp { FieldAttributes field_attr = FieldAttributes.Static | ModifiersExtensions.FieldAttr (ModFlags); // Decimals cannot be emitted into the constant blob. So, convert to 'readonly'. - if (member_type == TypeManager.decimal_type) { + if (member_type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { field_attr |= FieldAttributes.InitOnly; } else { field_attr |= FieldAttributes.Literal; @@ -87,7 +87,7 @@ namespace Mono.CSharp { public override void Emit () { var c = ((ConstSpec) spec).Value as Constant; - if (c.Type == TypeManager.decimal_type) { + if (c.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { Module.PredefinedAttributes.DecimalConstant.EmitAttribute (FieldBuilder, (decimal) c.GetValue (), c.Location); } else { FieldBuilder.SetConstant (c.GetValue ()); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/constant.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/constant.cs index b9fab14a8..872b9952c 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/constant.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/constant.cs @@ -10,6 +10,7 @@ // using System; +using System.Globalization; #if STATIC using IKVM.Reflection.Emit; @@ -22,7 +23,9 @@ namespace Mono.CSharp { /// /// Base class for constants and literals. /// - public abstract class Constant : Expression { + public abstract class Constant : Expression + { + static readonly NumberFormatInfo nfi = CultureInfo.InvariantCulture.NumberFormat; protected Constant (Location loc) { @@ -40,6 +43,8 @@ namespace Mono.CSharp { /// public abstract object GetValue (); + public abstract long GetValueAsLong (); + public abstract string GetValueAsLiteral (); #if !STATIC @@ -55,8 +60,8 @@ namespace Mono.CSharp { public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) { if (!expl && IsLiteral && - (TypeManager.IsPrimitiveType (target) || type == TypeManager.decimal_type) && - (TypeManager.IsPrimitiveType (type) || type == TypeManager.decimal_type)) { + BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) && + BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) { ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'", GetValueAsLiteral (), TypeManager.CSharpName (target)); } else { @@ -66,14 +71,14 @@ namespace Mono.CSharp { public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type, Location loc) { - Constant c = ConvertImplicitly (ec, type); + Constant c = ConvertImplicitly (type); if (c == null) Error_ValueCannotBeConverted (ec, loc, type, false); return c; } - public virtual Constant ConvertImplicitly (ResolveContext rc, TypeSpec type) + public virtual Constant ConvertImplicitly (TypeSpec type) { if (this.type == type) return this; @@ -82,7 +87,7 @@ namespace Mono.CSharp { return null; bool fail; - object constant_value = TypeManager.ChangeType (GetValue (), type, out fail); + object constant_value = ChangeType (GetValue (), type, out fail); if (fail){ // // We should always catch the error before this is ever @@ -92,53 +97,57 @@ namespace Mono.CSharp { TypeManager.CSharpName (Type), TypeManager.CSharpName (type)); } - return CreateConstant (rc, type, constant_value, loc); + return CreateConstant (type, constant_value, loc); } // // Returns a constant instance based on Type // - public static Constant CreateConstant (ResolveContext rc, TypeSpec t, object v, Location loc) + public static Constant CreateConstant (TypeSpec t, object v, Location loc) { - return CreateConstantFromValue (t, v, loc).Resolve (rc); + return CreateConstantFromValue (t, v, loc); } public static Constant CreateConstantFromValue (TypeSpec t, object v, Location loc) { - if (t == TypeManager.int32_type) - return new IntConstant ((int) v, loc); - if (t == TypeManager.string_type) - return new StringConstant ((string) v, loc); - if (t == TypeManager.uint32_type) - return new UIntConstant ((uint) v, loc); - if (t == TypeManager.int64_type) - return new LongConstant ((long) v, loc); - if (t == TypeManager.uint64_type) - return new ULongConstant ((ulong) v, loc); - if (t == TypeManager.float_type) - return new FloatConstant ((float) v, loc); - if (t == TypeManager.double_type) - return new DoubleConstant ((double) v, loc); - if (t == TypeManager.short_type) - return new ShortConstant ((short)v, loc); - if (t == TypeManager.ushort_type) - return new UShortConstant ((ushort)v, loc); - if (t == TypeManager.sbyte_type) - return new SByteConstant ((sbyte)v, loc); - if (t == TypeManager.byte_type) - return new ByteConstant ((byte)v, loc); - if (t == TypeManager.char_type) - return new CharConstant ((char)v, loc); - if (t == TypeManager.bool_type) - return new BoolConstant ((bool) v, loc); - if (t == TypeManager.decimal_type) - return new DecimalConstant ((decimal) v, loc); - if (TypeManager.IsEnumType (t)) { + switch (t.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + return new IntConstant (t, (int) v, loc); + case BuiltinTypeSpec.Type.String: + return new StringConstant (t, (string) v, loc); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (t, (uint) v, loc); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (t, (long) v, loc); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (t, (ulong) v, loc); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (t, (float) v, loc); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (t, (double) v, loc); + case BuiltinTypeSpec.Type.Short: + return new ShortConstant (t, (short) v, loc); + case BuiltinTypeSpec.Type.UShort: + return new UShortConstant (t, (ushort) v, loc); + case BuiltinTypeSpec.Type.SByte: + return new SByteConstant (t, (sbyte) v, loc); + case BuiltinTypeSpec.Type.Byte: + return new ByteConstant (t, (byte) v, loc); + case BuiltinTypeSpec.Type.Char: + return new CharConstant (t, (char) v, loc); + case BuiltinTypeSpec.Type.Bool: + return new BoolConstant (t, (bool) v, loc); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (t, (decimal) v, loc); + } + + if (t.IsEnum) { var real_type = EnumSpec.GetUnderlyingType (t); - return new EnumConstant (CreateConstantFromValue (real_type, v, loc).Resolve (null), t); + return new EnumConstant (CreateConstantFromValue (real_type, v, loc), t); } + if (v == null) { - if (TypeManager.IsNullableType (t)) + if (t.IsNullableType) return Nullable.LiftedNull.Create (t, loc); if (TypeManager.IsReferenceType (t)) @@ -158,7 +167,6 @@ namespace Mono.CSharp { return CreateExpressionFactoryCall (ec, "Constant", args); } - /// /// Maybe ConvertTo name is better. It tries to convert `this' constant to target_type. /// It throws OverflowException @@ -166,6 +174,74 @@ namespace Mono.CSharp { // DON'T CALL THIS METHOD DIRECTLY AS IT DOES NOT HANDLE ENUMS public abstract Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type); + // This is a custom version of Convert.ChangeType() which works + // with the TypeBuilder defined types when compiling corlib. + static object ChangeType (object value, TypeSpec targetType, out bool error) + { + IConvertible convert_value = value as IConvertible; + + if (convert_value == null) { + error = true; + return null; + } + + // + // We cannot rely on build-in type conversions as they are + // more limited than what C# supports. + // See char -> float/decimal/double conversion + // + error = false; + try { + switch (targetType.BuiltinType) { + case BuiltinTypeSpec.Type.Bool: + return convert_value.ToBoolean (nfi); + case BuiltinTypeSpec.Type.Byte: + return convert_value.ToByte (nfi); + case BuiltinTypeSpec.Type.Char: + return convert_value.ToChar (nfi); + case BuiltinTypeSpec.Type.Short: + return convert_value.ToInt16 (nfi); + case BuiltinTypeSpec.Type.Int: + return convert_value.ToInt32 (nfi); + case BuiltinTypeSpec.Type.Long: + return convert_value.ToInt64 (nfi); + case BuiltinTypeSpec.Type.SByte: + return convert_value.ToSByte (nfi); + case BuiltinTypeSpec.Type.Decimal: + if (convert_value.GetType () == typeof (char)) + return (decimal) convert_value.ToInt32 (nfi); + return convert_value.ToDecimal (nfi); + case BuiltinTypeSpec.Type.Double: + if (convert_value.GetType () == typeof (char)) + return (double) convert_value.ToInt32 (nfi); + return convert_value.ToDouble (nfi); + case BuiltinTypeSpec.Type.Float: + if (convert_value.GetType () == typeof (char)) + return (float) convert_value.ToInt32 (nfi); + return convert_value.ToSingle (nfi); + case BuiltinTypeSpec.Type.String: + return convert_value.ToString (nfi); + case BuiltinTypeSpec.Type.UShort: + return convert_value.ToUInt16 (nfi); + case BuiltinTypeSpec.Type.UInt: + return convert_value.ToUInt32 (nfi); + case BuiltinTypeSpec.Type.ULong: + return convert_value.ToUInt64 (nfi); + case BuiltinTypeSpec.Type.Object: + return value; + } + } catch { + } + + error = true; + return null; + } + + protected override Expression DoResolve (ResolveContext rc) + { + return this; + } + /// /// Attempts to do a compile-time folding of a constant cast. /// @@ -175,7 +251,7 @@ namespace Mono.CSharp { return TryReduce (ec, target_type); } catch (OverflowException) { - if (ec.ConstantCheckState && Type.BuildinType != BuildinTypeSpec.Type.Decimal) { + if (ec.ConstantCheckState && Type.BuiltinType != BuiltinTypeSpec.Type.Decimal) { ec.Report.Error (221, loc, "Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax to override)", GetValueAsLiteral (), target_type.GetSignatureForError ()); @@ -183,7 +259,7 @@ namespace Mono.CSharp { Error_ValueCannotBeConverted (ec, loc, target_type, false); } - return New.Constantify (target_type, loc).Resolve (ec); + return New.Constantify (target_type, loc); } } @@ -198,14 +274,10 @@ namespace Mono.CSharp { if (c == null) return null; - return new EnumConstant (c, target_type).Resolve (ec); + return new EnumConstant (c, target_type); } - c = ConvertExplicitly (ec.ConstantCheckState, target_type); - if (c != null) - c = c.Resolve (ec); - - return c; + return ConvertExplicitly (ec.ConstantCheckState, target_type); } /// @@ -272,25 +344,10 @@ namespace Mono.CSharp { #endif } - public new Constant Resolve (ResolveContext rc) + public new bool Resolve (ResolveContext rc) { - if (eclass != ExprClass.Unresolved) - return this; - - // Resolved constant has to be still a constant - Constant c = (Constant) DoResolve (rc); - if (c == null) - return null; - - if ((c.eclass & ExprClass.Value) == 0) { - c.Error_UnexpectedKind (rc, ResolveFlags.VariableOrValue, loc); - return null; - } - - if (c.type == null) - throw new InternalErrorException ("Expression `{0}' did not set its type after Resolve", c.GetType ()); - - return c; + // It exists only as hint not to call Resolve on constants + return true; } public override object Accept (StructuralVisitor visitor) @@ -302,9 +359,11 @@ namespace Mono.CSharp { public abstract class IntegralConstant : Constant { - protected IntegralConstant (Location loc) : - base (loc) + protected IntegralConstant (TypeSpec type, Location loc) + : base (loc) { + this.type = type; + eclass = ExprClass.Value; } public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) @@ -330,18 +389,19 @@ namespace Mono.CSharp { public class BoolConstant : Constant { public readonly bool Value; - - public BoolConstant (bool val, Location loc): - base (loc) + + public BoolConstant (BuiltinTypes types, bool val, Location loc) + : this (types.Bool, val, loc) { - Value = val; } - - protected override Expression DoResolve (ResolveContext ec) + + public BoolConstant (TypeSpec type, bool val, Location loc) + : base (loc) { - type = TypeManager.bool_type; eclass = ExprClass.Value; - return this; + this.type = type; + + Value = val; } public override object GetValue () @@ -354,6 +414,11 @@ namespace Mono.CSharp { return Value ? "true" : "false"; } + public override long GetValueAsLong () + { + return Value ? 1 : 0; + } + public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) { enc.Encode (Value); @@ -390,11 +455,17 @@ namespace Mono.CSharp { } - public class ByteConstant : IntegralConstant { + public class ByteConstant : IntegralConstant + { public readonly byte Value; - public ByteConstant (byte v, Location loc): - base (loc) + public ByteConstant (BuiltinTypes types, byte v, Location loc) + : this (types.Byte, v, loc) + { + } + + public ByteConstant (TypeSpec type, byte v, Location loc) + : base (type, loc) { Value = v; } @@ -409,21 +480,19 @@ namespace Mono.CSharp { ec.EmitInt (Value); } - protected override Expression DoResolve (ResolveContext ec) + public override object GetValue () { - type = TypeManager.byte_type; - eclass = ExprClass.Value; - return this; + return Value; } - public override object GetValue () + public override long GetValueAsLong () { return Value; } public override Constant Increment () { - return new ByteConstant (checked ((byte)(Value + 1)), loc); + return new ByteConstant (type, checked ((byte)(Value + 1)), loc); } public override bool IsDefaultValue { @@ -450,33 +519,34 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.sbyte_type) { + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: if (in_checked_context){ if (Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) - return new ShortConstant ((short) Value, Location); - if (target_type == TypeManager.ushort_type) - return new UShortConstant ((ushort) Value, Location); - if (target_type == TypeManager.int32_type) - return new IntConstant ((int) Value, Location); - if (target_type == TypeManager.uint32_type) - return new UIntConstant ((uint) Value, Location); - if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) - return new ULongConstant ((ulong) Value, Location); - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) - return new CharConstant ((char) Value, Location); - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); + } return null; } @@ -486,17 +556,18 @@ namespace Mono.CSharp { public class CharConstant : Constant { public readonly char Value; - public CharConstant (char v, Location loc): - base (loc) + public CharConstant (BuiltinTypes types, char v, Location loc) + : this (types.Char, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public CharConstant (TypeSpec type, char v, Location loc) + : base (loc) { - type = TypeManager.char_type; + this.type = type; eclass = ExprClass.Value; - return this; + + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -543,6 +614,11 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return Value; + } + public override string GetValueAsLiteral () { return "\"" + descape (Value) + "\""; @@ -566,61 +642,60 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < Byte.MinValue || Value > Byte.MaxValue) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value > Int16.MaxValue) throw new OverflowException (); - } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.int32_type) - return new IntConstant ((int) Value, Location); - if (target_type == TypeManager.uint32_type) - return new UIntConstant ((uint) Value, Location); - if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) - return new ULongConstant ((ulong) Value, Location); - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); + } + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); + } return null; } } - public class SByteConstant : IntegralConstant { + public class SByteConstant : IntegralConstant + { public readonly sbyte Value; - public SByteConstant (sbyte v, Location loc): - base (loc) + public SByteConstant (BuiltinTypes types, sbyte v, Location loc) + : this (types.SByte, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public SByteConstant (TypeSpec type, sbyte v, Location loc) + : base (type, loc) { - type = TypeManager.sbyte_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -638,9 +713,14 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return Value; + } + public override Constant Increment () { - return new SByteConstant (checked((sbyte)(Value + 1)), loc); + return new SByteConstant (type, checked((sbyte)(Value + 1)), loc); } public override bool IsDefaultValue { @@ -667,41 +747,40 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: if (in_checked_context && Value < 0) throw new OverflowException (); - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.short_type) - return new ShortConstant ((short) Value, Location); - if (target_type == TypeManager.ushort_type) { + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.Short: + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: if (in_checked_context && Value < 0) throw new OverflowException (); - return new UShortConstant ((ushort) Value, Location); - } if (target_type == TypeManager.int32_type) - return new IntConstant ((int) Value, Location); - if (target_type == TypeManager.uint32_type) { + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: if (in_checked_context && Value < 0) throw new OverflowException (); - return new UIntConstant ((uint) Value, Location); - } if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) { + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) throw new OverflowException (); - return new ULongConstant ((ulong) Value, Location); - } - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: if (in_checked_context && Value < 0) throw new OverflowException (); - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } @@ -711,17 +790,15 @@ namespace Mono.CSharp { public class ShortConstant : IntegralConstant { public readonly short Value; - public ShortConstant (short v, Location loc): - base (loc) + public ShortConstant (BuiltinTypes types, short v, Location loc) + : this (types.Short, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public ShortConstant (TypeSpec type, short v, Location loc) + : base (type, loc) { - type = TypeManager.short_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -739,9 +816,14 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return Value; + } + public override Constant Increment () { - return new ShortConstant (checked((short)(Value + 1)), loc); + return new ShortConstant (type, checked((short)(Value + 1)), loc); } public override bool IsDefaultValue { @@ -768,73 +850,68 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < Byte.MinValue || Value > Byte.MaxValue) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value < SByte.MinValue || Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.ushort_type) { + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.UShort: if (in_checked_context && Value < 0) throw new OverflowException (); - - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.int32_type) - return new IntConstant ((int) Value, Location); - if (target_type == TypeManager.uint32_type) { + + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: if (in_checked_context && Value < 0) throw new OverflowException (); - return new UIntConstant ((uint) Value, Location); - } - if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) { + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) throw new OverflowException (); - return new ULongConstant ((ulong) Value, Location); - } - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value < Char.MinValue) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } } - public class UShortConstant : IntegralConstant { + public class UShortConstant : IntegralConstant + { public readonly ushort Value; - public UShortConstant (ushort v, Location loc): - base (loc) + public UShortConstant (BuiltinTypes types, ushort v, Location loc) + : this (types.UShort, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public UShortConstant (TypeSpec type, ushort v, Location loc) + : base (type, loc) { - type = TypeManager.ushort_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -851,10 +928,15 @@ namespace Mono.CSharp { { return Value; } + + public override long GetValueAsLong () + { + return Value; + } public override Constant Increment () { - return new UShortConstant (checked((ushort)(Value + 1)), loc); + return new UShortConstant (type, checked((ushort)(Value + 1)), loc); } public override bool IsDefaultValue { @@ -881,67 +963,64 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value > Byte.MaxValue) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value > Int16.MaxValue) throw new OverflowException (); } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.int32_type) - return new IntConstant ((int) Value, Location); - if (target_type == TypeManager.uint32_type) - return new UIntConstant ((uint) Value, Location); - if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) - return new ULongConstant ((ulong) Value, Location); - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value > Char.MaxValue) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } } - public class IntConstant : IntegralConstant { + public class IntConstant : IntegralConstant + { public readonly int Value; - public IntConstant (int v, Location loc): - base (loc) + public IntConstant (BuiltinTypes types, int v, Location loc) + : this (types.Int, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public IntConstant (TypeSpec type, int v, Location loc) + : base (type, loc) { - type = TypeManager.int32_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -959,9 +1038,14 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return Value; + } + public override Constant Increment () { - return new IntConstant (checked(Value + 1), loc); + return new IntConstant (type, checked(Value + 1), loc); } public override bool IsDefaultValue { @@ -988,75 +1072,70 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < Byte.MinValue || Value > Byte.MaxValue) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value < SByte.MinValue || Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value < Int16.MinValue || Value > Int16.MaxValue) throw new OverflowException (); } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.ushort_type) { - if (in_checked_context){ + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: + if (in_checked_context) { if (Value < UInt16.MinValue || Value > UInt16.MaxValue) throw new OverflowException (); } - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.uint32_type) { - if (in_checked_context){ + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.UInt: + if (in_checked_context) { if (Value < UInt32.MinValue) throw new OverflowException (); } - return new UIntConstant ((uint) Value, Location); - } - if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) { + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) throw new OverflowException (); - return new ULongConstant ((ulong) Value, Location); - } - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value < Char.MinValue || Value > Char.MaxValue) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec type) + public override Constant ConvertImplicitly (TypeSpec type) { if (this.type == type) return this; Constant c = TryImplicitIntConversion (type); if (c != null) - return c.Resolve (rc); + return c; //.Resolve (rc); - return base.ConvertImplicitly (rc, type); + return base.ConvertImplicitly (type); } /// @@ -1066,39 +1145,41 @@ namespace Mono.CSharp { /// Constant TryImplicitIntConversion (TypeSpec target_type) { - if (target_type == TypeManager.sbyte_type) { + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: if (Value >= SByte.MinValue && Value <= SByte.MaxValue) - return new SByteConstant ((sbyte) Value, loc); - } - else if (target_type == TypeManager.byte_type) { + return new SByteConstant (target_type, (sbyte) Value, loc); + break; + case BuiltinTypeSpec.Type.Byte: if (Value >= Byte.MinValue && Value <= Byte.MaxValue) - return new ByteConstant ((byte) Value, loc); - } - else if (target_type == TypeManager.short_type) { + return new ByteConstant (target_type, (byte) Value, loc); + break; + case BuiltinTypeSpec.Type.Short: if (Value >= Int16.MinValue && Value <= Int16.MaxValue) - return new ShortConstant ((short) Value, loc); - } - else if (target_type == TypeManager.ushort_type) { + return new ShortConstant (target_type, (short) Value, loc); + break; + case BuiltinTypeSpec.Type.UShort: if (Value >= UInt16.MinValue && Value <= UInt16.MaxValue) - return new UShortConstant ((ushort) Value, loc); - } - else if (target_type == TypeManager.uint32_type) { + return new UShortConstant (target_type, (ushort) Value, loc); + break; + case BuiltinTypeSpec.Type.UInt: if (Value >= 0) - return new UIntConstant ((uint) Value, loc); - } - else if (target_type == TypeManager.uint64_type) { + return new UIntConstant (target_type, (uint) Value, loc); + break; + case BuiltinTypeSpec.Type.ULong: // // we can optimize this case: a positive int32 // always fits on a uint64. But we need an opcode // to do it. // if (Value >= 0) - return new ULongConstant ((ulong) Value, loc); - } - else if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, loc); - else if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, loc); + return new ULongConstant (target_type, (ulong) Value, loc); + break; + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, loc); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, loc); + } return null; } @@ -1107,17 +1188,15 @@ namespace Mono.CSharp { public class UIntConstant : IntegralConstant { public readonly uint Value; - public UIntConstant (uint v, Location loc): - base (loc) + public UIntConstant (BuiltinTypes types, uint v, Location loc) + : this (types.UInt, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public UIntConstant (TypeSpec type, uint v, Location loc) + : base (type, loc) { - type = TypeManager.uint32_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -1135,9 +1214,14 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return Value; + } + public override Constant Increment () { - return new UIntConstant (checked(Value + 1), loc); + return new UIntConstant (type, checked(Value + 1), loc); } public override bool IsDefaultValue { @@ -1164,58 +1248,54 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < 0 || Value > byte.MaxValue) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value > Int16.MaxValue) throw new OverflowException (); } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.ushort_type) { - if (in_checked_context){ + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: + if (in_checked_context) { if (Value < UInt16.MinValue || Value > UInt16.MaxValue) throw new OverflowException (); } - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.int32_type) { - if (in_checked_context){ + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + if (in_checked_context) { if (Value > Int32.MaxValue) throw new OverflowException (); } - return new IntConstant ((int) Value, Location); - } - if (target_type == TypeManager.int64_type) - return new LongConstant ((long) Value, Location); - if (target_type == TypeManager.uint64_type) - return new ULongConstant ((ulong) Value, Location); - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value < Char.MinValue || Value > Char.MaxValue) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } @@ -1225,17 +1305,15 @@ namespace Mono.CSharp { public class LongConstant : IntegralConstant { public readonly long Value; - public LongConstant (long v, Location loc): - base (loc) + public LongConstant (BuiltinTypes types, long v, Location loc) + : this (types.Long, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public LongConstant (TypeSpec type, long v, Location loc) + : base (type, loc) { - type = TypeManager.int64_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -1253,9 +1331,14 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return Value; + } + public override Constant Increment () { - return new LongConstant (checked(Value + 1), loc); + return new LongConstant (type, checked(Value + 1), loc); } public override bool IsDefaultValue { @@ -1282,94 +1365,86 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < Byte.MinValue || Value > Byte.MaxValue) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value < SByte.MinValue || Value > SByte.MaxValue) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value < Int16.MinValue || Value > Int16.MaxValue) throw new OverflowException (); } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.ushort_type) { - if (in_checked_context){ + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: + if (in_checked_context) { if (Value < UInt16.MinValue || Value > UInt16.MaxValue) throw new OverflowException (); } - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.int32_type) { - if (in_checked_context){ + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + if (in_checked_context) { if (Value < Int32.MinValue || Value > Int32.MaxValue) throw new OverflowException (); } - return new IntConstant ((int) Value, Location); - } - if (target_type == TypeManager.uint32_type) { - if (in_checked_context){ + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + if (in_checked_context) { if (Value < UInt32.MinValue || Value > UInt32.MaxValue) throw new OverflowException (); } - return new UIntConstant ((uint) Value, Location); - } - if (target_type == TypeManager.uint64_type) { + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) throw new OverflowException (); - return new ULongConstant ((ulong) Value, Location); - } - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value < Char.MinValue || Value > Char.MaxValue) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec type) + public override Constant ConvertImplicitly (TypeSpec type) { - if (Value >= 0 && type == TypeManager.uint64_type) { - return new ULongConstant ((ulong) Value, loc).Resolve (rc); + if (Value >= 0 && type.BuiltinType == BuiltinTypeSpec.Type.ULong) { + return new ULongConstant (type, (ulong) Value, loc); } - return base.ConvertImplicitly (rc, type); + return base.ConvertImplicitly (type); } } public class ULongConstant : IntegralConstant { public readonly ulong Value; - public ULongConstant (ulong v, Location loc): - base (loc) + public ULongConstant (BuiltinTypes types, ulong v, Location loc) + : this (types.ULong, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public ULongConstant (TypeSpec type, ulong v, Location loc) + : base (type, loc) { - type = TypeManager.uint64_type; - eclass = ExprClass.Value; - return this; + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -1387,9 +1462,14 @@ namespace Mono.CSharp { return Value; } + public override long GetValueAsLong () + { + return (long) Value; + } + public override Constant Increment () { - return new ULongConstant (checked(Value + 1), loc); + return new ULongConstant (type, checked(Value + 1), loc); } public override bool IsDefaultValue { @@ -1416,52 +1496,46 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: if (in_checked_context && Value > Byte.MaxValue) throw new OverflowException (); - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: if (in_checked_context && Value > ((ulong) SByte.MaxValue)) throw new OverflowException (); - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: if (in_checked_context && Value > ((ulong) Int16.MaxValue)) throw new OverflowException (); - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.ushort_type) { + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: if (in_checked_context && Value > UInt16.MaxValue) throw new OverflowException (); - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.int32_type) { + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: if (in_checked_context && Value > UInt32.MaxValue) throw new OverflowException (); - return new IntConstant ((int) Value, Location); - } - if (target_type == TypeManager.uint32_type) { - if (in_checked_context && Value > UInt32.MaxValue) + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + if (in_checked_context && Value > UInt32.MaxValue) throw new OverflowException (); - return new UIntConstant ((uint) Value, Location); - } - if (target_type == TypeManager.int64_type) { + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: if (in_checked_context && Value > Int64.MaxValue) throw new OverflowException (); - return new LongConstant ((long) Value, Location); - } - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: if (in_checked_context && Value > Char.MaxValue) throw new OverflowException (); - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } @@ -1469,19 +1543,20 @@ namespace Mono.CSharp { } public class FloatConstant : Constant { - public float Value; + public readonly float Value; - public FloatConstant (float v, Location loc): - base (loc) + public FloatConstant (BuiltinTypes types, float v, Location loc) + : this (types.Float, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public FloatConstant (TypeSpec type, float v, Location loc) + : base (loc) { - type = TypeManager.float_type; + this.type = type; eclass = ExprClass.Value; - return this; + + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -1504,6 +1579,11 @@ namespace Mono.CSharp { return Value.ToString (); } + public override long GetValueAsLong () + { + throw new NotSupportedException (); + } + public override bool IsDefaultValue { get { return Value == 0; @@ -1518,93 +1598,88 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < byte.MinValue || Value > byte.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value < sbyte.MinValue || Value > sbyte.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value < short.MinValue || Value > short.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.ushort_type) { - if (in_checked_context){ + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: + if (in_checked_context) { if (Value < ushort.MinValue || Value > ushort.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.int32_type) { - if (in_checked_context){ + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + if (in_checked_context) { if (Value < int.MinValue || Value > int.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new IntConstant ((int) Value, Location); - } - if (target_type == TypeManager.uint32_type) { - if (in_checked_context){ + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + if (in_checked_context) { if (Value < uint.MinValue || Value > uint.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new UIntConstant ((uint) Value, Location); - } - if (target_type == TypeManager.int64_type) { - if (in_checked_context){ + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + if (in_checked_context) { if (Value < long.MinValue || Value > long.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new LongConstant ((long) Value, Location); - } - if (target_type == TypeManager.uint64_type) { - if (in_checked_context){ + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: + if (in_checked_context) { if (Value < ulong.MinValue || Value > ulong.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new ULongConstant ((ulong) Value, Location); - } - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value < (float) char.MinValue || Value > (float) char.MaxValue || float.IsNaN (Value)) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } } - public class DoubleConstant : Constant { - public double Value; + public class DoubleConstant : Constant + { + public readonly double Value; - public DoubleConstant (double v, Location loc): - base (loc) + public DoubleConstant (BuiltinTypes types, double v, Location loc) + : this (types.Double, v, loc) { - Value = v; } - protected override Expression DoResolve (ResolveContext rc) + public DoubleConstant (TypeSpec type, double v, Location loc) + : base (loc) { - type = TypeManager.double_type; + this.type = type; eclass = ExprClass.Value; - return this; + + Value = v; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -1627,6 +1702,11 @@ namespace Mono.CSharp { return Value.ToString (); } + public override long GetValueAsLong () + { + throw new NotSupportedException (); + } + public override bool IsDefaultValue { get { return Value == 0; @@ -1641,73 +1721,66 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.byte_type) { - if (in_checked_context){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + if (in_checked_context) { if (Value < Byte.MinValue || Value > Byte.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new ByteConstant ((byte) Value, Location); - } - if (target_type == TypeManager.sbyte_type) { - if (in_checked_context){ + return new ByteConstant (target_type, (byte) Value, Location); + case BuiltinTypeSpec.Type.SByte: + if (in_checked_context) { if (Value < SByte.MinValue || Value > SByte.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new SByteConstant ((sbyte) Value, Location); - } - if (target_type == TypeManager.short_type) { - if (in_checked_context){ + return new SByteConstant (target_type, (sbyte) Value, Location); + case BuiltinTypeSpec.Type.Short: + if (in_checked_context) { if (Value < short.MinValue || Value > short.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new ShortConstant ((short) Value, Location); - } - if (target_type == TypeManager.ushort_type) { - if (in_checked_context){ + return new ShortConstant (target_type, (short) Value, Location); + case BuiltinTypeSpec.Type.UShort: + if (in_checked_context) { if (Value < ushort.MinValue || Value > ushort.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new UShortConstant ((ushort) Value, Location); - } - if (target_type == TypeManager.int32_type) { - if (in_checked_context){ + return new UShortConstant (target_type, (ushort) Value, Location); + case BuiltinTypeSpec.Type.Int: + if (in_checked_context) { if (Value < int.MinValue || Value > int.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new IntConstant ((int) Value, Location); - } - if (target_type == TypeManager.uint32_type) { - if (in_checked_context){ + return new IntConstant (target_type, (int) Value, Location); + case BuiltinTypeSpec.Type.UInt: + if (in_checked_context) { if (Value < uint.MinValue || Value > uint.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new UIntConstant ((uint) Value, Location); - } - if (target_type == TypeManager.int64_type) { - if (in_checked_context){ + return new UIntConstant (target_type, (uint) Value, Location); + case BuiltinTypeSpec.Type.Long: + if (in_checked_context) { if (Value < long.MinValue || Value > long.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new LongConstant ((long) Value, Location); - } - if (target_type == TypeManager.uint64_type) { - if (in_checked_context){ + return new LongConstant (target_type, (long) Value, Location); + case BuiltinTypeSpec.Type.ULong: + if (in_checked_context) { if (Value < ulong.MinValue || Value > ulong.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new ULongConstant ((ulong) Value, Location); - } - if (target_type == TypeManager.float_type) - return new FloatConstant ((float) Value, Location); - if (target_type == TypeManager.char_type) { - if (in_checked_context){ + return new ULongConstant (target_type, (ulong) Value, Location); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, Location); + case BuiltinTypeSpec.Type.Char: + if (in_checked_context) { if (Value < (double) char.MinValue || Value > (double) char.MaxValue || double.IsNaN (Value)) throw new OverflowException (); } - return new CharConstant ((char) Value, Location); + return new CharConstant (target_type, (char) Value, Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (target_type, (decimal) Value, Location); } - if (target_type == TypeManager.decimal_type) - return new DecimalConstant ((decimal) Value, Location); return null; } @@ -1717,60 +1790,47 @@ namespace Mono.CSharp { public class DecimalConstant : Constant { public readonly decimal Value; - public DecimalConstant (decimal d, Location loc): - base (loc) + public DecimalConstant (BuiltinTypes types, decimal d, Location loc) + : this (types.Decimal, d, loc) { - Value = d; } - protected override Expression DoResolve (ResolveContext rc) + public DecimalConstant (TypeSpec type, decimal d, Location loc) + : base (loc) { - type = TypeManager.decimal_type; + this.type = type; eclass = ExprClass.Value; - return this; - } - public override object GetValue () - { - return Value; - } - - public override string GetValueAsLiteral () - { - return Value.ToString () + "M"; + Value = d; } public override void Emit (EmitContext ec) { + MethodSpec m; + int [] words = decimal.GetBits (Value); int power = (words [3] >> 16) & 0xff; if (power == 0) { if (Value <= int.MaxValue && Value >= int.MinValue) { - if (TypeManager.void_decimal_ctor_int_arg == null) { - TypeManager.void_decimal_ctor_int_arg = TypeManager.GetPredefinedConstructor ( - TypeManager.decimal_type, loc, TypeManager.int32_type); - - if (TypeManager.void_decimal_ctor_int_arg == null) - return; + m = ec.Module.PredefinedMembers.DecimalCtorInt.Resolve (loc); + if (m == null) { + return; } ec.EmitInt ((int) Value); - ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_int_arg); + ec.Emit (OpCodes.Newobj, m); return; } if (Value <= long.MaxValue && Value >= long.MinValue) { - if (TypeManager.void_decimal_ctor_long_arg == null) { - TypeManager.void_decimal_ctor_long_arg = TypeManager.GetPredefinedConstructor ( - TypeManager.decimal_type, loc, TypeManager.int64_type); - - if (TypeManager.void_decimal_ctor_long_arg == null) - return; + m = ec.Module.PredefinedMembers.DecimalCtorLong.Resolve (loc); + if (m == null) { + return; } ec.EmitLong ((long) Value); - ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_long_arg); + ec.Emit (OpCodes.Newobj, m); return; } } @@ -1785,16 +1845,10 @@ namespace Mono.CSharp { // power ec.EmitInt (power); - if (TypeManager.void_decimal_ctor_five_args == null) { - TypeManager.void_decimal_ctor_five_args = TypeManager.GetPredefinedConstructor ( - TypeManager.decimal_type, loc, TypeManager.int32_type, TypeManager.int32_type, - TypeManager.int32_type, TypeManager.bool_type, TypeManager.byte_type); - - if (TypeManager.void_decimal_ctor_five_args == null) - return; + m = ec.Module.PredefinedMembers.DecimalCtor.Resolve (loc); + if (m != null) { + ec.Emit (OpCodes.Newobj, m); } - - ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_five_args); } public override bool IsDefaultValue { @@ -1811,48 +1865,65 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { - if (target_type == TypeManager.sbyte_type) - return new SByteConstant ((sbyte)Value, loc); - if (target_type == TypeManager.byte_type) - return new ByteConstant ((byte)Value, loc); - if (target_type == TypeManager.short_type) - return new ShortConstant ((short)Value, loc); - if (target_type == TypeManager.ushort_type) - return new UShortConstant ((ushort)Value, loc); - if (target_type == TypeManager.int32_type) - return new IntConstant ((int)Value, loc); - if (target_type == TypeManager.uint32_type) - return new UIntConstant ((uint)Value, loc); - if (target_type == TypeManager.int64_type) - return new LongConstant ((long)Value, loc); - if (target_type == TypeManager.uint64_type) - return new ULongConstant ((ulong)Value, loc); - if (target_type == TypeManager.char_type) - return new CharConstant ((char)Value, loc); - if (target_type == TypeManager.float_type) - return new FloatConstant ((float)Value, loc); - if (target_type == TypeManager.double_type) - return new DoubleConstant ((double)Value, loc); + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: + return new SByteConstant (target_type, (sbyte) Value, loc); + case BuiltinTypeSpec.Type.Byte: + return new ByteConstant (target_type, (byte) Value, loc); + case BuiltinTypeSpec.Type.Short: + return new ShortConstant (target_type, (short) Value, loc); + case BuiltinTypeSpec.Type.UShort: + return new UShortConstant (target_type, (ushort) Value, loc); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (target_type, (int) Value, loc); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (target_type, (uint) Value, loc); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (target_type, (long) Value, loc); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (target_type, (ulong) Value, loc); + case BuiltinTypeSpec.Type.Char: + return new CharConstant (target_type, (char) Value, loc); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (target_type, (float) Value, loc); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (target_type, (double) Value, loc); + } return null; } + public override object GetValue () + { + return Value; + } + + public override string GetValueAsLiteral () + { + return Value.ToString () + "M"; + } + + public override long GetValueAsLong () + { + throw new NotSupportedException (); + } } public class StringConstant : Constant { public readonly string Value; - public StringConstant (string s, Location loc): - base (loc) + public StringConstant (BuiltinTypes types, string s, Location loc) + : this (types.String, s, loc) { - Value = s; } - protected override Expression DoResolve (ResolveContext rc) + public StringConstant (TypeSpec type, string s, Location loc) + : base (loc) { - type = TypeManager.string_type; + this.type = type; eclass = ExprClass.Value; - return this; + + Value = s; } public override object GetValue () @@ -1865,6 +1936,11 @@ namespace Mono.CSharp { // FIXME: Escape the string. return "\"" + Value + "\""; } + + public override long GetValueAsLong () + { + throw new NotSupportedException (); + } public override void Emit (EmitContext ec) { @@ -1877,13 +1953,14 @@ namespace Mono.CSharp { // Use string.Empty for both literals and constants even if // it's not allowed at language level // - if (Value.Length == 0 && RootContext.Optimize && ec.CurrentType != TypeManager.string_type) { - if (TypeManager.string_empty == null) - TypeManager.string_empty = TypeManager.GetPredefinedField (TypeManager.string_type, "Empty", loc, TypeManager.string_type); - - if (TypeManager.string_empty != null) { - ec.Emit (OpCodes.Ldsfld, TypeManager.string_empty); - return; + if (Value.Length == 0 && ec.Module.Compiler.Settings.Optimize) { + var string_type = ec.BuiltinTypes.String; + if (ec.CurrentType != string_type) { + var m = ec.Module.PredefinedMembers.StringEmpty.Get (); + if (m != null) { + ec.Emit (OpCodes.Ldsfld, m); + return; + } } } @@ -1937,7 +2014,7 @@ namespace Mono.CSharp { public override Expression CreateExpressionTree (ResolveContext ec) { - if (type == InternalType.Null || type == TypeManager.object_type) { + if (type == InternalType.NullLiteral || type.BuiltinType == BuiltinTypeSpec.Type.Object) { // Optimized version, also avoids referencing literal internal type Arguments args = new Arguments (1); args.Add (new Argument (this)); @@ -1947,16 +2024,11 @@ namespace Mono.CSharp { return base.CreateExpressionTree (ec); } - protected override Expression DoResolve (ResolveContext ec) - { - return this; - } - public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) { // Type it as string cast - if (targetType == TypeManager.object_type || targetType == InternalType.Null) - enc.Encode (TypeManager.string_type); + if (targetType.BuiltinType == BuiltinTypeSpec.Type.Object) + enc.Encode (rc.Module.Compiler.BuiltinTypes.String); var ac = targetType as ArrayContainer; if (ac != null) { @@ -1974,7 +2046,7 @@ namespace Mono.CSharp { ec.Emit (OpCodes.Ldnull); // Only to make verifier happy - if (TypeManager.IsGenericParameter (type)) + if (type.IsGenericParameter) ec.Emit (OpCodes.Unbox_Any, type); } @@ -1988,13 +2060,13 @@ namespace Mono.CSharp { { if (targetType.IsPointer) { if (IsLiteral || this is NullPointer) - return new EmptyConstantCast (new NullPointer (loc), targetType); + return new NullPointer (targetType, loc); return null; } // Exlude internal compiler types - if (targetType.Kind == MemberKind.InternalCompilerType && targetType != InternalType.Dynamic && targetType != InternalType.Null) + if (targetType.Kind == MemberKind.InternalCompilerType && targetType.BuiltinType != BuiltinTypeSpec.Type.Dynamic) return null; if (!IsLiteral && !Convert.ImplicitStandardConversionExists (this, targetType)) @@ -2003,13 +2075,13 @@ namespace Mono.CSharp { if (TypeManager.IsReferenceType (targetType)) return new NullConstant (targetType, loc); - if (TypeManager.IsNullableType (targetType)) + if (targetType.IsNullableType) return Nullable.LiftedNull.Create (targetType, loc); return null; } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec targetType) + public override Constant ConvertImplicitly (TypeSpec targetType) { return ConvertExplicitly (false, targetType); } @@ -2029,6 +2101,11 @@ namespace Mono.CSharp { return GetSignatureForError (); } + public override long GetValueAsLong () + { + throw new NotSupportedException (); + } + public override bool IsDefaultValue { get { return true; } } @@ -2046,32 +2123,54 @@ namespace Mono.CSharp { } } + + // + // A null constant in a pointer context + // + class NullPointer : NullConstant + { + public NullPointer (TypeSpec type, Location loc) + : base (type, loc) + { + } + + public override Expression CreateExpressionTree (ResolveContext ec) + { + Error_PointerInsideExpressionTree (ec); + return base.CreateExpressionTree (ec); + } + + public override void Emit (EmitContext ec) + { + // + // Emits null pointer + // + ec.Emit (OpCodes.Ldc_I4_0); + ec.Emit (OpCodes.Conv_U); + } + } + /// /// The value is constant, but when emitted has a side effect. This is /// used by BitwiseAnd to ensure that the second expression is invoked /// regardless of the value of the left side. /// public class SideEffectConstant : Constant { - public Constant value; + public readonly Constant value; Expression side_effect; - public SideEffectConstant (Constant value, Expression side_effect, Location loc) : base (loc) + public SideEffectConstant (Constant value, Expression side_effect, Location loc) + : base (loc) { this.value = value; + type = value.Type; + eclass = ExprClass.Value; + while (side_effect is SideEffectConstant) side_effect = ((SideEffectConstant) side_effect).side_effect; this.side_effect = side_effect; } - protected override Expression DoResolve (ResolveContext rc) - { - value = value.Resolve (rc); - - type = value.Type; - eclass = ExprClass.Value; - return this; - } - public override object GetValue () { return value.GetValue (); @@ -2082,6 +2181,11 @@ namespace Mono.CSharp { return value.GetValueAsLiteral (); } + public override long GetValueAsLong () + { + return value.GetValueAsLong (); + } + public override void Emit (EmitContext ec) { side_effect.EmitSideEffect (ec); @@ -2109,7 +2213,13 @@ namespace Mono.CSharp { public override Constant ConvertExplicitly (bool in_checked_context, TypeSpec target_type) { Constant new_value = value.ConvertExplicitly (in_checked_context, target_type); - return new_value == null ? null : new SideEffectConstant (new_value, side_effect, new_value.Location); + if (new_value == null) + return null; + + var c = new SideEffectConstant (new_value, side_effect, new_value.Location); + c.type = target_type; + c.eclass = eclass; + return c; } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs index ef19e4e57..7715ce3d7 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; +using System.IO; #if STATIC using IKVM.Reflection.Emit; @@ -24,7 +25,7 @@ namespace Mono.CSharp // Implemented by elements which can act as independent contexts // during resolve phase. Used mostly for lookups. // - public interface IMemberContext + public interface IMemberContext : IModuleContext { // // A scope type context, it can be inflated for generic types @@ -48,16 +49,17 @@ namespace Mono.CSharp bool IsUnsafe { get; } bool IsStatic { get; } bool HasUnresolvedConstraints { get; } - ModuleContainer Module { get; } string GetSignatureForError (); IList LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope); FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104); FullNamedExpression LookupNamespaceAlias (string name); + } - // TODO: It has been replaced by module - CompilerContext Compiler { get; } + public interface IModuleContext + { + ModuleContainer Module { get; } } // @@ -352,7 +354,7 @@ namespace Mono.CSharp // // The default setting comes from the command line option // - if (RootContext.Checked) + if (mc.Module.Compiler.Settings.Checked) flags |= Options.CheckedScope; // @@ -367,8 +369,12 @@ namespace Mono.CSharp flags |= options; } - public CompilerContext Compiler { - get { return MemberContext.Compiler; } + #region Properties + + public BuiltinTypes BuiltinTypes { + get { + return MemberContext.Module.Compiler.BuiltinTypes; + } } public virtual ExplicitBlock ConstructorBlock { @@ -413,7 +419,34 @@ namespace Mono.CSharp } public bool IsInProbingMode { - get { return (flags & Options.ProbingMode) != 0; } + get { + return (flags & Options.ProbingMode) != 0; + } + } + + public bool IsObsolete { + get { + // Disables obsolete checks when probing is on + return MemberContext.IsObsolete; + } + } + + public bool IsStatic { + get { + return MemberContext.IsStatic; + } + } + + public bool IsUnsafe { + get { + return HasSet (Options.UnsafeScope) || MemberContext.IsUnsafe; + } + } + + public bool IsRuntimeBinder { + get { + return Module.Compiler.IsRuntimeBinder; + } } public bool IsVariableCapturingRequired { @@ -432,6 +465,14 @@ namespace Mono.CSharp get { return (flags & Options.OmitStructFlowAnalysis) != 0; } } + public Report Report { + get { + return Module.Compiler.Report; + } + } + + #endregion + public bool MustCaptureVariable (INamedBlockVariable local) { if (CurrentAnonymousMethod == null) @@ -455,11 +496,6 @@ namespace Mono.CSharp return (this.flags & options) != 0; } - public Report Report { - get { - return Compiler.Report; - } - } // Temporarily set all the given flags to the given value. Should be used in an 'using' statement public FlagsHandle Set (Options options) @@ -479,21 +515,6 @@ namespace Mono.CSharp return MemberContext.GetSignatureForError (); } - public bool IsObsolete { - get { - // Disables obsolete checks when probing is on - return MemberContext.IsObsolete; - } - } - - public bool IsStatic { - get { return MemberContext.IsStatic; } - } - - public bool IsUnsafe { - get { return HasSet (Options.UnsafeScope) || MemberContext.IsUnsafe; } - } - public IList LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope) { return MemberContext.LookupExtensionMethod (extensionType, name, arity, ref scope); @@ -557,24 +578,35 @@ namespace Mono.CSharp // public class CompilerContext { + static readonly TimeReporter DisabledTimeReporter = new TimeReporter (false); + readonly Report report; - readonly BuildinTypes buildin_types; + readonly BuiltinTypes builtin_types; + readonly CompilerSettings settings; + + Dictionary all_source_files; - public CompilerContext (Report report) + public CompilerContext (CompilerSettings settings, Report report) { + this.settings = settings; this.report = report; - this.buildin_types = new BuildinTypes (); + this.builtin_types = new BuiltinTypes (); + this.TimeReporter = DisabledTimeReporter; } #region Properties - public BuildinTypes BuildinTypes { + public BuiltinTypes BuiltinTypes { get { - return buildin_types; + return builtin_types; } } - public bool IsRuntimeBinder { get; set; } + // Used for special handling of runtime dynamic context mostly + // by error reporting but also by member accessibility checks + public bool IsRuntimeBinder { + get; set; + } public Report Report { get { @@ -582,9 +614,51 @@ namespace Mono.CSharp } } - internal TimeReporter TimeReporter { get; set; } + public CompilerSettings Settings { + get { + return settings; + } + } + + public List SourceFiles { + get { + return settings.SourceFiles; + } + } + + internal TimeReporter TimeReporter { + get; set; + } #endregion + + // + // This is used when we encounter a #line preprocessing directive during parsing + // to register additional source file names + // + public SourceFile LookupFile (CompilationSourceFile comp_unit, string name) + { + if (all_source_files == null) { + all_source_files = new Dictionary (); + foreach (var source in SourceFiles) + all_source_files[source.FullPathName] = source; + } + + string path; + if (!Path.IsPathRooted (name)) { + string root = Path.GetDirectoryName (comp_unit.FullPathName); + path = Path.Combine (root, name); + } else + path = name; + + SourceFile retval; + if (all_source_files.TryGetValue (path, out retval)) + return retval; + + retval = Location.AddFile (name, path); + all_source_files.Add (path, retval); + return retval; + } } // diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs index 33a161196..8a523a1ed 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs @@ -24,20 +24,8 @@ namespace Mono.CSharp { // // A container class for all the conversion operations // - static class Convert { - - static EmptyExpression MyEmptyExpr; - - static Convert () - { - Reset (); - } - - public static void Reset () - { - MyEmptyExpr = null; - } - + static class Convert + { // // From a one-dimensional array-type S[] to System.Collections.IList and base // interfaces of this interface, provided there is an implicit reference conversion @@ -45,13 +33,7 @@ namespace Mono.CSharp { // static bool ArrayToIList (ArrayContainer array, TypeSpec list, bool isExplicit) { - if (array.Rank != 1 || !list.IsGeneric) - return false; - - var open_version = list.GetDefinition (); - if ((open_version != TypeManager.generic_ilist_type) && - (open_version != TypeManager.generic_icollection_type) && - (open_version != TypeManager.generic_ienumerable_type)) + if (array.Rank != 1 || !list.IsGenericIterateInterface) return false; var arg_type = list.TypeArguments[0]; @@ -61,52 +43,36 @@ namespace Mono.CSharp { if (isExplicit) return ExplicitReferenceConversionExists (array.Element, arg_type); - if (MyEmptyExpr == null) - MyEmptyExpr = new EmptyExpression (array.Element); - else - MyEmptyExpr.SetType (array.Element); - - return ImplicitReferenceConversionExists (MyEmptyExpr, arg_type); + return ImplicitReferenceConversionExists (array.Element, arg_type); } static bool IList_To_Array(TypeSpec list, ArrayContainer array) { - if (array.Rank != 1 || !list.IsGeneric) - return false; - - var open_version = list.GetDefinition (); - if ((open_version != TypeManager.generic_ilist_type) && - (open_version != TypeManager.generic_icollection_type) && - (open_version != TypeManager.generic_ienumerable_type)) + if (array.Rank != 1 || !list.IsGenericIterateInterface) return false; var arg_type = list.TypeArguments[0]; if (array.Element == arg_type) return true; - if (MyEmptyExpr == null) - MyEmptyExpr = new EmptyExpression (array.Element); - else - MyEmptyExpr.SetType (array.Element); - - return ImplicitReferenceConversionExists (MyEmptyExpr, arg_type) || ExplicitReferenceConversionExists (array.Element, arg_type); + return ImplicitReferenceConversionExists (array.Element, arg_type) || ExplicitReferenceConversionExists (array.Element, arg_type); } - public static Expression ImplicitTypeParameterConversion (Expression expr, TypeSpec target_type) + public static Expression ImplicitTypeParameterConversion (Expression expr, TypeParameterSpec expr_type, TypeSpec target_type) { - var expr_type = (TypeParameterSpec) expr.Type; - // // From T to a type parameter U, provided T depends on U // - var ttype = target_type as TypeParameterSpec; - if (ttype != null) { + if (target_type.IsGenericParameter) { if (expr_type.TypeArguments != null) { foreach (var targ in expr_type.TypeArguments) { - if (!TypeSpecComparer.Override.IsEqual (ttype, targ)) + if (!TypeSpecComparer.Override.IsEqual (target_type, targ)) continue; - if (expr_type.IsReferenceType && !ttype.IsReferenceType) + if (expr == null) + return EmptyExpression.Null; + + if (expr_type.IsReferenceType && !((TypeParameterSpec)target_type).IsReferenceType) return new BoxedCast (expr, target_type); return new ClassCast (expr, target_type); @@ -119,7 +85,10 @@ namespace Mono.CSharp { // // LAMESPEC: From T to dynamic type because it's like T to object // - if (target_type == InternalType.Dynamic) { + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { + if (expr == null) + return EmptyExpression.Null; + if (expr_type.IsReferenceType) return new ClassCast (expr, target_type); @@ -128,11 +97,14 @@ namespace Mono.CSharp { // // From T to its effective base class C - // From T to any base class of C (it cannot contain dynamic of be of dynamic type) + // From T to any base class of C (it cannot contain dynamic or be of dynamic type) // From T to any interface implemented by C // var base_type = expr_type.GetEffectiveBase (); if (base_type == target_type || TypeSpec.IsBaseClass (base_type, target_type, false) || base_type.ImplementsInterface (target_type, true)) { + if (expr == null) + return EmptyExpression.Null; + if (expr_type.IsReferenceType) return new ClassCast (expr, target_type); @@ -140,6 +112,9 @@ namespace Mono.CSharp { } if (target_type.IsInterface && expr_type.IsConvertibleToInterface (target_type)) { + if (expr == null) + return EmptyExpression.Null; + if (expr_type.IsReferenceType) return new ClassCast (expr, target_type); @@ -191,21 +166,18 @@ namespace Mono.CSharp { expr.Emit (null); } - if (expr_type == TypeManager.void_type) - return null; - if (expr_type.Kind == MemberKind.TypeParameter) - return ImplicitTypeParameterConversion (expr, target_type); + return ImplicitTypeParameterConversion (expr, (TypeParameterSpec) expr.Type, target_type); // // from the null type to any reference-type. // NullLiteral nl = expr as NullLiteral; if (nl != null) { - return nl.ConvertImplicitly (null, target_type); + return nl.ConvertImplicitly (target_type); } - if (ImplicitReferenceConversionExists (expr, target_type)) { + if (ImplicitReferenceConversionExists (expr_type, target_type)) { // // Avoid wrapping implicitly convertible reference type // @@ -221,19 +193,17 @@ namespace Mono.CSharp { // // 6.1.6 Implicit reference conversions // - public static bool ImplicitReferenceConversionExists (Expression expr, TypeSpec target_type) + public static bool ImplicitReferenceConversionExists (TypeSpec expr_type, TypeSpec target_type) { - if (TypeManager.IsStruct (target_type)) + if (target_type.IsStruct) return false; - TypeSpec expr_type = expr.Type; - // from the null type to any reference-type. - if (expr_type == InternalType.Null) - return target_type != InternalType.AnonymousMethod; + if (expr_type == InternalType.NullLiteral) + return true; - if (TypeManager.IsGenericParameter (expr_type)) - return ImplicitTypeParameterConversion (expr, target_type) != null; + if (expr_type.IsGenericParameter) + return ImplicitTypeParameterConversion (null, (TypeParameterSpec) expr_type, target_type) != null; // This code is kind of mirrored inside ImplicitStandardConversionExists // with the small distinction that we only probe there @@ -250,7 +220,7 @@ namespace Mono.CSharp { // // Implicit reference conversions (no-boxing) to object or dynamic // - if (target_type == TypeManager.object_type || target_type == InternalType.Dynamic) { + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object || target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { switch (expr_type.Kind) { case MemberKind.Class: case MemberKind.Interface: @@ -259,18 +229,11 @@ namespace Mono.CSharp { return true; } - return expr_type == InternalType.Dynamic; + return expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; } - if (target_type == TypeManager.value_type) { - return expr_type == TypeManager.enum_type; - } else if (expr_type == target_type || TypeSpec.IsBaseClass (expr_type, target_type, true)) { - // - // Special case: enumeration to System.Enum. - // System.Enum is not a value type, it is a class, so we need - // a boxing conversion - // - if (target_type == TypeManager.enum_type || TypeManager.IsGenericParameter (expr_type)) + if (expr_type == target_type || TypeSpec.IsBaseClass (expr_type, target_type, true)) { + if (TypeManager.IsGenericParameter (expr_type)) return false; if (TypeManager.IsValueType (expr_type)) @@ -300,16 +263,14 @@ namespace Mono.CSharp { if (!TypeManager.IsReferenceType (target_element_type)) return false; - if (MyEmptyExpr == null) - MyEmptyExpr = new EmptyExpression (expr_element_type); - else - MyEmptyExpr.SetType (expr_element_type); - - return ImplicitStandardConversionExists (MyEmptyExpr, target_element_type); + // + // An implicit reference conversion exists from SE to TE + // + return ImplicitReferenceConversionExists (expr_element_type, target_element_type); } // from an array-type to System.Array - if (target_type == TypeManager.array_type) + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Array) return true; // from an array-type of type T to IList @@ -331,8 +292,8 @@ namespace Mono.CSharp { } // from any delegate type to System.Delegate - if (target_type == TypeManager.delegate_type && - (expr_type == TypeManager.delegate_type || expr_type.IsDelegate)) + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Delegate && + (expr_type.BuiltinType == BuiltinTypeSpec.Type.Delegate || expr_type.IsDelegate)) return true; return false; @@ -340,10 +301,12 @@ namespace Mono.CSharp { public static Expression ImplicitBoxingConversion (Expression expr, TypeSpec expr_type, TypeSpec target_type) { + switch (target_type.BuiltinType) { // // From any value-type to the type object. // - if (target_type == TypeManager.object_type || target_type == InternalType.Dynamic) { + case BuiltinTypeSpec.Type.Object: + case BuiltinTypeSpec.Type.Dynamic: // // A pointer type cannot be converted to object // @@ -354,31 +317,31 @@ namespace Mono.CSharp { return null; return expr == null ? EmptyExpression.Null : new BoxedCast (expr, target_type); - } - + // // From any value-type to the type System.ValueType. // - if (target_type == TypeManager.value_type) { + case BuiltinTypeSpec.Type.ValueType: if (!TypeManager.IsValueType (expr_type)) return null; return expr == null ? EmptyExpression.Null : new BoxedCast (expr, target_type); - } - if (target_type == TypeManager.enum_type) { + case BuiltinTypeSpec.Type.Enum: // // From any enum-type to the type System.Enum. // - if (TypeManager.IsEnumType (expr_type)) + if (expr_type.IsEnum) return expr == null ? EmptyExpression.Null : new BoxedCast (expr, target_type); + + break; } // // From a nullable-type to a reference type, if a boxing conversion exists from // the underlying type to the reference type // - if (TypeManager.IsNullableType (expr_type)) { + if (expr_type.IsNullableType) { if (!TypeManager.IsReferenceType (target_type)) return null; @@ -425,14 +388,14 @@ namespace Mono.CSharp { // // From null to any nullable type // - if (expr_type == InternalType.Null) + if (expr_type == InternalType.NullLiteral) return ec == null ? EmptyExpression.Null : Nullable.LiftedNull.Create (target_type, expr.Location); // S -> T? TypeSpec t_el = Nullable.NullableInfo.GetUnderlyingType (target_type); // S? -> T? - if (TypeManager.IsNullableType (expr_type)) + if (expr_type.IsNullableType) expr_type = Nullable.NullableInfo.GetUnderlyingType (expr_type); // @@ -446,7 +409,7 @@ namespace Mono.CSharp { return EmptyExpression.Null; if (expr is Constant) - return ((Constant) expr).ConvertImplicitly (ec, t_el); + return ((Constant) expr).ConvertImplicitly (t_el); return ImplicitNumericConversion (null, expr_type, t_el); } @@ -460,7 +423,7 @@ namespace Mono.CSharp { Expression conv = unwrap; if (!TypeSpecComparer.IsEqual (expr_type, t_el)) { if (conv is Constant) - conv = ((Constant)conv).ConvertImplicitly (ec, t_el); + conv = ((Constant)conv).ConvertImplicitly (t_el); else conv = ImplicitNumericConversion (conv, expr_type, t_el); @@ -487,143 +450,173 @@ namespace Mono.CSharp { static Expression ImplicitNumericConversion (Expression expr, TypeSpec expr_type, TypeSpec target_type) { - if (expr_type == TypeManager.sbyte_type){ + switch (expr_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: // // From sbyte to short, int, long, float, double, decimal // - if (target_type == TypeManager.int32_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I4); - if (target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I8); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I2); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.byte_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + + } + + break; + case BuiltinTypeSpec.Type.Byte: // // From byte to short, ushort, int, uint, long, ulong, float, double, decimal // - if (target_type == TypeManager.int32_type || target_type == TypeManager.uint32_type || - target_type == TypeManager.short_type || target_type == TypeManager.ushort_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: return expr == null ? EmptyExpression.Null : EmptyCast.Create (expr, target_type); - - if (target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_U8); - if (target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - - } else if (expr_type == TypeManager.short_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.Short: // // From short to int, long, float, double, decimal // - if (target_type == TypeManager.int32_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: return expr == null ? EmptyExpression.Null : EmptyCast.Create (expr, target_type); - if (target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I8); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - - } else if (expr_type == TypeManager.ushort_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.UShort: // // From ushort to int, uint, long, ulong, float, double, decimal // - if (target_type == TypeManager.int32_type || target_type == TypeManager.uint32_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: return expr == null ? EmptyExpression.Null : EmptyCast.Create (expr, target_type); - - if (target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_U8); - if (target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I8); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.int32_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.Int: // // From int to long, float, double, decimal // - if (target_type == TypeManager.int64_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I8); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.uint32_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.UInt: // // From uint to long, ulong, float, double, decimal // - if (target_type == TypeManager.int64_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_U8); - if (target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_U8); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCastDuplex (expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCastDuplex (expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R4); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.int64_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.Long: // - // From long/ulong to float, double + // From long to float, double, decimal // - if (target_type == TypeManager.double_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.uint64_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.ULong: // - // From ulong to float, double + // From ulong to float, double, decimal // - if (target_type == TypeManager.double_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCastDuplex (expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCastDuplex (expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R4); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.char_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.Char: // // From char to ushort, int, uint, long, ulong, float, double, decimal // - if ((target_type == TypeManager.ushort_type) || - (target_type == TypeManager.int32_type) || - (target_type == TypeManager.uint32_type)) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: return expr == null ? EmptyExpression.Null : EmptyCast.Create (expr, target_type); - if (target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_U8); - if (target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_I8); - if (target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.double_type) + case BuiltinTypeSpec.Type.Double: return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); - if (target_type == TypeManager.decimal_type) - return expr == null ? EmptyExpression.Null : new CastToDecimal (expr); - } else if (expr_type == TypeManager.float_type){ + case BuiltinTypeSpec.Type.Decimal: + return expr == null ? EmptyExpression.Null : new OperatorCast (expr, target_type); + } + break; + case BuiltinTypeSpec.Type.Float: // // float to double // - if (target_type == TypeManager.double_type) + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Double) return expr == null ? EmptyExpression.Null : new OpcodeCast (expr, target_type, OpCodes.Conv_R8); + break; } return null; @@ -639,7 +632,7 @@ namespace Mono.CSharp { return true; if (expr.Type == InternalType.AnonymousMethod) { - if (!TypeManager.IsDelegateType (target_type) && target_type.GetDefinition () != TypeManager.expression_type) + if (!target_type.IsDelegate && !target_type.IsExpressionTreeType) return false; AnonymousMethodExpression ame = (AnonymousMethodExpression) expr; @@ -647,7 +640,7 @@ namespace Mono.CSharp { } if (expr.eclass == ExprClass.MethodGroup) { - if (target_type.IsDelegate && RootContext.Version != LanguageVersion.ISO_1) { + if (target_type.IsDelegate && ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1) { MethodGroupExpr mg = expr as MethodGroupExpr; if (mg != null) return DelegateCreation.ImplicitStandardConversionExists (ec, mg, target_type); @@ -656,6 +649,10 @@ namespace Mono.CSharp { return false; } + // Conversion from __arglist to System.ArgIterator + if (expr.Type == InternalType.Arglist) + return target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec; + return ImplicitUserConversion (ec, expr, target_type, Location.Null) != null; } @@ -670,16 +667,13 @@ namespace Mono.CSharp { NullLiteral nl = expr as NullLiteral; if (nl != null) - return nl.ConvertImplicitly (null, target_type) != null; - - if (expr_type == TypeManager.void_type) - return false; + return nl.ConvertImplicitly (target_type) != null; if (expr_type == target_type) return true; // Implicit dynamic conversion - if (expr_type == InternalType.Dynamic) { + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { switch (target_type.Kind) { case MemberKind.ArrayType: case MemberKind.Class: @@ -698,7 +692,7 @@ namespace Mono.CSharp { return false; } - if (TypeManager.IsNullableType (target_type)) { + if (target_type.IsNullableType) { return ImplicitNulableConversion (null, expr, target_type) != null; } @@ -706,7 +700,7 @@ namespace Mono.CSharp { if (ImplicitNumericConversion (null, expr_type, target_type) != null) return true; - if (ImplicitReferenceConversionExists (expr, target_type)) + if (ImplicitReferenceConversionExists (expr_type, target_type)) return true; if (ImplicitBoxingConversion (null, expr_type, target_type) != null) @@ -717,23 +711,28 @@ namespace Mono.CSharp { // if (expr is IntConstant){ int value = ((IntConstant) expr).Value; - - if (target_type == TypeManager.sbyte_type){ + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: if (value >= SByte.MinValue && value <= SByte.MaxValue) return true; - } else if (target_type == TypeManager.byte_type){ + break; + case BuiltinTypeSpec.Type.Byte: if (value >= 0 && value <= Byte.MaxValue) return true; - } else if (target_type == TypeManager.short_type){ + break; + case BuiltinTypeSpec.Type.Short: if (value >= Int16.MinValue && value <= Int16.MaxValue) return true; - } else if (target_type == TypeManager.ushort_type){ + break; + case BuiltinTypeSpec.Type.UShort: if (value >= UInt16.MinValue && value <= UInt16.MaxValue) return true; - } else if (target_type == TypeManager.uint32_type){ + break; + case BuiltinTypeSpec.Type.UInt: if (value >= 0) return true; - } else if (target_type == TypeManager.uint64_type){ + break; + case BuiltinTypeSpec.Type.ULong: // // we can optimize this case: a positive int32 // always fits on a uint64. But we need an opcode @@ -741,10 +740,12 @@ namespace Mono.CSharp { // if (value >= 0) return true; + + break; } } - if (expr is LongConstant && target_type == TypeManager.uint64_type){ + if (expr is LongConstant && target_type.BuiltinType == BuiltinTypeSpec.Type.ULong){ // // Try the implicit constant expression conversion // from long to ulong, instead of a nice routine, @@ -755,7 +756,7 @@ namespace Mono.CSharp { return true; } - if (expr is IntegralConstant && TypeManager.IsEnumType (target_type)) { + if (expr is IntegralConstant && target_type.IsEnum) { var i = (IntegralConstant) expr; // // LAMESPEC: csc allows any constant like 0 values to be converted, including const float f = 0.0 @@ -774,13 +775,9 @@ namespace Mono.CSharp { if (target_type.IsInterface && expr_type.ImplementsInterface (target_type, true)) return true; - if (target_type.IsPointer && expr_type.IsPointer && ((PointerContainer) target_type).Element.BuildinType == BuildinTypeSpec.Type.Void) + if (target_type.IsPointer && expr_type.IsPointer && ((PointerContainer) target_type).Element.Kind == MemberKind.Void) return true; - // Conversion from __arglist to System.ArgIterator - if (expr_type == InternalType.Arglist) - return target_type == TypeManager.arg_iterator_type; - if (TypeSpecComparer.IsEqual (expr_type, target_type)) return true; @@ -794,7 +791,7 @@ namespace Mono.CSharp { public static TypeSpec FindMostEncompassedType (IEnumerable types) { TypeSpec best = null; - EmptyExpression expr = EmptyExpression.Grab (); + EmptyExpression expr; foreach (TypeSpec t in types) { if (best == null) { @@ -802,12 +799,12 @@ namespace Mono.CSharp { continue; } - expr.SetType (t); + expr = new EmptyExpression (t); if (ImplicitStandardConversionExists (expr, best)) best = t; } - expr.SetType (best); + expr = new EmptyExpression (best); foreach (TypeSpec t in types) { if (best == t) continue; @@ -817,8 +814,6 @@ namespace Mono.CSharp { } } - EmptyExpression.Release (expr); - return best; } @@ -836,15 +831,13 @@ namespace Mono.CSharp { if (types.Count == 1) return types [0]; - EmptyExpression expr = EmptyExpression.Grab (); - foreach (TypeSpec t in types) { if (best == null) { best = t; continue; } - expr.SetType (best); + var expr = new EmptyExpression (best); if (ImplicitStandardConversionExists (expr, t)) best = t; } @@ -852,15 +845,14 @@ namespace Mono.CSharp { foreach (TypeSpec t in types) { if (best == t) continue; - expr.SetType (t); + + var expr = new EmptyExpression (best); if (!ImplicitStandardConversionExists (expr, best)) { best = null; break; } } - EmptyExpression.Release (expr); - return best; } @@ -934,17 +926,13 @@ namespace Mono.CSharp { if (apply_explicit_conv_rules) { var candidate_set = new List (); - EmptyExpression expr = EmptyExpression.Grab (); - - foreach (TypeSpec ret_type in tgt_types_set){ - expr.SetType (ret_type); + foreach (TypeSpec ret_type in tgt_types_set) { + var expr = new EmptyExpression (ret_type); if (ImplicitStandardConversionExists (expr, target)) candidate_set.Add (ret_type); } - EmptyExpression.Release (expr); - if (candidate_set.Count != 0) return FindMostEncompassingType (candidate_set); } @@ -976,22 +964,10 @@ namespace Mono.CSharp { static void FindApplicableUserDefinedConversionOperators (IList operators, Expression source, TypeSpec target, bool implicitOnly, ref List candidates) { - // - // LAMESPEC: Undocumented IntPtr/UIntPtr conversions - // IntPtr -> uint uses int - // UIntPtr -> long uses ulong - // - if (source.Type == TypeManager.intptr_type) { - if (target == TypeManager.uint32_type) - target = TypeManager.int32_type; - } else if (source.Type == TypeManager.uintptr_type) { - if (target == TypeManager.int64_type) - target = TypeManager.uint64_type; - } - - // Neither A nor B are interface-types - if (source.Type.IsInterface) + if (source.Type.IsInterface) { + // Neither A nor B are interface-types return; + } // For a conversion operator to be applicable, it must be possible // to perform a standard conversion from the source type to @@ -1018,15 +994,11 @@ namespace Mono.CSharp { t = op.ReturnType; - // LAMESPEC: Exclude UIntPtr -> int conversion - if (t == TypeManager.uint32_type && source.Type == TypeManager.uintptr_type) - continue; - if (t.IsInterface) continue; if (target != t) { - if (TypeManager.IsNullableType (t)) + if (t.IsNullableType) t = Nullable.NullableInfo.GetUnderlyingType (t); if (!ImplicitStandardConversionExists (new EmptyExpression (t), target)) { @@ -1063,9 +1035,9 @@ namespace Mono.CSharp { TypeSpec target_type = target; Expression source_type_expr; - if (TypeManager.IsNullableType (source_type)) { + if (source_type.IsNullableType) { // No implicit conversion S? -> T for non-reference types - if (implicitOnly && !TypeManager.IsReferenceType (target_type) && !TypeManager.IsNullableType (target_type)) + if (implicitOnly && !TypeManager.IsReferenceType (target_type) && !target_type.IsNullableType) return null; source_type_expr = Nullable.Unwrap.Create (source); @@ -1074,13 +1046,13 @@ namespace Mono.CSharp { source_type_expr = source; } - if (TypeManager.IsNullableType (target_type)) + if (target_type.IsNullableType) target_type = Nullable.NullableInfo.GetUnderlyingType (target_type); // Only these containers can contain a user defined implicit or explicit operators const MemberKind user_conversion_kinds = MemberKind.Class | MemberKind.Struct | MemberKind.TypeParameter; - if ((source_type.Kind & user_conversion_kinds) != 0 && source_type != TypeManager.decimal_type) { + if ((source_type.Kind & user_conversion_kinds) != 0 && source_type.BuiltinType != BuiltinTypeSpec.Type.Decimal) { bool declared_only = source_type.IsStruct; var operators = MemberCache.GetUserOperator (source_type, Operator.OpType.Implicit, declared_only); @@ -1096,7 +1068,7 @@ namespace Mono.CSharp { } } - if ((target.Kind & user_conversion_kinds) != 0 && target_type != TypeManager.decimal_type) { + if ((target.Kind & user_conversion_kinds) != 0 && target_type.BuiltinType != BuiltinTypeSpec.Type.Decimal) { bool declared_only = target.IsStruct || implicitOnly; var operators = MemberCache.GetUserOperator (target_type, Operator.OpType.Implicit, declared_only); @@ -1186,7 +1158,7 @@ namespace Mono.CSharp { // // User operator is of T?, no need to lift it // - if (TypeManager.IsNullableType (t_x) && t_x == target) + if (t_x == target && t_x.IsNullableType) return source; source = implicitOnly ? @@ -1201,7 +1173,7 @@ namespace Mono.CSharp { // Source expression is of nullable type, lift the result in the case it's null and // not nullable/lifted user operator is used // - if (source_type_expr is Nullable.Unwrap && !TypeManager.IsNullableType (s_x) && (TypeManager.IsReferenceType (target) || target_type != target)) + if (source_type_expr is Nullable.Unwrap && !s_x.IsNullableType && (TypeManager.IsReferenceType (target) || target_type != target)) source = new Nullable.Lifted (source, source_type_expr, target).Resolve (ec); else if (target_type != target) source = Nullable.Wrap.Create (source, target); @@ -1260,7 +1232,7 @@ namespace Mono.CSharp { // // Only allow anonymous method conversions on post ISO_1 // - if (RootContext.Version != LanguageVersion.ISO_1){ + if (ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1){ MethodGroupExpr mg = expr as MethodGroupExpr; if (mg != null) return ImplicitDelegateCreation.Create ( @@ -1272,25 +1244,20 @@ namespace Mono.CSharp { Expression e; if (expr_type == target_type) { - if (expr_type != InternalType.Null && expr_type != InternalType.AnonymousMethod) + if (expr_type != InternalType.NullLiteral && expr_type != InternalType.AnonymousMethod) return expr; return null; } - if (expr_type == InternalType.Dynamic) { + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { switch (target_type.Kind) { case MemberKind.ArrayType: case MemberKind.Class: - if (target_type == TypeManager.object_type) + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object) return EmptyCast.Create (expr, target_type); goto case MemberKind.Struct; case MemberKind.Struct: - // TODO: Should really introduce MemberKind.Void - if (target_type == TypeManager.void_type) - return null; - - goto case MemberKind.Enum; case MemberKind.Delegate: case MemberKind.Enum: case MemberKind.Interface: @@ -1303,7 +1270,7 @@ namespace Mono.CSharp { return null; } - if (TypeManager.IsNullableType (target_type)) + if (target_type.IsNullableType) return ImplicitNulableConversion (ec, expr, target_type); // @@ -1312,7 +1279,7 @@ namespace Mono.CSharp { Constant c = expr as Constant; if (c != null) { try { - c = c.ConvertImplicitly (ec, target_type); + c = c.ConvertImplicitly (target_type); } catch { Console.WriteLine ("Conversion error happened in line {0}", loc); throw; @@ -1340,7 +1307,7 @@ namespace Mono.CSharp { // if (i.IsZeroInteger) { // Recreate 0 literal to remove any collected conversions - return new EnumConstant (new IntLiteral (0, i.Location), target_type).Resolve (ec); + return new EnumConstant (new IntLiteral (ec.BuiltinTypes, 0, i.Location), target_type); } } @@ -1354,14 +1321,14 @@ namespace Mono.CSharp { if (expr_type == target_pc) return expr; - if (target_pc.Element.BuildinType == BuildinTypeSpec.Type.Void) + if (target_pc.Element.Kind == MemberKind.Void) return EmptyCast.Create (expr, target_type); //return null; } - if (expr_type == InternalType.Null) - return EmptyCast.Create (new NullPointer (loc), target_type); + if (expr_type == InternalType.NullLiteral) + return new NullPointer (target_type, loc); } } @@ -1372,7 +1339,7 @@ namespace Mono.CSharp { return am.Resolve (ec); } - if (expr_type == InternalType.Arglist && target_type == TypeManager.arg_iterator_type) + if (expr_type == InternalType.Arglist && target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec) return expr; if (TypeSpecComparer.IsEqual (expr_type, target_type)) { @@ -1422,252 +1389,304 @@ namespace Mono.CSharp { /// Int16->UIntPtr /// /// - public static Expression ExplicitNumericConversion (Expression expr, TypeSpec target_type) + public static Expression ExplicitNumericConversion (ResolveContext rc, Expression expr, TypeSpec target_type) { - TypeSpec expr_type = expr.Type; - TypeSpec real_target_type = target_type; + // Not all predefined explicit numeric conversion are + // defined here, for some of them (mostly IntPtr/UIntPtr) we + // defer to user-operator handling which is now perfect but + // works for now + // + // LAMESPEC: Undocumented IntPtr/UIntPtr conversions + // IntPtr -> uint uses int + // UIntPtr -> long uses ulong + // - if (expr_type == TypeManager.sbyte_type){ + switch (expr.Type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: // // From sbyte to byte, ushort, uint, ulong, char, uintptr // - if (real_target_type == TypeManager.byte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.I1_U1); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.I1_U2); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.I1_U4); - if (real_target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.I1_U8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.I1_CH); // One of the built-in conversions that belonged in the class library - if (real_target_type == TypeManager.uintptr_type){ - Expression u8e = new ConvCast (expr, TypeManager.uint64_type, ConvCast.Mode.I1_U8); - - return new OperatorCast (u8e, TypeManager.uintptr_type, true); + case BuiltinTypeSpec.Type.UIntPtr: + return new OperatorCast (new ConvCast (expr, rc.BuiltinTypes.ULong, ConvCast.Mode.I1_U8), target_type, target_type, true); } - } else if (expr_type == TypeManager.byte_type){ + break; + case BuiltinTypeSpec.Type.Byte: // // From byte to sbyte and char // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.U1_I1); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.U1_CH); - } else if (expr_type == TypeManager.short_type){ + } + break; + case BuiltinTypeSpec.Type.Short: // // From short to sbyte, byte, ushort, uint, ulong, char, uintptr // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.I2_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.I2_U1); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.I2_U2); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.I2_U4); - if (real_target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.I2_U8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.I2_CH); // One of the built-in conversions that belonged in the class library - if (real_target_type == TypeManager.uintptr_type){ - Expression u8e = new ConvCast (expr, TypeManager.uint64_type, ConvCast.Mode.I2_U8); - - return new OperatorCast (u8e, TypeManager.uintptr_type, true); + case BuiltinTypeSpec.Type.UIntPtr: + return new OperatorCast (new ConvCast (expr, rc.BuiltinTypes.ULong, ConvCast.Mode.I2_U8), target_type, target_type, true); } - } else if (expr_type == TypeManager.ushort_type){ + break; + case BuiltinTypeSpec.Type.UShort: // // From ushort to sbyte, byte, short, char // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.U2_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.U2_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.U2_I2); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.U2_CH); - } else if (expr_type == TypeManager.int32_type){ + } + break; + case BuiltinTypeSpec.Type.Int: // // From int to sbyte, byte, short, ushort, uint, ulong, char, uintptr // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.I4_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.I4_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.I4_I2); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.I4_U2); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.I4_U4); - if (real_target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.I4_U8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.I4_CH); // One of the built-in conversions that belonged in the class library - if (real_target_type == TypeManager.uintptr_type){ - Expression u8e = new ConvCast (expr, TypeManager.uint64_type, ConvCast.Mode.I2_U8); - - return new OperatorCast (u8e, TypeManager.uintptr_type, true); + case BuiltinTypeSpec.Type.UIntPtr: + return new OperatorCast (new ConvCast (expr, rc.BuiltinTypes.ULong, ConvCast.Mode.I2_U8), target_type, target_type, true); } - } else if (expr_type == TypeManager.uint32_type){ + break; + case BuiltinTypeSpec.Type.UInt: // // From uint to sbyte, byte, short, ushort, int, char // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.U4_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.U4_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.U4_I2); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.U4_U2); - if (real_target_type == TypeManager.int32_type) + case BuiltinTypeSpec.Type.Int: return new ConvCast (expr, target_type, ConvCast.Mode.U4_I4); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.U4_CH); - } else if (expr_type == TypeManager.int64_type){ + } + break; + case BuiltinTypeSpec.Type.Long: // // From long to sbyte, byte, short, ushort, int, uint, ulong, char // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.I8_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.I8_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.I8_I2); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.I8_U2); - if (real_target_type == TypeManager.int32_type) + case BuiltinTypeSpec.Type.Int: return new ConvCast (expr, target_type, ConvCast.Mode.I8_I4); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.I8_U4); - if (real_target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.I8_U8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.I8_CH); - } else if (expr_type == TypeManager.uint64_type){ + } + break; + case BuiltinTypeSpec.Type.ULong: // // From ulong to sbyte, byte, short, ushort, int, uint, long, char // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.U8_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.U8_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.U8_I2); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.U8_U2); - if (real_target_type == TypeManager.int32_type) + case BuiltinTypeSpec.Type.Int: return new ConvCast (expr, target_type, ConvCast.Mode.U8_I4); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.U8_U4); - if (real_target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return new ConvCast (expr, target_type, ConvCast.Mode.U8_I8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.U8_CH); // One of the built-in conversions that belonged in the class library - if (real_target_type == TypeManager.intptr_type){ - return new OperatorCast (EmptyCast.Create (expr, TypeManager.int64_type), - TypeManager.intptr_type, true); + case BuiltinTypeSpec.Type.IntPtr: + return new OperatorCast (EmptyCast.Create (expr, rc.BuiltinTypes.Long), target_type, true); } - } else if (expr_type == TypeManager.char_type){ + break; + case BuiltinTypeSpec.Type.Char: // // From char to sbyte, byte, short // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.CH_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.CH_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.CH_I2); - } else if (expr_type == TypeManager.float_type){ + } + break; + case BuiltinTypeSpec.Type.Float: // // From float to sbyte, byte, short, // ushort, int, uint, long, ulong, char // or decimal // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.R4_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.R4_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.R4_I2); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.R4_U2); - if (real_target_type == TypeManager.int32_type) + case BuiltinTypeSpec.Type.Int: return new ConvCast (expr, target_type, ConvCast.Mode.R4_I4); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.R4_U4); - if (real_target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return new ConvCast (expr, target_type, ConvCast.Mode.R4_I8); - if (real_target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.R4_U8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.R4_CH); - if (real_target_type == TypeManager.decimal_type) - return new CastToDecimal (expr, true); - } else if (expr_type == TypeManager.double_type){ + case BuiltinTypeSpec.Type.Decimal: + return new OperatorCast (expr, target_type, true); + } + break; + case BuiltinTypeSpec.Type.Double: // // From double to sbyte, byte, short, // ushort, int, uint, long, ulong, // char, float or decimal // - if (real_target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new ConvCast (expr, target_type, ConvCast.Mode.R8_I1); - if (real_target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new ConvCast (expr, target_type, ConvCast.Mode.R8_U1); - if (real_target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new ConvCast (expr, target_type, ConvCast.Mode.R8_I2); - if (real_target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new ConvCast (expr, target_type, ConvCast.Mode.R8_U2); - if (real_target_type == TypeManager.int32_type) + case BuiltinTypeSpec.Type.Int: return new ConvCast (expr, target_type, ConvCast.Mode.R8_I4); - if (real_target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new ConvCast (expr, target_type, ConvCast.Mode.R8_U4); - if (real_target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return new ConvCast (expr, target_type, ConvCast.Mode.R8_I8); - if (real_target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.R8_U8); - if (real_target_type == TypeManager.char_type) + case BuiltinTypeSpec.Type.Char: return new ConvCast (expr, target_type, ConvCast.Mode.R8_CH); - if (real_target_type == TypeManager.float_type) + case BuiltinTypeSpec.Type.Float: return new ConvCast (expr, target_type, ConvCast.Mode.R8_R4); - if (real_target_type == TypeManager.decimal_type) - return new CastToDecimal (expr, true); - } else if (expr_type == TypeManager.uintptr_type){ + case BuiltinTypeSpec.Type.Decimal: + return new OperatorCast (expr, target_type, true); + } + break; + case BuiltinTypeSpec.Type.UIntPtr: // // Various built-in conversions that belonged in the class library // // from uintptr to sbyte, short, int32 // - if (real_target_type == TypeManager.sbyte_type){ - Expression uint32e = new OperatorCast (expr, TypeManager.uint32_type, true); - return new ConvCast (uint32e, TypeManager.sbyte_type, ConvCast.Mode.U4_I1); - } - if (real_target_type == TypeManager.short_type){ - Expression uint32e = new OperatorCast (expr, TypeManager.uint32_type, true); - return new ConvCast (uint32e, TypeManager.sbyte_type, ConvCast.Mode.U4_I2); + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: + return new ConvCast (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.UInt, true), target_type, ConvCast.Mode.U4_I1); + case BuiltinTypeSpec.Type.Short: + return new ConvCast (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.UInt, true), target_type, ConvCast.Mode.U4_I2); + case BuiltinTypeSpec.Type.Int: + return EmptyCast.Create (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.UInt, true), target_type); + case BuiltinTypeSpec.Type.UInt: + return new OperatorCast (expr, expr.Type, target_type, true); + case BuiltinTypeSpec.Type.Long: + return EmptyCast.Create (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.ULong, true), target_type); } - if (real_target_type == TypeManager.int32_type){ - return EmptyCast.Create (new OperatorCast (expr, TypeManager.uint32_type, true), - TypeManager.int32_type); - } - } else if (expr_type == TypeManager.intptr_type){ - if (real_target_type == TypeManager.uint64_type){ - return EmptyCast.Create (new OperatorCast (expr, TypeManager.int64_type, true), - TypeManager.uint64_type); + break; + case BuiltinTypeSpec.Type.IntPtr: + if (target_type.BuiltinType == BuiltinTypeSpec.Type.UInt) + return EmptyCast.Create (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.Int, true), target_type); + if (target_type.BuiltinType == BuiltinTypeSpec.Type.ULong) + return EmptyCast.Create (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.Long, true), target_type); + + break; + case BuiltinTypeSpec.Type.Decimal: + // From decimal to sbyte, byte, short, + // ushort, int, uint, long, ulong, char, + // float, or double + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.Double: + return new OperatorCast (expr, expr.Type, target_type, true); } - } else if (expr_type == TypeManager.decimal_type) { - return new CastFromDecimal (expr, target_type).Resolve (); + + break; } + return null; } @@ -1695,7 +1714,7 @@ namespace Mono.CSharp { // // From object to a generic parameter // - if (source_type == TypeManager.object_type && TypeManager.IsGenericParameter (target_type)) + if (source_type.BuiltinType == BuiltinTypeSpec.Type.Object && TypeManager.IsGenericParameter (target_type)) return source == null ? EmptyExpression.Null : new UnboxCast (source, target_type); // @@ -1704,18 +1723,18 @@ namespace Mono.CSharp { if (source_type.Kind == MemberKind.TypeParameter) return ExplicitTypeParameterConversion (source, source_type, target_type); - bool target_is_value_type = TypeManager.IsStruct (target_type) || TypeManager.IsEnumType (target_type); + bool target_is_value_type = target_type.Kind == MemberKind.Struct || target_type.Kind == MemberKind.Enum; // // Unboxing conversion from System.ValueType to any non-nullable-value-type // - if (source_type == TypeManager.value_type && target_is_value_type) + if (source_type.BuiltinType == BuiltinTypeSpec.Type.ValueType && target_is_value_type) return source == null ? EmptyExpression.Null : new UnboxCast (source, target_type); // // From object or dynamic to any reference type or value type (unboxing) // - if (source_type == TypeManager.object_type || source_type == InternalType.Dynamic) { + if (source_type.BuiltinType == BuiltinTypeSpec.Type.Object || source_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { if (target_type.IsPointer) return null; @@ -1736,7 +1755,7 @@ namespace Mono.CSharp { // From any interface-type S to to any class type T, provided T is not // sealed, or provided T implements S. // - if (source_type.IsInterface) { + if (source_type.Kind == MemberKind.Interface) { if (!target_type.IsSealed || target_type.ImplementsInterface (source_type, true)) { if (source == null) return EmptyExpression.Null; @@ -1766,7 +1785,7 @@ namespace Mono.CSharp { // // From System.Array to any array-type // - if (source_type == TypeManager.array_type) + if (source_type.BuiltinType == BuiltinTypeSpec.Type.Array) return source == null ? EmptyExpression.Null : new ClassCast (source, target_type); // @@ -1815,7 +1834,7 @@ namespace Mono.CSharp { // // From System delegate to any delegate-type // - if (source_type == TypeManager.delegate_type && TypeManager.IsDelegateType (target_type)) + if (source_type.BuiltinType == BuiltinTypeSpec.Type.Delegate && TypeManager.IsDelegateType (target_type)) return source == null ? EmptyExpression.Null : new ClassCast (source, target_type); // @@ -1837,7 +1856,7 @@ namespace Mono.CSharp { // //If TP is covariant, an implicit or explicit identity or reference conversion is required // - if (ImplicitReferenceConversionExists (new EmptyExpression (targs_src[i]), targs_dst[i])) + if (ImplicitReferenceConversionExists (targs_src[i], targs_dst[i])) continue; if (ExplicitReferenceConversionExists (targs_src[i], targs_dst[i])) @@ -1885,12 +1904,12 @@ namespace Mono.CSharp { ne = ImplicitNumericConversion (underlying, real_target); if (ne == null) - ne = ExplicitNumericConversion (underlying, real_target); + ne = ExplicitNumericConversion (ec, underlying, real_target); // // LAMESPEC: IntPtr and UIntPtr conversion to any Enum is allowed // - if (ne == null && (real_target == TypeManager.intptr_type || real_target == TypeManager.uintptr_type)) + if (ne == null && (real_target.BuiltinType == BuiltinTypeSpec.Type.IntPtr || real_target.BuiltinType == BuiltinTypeSpec.Type.UIntPtr)) ne = ExplicitUserConversion (ec, underlying, real_target, loc); return ne != null ? EmptyCast.Create (ne, target_type) : null; @@ -1900,7 +1919,7 @@ namespace Mono.CSharp { // // System.Enum can be unboxed to any enum-type // - if (expr_type == TypeManager.enum_type) + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Enum) return new UnboxCast (expr, target_type); TypeSpec real_target = TypeManager.IsEnumType (target_type) ? EnumSpec.GetUnderlyingType (target_type) : target_type; @@ -1912,20 +1931,20 @@ namespace Mono.CSharp { if (ne != null) return EmptyCast.Create (ne, target_type); - ne = ExplicitNumericConversion (expr, real_target); + ne = ExplicitNumericConversion (ec, expr, real_target); if (ne != null) return EmptyCast.Create (ne, target_type); // // LAMESPEC: IntPtr and UIntPtr conversion to any Enum is allowed // - if (expr_type == TypeManager.intptr_type || expr_type == TypeManager.uintptr_type) { + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.IntPtr || expr_type.BuiltinType == BuiltinTypeSpec.Type.UIntPtr) { ne = ExplicitUserConversion (ec, expr, real_target, loc); if (ne != null) return ExplicitConversionCore (ec, ne, target_type, loc); } } else { - ne = ExplicitNumericConversion (expr, target_type); + ne = ExplicitNumericConversion (ec, expr, target_type); if (ne != null) return ne; } @@ -1935,7 +1954,7 @@ namespace Mono.CSharp { // from Null to a ValueType, and ExplicitReference wont check against // null literal explicitly // - if (expr_type != InternalType.Null) { + if (expr_type != InternalType.NullLiteral) { ne = ExplicitReferenceConversion (expr, expr_type, target_type); if (ne != null) return ne; @@ -1958,40 +1977,44 @@ namespace Mono.CSharp { if (expr_type.IsPointer) return EmptyCast.Create (expr, target_type); - if (expr_type == TypeManager.sbyte_type || - expr_type == TypeManager.short_type || - expr_type == TypeManager.int32_type) + switch (expr_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.Int: return new OpcodeCast (expr, target_type, OpCodes.Conv_I); - if (expr_type == TypeManager.ushort_type || - expr_type == TypeManager.uint32_type || - expr_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Byte: return new OpcodeCast (expr, target_type, OpCodes.Conv_U); - if (expr_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return new ConvCast (expr, target_type, ConvCast.Mode.I8_I); - if (expr_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new ConvCast (expr, target_type, ConvCast.Mode.U8_I); + } } if (expr_type.IsPointer){ - if (target_type == TypeManager.sbyte_type) + switch (target_type.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: return new OpcodeCast (expr, target_type, OpCodes.Conv_I1); - if (target_type == TypeManager.byte_type) + case BuiltinTypeSpec.Type.Byte: return new OpcodeCast (expr, target_type, OpCodes.Conv_U1); - if (target_type == TypeManager.short_type) + case BuiltinTypeSpec.Type.Short: return new OpcodeCast (expr, target_type, OpCodes.Conv_I2); - if (target_type == TypeManager.ushort_type) + case BuiltinTypeSpec.Type.UShort: return new OpcodeCast (expr, target_type, OpCodes.Conv_U2); - if (target_type == TypeManager.int32_type) + case BuiltinTypeSpec.Type.Int: return new OpcodeCast (expr, target_type, OpCodes.Conv_I4); - if (target_type == TypeManager.uint32_type) + case BuiltinTypeSpec.Type.UInt: return new OpcodeCast (expr, target_type, OpCodes.Conv_U4); - if (target_type == TypeManager.int64_type) + case BuiltinTypeSpec.Type.Long: return new ConvCast (expr, target_type, ConvCast.Mode.I_I8); - if (target_type == TypeManager.uint64_type) + case BuiltinTypeSpec.Type.ULong: return new OpcodeCast (expr, target_type, OpCodes.Conv_U8); + } } return null; } @@ -2010,7 +2033,7 @@ namespace Mono.CSharp { if (ne != null) return ne; - ne = ExplicitNumericConversion (expr, target_type); + ne = ExplicitNumericConversion (ec, expr, target_type); if (ne != null) return ne; @@ -2018,7 +2041,7 @@ namespace Mono.CSharp { if (ne != null) return ne; - if (ec.IsUnsafe && expr.Type.IsPointer && target_type.IsPointer && ((PointerContainer)expr.Type).Element.BuildinType == BuildinTypeSpec.Type.Void) + if (ec.IsUnsafe && expr.Type.IsPointer && target_type.IsPointer && ((PointerContainer)expr.Type).Element.Kind == MemberKind.Void) return EmptyCast.Create (expr, target_type); expr.Error_ValueCannotBeConverted (ec, l, target_type, true); @@ -2038,10 +2061,10 @@ namespace Mono.CSharp { // Don't eliminate explicit precission casts // if (e == expr) { - if (target_type == TypeManager.float_type) + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Float) return new OpcodeCast (expr, target_type, OpCodes.Conv_R4); - if (target_type == TypeManager.double_type) + if (target_type.BuiltinType == BuiltinTypeSpec.Type.Double) return new OpcodeCast (expr, target_type, OpCodes.Conv_R8); } @@ -2049,25 +2072,27 @@ namespace Mono.CSharp { } TypeSpec expr_type = expr.Type; - if (TypeManager.IsNullableType (target_type)) { - if (TypeManager.IsNullableType (expr_type)) { - TypeSpec target = Nullable.NullableInfo.GetUnderlyingType (target_type); + if (target_type.IsNullableType) { + TypeSpec target; + + if (expr_type.IsNullableType) { + target = Nullable.NullableInfo.GetUnderlyingType (target_type); Expression unwrap = Nullable.Unwrap.Create (expr); e = ExplicitConversion (ec, unwrap, target, expr.Location); if (e == null) return null; return new Nullable.Lifted (e, unwrap, target_type).Resolve (ec); - } else if (expr_type == TypeManager.object_type) { + } + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Object) { return new UnboxCast (expr, target_type); - } else { - TypeSpec target = TypeManager.GetTypeArguments (target_type) [0]; - - e = ExplicitConversionCore (ec, expr, target, loc); - if (e != null) - return Nullable.Wrap.Create (e, target_type); } - } else if (TypeManager.IsNullableType (expr_type)) { + + target = TypeManager.GetTypeArguments (target_type) [0]; + e = ExplicitConversionCore (ec, expr, target, loc); + if (e != null) + return Nullable.Wrap.Create (e, target_type); + } else if (expr_type.IsNullableType) { e = ImplicitBoxingConversion (expr, Nullable.NullableInfo.GetUnderlyingType (expr_type), target_type); if (e != null) return e; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs index f494dd163..4d2bedfe5 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs @@ -96,7 +96,7 @@ namespace Mono.CSharp /// /// The current file. /// - CompilationUnit file; + readonly CompilationSourceFile file; /// /// Temporary Xml documentation cache. @@ -108,16 +108,13 @@ namespace Mono.CSharp /// Current attribute target string current_attr_target; - /// assembly and module attribute definitions are enabled - bool global_attrs_enabled = true; - ParameterModifierType valid_param_mod; bool default_parameter_used; /// When using the interactive parser, this holds the /// resulting expression - public object InteractiveResult; + public Class InteractiveResult; // // Keeps track of global data changes to undo on parser error @@ -126,12 +123,12 @@ namespace Mono.CSharp Stack linq_clause_blocks; - // A counter to create new class names in interactive mode - static int class_count; - ModuleContainer module; - CompilerContext compiler; + readonly CompilerContext compiler; + readonly LanguageVersion lang_version; + readonly bool doc_support; + readonly CompilerSettings settings; // // Instead of allocating carrier array everytime we @@ -146,7 +143,7 @@ namespace Mono.CSharp LocationsBag lbag; UsingsBag ubag; List> mod_locations; - Location parameterModifierLocation; + Location parameterModifierLocation, savedLocation; #line default /** error output stream. @@ -184,25 +181,21 @@ namespace Mono.CSharp */ //t internal yydebug.yyDebug debug; - protected const int yyFinal = 9; + protected const int yyFinal = 6; //t // Put this array into a separate class so it is only initialized if debugging is actually used //t // Use MarshalByRefObject to disable inlining //t class YYRules : MarshalByRefObject { //t public static readonly string [] yyRule = { //t "$accept : compilation_unit", -//t "compilation_unit : outer_declarations opt_EOF", -//t "compilation_unit : outer_declarations global_attributes opt_EOF", -//t "compilation_unit : global_attributes opt_EOF", -//t "compilation_unit : opt_EOF", +//t "compilation_unit : outer_declaration opt_EOF", //t "$$1 :", //t "compilation_unit : interactive_parsing $$1 opt_EOF", +//t "outer_declaration : opt_extern_alias_directives opt_using_directives", +//t "outer_declaration : opt_extern_alias_directives opt_using_directives namespace_or_type_declarations opt_attributes", +//t "outer_declaration : opt_extern_alias_directives opt_using_directives attribute_sections", +//t "outer_declaration : error", //t "opt_EOF :", //t "opt_EOF : EOF", -//t "outer_declarations : outer_declaration", -//t "outer_declarations : outer_declarations outer_declaration", -//t "outer_declaration : extern_alias_directive", -//t "outer_declaration : using_directive", -//t "outer_declaration : namespace_member_declaration", //t "extern_alias_directives : extern_alias_directive", //t "extern_alias_directives : extern_alias_directives extern_alias_directive", //t "extern_alias_directive : EXTERN_ALIAS IDENTIFIER IDENTIFIER SEMICOLON", @@ -215,7 +208,8 @@ namespace Mono.CSharp //t "using_alias_directive : USING error", //t "using_namespace_directive : USING namespace_name SEMICOLON", //t "$$2 :", -//t "namespace_declaration : opt_attributes NAMESPACE qualified_identifier $$2 namespace_body opt_semicolon", +//t "$$3 :", +//t "namespace_declaration : opt_attributes NAMESPACE qualified_identifier $$2 OPEN_BRACE $$3 opt_extern_alias_directives opt_using_directives opt_namespace_or_type_declarations CLOSE_BRACE opt_semicolon", //t "qualified_identifier : IDENTIFIER", //t "qualified_identifier : qualified_identifier DOT IDENTIFIER", //t "qualified_identifier : error", @@ -224,40 +218,38 @@ namespace Mono.CSharp //t "opt_comma :", //t "opt_comma : COMMA", //t "namespace_name : namespace_or_type_name", -//t "$$3 :", -//t "namespace_body : OPEN_BRACE $$3 opt_extern_alias_directives opt_using_directives opt_namespace_member_declarations CLOSE_BRACE", //t "opt_using_directives :", //t "opt_using_directives : using_directives", //t "opt_extern_alias_directives :", //t "opt_extern_alias_directives : extern_alias_directives", -//t "opt_namespace_member_declarations :", -//t "opt_namespace_member_declarations : namespace_member_declarations", -//t "namespace_member_declarations : namespace_member_declaration", -//t "namespace_member_declarations : namespace_member_declarations namespace_member_declaration", -//t "namespace_member_declaration : type_declaration", -//t "namespace_member_declaration : namespace_declaration", -//t "namespace_member_declaration : error", +//t "opt_namespace_or_type_declarations :", +//t "opt_namespace_or_type_declarations : namespace_or_type_declarations", +//t "namespace_or_type_declarations : namespace_or_type_declaration", +//t "namespace_or_type_declarations : namespace_or_type_declarations namespace_or_type_declaration", +//t "namespace_or_type_declaration : type_declaration", +//t "namespace_or_type_declaration : namespace_declaration", //t "type_declaration : class_declaration", //t "type_declaration : struct_declaration", //t "type_declaration : interface_declaration", //t "type_declaration : enum_declaration", //t "type_declaration : delegate_declaration", -//t "global_attributes : attribute_sections", //t "opt_attributes :", //t "opt_attributes : attribute_sections", //t "attribute_sections : attribute_section", //t "attribute_sections : attribute_sections attribute_section", -//t "attribute_section : OPEN_BRACKET attribute_target_specifier attribute_list opt_comma CLOSE_BRACKET", -//t "attribute_section : OPEN_BRACKET attribute_list opt_comma CLOSE_BRACKET", -//t "attribute_target_specifier : attribute_target COLON", +//t "$$4 :", +//t "attribute_section : OPEN_BRACKET $$4 attribute_section_cont", +//t "$$5 :", +//t "attribute_section_cont : attribute_target COLON $$5 attribute_list opt_comma CLOSE_BRACKET", +//t "attribute_section_cont : attribute_list opt_comma CLOSE_BRACKET", //t "attribute_target : IDENTIFIER", //t "attribute_target : EVENT", //t "attribute_target : RETURN", //t "attribute_target : error", //t "attribute_list : attribute", //t "attribute_list : attribute_list COMMA attribute", -//t "$$4 :", -//t "attribute : attribute_name $$4 opt_attribute_arguments", +//t "$$6 :", +//t "attribute : attribute_name $$6 opt_attribute_arguments", //t "attribute_name : namespace_or_type_name", //t "opt_attribute_arguments :", //t "opt_attribute_arguments : OPEN_PARENS attribute_arguments CLOSE_PARENS", @@ -268,8 +260,8 @@ namespace Mono.CSharp //t "attribute_arguments : attribute_arguments COMMA named_attribute_argument", //t "positional_or_named_argument : expression", //t "positional_or_named_argument : named_argument", -//t "$$5 :", -//t "named_attribute_argument : IDENTIFIER ASSIGN $$5 expression", +//t "$$7 :", +//t "named_attribute_argument : IDENTIFIER ASSIGN $$7 expression", //t "named_argument : IDENTIFIER COLON opt_named_modifier expression", //t "opt_named_modifier :", //t "opt_named_modifier : REF", @@ -289,14 +281,14 @@ namespace Mono.CSharp //t "class_member_declaration : destructor_declaration", //t "class_member_declaration : type_declaration", //t "class_member_declaration : error", -//t "$$6 :", -//t "$$7 :", //t "$$8 :", //t "$$9 :", -//t "struct_declaration : opt_attributes opt_modifiers opt_partial STRUCT $$6 type_declaration_name $$7 opt_class_base opt_type_parameter_constraints_clauses $$8 struct_body $$9 opt_semicolon", -//t "struct_declaration : opt_attributes opt_modifiers opt_partial STRUCT error", //t "$$10 :", -//t "struct_body : OPEN_BRACE $$10 opt_struct_member_declarations CLOSE_BRACE", +//t "$$11 :", +//t "struct_declaration : opt_attributes opt_modifiers opt_partial STRUCT $$8 type_declaration_name $$9 opt_class_base opt_type_parameter_constraints_clauses $$10 struct_body $$11 opt_semicolon", +//t "struct_declaration : opt_attributes opt_modifiers opt_partial STRUCT error", +//t "$$12 :", +//t "struct_body : OPEN_BRACE $$12 opt_struct_member_declarations CLOSE_BRACE", //t "opt_struct_member_declarations :", //t "opt_struct_member_declarations : struct_member_declarations", //t "struct_member_declarations : struct_member_declaration", @@ -311,52 +303,52 @@ namespace Mono.CSharp //t "struct_member_declaration : constructor_declaration", //t "struct_member_declaration : type_declaration", //t "struct_member_declaration : destructor_declaration", -//t "$$11 :", -//t "constant_declaration : opt_attributes opt_modifiers CONST type IDENTIFIER $$11 constant_initializer opt_constant_declarators SEMICOLON", +//t "$$13 :", +//t "constant_declaration : opt_attributes opt_modifiers CONST type IDENTIFIER $$13 constant_initializer opt_constant_declarators SEMICOLON", //t "opt_constant_declarators :", //t "opt_constant_declarators : constant_declarators", //t "constant_declarators : constant_declarator", //t "constant_declarators : constant_declarators constant_declarator", //t "constant_declarator : COMMA IDENTIFIER constant_initializer", -//t "$$12 :", -//t "constant_initializer : ASSIGN $$12 constant_initializer_expr", +//t "$$14 :", +//t "constant_initializer : ASSIGN $$14 constant_initializer_expr", //t "constant_initializer : error", //t "constant_initializer_expr : constant_expression", //t "constant_initializer_expr : array_initializer", -//t "$$13 :", -//t "field_declaration : opt_attributes opt_modifiers member_type IDENTIFIER $$13 opt_field_initializer opt_field_declarators SEMICOLON", -//t "$$14 :", -//t "field_declaration : opt_attributes opt_modifiers FIXED simple_type IDENTIFIER $$14 fixed_field_size opt_fixed_field_declarators SEMICOLON", +//t "$$15 :", +//t "field_declaration : opt_attributes opt_modifiers member_type IDENTIFIER $$15 opt_field_initializer opt_field_declarators SEMICOLON", +//t "$$16 :", +//t "field_declaration : opt_attributes opt_modifiers FIXED simple_type IDENTIFIER $$16 fixed_field_size opt_fixed_field_declarators SEMICOLON", //t "field_declaration : opt_attributes opt_modifiers FIXED simple_type error SEMICOLON", //t "opt_field_initializer :", -//t "$$15 :", -//t "opt_field_initializer : ASSIGN $$15 variable_initializer", +//t "$$17 :", +//t "opt_field_initializer : ASSIGN $$17 variable_initializer", //t "opt_field_declarators :", //t "opt_field_declarators : field_declarators", //t "field_declarators : field_declarator", //t "field_declarators : field_declarators field_declarator", //t "field_declarator : COMMA IDENTIFIER", -//t "$$16 :", -//t "field_declarator : COMMA IDENTIFIER ASSIGN $$16 variable_initializer", +//t "$$18 :", +//t "field_declarator : COMMA IDENTIFIER ASSIGN $$18 variable_initializer", //t "opt_fixed_field_declarators :", //t "opt_fixed_field_declarators : fixed_field_declarators", //t "fixed_field_declarators : fixed_field_declarator", //t "fixed_field_declarators : fixed_field_declarators fixed_field_declarator", //t "fixed_field_declarator : COMMA IDENTIFIER fixed_field_size", -//t "$$17 :", -//t "fixed_field_size : OPEN_BRACKET $$17 expression CLOSE_BRACKET", +//t "$$19 :", +//t "fixed_field_size : OPEN_BRACKET $$19 expression CLOSE_BRACKET", //t "fixed_field_size : OPEN_BRACKET error", //t "variable_initializer : expression", //t "variable_initializer : array_initializer", //t "variable_initializer : error", -//t "$$18 :", -//t "method_declaration : method_header $$18 method_body", -//t "$$19 :", //t "$$20 :", -//t "method_header : opt_attributes opt_modifiers member_type method_declaration_name OPEN_PARENS $$19 opt_formal_parameter_list CLOSE_PARENS $$20 opt_type_parameter_constraints_clauses", +//t "method_declaration : method_header $$20 method_body", //t "$$21 :", //t "$$22 :", -//t "method_header : opt_attributes opt_modifiers PARTIAL VOID method_declaration_name OPEN_PARENS $$21 opt_formal_parameter_list CLOSE_PARENS $$22 opt_type_parameter_constraints_clauses", +//t "method_header : opt_attributes opt_modifiers member_type method_declaration_name OPEN_PARENS $$21 opt_formal_parameter_list CLOSE_PARENS $$22 opt_type_parameter_constraints_clauses", +//t "$$23 :", +//t "$$24 :", +//t "method_header : opt_attributes opt_modifiers PARTIAL VOID method_declaration_name OPEN_PARENS $$23 opt_formal_parameter_list CLOSE_PARENS $$24 opt_type_parameter_constraints_clauses", //t "method_header : opt_attributes opt_modifiers member_type modifiers method_declaration_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS", //t "method_body : block", //t "method_body : SEMICOLON", @@ -377,8 +369,8 @@ namespace Mono.CSharp //t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER", //t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER OPEN_BRACKET CLOSE_BRACKET", //t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type error", -//t "$$23 :", -//t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER ASSIGN $$23 constant_expression", +//t "$$25 :", +//t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER ASSIGN $$25 constant_expression", //t "opt_parameter_modifier :", //t "opt_parameter_modifier : parameter_modifiers", //t "parameter_modifiers : parameter_modifier", @@ -393,31 +385,31 @@ namespace Mono.CSharp //t "params_modifier : PARAMS parameter_modifier", //t "params_modifier : PARAMS params_modifier", //t "arglist_modifier : ARGLIST", -//t "$$24 :", -//t "$$25 :", //t "$$26 :", -//t "property_declaration : opt_attributes opt_modifiers member_type member_declaration_name $$24 OPEN_BRACE $$25 accessor_declarations $$26 CLOSE_BRACE", //t "$$27 :", //t "$$28 :", +//t "property_declaration : opt_attributes opt_modifiers member_type member_declaration_name $$26 OPEN_BRACE $$27 accessor_declarations $$28 CLOSE_BRACE", //t "$$29 :", -//t "indexer_declaration : opt_attributes opt_modifiers member_type indexer_declaration_name OPEN_BRACKET $$27 opt_formal_parameter_list CLOSE_BRACKET OPEN_BRACE $$28 accessor_declarations $$29 CLOSE_BRACE", +//t "$$30 :", +//t "$$31 :", +//t "indexer_declaration : opt_attributes opt_modifiers member_type indexer_declaration_name OPEN_BRACKET $$29 opt_formal_parameter_list CLOSE_BRACKET OPEN_BRACE $$30 accessor_declarations $$31 CLOSE_BRACE", //t "accessor_declarations : get_accessor_declaration", //t "accessor_declarations : get_accessor_declaration accessor_declarations", //t "accessor_declarations : set_accessor_declaration", //t "accessor_declarations : set_accessor_declaration accessor_declarations", //t "accessor_declarations : error", -//t "$$30 :", -//t "get_accessor_declaration : opt_attributes opt_modifiers GET $$30 accessor_body", -//t "$$31 :", -//t "set_accessor_declaration : opt_attributes opt_modifiers SET $$31 accessor_body", +//t "$$32 :", +//t "get_accessor_declaration : opt_attributes opt_modifiers GET $$32 accessor_body", +//t "$$33 :", +//t "set_accessor_declaration : opt_attributes opt_modifiers SET $$33 accessor_body", //t "accessor_body : block", //t "accessor_body : SEMICOLON", //t "accessor_body : error", -//t "$$32 :", -//t "$$33 :", //t "$$34 :", //t "$$35 :", -//t "interface_declaration : opt_attributes opt_modifiers opt_partial INTERFACE $$32 type_declaration_name $$33 opt_class_base opt_type_parameter_constraints_clauses $$34 OPEN_BRACE opt_interface_member_declarations CLOSE_BRACE $$35 opt_semicolon", +//t "$$36 :", +//t "$$37 :", +//t "interface_declaration : opt_attributes opt_modifiers opt_partial INTERFACE $$34 type_declaration_name $$35 opt_class_base opt_type_parameter_constraints_clauses $$36 OPEN_BRACE opt_interface_member_declarations CLOSE_BRACE $$37 opt_semicolon", //t "interface_declaration : opt_attributes opt_modifiers opt_partial INTERFACE error", //t "opt_interface_member_declarations :", //t "opt_interface_member_declarations : interface_member_declarations", @@ -432,14 +424,14 @@ namespace Mono.CSharp //t "interface_member_declaration : operator_declaration", //t "interface_member_declaration : constructor_declaration", //t "interface_member_declaration : type_declaration", -//t "$$36 :", -//t "operator_declaration : opt_attributes opt_modifiers operator_declarator $$36 operator_body", +//t "$$38 :", +//t "operator_declaration : opt_attributes opt_modifiers operator_declarator $$38 operator_body", //t "operator_body : block", //t "operator_body : SEMICOLON", //t "operator_type : type_expression_or_array", //t "operator_type : VOID", -//t "$$37 :", -//t "operator_declarator : operator_type OPERATOR overloadable_operator OPEN_PARENS $$37 opt_formal_parameter_list CLOSE_PARENS", +//t "$$39 :", +//t "operator_declarator : operator_type OPERATOR overloadable_operator OPEN_PARENS $$39 opt_formal_parameter_list CLOSE_PARENS", //t "operator_declarator : conversion_operator_declarator", //t "overloadable_operator : BANG", //t "overloadable_operator : TILDE", @@ -463,59 +455,59 @@ namespace Mono.CSharp //t "overloadable_operator : OP_LT", //t "overloadable_operator : OP_GE", //t "overloadable_operator : OP_LE", -//t "$$38 :", -//t "conversion_operator_declarator : IMPLICIT OPERATOR type OPEN_PARENS $$38 opt_formal_parameter_list CLOSE_PARENS", -//t "$$39 :", -//t "conversion_operator_declarator : EXPLICIT OPERATOR type OPEN_PARENS $$39 opt_formal_parameter_list CLOSE_PARENS", +//t "$$40 :", +//t "conversion_operator_declarator : IMPLICIT OPERATOR type OPEN_PARENS $$40 opt_formal_parameter_list CLOSE_PARENS", +//t "$$41 :", +//t "conversion_operator_declarator : EXPLICIT OPERATOR type OPEN_PARENS $$41 opt_formal_parameter_list CLOSE_PARENS", //t "conversion_operator_declarator : IMPLICIT error", //t "conversion_operator_declarator : EXPLICIT error", //t "constructor_declaration : constructor_declarator constructor_body", -//t "$$40 :", -//t "$$41 :", -//t "constructor_declarator : opt_attributes opt_modifiers IDENTIFIER $$40 OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS $$41 opt_constructor_initializer", +//t "$$42 :", +//t "$$43 :", +//t "constructor_declarator : opt_attributes opt_modifiers IDENTIFIER $$42 OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS $$43 opt_constructor_initializer", //t "constructor_body : block_prepared", //t "constructor_body : SEMICOLON", //t "opt_constructor_initializer :", //t "opt_constructor_initializer : constructor_initializer", -//t "$$42 :", -//t "constructor_initializer : COLON BASE OPEN_PARENS $$42 opt_argument_list CLOSE_PARENS", -//t "$$43 :", -//t "constructor_initializer : COLON THIS OPEN_PARENS $$43 opt_argument_list CLOSE_PARENS", -//t "constructor_initializer : error", //t "$$44 :", -//t "destructor_declaration : opt_attributes opt_modifiers TILDE $$44 IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body", +//t "constructor_initializer : COLON BASE OPEN_PARENS $$44 opt_argument_list CLOSE_PARENS", //t "$$45 :", -//t "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name $$45 opt_event_initializer opt_event_declarators SEMICOLON", +//t "constructor_initializer : COLON THIS OPEN_PARENS $$45 opt_argument_list CLOSE_PARENS", +//t "constructor_initializer : error", //t "$$46 :", +//t "destructor_declaration : opt_attributes opt_modifiers TILDE $$46 IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body", //t "$$47 :", -//t "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name OPEN_BRACE $$46 event_accessor_declarations $$47 CLOSE_BRACE", -//t "opt_event_initializer :", +//t "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name $$47 opt_event_initializer opt_event_declarators SEMICOLON", //t "$$48 :", -//t "opt_event_initializer : ASSIGN $$48 event_variable_initializer", +//t "$$49 :", +//t "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name OPEN_BRACE $$48 event_accessor_declarations $$49 CLOSE_BRACE", +//t "opt_event_initializer :", +//t "$$50 :", +//t "opt_event_initializer : ASSIGN $$50 event_variable_initializer", //t "opt_event_declarators :", //t "opt_event_declarators : event_declarators", //t "event_declarators : event_declarator", //t "event_declarators : event_declarators event_declarator", //t "event_declarator : COMMA IDENTIFIER", -//t "$$49 :", -//t "event_declarator : COMMA IDENTIFIER ASSIGN $$49 event_variable_initializer", -//t "$$50 :", -//t "event_variable_initializer : $$50 variable_initializer", +//t "$$51 :", +//t "event_declarator : COMMA IDENTIFIER ASSIGN $$51 event_variable_initializer", +//t "$$52 :", +//t "event_variable_initializer : $$52 variable_initializer", //t "event_accessor_declarations : add_accessor_declaration remove_accessor_declaration", //t "event_accessor_declarations : remove_accessor_declaration add_accessor_declaration", //t "event_accessor_declarations : add_accessor_declaration", //t "event_accessor_declarations : remove_accessor_declaration", //t "event_accessor_declarations : error", -//t "$$51 :", -//t "add_accessor_declaration : opt_attributes opt_modifiers ADD $$51 event_accessor_block", -//t "$$52 :", -//t "remove_accessor_declaration : opt_attributes opt_modifiers REMOVE $$52 event_accessor_block", -//t "event_accessor_block : opt_semicolon", -//t "event_accessor_block : block", //t "$$53 :", +//t "add_accessor_declaration : opt_attributes opt_modifiers ADD $$53 event_accessor_block", //t "$$54 :", +//t "remove_accessor_declaration : opt_attributes opt_modifiers REMOVE $$54 event_accessor_block", +//t "event_accessor_block : opt_semicolon", +//t "event_accessor_block : block", //t "$$55 :", -//t "enum_declaration : opt_attributes opt_modifiers ENUM type_declaration_name opt_enum_base $$53 OPEN_BRACE $$54 opt_enum_member_declarations $$55 CLOSE_BRACE opt_semicolon", +//t "$$56 :", +//t "$$57 :", +//t "enum_declaration : opt_attributes opt_modifiers ENUM type_declaration_name opt_enum_base $$55 OPEN_BRACE $$56 opt_enum_member_declarations $$57 CLOSE_BRACE opt_semicolon", //t "opt_enum_base :", //t "opt_enum_base : COLON type", //t "opt_enum_base : COLON error", @@ -525,12 +517,12 @@ namespace Mono.CSharp //t "enum_member_declarations : enum_member_declaration", //t "enum_member_declarations : enum_member_declarations COMMA enum_member_declaration", //t "enum_member_declaration : opt_attributes IDENTIFIER", -//t "$$56 :", -//t "enum_member_declaration : opt_attributes IDENTIFIER $$56 ASSIGN constant_expression", -//t "$$57 :", //t "$$58 :", +//t "enum_member_declaration : opt_attributes IDENTIFIER $$58 ASSIGN constant_expression", //t "$$59 :", -//t "delegate_declaration : opt_attributes opt_modifiers DELEGATE member_type type_declaration_name OPEN_PARENS $$57 opt_formal_parameter_list CLOSE_PARENS $$58 opt_type_parameter_constraints_clauses $$59 SEMICOLON", +//t "$$60 :", +//t "$$61 :", +//t "delegate_declaration : opt_attributes opt_modifiers DELEGATE member_type type_declaration_name OPEN_PARENS $$59 opt_formal_parameter_list CLOSE_PARENS $$60 opt_type_parameter_constraints_clauses $$61 SEMICOLON", //t "opt_nullable :", //t "opt_nullable : INTERR_NULLABLE", //t "namespace_or_type_name : member_name", @@ -543,8 +535,8 @@ namespace Mono.CSharp //t "opt_type_argument_list : OP_GENERICS_LT error", //t "type_arguments : type", //t "type_arguments : type_arguments COMMA type", -//t "$$60 :", -//t "type_declaration_name : IDENTIFIER $$60 opt_type_parameter_list", +//t "$$62 :", +//t "type_declaration_name : IDENTIFIER $$62 opt_type_parameter_list", //t "member_declaration_name : method_declaration_name", //t "method_declaration_name : type_declaration_name", //t "method_declaration_name : explicit_interface IDENTIFIER opt_type_parameter_list", @@ -614,6 +606,7 @@ namespace Mono.CSharp //t "primary_expression : unchecked_expression", //t "primary_expression : pointer_member_access", //t "primary_expression : anonymous_method_expression", +//t "primary_expression : undocumented_expressions", //t "primary_expression_or_type : IDENTIFIER opt_type_argument_list", //t "primary_expression_or_type : IDENTIFIER GENERATE_COMPLETION", //t "primary_expression_or_type : member_access", @@ -689,8 +682,8 @@ namespace Mono.CSharp //t "array_creation_expression : NEW rank_specifier array_initializer", //t "array_creation_expression : NEW new_expr_type OPEN_BRACKET CLOSE_BRACKET OPEN_BRACKET_EXPR error CLOSE_BRACKET", //t "array_creation_expression : NEW new_expr_type error", -//t "$$61 :", -//t "new_expr_type : $$61 simple_type", +//t "$$63 :", +//t "new_expr_type : $$63 simple_type", //t "anonymous_type_expression : NEW OPEN_BRACE anonymous_type_parameters_opt_comma CLOSE_BRACE", //t "anonymous_type_parameters_opt_comma : anonymous_type_parameters_opt", //t "anonymous_type_parameters_opt_comma : anonymous_type_parameters COMMA", @@ -716,8 +709,8 @@ namespace Mono.CSharp //t "array_initializer : OPEN_BRACE variable_initializer_list opt_comma CLOSE_BRACE", //t "variable_initializer_list : variable_initializer", //t "variable_initializer_list : variable_initializer_list COMMA variable_initializer", -//t "$$62 :", -//t "typeof_expression : TYPEOF $$62 open_parens_any typeof_type_expression CLOSE_PARENS", +//t "$$64 :", +//t "typeof_expression : TYPEOF $$64 open_parens_any typeof_type_expression CLOSE_PARENS", //t "typeof_type_expression : type_and_void", //t "typeof_type_expression : unbound_type_name", //t "typeof_type_expression : error", @@ -732,12 +725,12 @@ namespace Mono.CSharp //t "checked_expression : CHECKED open_parens_any expression CLOSE_PARENS", //t "unchecked_expression : UNCHECKED open_parens_any expression CLOSE_PARENS", //t "pointer_member_access : primary_expression OP_PTR IDENTIFIER", -//t "$$63 :", -//t "anonymous_method_expression : DELEGATE opt_anonymous_method_signature $$63 block", +//t "$$65 :", +//t "anonymous_method_expression : DELEGATE opt_anonymous_method_signature $$65 block", //t "opt_anonymous_method_signature :", //t "opt_anonymous_method_signature : anonymous_method_signature", -//t "$$64 :", -//t "anonymous_method_signature : OPEN_PARENS $$64 opt_formal_parameter_list CLOSE_PARENS", +//t "$$66 :", +//t "anonymous_method_signature : OPEN_PARENS $$66 opt_formal_parameter_list CLOSE_PARENS", //t "default_value_expression : DEFAULT open_parens_any type CLOSE_PARENS", //t "unary_expression : primary_expression", //t "unary_expression : BANG prefixed_unary_expression", @@ -806,28 +799,31 @@ namespace Mono.CSharp //t "opt_lambda_parameter_list : lambda_parameter_list", //t "lambda_expression_body : lambda_expression_body_simple", //t "lambda_expression_body : block", -//t "$$65 :", -//t "lambda_expression_body_simple : $$65 expression_or_error", +//t "$$67 :", +//t "lambda_expression_body_simple : $$67 expression_or_error", //t "expression_or_error : expression", //t "expression_or_error : error", -//t "$$66 :", -//t "lambda_expression : IDENTIFIER ARROW $$66 lambda_expression_body", -//t "$$67 :", //t "$$68 :", -//t "lambda_expression : OPEN_PARENS_LAMBDA $$67 opt_lambda_parameter_list CLOSE_PARENS ARROW $$68 lambda_expression_body", +//t "lambda_expression : IDENTIFIER ARROW $$68 lambda_expression_body", +//t "$$69 :", +//t "$$70 :", +//t "lambda_expression : OPEN_PARENS_LAMBDA $$69 opt_lambda_parameter_list CLOSE_PARENS ARROW $$70 lambda_expression_body", //t "expression : assignment_expression", //t "expression : non_assignment_expression", //t "non_assignment_expression : conditional_expression", //t "non_assignment_expression : lambda_expression", //t "non_assignment_expression : query_expression", //t "non_assignment_expression : ARGLIST", +//t "undocumented_expressions : REFVALUE OPEN_PARENS non_assignment_expression COMMA type CLOSE_PARENS", +//t "undocumented_expressions : REFTYPE open_parens_any expression CLOSE_PARENS", +//t "undocumented_expressions : MAKEREF open_parens_any expression CLOSE_PARENS", //t "constant_expression : expression", //t "boolean_expression : expression", -//t "$$69 :", -//t "$$70 :", //t "$$71 :", //t "$$72 :", -//t "class_declaration : opt_attributes opt_modifiers opt_partial CLASS $$69 type_declaration_name $$70 opt_class_base opt_type_parameter_constraints_clauses $$71 OPEN_BRACE opt_class_member_declarations CLOSE_BRACE $$72 opt_semicolon", +//t "$$73 :", +//t "$$74 :", +//t "class_declaration : opt_attributes opt_modifiers opt_partial CLASS $$71 type_declaration_name $$72 opt_class_base opt_type_parameter_constraints_clauses $$73 OPEN_BRACE opt_class_member_declarations CLOSE_BRACE $$74 opt_semicolon", //t "opt_partial :", //t "opt_partial : PARTIAL", //t "opt_modifiers :", @@ -867,12 +863,12 @@ namespace Mono.CSharp //t "opt_type_parameter_variance : type_parameter_variance", //t "type_parameter_variance : OUT", //t "type_parameter_variance : IN", -//t "$$73 :", -//t "block : OPEN_BRACE $$73 opt_statement_list block_end", +//t "$$75 :", +//t "block : OPEN_BRACE $$75 opt_statement_list block_end", //t "block_end : CLOSE_BRACE", //t "block_end : COMPLETE_COMPLETION", -//t "$$74 :", -//t "block_prepared : OPEN_BRACE $$74 opt_statement_list CLOSE_BRACE", +//t "$$76 :", +//t "block_prepared : OPEN_BRACE $$76 opt_statement_list CLOSE_BRACE", //t "opt_statement_list :", //t "opt_statement_list : statement_list", //t "statement_list : statement", @@ -917,8 +913,8 @@ namespace Mono.CSharp //t "embedded_statement : labeled_statement", //t "embedded_statement : error", //t "empty_statement : SEMICOLON", -//t "$$75 :", -//t "labeled_statement : IDENTIFIER COLON $$75 statement", +//t "$$77 :", +//t "labeled_statement : IDENTIFIER COLON $$77 statement", //t "variable_type : variable_type_simple", //t "variable_type : variable_type_simple rank_specifiers", //t "variable_type_simple : primary_expression_or_type opt_nullable", @@ -930,10 +926,10 @@ namespace Mono.CSharp //t "pointer_stars : pointer_star", //t "pointer_stars : pointer_star pointer_stars", //t "pointer_star : STAR", -//t "$$76 :", -//t "block_variable_declaration : variable_type IDENTIFIER $$76 opt_local_variable_initializer opt_variable_declarators SEMICOLON", -//t "$$77 :", -//t "block_variable_declaration : CONST variable_type IDENTIFIER $$77 const_variable_initializer opt_const_declarators SEMICOLON", +//t "$$78 :", +//t "block_variable_declaration : variable_type IDENTIFIER $$78 opt_local_variable_initializer opt_variable_declarators SEMICOLON", +//t "$$79 :", +//t "block_variable_declaration : CONST variable_type IDENTIFIER $$79 const_variable_initializer opt_const_declarators SEMICOLON", //t "opt_local_variable_initializer :", //t "opt_local_variable_initializer : ASSIGN block_variable_initializer", //t "opt_local_variable_initializer : error", @@ -964,15 +960,15 @@ namespace Mono.CSharp //t "selection_statement : switch_statement", //t "if_statement : IF open_parens_any boolean_expression CLOSE_PARENS embedded_statement", //t "if_statement : IF open_parens_any boolean_expression CLOSE_PARENS embedded_statement ELSE embedded_statement", -//t "$$78 :", -//t "switch_statement : SWITCH open_parens_any expression CLOSE_PARENS OPEN_BRACE $$78 opt_switch_sections CLOSE_BRACE", +//t "$$80 :", +//t "switch_statement : SWITCH open_parens_any expression CLOSE_PARENS OPEN_BRACE $$80 opt_switch_sections CLOSE_BRACE", //t "opt_switch_sections :", //t "opt_switch_sections : switch_sections", //t "switch_sections : switch_section", //t "switch_sections : switch_sections switch_section", //t "switch_sections : error", -//t "$$79 :", -//t "switch_section : switch_labels $$79 statement_list", +//t "$$81 :", +//t "switch_section : switch_labels $$81 statement_list", //t "switch_labels : switch_label", //t "switch_labels : switch_labels switch_label", //t "switch_label : CASE constant_expression COLON", @@ -983,14 +979,14 @@ namespace Mono.CSharp //t "iteration_statement : foreach_statement", //t "while_statement : WHILE open_parens_any boolean_expression CLOSE_PARENS embedded_statement", //t "do_statement : DO embedded_statement WHILE open_parens_any boolean_expression CLOSE_PARENS SEMICOLON", -//t "$$80 :", -//t "for_statement : FOR open_parens_any $$80 for_statement_cont", +//t "$$82 :", +//t "for_statement : FOR open_parens_any $$82 for_statement_cont", //t "for_statement_cont : opt_for_initializer SEMICOLON opt_for_condition SEMICOLON opt_for_iterator CLOSE_PARENS embedded_statement", //t "for_statement_cont : error", //t "opt_for_initializer :", //t "opt_for_initializer : for_initializer", -//t "$$81 :", -//t "for_initializer : variable_type IDENTIFIER $$81 opt_local_variable_initializer opt_variable_declarators", +//t "$$83 :", +//t "for_initializer : variable_type IDENTIFIER $$83 opt_local_variable_initializer opt_variable_declarators", //t "for_initializer : statement_expression_list", //t "opt_for_condition :", //t "opt_for_condition : boolean_expression", @@ -1000,8 +996,8 @@ namespace Mono.CSharp //t "statement_expression_list : statement_expression", //t "statement_expression_list : statement_expression_list COMMA statement_expression", //t "foreach_statement : FOREACH open_parens_any type IN expression CLOSE_PARENS", -//t "$$82 :", -//t "foreach_statement : FOREACH open_parens_any type IDENTIFIER IN expression CLOSE_PARENS $$82 embedded_statement", +//t "$$84 :", +//t "foreach_statement : FOREACH open_parens_any type IDENTIFIER IN expression CLOSE_PARENS $$84 embedded_statement", //t "jump_statement : break_statement", //t "jump_statement : continue_statement", //t "jump_statement : goto_statement", @@ -1028,20 +1024,20 @@ namespace Mono.CSharp //t "opt_identifier :", //t "opt_identifier : IDENTIFIER", //t "catch_clause : CATCH block", -//t "$$83 :", -//t "catch_clause : CATCH open_parens_any type opt_identifier CLOSE_PARENS $$83 block_prepared", +//t "$$85 :", +//t "catch_clause : CATCH open_parens_any type opt_identifier CLOSE_PARENS $$85 block_prepared", //t "catch_clause : CATCH open_parens_any error", //t "checked_statement : CHECKED block", //t "unchecked_statement : UNCHECKED block", -//t "$$84 :", -//t "unsafe_statement : UNSAFE $$84 block", -//t "lock_statement : LOCK open_parens_any expression CLOSE_PARENS embedded_statement", -//t "$$85 :", //t "$$86 :", -//t "fixed_statement : FIXED open_parens_any variable_type IDENTIFIER $$85 using_or_fixed_variable_initializer opt_variable_declarators CLOSE_PARENS $$86 embedded_statement", +//t "unsafe_statement : UNSAFE $$86 block", +//t "lock_statement : LOCK open_parens_any expression CLOSE_PARENS embedded_statement", //t "$$87 :", //t "$$88 :", -//t "using_statement : USING open_parens_any variable_type IDENTIFIER $$87 using_or_fixed_variable_initializer opt_variable_declarators CLOSE_PARENS $$88 embedded_statement", +//t "fixed_statement : FIXED open_parens_any variable_type IDENTIFIER $$87 using_or_fixed_variable_initializer opt_variable_declarators CLOSE_PARENS $$88 embedded_statement", +//t "$$89 :", +//t "$$90 :", +//t "using_statement : USING open_parens_any variable_type IDENTIFIER $$89 using_or_fixed_variable_initializer opt_variable_declarators CLOSE_PARENS $$90 embedded_statement", //t "using_statement : USING open_parens_any expression CLOSE_PARENS embedded_statement", //t "using_or_fixed_variable_initializer :", //t "using_or_fixed_variable_initializer : ASSIGN variable_initializer", @@ -1053,18 +1049,18 @@ namespace Mono.CSharp //t "first_from_clause : FROM_FIRST type IDENTIFIER IN expression", //t "nested_from_clause : FROM IDENTIFIER IN expression", //t "nested_from_clause : FROM type IDENTIFIER IN expression", -//t "$$89 :", -//t "from_clause : FROM IDENTIFIER IN $$89 expression", -//t "$$90 :", -//t "from_clause : FROM type IDENTIFIER IN $$90 expression", +//t "$$91 :", +//t "from_clause : FROM IDENTIFIER IN $$91 expression", +//t "$$92 :", +//t "from_clause : FROM type IDENTIFIER IN $$92 expression", //t "query_body : opt_query_body_clauses select_or_group_clause opt_query_continuation", //t "query_body : opt_query_body_clauses COMPLETE_COMPLETION", //t "query_body : error", -//t "$$91 :", -//t "select_or_group_clause : SELECT $$91 expression", -//t "$$92 :", //t "$$93 :", -//t "select_or_group_clause : GROUP $$92 expression $$93 BY expression", +//t "select_or_group_clause : SELECT $$93 expression", +//t "$$94 :", +//t "$$95 :", +//t "select_or_group_clause : GROUP $$94 expression $$95 BY expression", //t "opt_query_body_clauses :", //t "opt_query_body_clauses : query_body_clauses", //t "query_body_clauses : query_body_clause", @@ -1074,28 +1070,28 @@ namespace Mono.CSharp //t "query_body_clause : where_clause", //t "query_body_clause : join_clause", //t "query_body_clause : orderby_clause", -//t "$$94 :", -//t "let_clause : LET IDENTIFIER ASSIGN $$94 expression", -//t "$$95 :", -//t "where_clause : WHERE $$95 boolean_expression", //t "$$96 :", +//t "let_clause : LET IDENTIFIER ASSIGN $$96 expression", //t "$$97 :", +//t "where_clause : WHERE $$97 expression", //t "$$98 :", -//t "join_clause : JOIN IDENTIFIER IN $$96 expression ON $$97 expression EQUALS $$98 expression opt_join_into", //t "$$99 :", //t "$$100 :", +//t "join_clause : JOIN IDENTIFIER IN $$98 expression ON $$99 expression EQUALS $$100 expression opt_join_into", //t "$$101 :", -//t "join_clause : JOIN type IDENTIFIER IN $$99 expression ON $$100 expression EQUALS $$101 expression opt_join_into", +//t "$$102 :", +//t "$$103 :", +//t "join_clause : JOIN type IDENTIFIER IN $$101 expression ON $$102 expression EQUALS $$103 expression opt_join_into", //t "opt_join_into :", //t "opt_join_into : INTO IDENTIFIER", -//t "$$102 :", -//t "orderby_clause : ORDERBY $$102 orderings", +//t "$$104 :", +//t "orderby_clause : ORDERBY $$104 orderings", //t "orderings : order_by", -//t "$$103 :", -//t "orderings : order_by COMMA $$103 orderings_then_by", +//t "$$105 :", +//t "orderings : order_by COMMA $$105 orderings_then_by", //t "orderings_then_by : then_by", -//t "$$104 :", -//t "orderings_then_by : orderings_then_by COMMA $$104 then_by", +//t "$$106 :", +//t "orderings_then_by : orderings_then_by COMMA $$106 then_by", //t "order_by : expression", //t "order_by : expression ASCENDING", //t "order_by : expression DESCENDING", @@ -1103,18 +1099,15 @@ namespace Mono.CSharp //t "then_by : expression ASCENDING", //t "then_by : expression DESCENDING", //t "opt_query_continuation :", -//t "$$105 :", -//t "opt_query_continuation : INTO IDENTIFIER $$105 query_body", +//t "$$107 :", +//t "opt_query_continuation : INTO IDENTIFIER $$107 query_body", //t "interactive_parsing : EVAL_STATEMENT_PARSER EOF", //t "interactive_parsing : EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives opt_COMPLETE_COMPLETION", -//t "$$106 :", -//t "interactive_parsing : EVAL_STATEMENT_PARSER $$106 interactive_statement_list opt_COMPLETE_COMPLETION", -//t "$$107 :", -//t "interactive_parsing : EVAL_COMPILATION_UNIT_PARSER $$107 interactive_compilation_unit", -//t "interactive_compilation_unit : outer_declarations", -//t "interactive_compilation_unit : outer_declarations global_attributes", -//t "interactive_compilation_unit : global_attributes", -//t "interactive_compilation_unit :", +//t "$$108 :", +//t "interactive_parsing : EVAL_STATEMENT_PARSER $$108 interactive_statement_list opt_COMPLETE_COMPLETION", +//t "interactive_parsing : EVAL_COMPILATION_UNIT_PARSER interactive_compilation_unit", +//t "interactive_compilation_unit : opt_extern_alias_directives opt_using_directives", +//t "interactive_compilation_unit : opt_extern_alias_directives opt_using_directives namespace_or_type_declarations", //t "opt_COMPLETE_COMPLETION :", //t "opt_COMPLETE_COMPLETION : COMPLETE_COMPLETION", //t "close_brace_or_complete_completion : CLOSE_BRACE", @@ -1157,14 +1150,14 @@ namespace Mono.CSharp "VOLATILE","WHERE","WHILE","ARGLIST","PARTIAL","ARROW","FROM", "FROM_FIRST","JOIN","ON","EQUALS","SELECT","GROUP","BY","LET", "ORDERBY","ASCENDING","DESCENDING","INTO","INTERR_NULLABLE", - "EXTERN_ALIAS","ASYNC","GET","SET","LAST_KEYWORD","OPEN_BRACE", - "CLOSE_BRACE","OPEN_BRACKET","CLOSE_BRACKET","OPEN_PARENS", - "CLOSE_PARENS","DOT","COMMA","COLON","SEMICOLON","TILDE","PLUS", - "MINUS","BANG","ASSIGN","OP_LT","OP_GT","BITWISE_AND","BITWISE_OR", - "STAR","PERCENT","DIV","CARRET","INTERR","DOUBLE_COLON","OP_INC", - "OP_DEC","OP_SHIFT_LEFT","OP_SHIFT_RIGHT","OP_LE","OP_GE","OP_EQ", - "OP_NE","OP_AND","OP_OR","OP_MULT_ASSIGN","OP_DIV_ASSIGN", - "OP_MOD_ASSIGN","OP_ADD_ASSIGN","OP_SUB_ASSIGN", + "EXTERN_ALIAS","ASYNC","REFVALUE","REFTYPE","MAKEREF","GET","SET", + "LAST_KEYWORD","OPEN_BRACE","CLOSE_BRACE","OPEN_BRACKET", + "CLOSE_BRACKET","OPEN_PARENS","CLOSE_PARENS","DOT","COMMA","COLON", + "SEMICOLON","TILDE","PLUS","MINUS","BANG","ASSIGN","OP_LT","OP_GT", + "BITWISE_AND","BITWISE_OR","STAR","PERCENT","DIV","CARRET","INTERR", + "DOUBLE_COLON","OP_INC","OP_DEC","OP_SHIFT_LEFT","OP_SHIFT_RIGHT", + "OP_LE","OP_GE","OP_EQ","OP_NE","OP_AND","OP_OR","OP_MULT_ASSIGN", + "OP_DIV_ASSIGN","OP_MOD_ASSIGN","OP_ADD_ASSIGN","OP_SUB_ASSIGN", "OP_SHIFT_LEFT_ASSIGN","OP_SHIFT_RIGHT_ASSIGN","OP_AND_ASSIGN", "OP_XOR_ASSIGN","OP_OR_ASSIGN","OP_PTR","OP_COALESCING", "OP_GENERICS_LT","OP_GENERICS_LT_DECL","OP_GENERICS_GT","LITERAL", @@ -1357,30 +1350,48 @@ namespace Mono.CSharp //t debug.reduce(yyState, yyStates[yyV-1], yyN, YYRules.getRule (yyN), yyLen[yyN]); yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { -case 5: +case 1: +#line 376 "cs-parser.jay" + { + Lexer.check_incorrect_doc_comment (); + } + break; +case 2: #line 377 "cs-parser.jay" { Lexer.CompleteOnEOF = false; } break; -case 7: -#line 384 "cs-parser.jay" +case 5: + case_5(); + break; +case 6: +#line 393 "cs-parser.jay" { - Lexer.check_incorrect_doc_comment (); + module.AddAttributes ((Attributes) yyVals[0+yyTop], current_namespace); } break; -case 8: -#line 388 "cs-parser.jay" +case 7: + case_7(); + break; +case 12: + case_12(); + break; +case 13: +#line 431 "cs-parser.jay" { - Lexer.check_incorrect_doc_comment (); + syntax_error (GetLocation (yyVals[-1+yyTop]), "`alias' expected"); /* TODO: better*/ } break; case 16: case_16(); break; case 17: -#line 424 "cs-parser.jay" - { - syntax_error (GetLocation (yyVals[-1+yyTop]), "`alias' expected"); /* TODO: better*/ - } + case_17(); + break; +case 18: + case_18(); + break; +case 19: + case_19(); break; case 20: case_20(); @@ -1403,41 +1414,32 @@ case 25: case 26: case_26(); break; -case 27: - case_27(); - break; -case 28: - case_28(); - break; -case 29: - case_29(); - break; -case 34: - case_34(); +case 31: + case_31(); break; -case 35: - case_35(); +case 40: + case_40(); break; -case 36: -#line 549 "cs-parser.jay" +case 41: +#line 619 "cs-parser.jay" { - ubag.CloseNamespace (GetLocation (yyVals[0+yyTop])); + current_namespace.DeclarationFound = true; } break; -case 45: - case_45(); +case 49: + case_49(); + break; +case 50: + case_50(); break; -case 46: -#line 587 "cs-parser.jay" +case 51: +#line 668 "cs-parser.jay" { - current_namespace.DeclarationFound = true; + lexer.parsing_attribute_section = true; } break; -case 47: -#line 591 "cs-parser.jay" - { - Error_SyntaxError (yyToken); - } +case 52: + case_52(); break; case 53: case_53(); @@ -1446,196 +1448,189 @@ case 54: case_54(); break; case 55: - case_55(); +#line 698 "cs-parser.jay" + { + yyVal = yyVals[-2+yyTop]; + } break; case 56: case_56(); break; case 57: - case_57(); +#line 707 "cs-parser.jay" + { yyVal = "event"; } break; case 58: -#line 706 "cs-parser.jay" - { - yyVal = yyVals[-2+yyTop]; - } +#line 708 "cs-parser.jay" + { yyVal = "return"; } break; case 59: -#line 710 "cs-parser.jay" - { - yyVal = yyVals[-2+yyTop]; - } + case_59(); break; case 60: - case_60(); +#line 725 "cs-parser.jay" + { + yyVal = new List (4) { (Attribute) yyVals[0+yyTop] }; + } break; case 61: case_61(); break; case 62: -#line 727 "cs-parser.jay" - { yyVal = "event"; } +#line 739 "cs-parser.jay" + { + ++lexer.parsing_block; + } break; case 63: -#line 728 "cs-parser.jay" - { yyVal = "return"; } - break; -case 64: - case_64(); + case_63(); break; case 65: -#line 740 "cs-parser.jay" - { - yyVal = new List (4) { (Attribute) yyVals[0+yyTop] }; - } +#line 760 "cs-parser.jay" + { yyVal = null; } break; case 66: - case_66(); - break; -case 67: -#line 754 "cs-parser.jay" +#line 764 "cs-parser.jay" { - ++lexer.parsing_block; + yyVal = yyVals[-1+yyTop]; } break; +case 67: +#line 769 "cs-parser.jay" + { yyVal = null; } + break; case 68: case_68(); break; case 69: -#line 779 "cs-parser.jay" - { /* reserved attribute name or identifier: 17.4 */ } + case_69(); break; case 70: -#line 783 "cs-parser.jay" - { yyVal = null; } + case_70(); break; case 71: -#line 787 "cs-parser.jay" - { - yyVal = yyVals[-1+yyTop]; - } + case_71(); break; case 72: -#line 792 "cs-parser.jay" - { yyVal = null; } - break; -case 73: - case_73(); - break; -case 74: - case_74(); - break; -case 75: - case_75(); - break; -case 76: - case_76(); - break; -case 77: -#line 836 "cs-parser.jay" +#line 813 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; -case 79: -#line 844 "cs-parser.jay" +case 74: +#line 821 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 80: - case_80(); +case 75: + case_75(); break; -case 81: - case_81(); +case 76: + case_76(); break; -case 82: -#line 868 "cs-parser.jay" +case 77: +#line 845 "cs-parser.jay" { yyVal = null; } break; -case 83: -#line 872 "cs-parser.jay" +case 78: +#line 849 "cs-parser.jay" { yyVal = Argument.AType.Ref; } break; -case 84: -#line 876 "cs-parser.jay" +case 79: +#line 853 "cs-parser.jay" { yyVal = Argument.AType.Out; } break; -case 99: - case_99(); +case 94: + case_94(); break; -case 100: -#line 917 "cs-parser.jay" +case 95: +#line 894 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 101: - case_101(); +case 96: + case_96(); break; -case 102: - case_102(); +case 97: + case_97(); break; -case 103: - case_103(); +case 98: + case_98(); break; -case 104: - case_104(); +case 99: + case_99(); break; -case 105: -#line 949 "cs-parser.jay" +case 100: +#line 926 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; -case 106: - case_106(); +case 101: + case_101(); break; -case 107: -#line 961 "cs-parser.jay" +case 102: +#line 938 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } break; -case 122: - case_122(); +case 117: + case_117(); break; -case 123: - case_123(); +case 118: + case_118(); break; -case 126: -#line 1030 "cs-parser.jay" +case 121: +#line 1007 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 127: -#line 1034 "cs-parser.jay" +case 122: +#line 1011 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 128: - case_128(); +case 123: + case_123(); break; -case 129: -#line 1050 "cs-parser.jay" +case 124: +#line 1027 "cs-parser.jay" { ++lexer.parsing_block; } break; +case 125: + case_125(); + break; +case 126: + case_126(); + break; +case 129: + case_129(); + break; case 130: case_130(); break; case 131: case_131(); break; -case 134: - case_134(); +case 132: + case_132(); + break; +case 133: +#line 1106 "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"); + } break; case 135: case_135(); @@ -1643,65 +1638,59 @@ case 135: case 136: case_136(); break; -case 137: - case_137(); - break; -case 138: -#line 1128 "cs-parser.jay" +case 139: +#line 1136 "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"); + current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 140: - case_140(); +#line 1140 "cs-parser.jay" + { + current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); + } break; case 141: case_141(); break; -case 144: -#line 1158 "cs-parser.jay" +case 142: +#line 1153 "cs-parser.jay" { - current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); + ++lexer.parsing_block; } break; -case 145: -#line 1162 "cs-parser.jay" +case 143: + case_143(); + break; +case 146: +#line 1172 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 146: - case_146(); - break; case 147: -#line 1175 "cs-parser.jay" +#line 1176 "cs-parser.jay" { - ++lexer.parsing_block; + current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 148: case_148(); break; -case 151: -#line 1194 "cs-parser.jay" +case 149: +#line 1192 "cs-parser.jay" { - current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); + ++lexer.parsing_block; } break; -case 152: -#line 1198 "cs-parser.jay" - { - current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); - } +case 150: + case_150(); break; -case 153: - case_153(); +case 151: + case_151(); break; case 154: -#line 1214 "cs-parser.jay" - { - ++lexer.parsing_block; - } + case_154(); break; case 155: case_155(); @@ -1709,55 +1698,61 @@ case 155: case 156: case_156(); break; -case 159: - case_159(); - break; -case 160: - case_160(); - break; -case 161: - case_161(); - break; -case 162: -#line 1271 "cs-parser.jay" +case 157: +#line 1249 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; -case 163: -#line 1275 "cs-parser.jay" +case 158: +#line 1253 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 164: - case_164(); +case 159: + case_159(); break; -case 165: -#line 1316 "cs-parser.jay" +case 160: +#line 1294 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; -case 166: -#line 1320 "cs-parser.jay" +case 161: +#line 1298 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 167: - case_167(); +case 162: + case_162(); + break; +case 163: + case_163(); + break; +case 165: +#line 1374 "cs-parser.jay" + { yyVal = null; } + break; +case 166: +#line 1378 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 168: case_168(); break; +case 169: + case_169(); + break; case 170: -#line 1396 "cs-parser.jay" - { yyVal = null; } + case_170(); break; case 171: -#line 1400 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + case_171(); + break; +case 172: + case_172(); break; case 173: case_173(); @@ -1766,10 +1761,16 @@ case 174: case_174(); break; case 175: - case_175(); +#line 1437 "cs-parser.jay" + { + yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); + } break; case 176: - case_176(); +#line 1441 "cs-parser.jay" + { + yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); + } break; case 177: case_177(); @@ -1781,47 +1782,41 @@ case 179: case_179(); break; case 180: -#line 1459 "cs-parser.jay" - { - yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); - } + case_180(); break; case 181: -#line 1463 "cs-parser.jay" - { - yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); - } + case_181(); break; case 182: case_182(); break; case 183: - case_183(); +#line 1516 "cs-parser.jay" + { + ++lexer.parsing_block; + } break; case 184: case_184(); break; case 185: - case_185(); - break; -case 186: - case_186(); +#line 1557 "cs-parser.jay" + { yyVal = Parameter.Modifier.NONE; } break; case 187: case_187(); break; case 188: -#line 1538 "cs-parser.jay" - { - ++lexer.parsing_block; - } + case_188(); break; case 189: case_189(); break; case 190: -#line 1579 "cs-parser.jay" - { yyVal = Parameter.Modifier.NONE; } + case_190(); + break; +case 191: + case_191(); break; case 192: case_192(); @@ -1839,7 +1834,10 @@ case 196: case_196(); break; case 197: - case_197(); +#line 1655 "cs-parser.jay" + { + Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); + } break; case 198: case_198(); @@ -1854,46 +1852,40 @@ case 201: case_201(); break; case 202: -#line 1677 "cs-parser.jay" - { - Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); - } + case_202(); break; case 203: - case_203(); +#line 1709 "cs-parser.jay" + { + valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; + } break; case 204: case_204(); break; case 205: - case_205(); +#line 1739 "cs-parser.jay" + { + lexer.PropertyParsing = false; + } break; case 206: case_206(); break; -case 207: - case_207(); - break; -case 208: -#line 1730 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; - } +case 211: + case_211(); break; -case 209: - case_209(); +case 212: + case_212(); break; -case 210: -#line 1760 "cs-parser.jay" - { - lexer.PropertyParsing = false; - } +case 213: + case_213(); break; -case 211: - case_211(); +case 214: + case_214(); break; -case 216: - case_216(); +case 215: + case_215(); break; case 217: case_217(); @@ -1902,11 +1894,17 @@ case 218: case_218(); break; case 219: - case_219(); +#line 1881 "cs-parser.jay" + { + lexer.ConstraintsParsing = true; + } break; case 220: case_220(); break; +case 221: + case_221(); + break; case 222: case_222(); break; @@ -1914,225 +1912,222 @@ case 223: case_223(); break; case 224: -#line 1902 "cs-parser.jay" - { - lexer.ConstraintsParsing = true; - } - break; -case 225: - case_225(); - break; -case 226: - case_226(); - break; -case 227: - case_227(); - break; -case 228: - case_228(); - break; -case 229: -#line 1935 "cs-parser.jay" +#line 1914 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; -case 234: -#line 1952 "cs-parser.jay" +case 229: +#line 1931 "cs-parser.jay" { Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; -case 235: -#line 1956 "cs-parser.jay" +case 230: +#line 1935 "cs-parser.jay" { Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; -case 240: -#line 1964 "cs-parser.jay" +case 235: +#line 1943 "cs-parser.jay" { Report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators"); } break; -case 241: -#line 1968 "cs-parser.jay" +case 236: +#line 1947 "cs-parser.jay" { Report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors"); } break; -case 242: -#line 1972 "cs-parser.jay" +case 237: +#line 1951 "cs-parser.jay" { Report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); } break; -case 243: -#line 1978 "cs-parser.jay" +case 238: +#line 1957 "cs-parser.jay" { } break; -case 244: - case_244(); +case 239: + case_239(); break; -case 246: -#line 2005 "cs-parser.jay" +case 241: +#line 1984 "cs-parser.jay" { yyVal = null; } break; -case 248: - case_248(); +case 243: + case_243(); break; -case 249: -#line 2021 "cs-parser.jay" +case 244: +#line 2000 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; -case 250: - case_250(); +case 245: + case_245(); break; -case 252: -#line 2067 "cs-parser.jay" +case 247: +#line 2046 "cs-parser.jay" { yyVal = Operator.OpType.LogicalNot; } break; -case 253: -#line 2068 "cs-parser.jay" +case 248: +#line 2047 "cs-parser.jay" { yyVal = Operator.OpType.OnesComplement; } break; -case 254: -#line 2069 "cs-parser.jay" +case 249: +#line 2048 "cs-parser.jay" { yyVal = Operator.OpType.Increment; } break; -case 255: -#line 2070 "cs-parser.jay" +case 250: +#line 2049 "cs-parser.jay" { yyVal = Operator.OpType.Decrement; } break; -case 256: -#line 2071 "cs-parser.jay" +case 251: +#line 2050 "cs-parser.jay" { yyVal = Operator.OpType.True; } break; -case 257: -#line 2072 "cs-parser.jay" +case 252: +#line 2051 "cs-parser.jay" { yyVal = Operator.OpType.False; } break; -case 258: -#line 2074 "cs-parser.jay" +case 253: +#line 2053 "cs-parser.jay" { yyVal = Operator.OpType.Addition; } break; -case 259: -#line 2075 "cs-parser.jay" +case 254: +#line 2054 "cs-parser.jay" { yyVal = Operator.OpType.Subtraction; } break; -case 260: -#line 2077 "cs-parser.jay" +case 255: +#line 2056 "cs-parser.jay" { yyVal = Operator.OpType.Multiply; } break; -case 261: -#line 2078 "cs-parser.jay" +case 256: +#line 2057 "cs-parser.jay" { yyVal = Operator.OpType.Division; } break; -case 262: -#line 2079 "cs-parser.jay" +case 257: +#line 2058 "cs-parser.jay" { yyVal = Operator.OpType.Modulus; } break; -case 263: -#line 2080 "cs-parser.jay" +case 258: +#line 2059 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseAnd; } break; -case 264: -#line 2081 "cs-parser.jay" +case 259: +#line 2060 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseOr; } break; -case 265: -#line 2082 "cs-parser.jay" +case 260: +#line 2061 "cs-parser.jay" { yyVal = Operator.OpType.ExclusiveOr; } break; -case 266: -#line 2083 "cs-parser.jay" +case 261: +#line 2062 "cs-parser.jay" { yyVal = Operator.OpType.LeftShift; } break; -case 267: -#line 2084 "cs-parser.jay" +case 262: +#line 2063 "cs-parser.jay" { yyVal = Operator.OpType.RightShift; } break; -case 268: -#line 2085 "cs-parser.jay" +case 263: +#line 2064 "cs-parser.jay" { yyVal = Operator.OpType.Equality; } break; -case 269: -#line 2086 "cs-parser.jay" +case 264: +#line 2065 "cs-parser.jay" { yyVal = Operator.OpType.Inequality; } break; -case 270: -#line 2087 "cs-parser.jay" +case 265: +#line 2066 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThan; } break; -case 271: -#line 2088 "cs-parser.jay" +case 266: +#line 2067 "cs-parser.jay" { yyVal = Operator.OpType.LessThan; } break; -case 272: -#line 2089 "cs-parser.jay" +case 267: +#line 2068 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThanOrEqual; } break; -case 273: -#line 2090 "cs-parser.jay" +case 268: +#line 2069 "cs-parser.jay" { yyVal = Operator.OpType.LessThanOrEqual; } break; -case 274: -#line 2097 "cs-parser.jay" +case 269: +#line 2076 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; -case 275: - case_275(); +case 270: + case_270(); break; -case 276: -#line 2116 "cs-parser.jay" +case 271: +#line 2095 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; +case 272: + case_272(); + break; +case 273: + case_273(); + break; +case 274: + case_274(); + break; +case 275: + case_275(); + break; +case 276: + case_276(); + break; case 277: case_277(); break; case 278: case_278(); break; -case 279: - case_279(); - break; case 280: - case_280(); - break; -case 281: - case_281(); - break; -case 282: - case_282(); +#line 2198 "cs-parser.jay" + { current_block = null; yyVal = null; } break; case 283: - case_283(); +#line 2210 "cs-parser.jay" + { + ++lexer.parsing_block; + } break; -case 285: -#line 2219 "cs-parser.jay" - { current_block = null; yyVal = null; } +case 284: + case_284(); break; -case 288: -#line 2231 "cs-parser.jay" +case 285: +#line 2220 "cs-parser.jay" { ++lexer.parsing_block; } break; +case 286: + case_286(); + break; +case 287: + case_287(); + break; +case 288: + case_288(); + break; case 289: case_289(); break; case 290: -#line 2241 "cs-parser.jay" - { - ++lexer.parsing_block; - } + case_290(); break; case 291: case_291(); @@ -2146,49 +2141,46 @@ case 293: case 294: case_294(); break; -case 295: - case_295(); - break; case 296: - case_296(); +#line 2329 "cs-parser.jay" + { + ++lexer.parsing_block; + } break; case 297: case_297(); break; -case 298: - case_298(); - break; -case 299: - case_299(); +case 300: +#line 2346 "cs-parser.jay" + { + current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); + } break; case 301: #line 2350 "cs-parser.jay" { - ++lexer.parsing_block; + current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 302: case_302(); break; -case 305: -#line 2367 "cs-parser.jay" +case 303: +#line 2363 "cs-parser.jay" { - current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); + ++lexer.parsing_block; } break; -case 306: -#line 2371 "cs-parser.jay" - { - current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); - } +case 304: + case_304(); break; -case 307: - case_307(); +case 305: + case_305(); break; -case 308: -#line 2384 "cs-parser.jay" +case 306: +#line 2388 "cs-parser.jay" { - ++lexer.parsing_block; + yyVal = yyVals[0+yyTop]; } break; case 309: @@ -2198,10 +2190,13 @@ case 310: case_310(); break; case 311: -#line 2409 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_311(); + break; +case 312: + case_312(); + break; +case 313: + case_313(); break; case 314: case_314(); @@ -2212,9 +2207,6 @@ case 315: case 316: case_316(); break; -case 317: - case_317(); - break; case 318: case_318(); break; @@ -2233,53 +2225,50 @@ case 323: case 324: case_324(); break; -case 325: - case_325(); - break; -case 326: - case_326(); - break; -case 328: - case_328(); +case 327: +#line 2543 "cs-parser.jay" + { + lbag.AddLocation (yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); + } break; case 329: case_329(); break; +case 330: + case_330(); + break; +case 331: + case_331(); + break; case 332: -#line 2568 "cs-parser.jay" + case_332(); + break; +case 333: +#line 2601 "cs-parser.jay" { - lbag.AddLocation (yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; } break; case 334: case_334(); break; case 335: - case_335(); +#line 2621 "cs-parser.jay" + { + lexer.ConstraintsParsing = false; + } break; case 336: case_336(); break; -case 337: - case_337(); - break; case 338: -#line 2626 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; - } - break; -case 339: - case_339(); + case_338(); break; case 340: -#line 2652 "cs-parser.jay" - { - lexer.ConstraintsParsing = false; - } + case_340(); break; -case 341: - case_341(); +case 342: + case_342(); break; case 343: case_343(); @@ -2287,29 +2276,32 @@ case 343: case 345: case_345(); break; +case 346: + case_346(); + break; case 347: case_347(); break; case 348: case_348(); break; +case 349: +#line 2719 "cs-parser.jay" + { + lexer.parsing_generic_declaration = true; + } + break; case 350: case_350(); break; case 351: case_351(); break; -case 352: - case_352(); - break; case 353: case_353(); break; case 354: -#line 2745 "cs-parser.jay" - { - lexer.parsing_generic_declaration = true; - } + case_354(); break; case 355: case_355(); @@ -2317,12 +2309,12 @@ case 355: case 356: case_356(); break; +case 357: + case_357(); + break; case 358: case_358(); break; -case 359: - case_359(); - break; case 360: case_360(); break; @@ -2335,197 +2327,195 @@ case 362: case 363: case_363(); break; -case 365: - case_365(); +case 364: + case_364(); break; case 366: - case_366(); +#line 2837 "cs-parser.jay" + { + yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); + } break; case 367: - case_367(); - break; -case 368: - case_368(); +#line 2844 "cs-parser.jay" + { + lexer.parsing_generic_declaration = true; + } break; case 369: case_369(); break; case 371: -#line 2863 "cs-parser.jay" - { - yyVal = new TypeExpression (TypeManager.void_type, GetLocation (yyVals[0+yyTop])); - } + case_371(); break; -case 372: -#line 2870 "cs-parser.jay" +case 373: + case_373(); + break; +case 375: +#line 2882 "cs-parser.jay" { - lexer.parsing_generic_declaration = true; + yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 374: - case_374(); - break; case 376: case_376(); break; +case 377: +#line 2902 "cs-parser.jay" + { + yyVal = new ComposedCast (((MemberName) yyVals[-1+yyTop]).GetTypeExpression (), (ComposedTypeSpecifier) yyVals[0+yyTop]); + } + break; case 378: case_378(); break; -case 380: -#line 2908 "cs-parser.jay" +case 379: +#line 2911 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; +case 380: +#line 2915 "cs-parser.jay" + { + yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); + } + break; case 381: case_381(); break; case 382: -#line 2928 "cs-parser.jay" - { - yyVal = new ComposedCast (((MemberName) yyVals[-1+yyTop]).GetTypeExpression (), (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_382(); break; case 383: case_383(); break; case 384: -#line 2937 "cs-parser.jay" - { - yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_384(); break; case 385: -#line 2941 "cs-parser.jay" - { - yyVal = new ComposedCast (new TypeExpression (TypeManager.void_type, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); - } +#line 2953 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } break; case 386: - case_386(); +#line 2954 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } break; case 387: - case_387(); +#line 2955 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } break; case 388: - case_388(); +#line 2956 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } break; case 389: - case_389(); +#line 2957 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } break; case 390: -#line 2979 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.object_type, GetLocation (yyVals[0+yyTop])); } - break; -case 391: -#line 2980 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.string_type, GetLocation (yyVals[0+yyTop])); } +#line 2958 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } break; case 392: -#line 2981 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.bool_type, GetLocation (yyVals[0+yyTop])); } +#line 2963 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); } break; case 393: -#line 2982 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.decimal_type, GetLocation (yyVals[0+yyTop])); } +#line 2964 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); } break; case 394: -#line 2983 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.float_type, GetLocation (yyVals[0+yyTop])); } +#line 2965 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); } break; case 395: -#line 2984 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.double_type, GetLocation (yyVals[0+yyTop])); } +#line 2966 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); } + break; +case 396: +#line 2967 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); } break; case 397: -#line 2989 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.sbyte_type, GetLocation (yyVals[0+yyTop])); } +#line 2968 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); } break; case 398: -#line 2990 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.byte_type, GetLocation (yyVals[0+yyTop])); } +#line 2969 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); } break; case 399: -#line 2991 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.short_type, GetLocation (yyVals[0+yyTop])); } +#line 2970 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); } break; case 400: -#line 2992 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.ushort_type, GetLocation (yyVals[0+yyTop])); } +#line 2971 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); } break; -case 401: -#line 2993 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.int32_type, GetLocation (yyVals[0+yyTop])); } +case 421: + case_421(); break; -case 402: -#line 2994 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.uint32_type, GetLocation (yyVals[0+yyTop])); } +case 422: + case_422(); break; -case 403: -#line 2995 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.int64_type, GetLocation (yyVals[0+yyTop])); } - break; -case 404: -#line 2996 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.uint64_type, GetLocation (yyVals[0+yyTop])); } +case 426: +#line 3018 "cs-parser.jay" + { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } break; -case 405: -#line 2997 "cs-parser.jay" - { yyVal = new TypeExpression (TypeManager.char_type, GetLocation (yyVals[0+yyTop])); } +case 427: +#line 3022 "cs-parser.jay" + { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } break; -case 425: - case_425(); +case 428: +#line 3023 "cs-parser.jay" + { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } break; -case 426: - case_426(); +case 433: + case_433(); break; -case 430: -#line 3043 "cs-parser.jay" - { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } +case 434: +#line 3056 "cs-parser.jay" + { + yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); + } break; -case 431: -#line 3047 "cs-parser.jay" - { yyVal = new BoolLiteral (true, GetLocation (yyVals[0+yyTop])); } +case 435: + case_435(); break; -case 432: -#line 3048 "cs-parser.jay" - { yyVal = new BoolLiteral (false, GetLocation (yyVals[0+yyTop])); } +case 436: + case_436(); break; case 437: case_437(); break; case 438: -#line 3081 "cs-parser.jay" - { - yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); - } + case_438(); break; case 439: - case_439(); +#line 3087 "cs-parser.jay" + { + yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); + } break; case 440: case_440(); break; case 441: - case_441(); +#line 3095 "cs-parser.jay" + { + yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); + } break; case 442: case_442(); break; case 443: -#line 3112 "cs-parser.jay" - { - yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); - } + case_443(); break; case 444: - case_444(); - break; -case 445: -#line 3120 "cs-parser.jay" - { - yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); - } +#line 3111 "cs-parser.jay" + { yyVal = null; } break; case 446: case_446(); @@ -2534,9 +2524,15 @@ case 447: case_447(); break; case 448: -#line 3136 "cs-parser.jay" +#line 3134 "cs-parser.jay" { yyVal = null; } break; +case 449: +#line 3138 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } + break; case 450: case_450(); break; @@ -2544,17 +2540,16 @@ case 451: case_451(); break; case 452: -#line 3159 "cs-parser.jay" - { yyVal = null; } + case_452(); break; case 453: -#line 3163 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_453(); break; case 454: - case_454(); +#line 3170 "cs-parser.jay" + { + yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); + } break; case 455: case_455(); @@ -2565,48 +2560,42 @@ case 456: case 457: case_457(); break; -case 458: -#line 3195 "cs-parser.jay" - { - yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); - } - break; -case 459: - case_459(); - break; case 460: - case_460(); +#line 3198 "cs-parser.jay" + { yyVal = null; } break; -case 461: - case_461(); +case 462: + case_462(); + break; +case 463: + case_463(); break; case 464: -#line 3223 "cs-parser.jay" - { yyVal = null; } + case_464(); + break; +case 465: + case_465(); break; case 466: case_466(); break; case 467: - case_467(); - break; -case 468: - case_468(); - break; -case 469: - case_469(); - break; -case 470: - case_470(); - break; -case 471: -#line 3275 "cs-parser.jay" +#line 3250 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; -case 475: - case_475(); +case 471: + case_471(); + break; +case 472: + case_472(); + break; +case 473: + case_473(); + break; +case 474: + case_474(); break; case 476: case_476(); @@ -2617,6 +2606,9 @@ case 477: case 478: case_478(); break; +case 479: + case_479(); + break; case 480: case_480(); break; @@ -2624,27 +2616,33 @@ case 481: case_481(); break; case 482: - case_482(); - break; -case 483: - case_483(); +#line 3337 "cs-parser.jay" + { + yyVal = new Argument ((Expression) yyVals[0+yyTop]); + } break; case 484: - case_484(); +#line 3345 "cs-parser.jay" + { + yyVal = new This (GetLocation (yyVals[0+yyTop])); + } break; case 485: case_485(); break; case 486: -#line 3362 "cs-parser.jay" + case_486(); + break; +case 487: +#line 3365 "cs-parser.jay" { - yyVal = new Argument ((Expression) yyVals[0+yyTop]); + yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; case 488: -#line 3370 "cs-parser.jay" +#line 3372 "cs-parser.jay" { - yyVal = new This (GetLocation (yyVals[0+yyTop])); + yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; case 489: @@ -2654,16 +2652,10 @@ case 490: case_490(); break; case 491: -#line 3390 "cs-parser.jay" - { - yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); - } + case_491(); break; case 492: -#line 3397 "cs-parser.jay" - { - yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); - } + case_492(); break; case 493: case_493(); @@ -2675,7 +2667,10 @@ case 495: case_495(); break; case 496: - case_496(); +#line 3438 "cs-parser.jay" + { + ++lexer.parsing_type; + } break; case 497: case_497(); @@ -2683,24 +2678,21 @@ case 497: case 498: case_498(); break; -case 499: - case_499(); - break; -case 500: -#line 3463 "cs-parser.jay" - { - ++lexer.parsing_type; - } - break; case 501: - case_501(); +#line 3465 "cs-parser.jay" + { yyVal = null; } break; -case 502: - case_502(); +case 503: + case_503(); + break; +case 504: + case_504(); break; case 505: -#line 3490 "cs-parser.jay" - { yyVal = null; } + case_505(); + break; +case 506: + case_506(); break; case 507: case_507(); @@ -2708,72 +2700,72 @@ case 507: case 508: case_508(); break; -case 509: - case_509(); - break; -case 510: - case_510(); - break; -case 511: - case_511(); - break; case 512: case_512(); break; -case 516: - case_516(); - break; -case 517: - case_517(); +case 513: + case_513(); break; -case 518: - case_518(); +case 514: + case_514(); break; -case 519: -#line 3566 "cs-parser.jay" +case 515: +#line 3541 "cs-parser.jay" { yyVal = 2; } break; -case 520: -#line 3570 "cs-parser.jay" +case 516: +#line 3545 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; -case 521: -#line 3577 "cs-parser.jay" +case 517: +#line 3552 "cs-parser.jay" { yyVal = null; } break; -case 522: -#line 3581 "cs-parser.jay" +case 518: +#line 3556 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 523: - case_523(); +case 519: + case_519(); break; -case 524: - case_524(); +case 520: + case_520(); break; -case 525: - case_525(); +case 521: + case_521(); break; -case 526: - case_526(); +case 522: + case_522(); break; -case 527: -#line 3625 "cs-parser.jay" +case 523: +#line 3600 "cs-parser.jay" { lexer.TypeOfParsing = true; } break; +case 524: + case_524(); + break; +case 527: + case_527(); + break; case 528: case_528(); break; +case 529: + case_529(); + break; +case 530: + case_530(); + break; case 531: case_531(); break; @@ -2799,130 +2791,127 @@ case 538: case_538(); break; case 539: - case_539(); - break; -case 540: - case_540(); - break; -case 541: - case_541(); - break; -case 542: - case_542(); - break; -case 543: -#line 3738 "cs-parser.jay" +#line 3713 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 544: -#line 3742 "cs-parser.jay" +case 540: +#line 3717 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); } break; -case 545: -#line 3749 "cs-parser.jay" +case 541: +#line 3724 "cs-parser.jay" { yyVal = ParametersCompiled.Undefined; } break; -case 547: -#line 3757 "cs-parser.jay" +case 543: +#line 3732 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 548: - case_548(); +case 544: + case_544(); break; -case 549: - case_549(); +case 545: + case_545(); break; -case 551: -#line 3781 "cs-parser.jay" +case 547: +#line 3756 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 552: -#line 3785 "cs-parser.jay" +case 548: +#line 3760 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 554: - case_554(); +case 550: + case_550(); break; -case 556: -#line 3806 "cs-parser.jay" +case 552: +#line 3781 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 557: -#line 3810 "cs-parser.jay" +case 553: +#line 3785 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 558: -#line 3814 "cs-parser.jay" +case 554: +#line 3789 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 559: -#line 3818 "cs-parser.jay" +case 555: +#line 3793 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 560: -#line 3822 "cs-parser.jay" +case 556: +#line 3797 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 561: -#line 3826 "cs-parser.jay" +case 557: +#line 3801 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; +case 559: + case_559(); + break; +case 560: + case_560(); + break; +case 561: + case_561(); + break; case 563: case_563(); break; case 564: - case_564(); +#line 3833 "cs-parser.jay" + { + yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 565: case_565(); break; -case 567: - case_567(); +case 566: +#line 3842 "cs-parser.jay" + { + yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; -case 568: -#line 3858 "cs-parser.jay" +case 567: +#line 3846 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 569: case_569(); break; case 570: -#line 3867 "cs-parser.jay" - { - yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_570(); break; -case 571: -#line 3871 "cs-parser.jay" - { - yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } +case 572: + case_572(); break; case 573: case_573(); @@ -2930,8 +2919,8 @@ case 573: case 574: case_574(); break; -case 576: - case_576(); +case 575: + case_575(); break; case 577: case_577(); @@ -2939,11 +2928,8 @@ case 577: case 578: case_578(); break; -case 579: - case_579(); - break; -case 581: - case_581(); +case 580: + case_580(); break; case 582: case_582(); @@ -2963,17 +2949,23 @@ case 590: case 592: case_592(); break; +case 593: +#line 3970 "cs-parser.jay" + { + yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } + break; case 594: case_594(); break; +case 595: + case_595(); + break; case 596: case_596(); break; case 597: -#line 3995 "cs-parser.jay" - { - yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_597(); break; case 598: case_598(); @@ -3009,68 +3001,68 @@ case 608: case_608(); break; case 609: - case_609(); +#line 4065 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 610: case_610(); break; -case 611: - case_611(); - break; -case 612: - case_612(); - break; case 613: -#line 4090 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } - break; -case 614: - case_614(); - break; -case 617: -#line 4105 "cs-parser.jay" +#line 4080 "cs-parser.jay" { start_block (lexer.Location); } break; +case 614: + case_614(); + break; +case 616: + case_616(); + break; +case 617: + case_617(); + break; case 618: case_618(); break; +case 619: + case_619(); + break; case 620: case_620(); break; case 621: case_621(); break; -case 622: - case_622(); +case 627: +#line 4142 "cs-parser.jay" + { + yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + } break; -case 623: - case_623(); +case 628: + case_628(); break; -case 624: - case_624(); +case 629: + case_629(); break; -case 625: - case_625(); +case 630: + case_630(); break; -case 631: -#line 4166 "cs-parser.jay" +case 632: +#line 4171 "cs-parser.jay" { - yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); } break; case 633: -#line 4177 "cs-parser.jay" +#line 4184 "cs-parser.jay" { - yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); + lexer.ConstraintsParsing = true; } break; case 634: -#line 4190 "cs-parser.jay" - { - lexer.ConstraintsParsing = true; - } + case_634(); break; case 635: case_635(); @@ -3082,18 +3074,18 @@ case 637: case_637(); break; case 638: - case_638(); +#line 4223 "cs-parser.jay" + { yyVal = null; } break; case 639: -#line 4224 "cs-parser.jay" - { yyVal = null; } +#line 4225 "cs-parser.jay" + { yyVal = yyVals[0+yyTop]; } break; case 640: -#line 4226 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; } + case_640(); break; -case 641: - case_641(); +case 643: + case_643(); break; case 644: case_644(); @@ -3140,21 +3132,21 @@ case 657: case 658: case_658(); break; -case 659: - case_659(); - break; -case 661: -#line 4346 "cs-parser.jay" +case 660: +#line 4345 "cs-parser.jay" { current_container.AddBasesForPart (current_class, (List) yyVals[0+yyTop]); } break; -case 663: -#line 4354 "cs-parser.jay" +case 662: +#line 4353 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; +case 663: + case_663(); + break; case 664: case_664(); break; @@ -3177,50 +3169,50 @@ case 670: case_670(); break; case 671: - case_671(); - break; -case 672: -#line 4443 "cs-parser.jay" +#line 4442 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; -case 673: -#line 4447 "cs-parser.jay" +case 672: +#line 4446 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; -case 674: -#line 4454 "cs-parser.jay" +case 673: +#line 4453 "cs-parser.jay" { yyVal = Variance.None; } break; -case 675: - case_675(); +case 674: + case_674(); break; -case 676: -#line 4468 "cs-parser.jay" +case 675: +#line 4467 "cs-parser.jay" { yyVal = Variance.Covariant; } break; -case 677: -#line 4472 "cs-parser.jay" +case 676: +#line 4471 "cs-parser.jay" { yyVal = Variance.Contravariant; } break; -case 678: - case_678(); +case 677: + case_677(); break; -case 679: -#line 4497 "cs-parser.jay" +case 678: +#line 4496 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; +case 679: + case_679(); + break; case 680: case_680(); break; @@ -3230,36 +3222,36 @@ case 681: case 682: case_682(); break; -case 683: - case_683(); - break; -case 688: -#line 4541 "cs-parser.jay" +case 687: +#line 4540 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 689: -#line 4545 "cs-parser.jay" +case 688: +#line 4544 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 691: - case_691(); +case 690: + case_690(); break; -case 694: -#line 4569 "cs-parser.jay" +case 693: +#line 4568 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 695: -#line 4573 "cs-parser.jay" +case 694: +#line 4572 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; +case 723: + case_723(); + break; case 724: case_724(); break; @@ -3272,8 +3264,8 @@ case 726: case 727: case_727(); break; -case 728: - case_728(); +case 730: + case_730(); break; case 731: case_731(); @@ -3285,32 +3277,32 @@ case 733: case_733(); break; case 734: - case_734(); - break; -case 735: -#line 4717 "cs-parser.jay" +#line 4716 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 736: -#line 4721 "cs-parser.jay" +case 735: +#line 4720 "cs-parser.jay" { - yyVal = new ComposedCast (new TypeExpression (TypeManager.void_type, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); + yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 737: - case_737(); +case 736: + case_736(); break; -case 739: - case_739(); +case 738: + case_738(); break; -case 740: -#line 4742 "cs-parser.jay" +case 739: +#line 4741 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); } break; +case 740: + case_740(); + break; case 741: case_741(); break; @@ -3320,35 +3312,32 @@ case 742: case 743: case_743(); break; -case 744: - case_744(); +case 745: + case_745(); break; case 746: case_746(); break; -case 747: - case_747(); +case 751: + case_751(); break; case 752: case_752(); break; case 753: - case_753(); - break; -case 754: -#line 4827 "cs-parser.jay" +#line 4830 "cs-parser.jay" { Report.Error (145, lexer.Location, "A const field requires a value to be provided"); } break; -case 755: -#line 4831 "cs-parser.jay" - { - current_variable.Initializer = (Expression) yyVals[0+yyTop]; - } +case 754: + case_754(); break; -case 760: - case_760(); +case 759: + case_759(); + break; +case 761: + case_761(); break; case 762: case_762(); @@ -3357,19 +3346,19 @@ case 763: case_763(); break; case 764: - case_764(); +#line 4880 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 765: -#line 4876 "cs-parser.jay" +#line 4884 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 766: -#line 4880 "cs-parser.jay" +#line 4885 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 767: -#line 4881 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } + case_767(); break; case 768: case_768(); @@ -3377,26 +3366,26 @@ case 768: case 769: case_769(); break; -case 770: - case_770(); +case 772: + case_772(); break; case 773: case_773(); break; case 774: - case_774(); - break; -case 775: -#line 4949 "cs-parser.jay" +#line 4953 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); } break; +case 775: + case_775(); + break; case 776: case_776(); break; -case 777: - case_777(); +case 778: + case_778(); break; case 779: case_779(); @@ -3405,20 +3394,20 @@ case 780: case_780(); break; case 781: - case_781(); - break; -case 782: -#line 4993 "cs-parser.jay" +#line 4997 "cs-parser.jay" { current_block = current_block.CreateSwitchBlock (lexer.Location); } break; -case 783: -#line 4997 "cs-parser.jay" +case 782: +#line 5001 "cs-parser.jay" { yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); } break; +case 783: + case_783(); + break; case 784: case_784(); break; @@ -3426,14 +3415,14 @@ case 785: case_785(); break; case 786: - case_786(); - break; -case 787: -#line 5026 "cs-parser.jay" +#line 5030 "cs-parser.jay" { yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } break; +case 791: + case_791(); + break; case 792: case_792(); break; @@ -3441,38 +3430,38 @@ case 793: case_793(); break; case 794: - case_794(); - break; -case 795: -#line 5065 "cs-parser.jay" +#line 5069 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; +case 795: + case_795(); + break; case 796: case_796(); break; case 797: - case_797(); - break; -case 798: -#line 5093 "cs-parser.jay" +#line 5097 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; +case 799: + case_799(); + break; case 800: case_800(); break; -case 801: - case_801(); - break; -case 803: -#line 5114 "cs-parser.jay" +case 802: +#line 5118 "cs-parser.jay" { yyVal = null; } break; -case 805: -#line 5119 "cs-parser.jay" +case 804: +#line 5123 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; +case 808: + case_808(); + break; case 809: case_809(); break; @@ -3482,8 +3471,8 @@ case 810: case 811: case_811(); break; -case 812: - case_812(); +case 818: + case_818(); break; case 819: case_819(); @@ -3509,15 +3498,15 @@ case 825: case 826: case_826(); break; -case 827: - case_827(); - break; -case 830: -#line 5274 "cs-parser.jay" +case 829: +#line 5278 "cs-parser.jay" { yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); } break; +case 830: + case_830(); + break; case 831: case_831(); break; @@ -3530,48 +3519,48 @@ case 833: case 834: case_834(); break; -case 835: - case_835(); - break; -case 838: -#line 5327 "cs-parser.jay" +case 837: +#line 5331 "cs-parser.jay" { yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 839: - case_839(); +case 838: + case_838(); break; -case 840: -#line 5346 "cs-parser.jay" +case 839: +#line 5350 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; -case 841: - case_841(); +case 840: + case_840(); break; -case 842: -#line 5364 "cs-parser.jay" +case 841: +#line 5368 "cs-parser.jay" { yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 843: -#line 5371 "cs-parser.jay" +case 842: +#line 5375 "cs-parser.jay" { yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 844: - case_844(); +case 843: + case_843(); break; -case 845: -#line 5381 "cs-parser.jay" +case 844: +#line 5385 "cs-parser.jay" { yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } break; +case 845: + case_845(); + break; case 846: case_846(); break; @@ -3594,14 +3583,14 @@ case 852: case_852(); break; case 853: - case_853(); - break; -case 854: -#line 5464 "cs-parser.jay" +#line 5468 "cs-parser.jay" { Report.Error (210, lexer.Location, "You must provide an initializer in a fixed or using statement declaration"); } break; +case 854: + case_854(); + break; case 855: case_855(); break; @@ -3627,38 +3616,38 @@ case 862: case_862(); break; case 863: - case_863(); - break; -case 864: -#line 5564 "cs-parser.jay" +#line 5568 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 865: - case_865(); +case 864: + case_864(); break; -case 866: -#line 5579 "cs-parser.jay" +case 865: +#line 5583 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; +case 866: + case_866(); + break; case 867: case_867(); break; -case 868: - case_868(); +case 869: + case_869(); break; case 870: - case_870(); - break; -case 871: -#line 5624 "cs-parser.jay" +#line 5628 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; +case 871: + case_871(); + break; case 872: case_872(); break; @@ -3668,27 +3657,27 @@ case 873: case 874: case_874(); break; -case 875: - case_875(); +case 878: + case_878(); break; -case 879: - case_879(); - break; -case 885: -#line 5682 "cs-parser.jay" +case 884: +#line 5686 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 886: - case_886(); +case 885: + case_885(); break; -case 887: -#line 5700 "cs-parser.jay" +case 886: +#line 5704 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; +case 887: + case_887(); + break; case 888: case_888(); break; @@ -3713,90 +3702,81 @@ case 894: case 895: case_895(); break; -case 896: - case_896(); - break; -case 898: -#line 5842 "cs-parser.jay" +case 897: +#line 5846 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 899: -#line 5849 "cs-parser.jay" +case 898: +#line 5853 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 900: - case_900(); +case 899: + case_899(); + break; +case 901: + case_901(); break; case 902: case_902(); break; -case 903: - case_903(); +case 904: + case_904(); break; case 905: case_905(); break; case 906: - case_906(); - break; -case 907: -#line 5895 "cs-parser.jay" +#line 5899 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } break; -case 908: -#line 5899 "cs-parser.jay" +case 907: +#line 5903 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); } break; -case 909: -#line 5903 "cs-parser.jay" +case 908: +#line 5907 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); } break; -case 910: -#line 5910 "cs-parser.jay" +case 909: +#line 5914 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } break; -case 911: -#line 5914 "cs-parser.jay" +case 910: +#line 5918 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); } break; -case 912: -#line 5918 "cs-parser.jay" +case 911: +#line 5922 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); } break; +case 913: + case_913(); + break; case 914: case_914(); break; -case 915: - case_915(); +case 917: + case_917(); break; case 918: case_918(); break; -case 919: - case_919(); - break; -case 920: -#line 6010 "cs-parser.jay" - { - Evaluator.LoadAliases (current_namespace); - } - break; #line default } yyTop -= yyLen[yyN]; @@ -3832,105 +3812,160 @@ case 920: /* All more than 3 lines long rules are wrapped into a method */ -void case_16() -#line 409 "cs-parser.jay" +void case_5() +#line 383 "cs-parser.jay" +{ + if (yyVals[0+yyTop] != null) { + Attributes attrs = (Attributes) yyVals[0+yyTop]; + Report.Error (1730, attrs.Attrs [0].Location, + "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); + } + } + +void case_7() +#line 395 "cs-parser.jay" +{ + if (yyToken == Token.EXTERN_ALIAS) + Report.Error (439, lexer.Location, "An extern alias declaration must precede all other elements"); + else + Error_SyntaxError (yyToken); + } + +void case_12() +#line 415 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; if (s != "alias"){ syntax_error (lt.Location, "`alias' expected"); - } else if (RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (lt.Location, "external alias"); + } else if (lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (lt.Location, "external alias"); } else { lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; current_namespace.AddUsingExternalAlias (lt.Value, lt.Location, Report); + ubag.AddExternAlias (GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop]), lt, GetLocation (yyVals[0+yyTop])); } } -void case_20() -#line 434 "cs-parser.jay" +void case_16() +#line 441 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_21() -#line 439 "cs-parser.jay" +void case_17() +#line 446 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_22() -#line 447 "cs-parser.jay" +void case_18() +#line 454 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; + if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") { + Report.Warning (440, 2, lt.Location, + "An alias named `global' will not be used when resolving `global::'. The global namespace will be used instead"); + } + current_namespace.AddUsingAlias (lt.Value, (MemberName) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); ubag.AddUsingAlias (GetLocation (yyVals[-4+yyTop]), lt, GetLocation (yyVals[-2+yyTop]), (MemberName) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); - } + } -void case_23() -#line 453 "cs-parser.jay" +void case_19() +#line 465 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_24() -#line 461 "cs-parser.jay" +void case_20() +#line 473 "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_25() -#line 474 "cs-parser.jay" +void case_21() +#line 486 "cs-parser.jay" { + Attributes attrs = (Attributes) yyVals[-2+yyTop]; MemberName name = (MemberName) yyVals[0+yyTop]; - - if (yyVals[-2+yyTop] != null) { - Report.Error(1671, name.Location, "A namespace declaration cannot have modifiers or attributes"); + if (attrs != null) { + bool valid_global_attrs = true; + if ((current_namespace.DeclarationFound || current_namespace != file.NamespaceContainer)) { + valid_global_attrs = false; + } else { + foreach (var a in attrs.Attrs) { + if (a.ExplicitTarget == "assembly" || a.ExplicitTarget == "module") + continue; + + valid_global_attrs = false; + break; + } + } + + if (!valid_global_attrs) + Report.Error (1671, name.Location, "A namespace declaration cannot have modifiers or attributes"); } - - current_namespace = new NamespaceEntry (module, - current_namespace, file, name.GetName ()); + + current_namespace = new NamespaceEntry (module, current_namespace, file, name.GetName ()); current_class = current_namespace.SlaveDeclSpace; current_container = current_class.PartialContainer; + + module.AddAttributes (attrs, current_namespace); + ubag.DeclareNamespace (GetLocation (yyVals[-1+yyTop]), name); } -void case_26() -#line 488 "cs-parser.jay" -{ +void case_22() +#line 516 "cs-parser.jay" +{ + if (doc_support) + Lexer.doc_state = XmlCommentState.Allowed; + ubag.OpenNamespace (GetLocation (yyVals[0+yyTop])); + } + +void case_23() +#line 522 "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])); + else + lbag.AddLocation (current_namespace, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-1+yyTop])); + current_namespace = current_namespace.Parent; current_class = current_namespace.SlaveDeclSpace; current_container = current_class.PartialContainer; - ubag.EndNamespace (GetLocation (yyVals[0+yyTop])); + ubag.CloseNamespace (GetLocation (yyVals[-1+yyTop])); + ubag.EndNamespace (GetLocation (yyVals[-1+yyTop])); } -void case_27() -#line 498 "cs-parser.jay" +void case_24() +#line 538 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName (lt.Value, lt.Location); } -void case_28() -#line 503 "cs-parser.jay" +void case_25() +#line 543 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, lt.Location); } -void case_29() -#line 508 "cs-parser.jay" +void case_26() +#line 548 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new MemberName ("", lexer.Location); } -void case_34() -#line 526 "cs-parser.jay" +void case_31() +#line 566 "cs-parser.jay" { MemberName name = (MemberName) yyVals[0+yyTop]; @@ -3940,140 +3975,96 @@ void case_34() yyVal = name; } -void case_35() -#line 538 "cs-parser.jay" -{ - if (RootContext.Documentation != null) - Lexer.doc_state = XmlCommentState.Allowed; - ubag.OpenNamespace (GetLocation (yyVals[0+yyTop])); - - } - -void case_45() -#line 574 "cs-parser.jay" +void case_40() +#line 598 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { - DeclSpace ds = (DeclSpace)yyVals[0+yyTop]; - if ((ds.ModFlags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){ + TypeContainer ds = (TypeContainer)yyVals[0+yyTop]; + + if ((ds.ModFlags & (Modifiers.PRIVATE | Modifiers.PROTECTED)) != 0){ Report.Error (1527, ds.Location, "Namespace elements cannot be explicitly declared as private, protected or protected internal"); } + + /* Here is a trick, for explicit attributes we don't know where they belong to until*/ + /* we parse succeeding declaration hence we parse them as normal and re-attach them*/ + /* when we know whether they are global (assembly:, module:) or local (type:).*/ + if (ds.OptAttributes != null) { + ds.OptAttributes.ConvertGlobalAttributes (ds, current_namespace, !current_namespace.DeclarationFound && current_namespace == file.NamespaceContainer); + } } current_namespace.DeclarationFound = true; } -void case_53() -#line 615 "cs-parser.jay" +void case_49() +#line 648 "cs-parser.jay" { - if (yyVals[0+yyTop] != null) { - Attributes attrs = (Attributes)yyVals[0+yyTop]; - if (global_attrs_enabled) { - module.AddAttributes (attrs.Attrs, current_namespace); - } else { - foreach (Attribute a in attrs.Attrs) { - Report.Error (1730, a.Location, "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); - } - } - } - yyVal = yyVals[0+yyTop]; + var sect = (List) yyVals[0+yyTop]; + yyVal = new Attributes (sect); } -void case_54() -#line 632 "cs-parser.jay" +void case_50() +#line 653 "cs-parser.jay" { - global_attrs_enabled = false; - yyVal = null; - } + Attributes attrs = yyVals[-1+yyTop] as Attributes; + var sect = (List) yyVals[0+yyTop]; + if (attrs == null) + attrs = new Attributes (sect); + else + attrs.AddAttributes (sect); + yyVal = attrs; + } -void case_55() -#line 637 "cs-parser.jay" -{ - global_attrs_enabled = false; +void case_52() +#line 670 "cs-parser.jay" +{ + lexer.parsing_attribute_section = false; yyVal = yyVals[0+yyTop]; } -void case_56() -#line 646 "cs-parser.jay" +void case_53() +#line 678 "cs-parser.jay" { - if (current_attr_target != String.Empty) { - var sect = (List) yyVals[0+yyTop]; - - if (global_attrs_enabled) { - if (!string.IsNullOrEmpty (current_attr_target)) { - module.AddAttributes (sect, current_namespace); - yyVal = null; - } else { - yyVal = new Attributes (sect); - } - if (yyVal == null) { - if (RootContext.Documentation != null) { - Lexer.check_incorrect_doc_comment (); - Lexer.doc_state = - XmlCommentState.Allowed; - } - } - } else { - yyVal = new Attributes (sect); - } + current_attr_target = (string) yyVals[-1+yyTop]; + if (current_attr_target == "assembly" || current_attr_target == "module") { + Lexer.check_incorrect_doc_comment (); } - else - yyVal = null; - current_attr_target = null; } -void case_57() -#line 673 "cs-parser.jay" +void case_54() +#line 685 "cs-parser.jay" { - if (current_attr_target != String.Empty) { - Attributes attrs = yyVals[-1+yyTop] as Attributes; - var sect = (List) yyVals[0+yyTop]; - - if (global_attrs_enabled) { - if (!string.IsNullOrEmpty (current_attr_target)) { - module.AddAttributes (sect); - yyVal = null; - } else { - if (attrs == null) - attrs = new Attributes (sect); - else - attrs.AddAttributes (sect); - } - } else { - if (attrs == null) - attrs = new Attributes (sect); - else - attrs.AddAttributes (sect); - } - yyVal = attrs; - } + /* when attribute target is invalid*/ + if (current_attr_target == string.Empty) + yyVal = new List (0); else - yyVal = null; + yyVal = yyVals[-2+yyTop]; + current_attr_target = null; - } - -void case_60() -#line 715 "cs-parser.jay" -{ - current_attr_target = (string)yyVals[-1+yyTop]; - yyVal = yyVals[-1+yyTop]; - } + lexer.parsing_attribute_section = false; + } -void case_61() -#line 723 "cs-parser.jay" +void case_56() +#line 703 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = CheckAttributeTarget (lt.Value, lt.Location); } -void case_64() -#line 730 "cs-parser.jay" +void case_59() +#line 710 "cs-parser.jay" { - string name = GetTokenName (yyToken); - yyVal = CheckAttributeTarget (name, GetLocation (yyVals[0+yyTop])); + if (yyToken == Token.IDENTIFIER) { + Error_SyntaxError (yyToken); + yyVal = null; + } else { + string name = GetTokenName (yyToken); + yyVal = CheckAttributeTarget (name, GetLocation (yyVals[0+yyTop])); + } } -void case_66() -#line 742 "cs-parser.jay" +void case_61() +#line 727 "cs-parser.jay" { var attrs = (List) yyVals[-2+yyTop]; attrs.Add ((Attribute) yyVals[0+yyTop]); @@ -4081,8 +4072,8 @@ void case_66() yyVal = attrs; } -void case_68() -#line 756 "cs-parser.jay" +void case_63() +#line 741 "cs-parser.jay" { --lexer.parsing_block; MemberName mname = (MemberName) yyVals[-2+yyTop]; @@ -4093,35 +4084,27 @@ void case_68() Arguments [] arguments = (Arguments []) yyVals[0+yyTop]; ATypeNameExpression expr = mname.GetTypeExpression (); - - if (current_attr_target == String.Empty) - yyVal = null; - else if (global_attrs_enabled && (current_attr_target == "assembly" || current_attr_target == "module")) - /* FIXME: supply "nameEscaped" parameter here.*/ - yyVal = new GlobalAttribute (current_namespace, current_attr_target, - expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); - else - yyVal = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); + yyVal = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); } -void case_73() -#line 794 "cs-parser.jay" +void case_68() +#line 771 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); yyVal = new Arguments [] { a, null }; } -void case_74() -#line 800 "cs-parser.jay" +void case_69() +#line 777 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); yyVal = new Arguments [] { null, a }; } -void case_75() -#line 806 "cs-parser.jay" +void case_70() +#line 783 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] != null) { @@ -4137,8 +4120,8 @@ void case_75() lbag.AppendTo (args, GetLocation (yyVals[-1+yyTop])); } -void case_76() -#line 821 "cs-parser.jay" +void case_71() +#line 798 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] == null) { @@ -4149,19 +4132,19 @@ void case_76() lbag.AppendTo (o[1], GetLocation (yyVals[-1+yyTop])); } -void case_80() -#line 846 "cs-parser.jay" +void case_75() +#line 823 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; yyVal = new NamedArgument (lt.Value, lt.Location, (Expression) yyVals[0+yyTop]); } -void case_81() -#line 855 "cs-parser.jay" +void case_76() +#line 832 "cs-parser.jay" { - if (RootContext.Version <= LanguageVersion.V_3) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument"); + if (lang_version <= LanguageVersion.V_3) + FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument"); /* Avoid boxing in common case (no modifier)*/ var arg_mod = yyVals[-1+yyTop] == null ? Argument.AType.None : (Argument.AType) yyVals[-1+yyTop]; @@ -4170,8 +4153,8 @@ void case_81() yyVal = new NamedArgument (lt.Value, lt.Location, (Expression) yyVals[0+yyTop], arg_mod); } -void case_99() -#line 902 "cs-parser.jay" +void case_94() +#line 879 "cs-parser.jay" { Report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName (yyToken)); @@ -4179,50 +4162,50 @@ void case_99() lexer.parsing_generic_declaration = false; } -void case_101() -#line 919 "cs-parser.jay" +void case_96() +#line 896 "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_102() -#line 925 "cs-parser.jay" +void case_97() +#line 902 "cs-parser.jay" { lexer.ConstraintsParsing = false; current_class.SetParameterInfo ((List) yyVals[0+yyTop]); - if (RootContext.Documentation != null) + if (doc_support) current_container.DocComment = Lexer.consume_doc_comment (); lbag.AddMember (current_class, GetModifierLocations (), GetLocation (yyVals[-5+yyTop])); } -void case_103() -#line 936 "cs-parser.jay" +void case_98() +#line 913 "cs-parser.jay" { --lexer.parsing_declaration; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_104() -#line 942 "cs-parser.jay" +void case_99() +#line 919 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[0+yyTop])); yyVal = pop_current_class (); } -void case_106() -#line 954 "cs-parser.jay" +void case_101() +#line 931 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_122() -#line 996 "cs-parser.jay" +void case_117() +#line 973 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var mod = (Modifiers) yyVals[-3+yyTop]; @@ -4236,10 +4219,10 @@ void case_122() yyVal = current_field; } -void case_123() -#line 1009 "cs-parser.jay" +void case_118() +#line 986 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -4249,35 +4232,36 @@ void case_123() current_field = null; } -void case_128() -#line 1039 "cs-parser.jay" +void case_123() +#line 1016 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_130() -#line 1052 "cs-parser.jay" +void case_125() +#line 1029 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_131() -#line 1057 "cs-parser.jay" +void case_126() +#line 1035 "cs-parser.jay" { Report.Error (145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } -void case_134() -#line 1072 "cs-parser.jay" +void case_129() +#line 1050 "cs-parser.jay" { lexer.parsing_generic_declaration = false; FullNamedExpression type = (FullNamedExpression) yyVals[-1+yyTop]; - if (type.Type == TypeManager.void_type) + if (type.Type != null && type.Type.Kind == MemberKind.Void) Report.Error (670, GetLocation (yyVals[-1+yyTop]), "Fields cannot have void type"); var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -4286,10 +4270,10 @@ void case_134() yyVal = current_field; } -void case_135() -#line 1087 "cs-parser.jay" +void case_130() +#line 1065 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -4299,11 +4283,11 @@ void case_135() current_field = null; } -void case_136() -#line 1100 "cs-parser.jay" +void case_131() +#line 1078 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; current_field = new FixedField (current_class, (FullNamedExpression) yyVals[-1+yyTop], (Modifiers) yyVals[-3+yyTop], @@ -4312,30 +4296,30 @@ void case_136() current_container.AddField (current_field); } -void case_137() -#line 1111 "cs-parser.jay" +void case_132() +#line 1089 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } current_field.Initializer = (ConstInitializer) yyVals[-2+yyTop]; - lbag.AddMember (current_field, GetModifierLocations (), GetLocation (yyVals[0+yyTop]), GetLocation (yyVals[-6+yyTop])); + lbag.AddMember (current_field, GetModifierLocations (), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop])); yyVal = current_field; current_field = null; } -void case_140() -#line 1134 "cs-parser.jay" +void case_135() +#line 1112 "cs-parser.jay" { ++lexer.parsing_block; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; start_block (GetLocation (yyVals[0+yyTop])); } -void case_141() -#line 1140 "cs-parser.jay" +void case_136() +#line 1118 "cs-parser.jay" { --lexer.parsing_block; current_field.Initializer = (Expression) yyVals[0+yyTop]; @@ -4344,16 +4328,16 @@ void case_141() current_local_parameters = null; } -void case_146() -#line 1167 "cs-parser.jay" +void case_141() +#line 1145 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_148() -#line 1177 "cs-parser.jay" +void case_143() +#line 1155 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4361,49 +4345,49 @@ void case_148() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_153() -#line 1203 "cs-parser.jay" +void case_148() +#line 1181 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_155() -#line 1216 "cs-parser.jay" +void case_150() +#line 1194 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_156() -#line 1222 "cs-parser.jay" +void case_151() +#line 1200 "cs-parser.jay" { Report.Error (443, lexer.Location, "Value or constant expected"); yyVal = null; } -void case_159() -#line 1232 "cs-parser.jay" +void case_154() +#line 1210 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); yyVal = null; } -void case_160() -#line 1241 "cs-parser.jay" +void case_155() +#line 1219 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; /* Add it early in the case of body being eof for full aot*/ current_container.AddMethod ((Method) yyVals[0+yyTop]); } -void case_161() -#line 1249 "cs-parser.jay" +void case_156() +#line 1227 "cs-parser.jay" { Method method = (Method) yyVals[-2+yyTop]; method.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4414,12 +4398,12 @@ void case_161() current_local_parameters = null; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_164() -#line 1277 "cs-parser.jay" +void case_159() +#line 1255 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4446,15 +4430,15 @@ void case_164() method.GetSignatureForError ()); } - if (RootContext.Documentation != null) + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); lbag.AddMember (method, GetModifierLocations (), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop])); yyVal = method; } -void case_167() -#line 1322 "cs-parser.jay" +void case_162() +#line 1300 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4470,7 +4454,7 @@ void case_167() GenericMethod generic = null; if (name.TypeArguments != null) { generic = new GenericMethod (current_namespace, current_class, name, - new TypeExpression (TypeManager.void_type, GetLocation (yyVals[-7+yyTop])), + new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-7+yyTop])), current_local_parameters); generic.SetParameterInfo ((List) yyVals[0+yyTop]); @@ -4495,10 +4479,10 @@ void case_167() modifiers |= Modifiers.PARTIAL | Modifiers.PRIVATE; - method = new Method (current_class, generic, new TypeExpression (TypeManager.void_type, GetLocation (yyVals[-7+yyTop])), + method = new Method (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-7+yyTop])), modifiers, name, current_local_parameters, (Attributes) yyVals[-10+yyTop]); - if (RootContext.Documentation != null) + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); /* TODO: lbag, push void*/ @@ -4507,8 +4491,8 @@ void case_167() yyVal = method; } -void case_168() -#line 1377 "cs-parser.jay" +void case_163() +#line 1355 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-3+yyTop]; Report.Error (1585, name.Location, @@ -4519,22 +4503,22 @@ void case_168() current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; - if (RootContext.Documentation != null) + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); yyVal = method; } -void case_173() -#line 1406 "cs-parser.jay" +void case_168() +#line 1384 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); lbag.AddLocation (yyVal, lbag.GetLocations (pars_list)); } -void case_174() -#line 1412 "cs-parser.jay" +void case_169() +#line 1390 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add ((Parameter) yyVals[0+yyTop]); @@ -4542,16 +4526,16 @@ void case_174() yyVal = new ParametersCompiled (pars_list.ToArray ()); } -void case_175() -#line 1419 "cs-parser.jay" +void case_170() +#line 1397 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add (new ArglistParameter (GetLocation (yyVals[0+yyTop]))); yyVal = new ParametersCompiled (pars_list.ToArray (), true); } -void case_176() -#line 1425 "cs-parser.jay" +void case_171() +#line 1403 "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"); @@ -4559,8 +4543,8 @@ void case_176() yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[-2+yyTop] } ); } -void case_177() -#line 1432 "cs-parser.jay" +void case_172() +#line 1410 "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"); @@ -4571,16 +4555,16 @@ void case_177() yyVal = new ParametersCompiled (pars_list.ToArray (), true); } -void case_178() -#line 1442 "cs-parser.jay" +void case_173() +#line 1420 "cs-parser.jay" { Report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[-2+yyTop])) }, true); } -void case_179() -#line 1448 "cs-parser.jay" +void case_174() +#line 1426 "cs-parser.jay" { Report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4590,15 +4574,15 @@ void case_179() yyVal = new ParametersCompiled (pars_list.ToArray (), true); } -void case_182() -#line 1465 "cs-parser.jay" +void case_177() +#line 1443 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } -void case_183() -#line 1473 "cs-parser.jay" +void case_178() +#line 1451 "cs-parser.jay" { parameters_bucket.Clear (); Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4608,8 +4592,8 @@ void case_183() yyVal = parameters_bucket; } -void case_184() -#line 1482 "cs-parser.jay" +void case_179() +#line 1460 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4628,16 +4612,16 @@ void case_184() yyVal = yyVals[-2+yyTop]; } -void case_185() -#line 1506 "cs-parser.jay" +void case_180() +#line 1484 "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); lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_186() -#line 1515 "cs-parser.jay" +void case_181() +#line 1493 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; Report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name"); @@ -4645,8 +4629,8 @@ void case_186() lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_187() -#line 1525 "cs-parser.jay" +void case_182() +#line 1503 "cs-parser.jay" { Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); @@ -4654,12 +4638,12 @@ void case_187() lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_189() -#line 1540 "cs-parser.jay" +void case_184() +#line 1518 "cs-parser.jay" { --lexer.parsing_block; - if (RootContext.Version <= LanguageVersion.V_3) { - Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "optional parameter"); + if (lang_version <= LanguageVersion.V_3) { + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "optional parameter"); } Parameter.Modifier mod = (Parameter.Modifier) yyVals[-5+yyTop]; @@ -4693,15 +4677,15 @@ void case_189() ((Parameter) yyVal).DefaultValue = new DefaultParameterValueExpression ((Expression) yyVals[0+yyTop]); } -void case_192() -#line 1585 "cs-parser.jay" +void case_187() +#line 1563 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; parameterModifierLocation = GetLocation (yyVals[0+yyTop]); } -void case_193() -#line 1590 "cs-parser.jay" +void case_188() +#line 1568 "cs-parser.jay" { Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop]; Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2; @@ -4723,8 +4707,8 @@ void case_193() yyVal = mod; } -void case_194() -#line 1614 "cs-parser.jay" +void case_189() +#line 1592 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Ref) == 0) Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop])); @@ -4732,8 +4716,8 @@ void case_194() yyVal = Parameter.Modifier.REF; } -void case_195() -#line 1621 "cs-parser.jay" +void case_190() +#line 1599 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Out) == 0) Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop])); @@ -4741,27 +4725,27 @@ void case_195() yyVal = Parameter.Modifier.OUT; } -void case_196() -#line 1628 "cs-parser.jay" +void case_191() +#line 1606 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop])); - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "extension methods"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "extension methods"); yyVal = Parameter.Modifier.This; } -void case_197() -#line 1641 "cs-parser.jay" +void case_192() +#line 1619 "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_198() -#line 1646 "cs-parser.jay" +void case_193() +#line 1624 "cs-parser.jay" { Report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array"); @@ -4769,22 +4753,22 @@ void case_198() yyVal = new ParamsParameter ((FullNamedExpression) yyVals[-3+yyTop], lt.Value, (Attributes) yyVals[-5+yyTop], lt.Location); } -void case_199() -#line 1653 "cs-parser.jay" +void case_194() +#line 1631 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_200() -#line 1661 "cs-parser.jay" +void case_195() +#line 1639 "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_201() -#line 1666 "cs-parser.jay" +void case_196() +#line 1644 "cs-parser.jay" { Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop]; if ((mod & Parameter.Modifier.This) != 0) { @@ -4794,27 +4778,28 @@ void case_201() } } -void case_203() -#line 1682 "cs-parser.jay" +void case_198() +#line 1660 "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_204() -#line 1693 "cs-parser.jay" +void case_199() +#line 1671 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) tmpComment = Lexer.consume_doc_comment (); } -void case_205() -#line 1698 "cs-parser.jay" +void case_200() +#line 1676 "cs-parser.jay" { - current_property = new Property (current_class, (FullNamedExpression) yyVals[-3+yyTop], (Modifiers) yyVals[-4+yyTop], + var type = (FullNamedExpression) yyVals[-3+yyTop]; + current_property = new Property (current_class, type, (Modifiers) yyVals[-4+yyTop], (MemberName) yyVals[-2+yyTop], (Attributes) yyVals[-5+yyTop]); - if (current_property.TypeExpression.Type == TypeManager.void_type) + if (type.Type != null && type.Type.Kind == MemberKind.Void) Report.Error (547, GetLocation (yyVals[-3+yyTop]), "`{0}': property or indexer cannot have void type", current_property.GetSignatureForError ()); current_container.AddProperty ((Property)current_property); @@ -4823,28 +4808,28 @@ void case_205() lexer.PropertyParsing = true; } -void case_206() -#line 1711 "cs-parser.jay" +void case_201() +#line 1690 "cs-parser.jay" { lexer.PropertyParsing = false; - if (RootContext.Documentation != null) + if (doc_support) current_property.DocComment = ConsumeStoredComment (); } -void case_207() -#line 1718 "cs-parser.jay" +void case_202() +#line 1697 "cs-parser.jay" { lbag.AppendToMember (current_property, GetLocation (yyVals[0+yyTop])); current_property = null; } -void case_209() -#line 1732 "cs-parser.jay" +void case_204() +#line 1711 "cs-parser.jay" { valid_param_mod = 0; - - Indexer indexer = new Indexer (current_class, (FullNamedExpression) yyVals[-6+yyTop], + var type = (FullNamedExpression) yyVals[-6+yyTop]; + Indexer indexer = new Indexer (current_class, type, (MemberName)yyVals[-5+yyTop], (Modifiers) yyVals[-7+yyTop], (ParametersCompiled) yyVals[-2+yyTop], (Attributes) yyVals[-8+yyTop]); current_property = indexer; @@ -4852,14 +4837,14 @@ void case_209() current_container.AddIndexer (indexer); lbag.AddMember (current_property, GetModifierLocations (), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); - if (indexer.TypeExpression.Type == TypeManager.void_type) + if (type.Type != null && type.Type.Kind == MemberKind.Void) Report.Error (620, GetLocation (yyVals[-6+yyTop]), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError ()); if (indexer.Parameters.IsEmpty) { Report.Error (1551, GetLocation (yyVals[-4+yyTop]), "Indexers must have at least one parameter"); } - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -4867,18 +4852,18 @@ void case_209() lexer.PropertyParsing = true; } -void case_211() -#line 1762 "cs-parser.jay" +void case_206() +#line 1741 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) current_property.DocComment = ConsumeStoredComment (); lbag.AppendToMember (current_property, GetLocation (yyVals[-1+yyTop])); current_property = null; } -void case_216() -#line 1778 "cs-parser.jay" +void case_211() +#line 1757 "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 ()); @@ -4890,11 +4875,11 @@ void case_216() } } -void case_217() -#line 1792 "cs-parser.jay" +void case_212() +#line 1771 "cs-parser.jay" { - if (yyVals[-1+yyTop] != ModifierNone && RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); + if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); } if (current_property.Get != null) { @@ -4914,8 +4899,8 @@ void case_217() lexer.PropertyParsing = false; } -void case_218() -#line 1814 "cs-parser.jay" +void case_213() +#line 1793 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Get.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4929,16 +4914,16 @@ void case_218() current_local_parameters = null; lexer.PropertyParsing = true; - if (RootContext.Documentation != null) + if (doc_support) if (Lexer.doc_state == XmlCommentState.Error) Lexer.doc_state = XmlCommentState.NotAllowed; } -void case_219() -#line 1835 "cs-parser.jay" +void case_214() +#line 1814 "cs-parser.jay" { - if (yyVals[-1+yyTop] != ModifierNone && RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); + if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); } if (current_property.Set != null) { @@ -4963,8 +4948,8 @@ void case_219() lexer.PropertyParsing = false; } -void case_220() -#line 1862 "cs-parser.jay" +void case_215() +#line 1841 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Set.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4978,63 +4963,63 @@ void case_220() current_local_parameters = null; lexer.PropertyParsing = true; - if (RootContext.Documentation != null + if (doc_support && Lexer.doc_state == XmlCommentState.Error) Lexer.doc_state = XmlCommentState.NotAllowed; } -void case_222() -#line 1884 "cs-parser.jay" +void case_217() +#line 1863 "cs-parser.jay" { lbag.AppendToMember (lbag.LastMember, GetLocation (yyVals[0+yyTop])); yyVal = null; } -void case_223() -#line 1889 "cs-parser.jay" +void case_218() +#line 1868 "cs-parser.jay" { Error_SyntaxError (1043, yyToken, "Invalid accessor body"); yyVal = null; } -void case_225() -#line 1904 "cs-parser.jay" +void case_220() +#line 1883 "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]); lbag.AddMember (current_class, GetModifierLocations (), GetLocation (yyVals[-2+yyTop])); } -void case_226() -#line 1911 "cs-parser.jay" +void case_221() +#line 1890 "cs-parser.jay" { lexer.ConstraintsParsing = false; current_class.SetParameterInfo ((List) yyVals[0+yyTop]); - if (RootContext.Documentation != null) { + if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } } -void case_227() -#line 1922 "cs-parser.jay" +void case_222() +#line 1901 "cs-parser.jay" { --lexer.parsing_declaration; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_228() -#line 1928 "cs-parser.jay" +void case_223() +#line 1907 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); yyVal = pop_current_class (); } -void case_244() -#line 1980 "cs-parser.jay" +void case_239() +#line 1959 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { @@ -5043,7 +5028,7 @@ void case_244() current_local_parameters, (ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location); - if (RootContext.Documentation != null) { + if (doc_support) { op.DocComment = tmpComment; Lexer.doc_state = XmlCommentState.Allowed; } @@ -5057,15 +5042,15 @@ void case_244() current_local_parameters = null; } -void case_248() -#line 2011 "cs-parser.jay" +void case_243() +#line 1990 "cs-parser.jay" { Report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void"); - yyVal = new TypeExpression (TypeManager.void_type, GetLocation (yyVals[0+yyTop])); + yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_250() -#line 2023 "cs-parser.jay" +void case_245() +#line 2002 "cs-parser.jay" { valid_param_mod = 0; @@ -5097,7 +5082,7 @@ void case_250() } } - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -5106,15 +5091,15 @@ void case_250() lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_275() -#line 2099 "cs-parser.jay" +void case_270() +#line 2078 "cs-parser.jay" { valid_param_mod = 0; Location loc = GetLocation (yyVals[-5+yyTop]); current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop]; - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -5123,15 +5108,15 @@ void case_275() lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_277() -#line 2118 "cs-parser.jay" +void case_272() +#line 2097 "cs-parser.jay" { valid_param_mod = 0; Location loc = GetLocation (yyVals[-5+yyTop]); current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop]; - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -5140,42 +5125,42 @@ void case_277() lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_278() -#line 2133 "cs-parser.jay" +void case_273() +#line 2112 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration (Operator.OpType.Implicit, null, GetLocation (yyVals[-1+yyTop])); } -void case_279() -#line 2139 "cs-parser.jay" +void case_274() +#line 2118 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration (Operator.OpType.Explicit, null, GetLocation (yyVals[-1+yyTop])); } -void case_280() -#line 2149 "cs-parser.jay" +void case_275() +#line 2128 "cs-parser.jay" { Constructor c = (Constructor) yyVals[-1+yyTop]; c.Block = (ToplevelBlock) yyVals[0+yyTop]; - if (RootContext.Documentation != null) + if (doc_support) c.DocComment = ConsumeStoredComment (); current_container.AddConstructor (c); current_local_parameters = null; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_281() -#line 2168 "cs-parser.jay" +void case_276() +#line 2147 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -5183,8 +5168,8 @@ void case_281() valid_param_mod = ParameterModifierType.All; } -void case_282() -#line 2177 "cs-parser.jay" +void case_277() +#line 2156 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -5196,8 +5181,8 @@ void case_282() start_block (lexer.Location); } -void case_283() -#line 2188 "cs-parser.jay" +void case_278() +#line 2167 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-6+yyTop]; var mods = (Modifiers) yyVals[-7+yyTop]; @@ -5226,33 +5211,33 @@ void case_283() yyVal = c; } -void case_289() -#line 2233 "cs-parser.jay" +void case_284() +#line 2212 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorBaseInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_291() -#line 2243 "cs-parser.jay" +void case_286() +#line 2222 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorThisInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_292() -#line 2249 "cs-parser.jay" +void case_287() +#line 2228 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_293() -#line 2257 "cs-parser.jay" +void case_288() +#line 2236 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -5260,8 +5245,8 @@ void case_293() current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } -void case_294() -#line 2266 "cs-parser.jay" +void case_289() +#line 2245 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ @@ -5272,7 +5257,7 @@ void case_294() Destructor d = new Destructor (current_class, (Modifiers) yyVals[-6+yyTop], ParametersCompiled.EmptyReadOnlyParameters, (Attributes) yyVals[-7+yyTop], lt.Location); - if (RootContext.Documentation != null) + if (doc_support) d.DocComment = ConsumeStoredComment (); d.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5282,8 +5267,8 @@ void case_294() current_local_parameters = null; } -void case_295() -#line 2291 "cs-parser.jay" +void case_290() +#line 2270 "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); @@ -5296,10 +5281,10 @@ void case_295() yyVal = current_event_field; } -void case_296() -#line 2305 "cs-parser.jay" +void case_291() +#line 2284 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -5308,8 +5293,8 @@ void case_296() current_event_field = null; } -void case_297() -#line 2318 "cs-parser.jay" +void case_292() +#line 2297 "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); @@ -5318,8 +5303,8 @@ void case_297() lexer.EventParsing = true; } -void case_298() -#line 2326 "cs-parser.jay" +void case_293() +#line 2305 "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"); @@ -5327,10 +5312,10 @@ void case_298() lexer.EventParsing = false; } -void case_299() -#line 2333 "cs-parser.jay" +void case_294() +#line 2312 "cs-parser.jay" { - if (RootContext.Documentation != null) { + if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -5340,23 +5325,23 @@ void case_299() current_local_parameters = null; } -void case_302() -#line 2352 "cs-parser.jay" +void case_297() +#line 2331 "cs-parser.jay" { --lexer.parsing_block; current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } -void case_307() -#line 2376 "cs-parser.jay" +void case_302() +#line 2355 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_309() -#line 2386 "cs-parser.jay" +void case_304() +#line 2365 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -5364,8 +5349,8 @@ void case_309() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_310() -#line 2395 "cs-parser.jay" +void case_305() +#line 2374 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { Report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", @@ -5378,29 +5363,29 @@ void case_310() } } -void case_314() -#line 2416 "cs-parser.jay" +void case_309() +#line 2395 "cs-parser.jay" { Report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } -void case_315() -#line 2421 "cs-parser.jay" +void case_310() +#line 2400 "cs-parser.jay" { Report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } -void case_316() -#line 2426 "cs-parser.jay" +void case_311() +#line 2405 "cs-parser.jay" { Report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } -void case_317() -#line 2434 "cs-parser.jay" +void case_312() +#line 2413 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { Report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5413,8 +5398,8 @@ void case_317() lexer.EventParsing = false; } -void case_318() -#line 2446 "cs-parser.jay" +void case_313() +#line 2425 "cs-parser.jay" { lexer.EventParsing = true; @@ -5428,8 +5413,8 @@ void case_318() current_local_parameters = null; } -void case_319() -#line 2462 "cs-parser.jay" +void case_314() +#line 2441 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { Report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5442,8 +5427,8 @@ void case_319() lexer.EventParsing = false; } -void case_320() -#line 2474 "cs-parser.jay" +void case_315() +#line 2453 "cs-parser.jay" { lexer.EventParsing = true; @@ -5457,24 +5442,24 @@ void case_320() current_local_parameters = null; } -void case_321() -#line 2490 "cs-parser.jay" +void case_316() +#line 2469 "cs-parser.jay" { Report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } -void case_323() -#line 2502 "cs-parser.jay" +void case_318() +#line 2481 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } -void case_324() -#line 2507 "cs-parser.jay" +void case_319() +#line 2486 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; MemberName name = (MemberName) yyVals[-3+yyTop]; @@ -5485,38 +5470,34 @@ void case_324() push_current_class (new Enum (current_namespace, current_class, (TypeExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-5+yyTop], MakeName (name), (Attributes) yyVals[-6+yyTop]), null); } -void case_325() -#line 2519 "cs-parser.jay" +void case_320() +#line 2498 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_326() -#line 2525 "cs-parser.jay" +void case_321() +#line 2504 "cs-parser.jay" { - if (RootContext.Documentation != null) + if (doc_support) current_class.DocComment = enumTypeComment; --lexer.parsing_declaration; -/* if (RootContext.Documentation != null)*/ +/* if (doc_support)*/ /* em.DocComment = ev.DocComment;*/ lbag.AddMember (current_class, GetModifierLocations (), GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-1+yyTop])); yyVal = pop_current_class (); } -void case_328() -#line 2542 "cs-parser.jay" +void case_323() +#line 2521 "cs-parser.jay" { var te = yyVals[0+yyTop] as TypeExpression; - if (te == null || - (te.Type != TypeManager.int32_type && te.Type != TypeManager.uint32_type && - te.Type != TypeManager.int64_type && te.Type != TypeManager.uint64_type && - te.Type != TypeManager.short_type && te.Type != TypeManager.ushort_type && - te.Type != TypeManager.byte_type && te.Type != TypeManager.sbyte_type)) { + if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { Enum.Error_1008 (GetLocation (yyVals[0+yyTop]), Report); yyVal = null; } else { @@ -5524,28 +5505,28 @@ void case_328() } } -void case_329() -#line 2556 "cs-parser.jay" +void case_324() +#line 2531 "cs-parser.jay" { Error_TypeExpected (GetLocation (yyVals[-1+yyTop])); yyVal = null; } -void case_334() -#line 2574 "cs-parser.jay" +void case_329() +#line 2549 "cs-parser.jay" { lbag.AddLocation (yyVals[-2+yyTop], GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } -void case_335() -#line 2582 "cs-parser.jay" +void case_330() +#line 2557 "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]); ((Enum) current_class).AddEnumMember (em); - if (RootContext.Documentation != null) { + if (doc_support) { em.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -5553,18 +5534,18 @@ void case_335() yyVal = em; } -void case_336() -#line 2595 "cs-parser.jay" +void case_331() +#line 2570 "cs-parser.jay" { ++lexer.parsing_block; - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } } -void case_337() -#line 2603 "cs-parser.jay" +void case_332() +#line 2578 "cs-parser.jay" { --lexer.parsing_block; @@ -5573,14 +5554,14 @@ void case_337() em.Initializer = new ConstInitializer (em, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); ((Enum) current_class).AddEnumMember (em); - if (RootContext.Documentation != null) + if (doc_support) em.DocComment = ConsumeStoredComment (); yyVal = em; } -void case_339() -#line 2628 "cs-parser.jay" +void case_334() +#line 2603 "cs-parser.jay" { valid_param_mod = 0; @@ -5590,22 +5571,21 @@ void case_339() Delegate del = new Delegate (current_namespace, current_class, (FullNamedExpression) yyVals[-5+yyTop], (Modifiers) yyVals[-7+yyTop], name, p, (Attributes) yyVals[-8+yyTop]); - if (RootContext.Documentation != null) { - del.DocComment = Lexer.consume_doc_comment (); - Lexer.doc_state = XmlCommentState.Allowed; - } - ubag.PushTypeDeclaration (del); ubag.PopTypeDeclaration (); - current_container.AddDelegate (del); current_delegate = del; lexer.ConstraintsParsing = true; } -void case_341() -#line 2654 "cs-parser.jay" +void case_336() +#line 2623 "cs-parser.jay" { + if (doc_support) { + current_delegate.DocComment = Lexer.consume_doc_comment (); + Lexer.doc_state = XmlCommentState.Allowed; + } + current_delegate.SetParameterInfo ((List) yyVals[-2+yyTop]); lbag.AddMember (current_delegate, GetModifierLocations (), GetLocation (yyVals[-10+yyTop]), GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[0+yyTop])); @@ -5614,17 +5594,17 @@ void case_341() current_delegate = null; } -void case_343() -#line 2667 "cs-parser.jay" +void case_338() +#line 2641 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); yyVal = ComposedTypeSpecifier.CreateNullable (GetLocation (yyVals[0+yyTop])); } -void case_345() -#line 2678 "cs-parser.jay" +void case_340() +#line 2652 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5632,63 +5612,63 @@ void case_345() yyVal = new MemberName (lt1.Value, lt2.Value, (TypeArguments) yyVals[0+yyTop], lt1.Location); } -void case_347() -#line 2689 "cs-parser.jay" +void case_342() +#line 2663 "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); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_348() -#line 2698 "cs-parser.jay" +void case_343() +#line 2672 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_350() -#line 2710 "cs-parser.jay" +void case_345() +#line 2684 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); yyVal = yyVals[-1+yyTop]; } -void case_351() -#line 2717 "cs-parser.jay" +void case_346() +#line 2691 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = new TypeArguments (); } -void case_352() -#line 2725 "cs-parser.jay" +void case_347() +#line 2699 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = type_args; } -void case_353() -#line 2731 "cs-parser.jay" +void case_348() +#line 2705 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = type_args; } -void case_355() -#line 2747 "cs-parser.jay" +void case_350() +#line 2721 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_356() -#line 2756 "cs-parser.jay" +void case_351() +#line 2730 "cs-parser.jay" { MemberName mn = (MemberName)yyVals[0+yyTop]; if (mn.TypeArguments != null) @@ -5696,38 +5676,38 @@ void case_356() mn.GetSignatureForError ())); } -void case_358() -#line 2767 "cs-parser.jay" +void case_353() +#line 2741 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); } -void case_359() -#line 2776 "cs-parser.jay" +void case_354() +#line 2750 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeContainer.DefaultIndexerName, GetLocation (yyVals[0+yyTop])); } -void case_360() -#line 2781 "cs-parser.jay" +void case_355() +#line 2755 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName ((MemberName) yyVals[-1+yyTop], TypeContainer.DefaultIndexerName, null, GetLocation (yyVals[-1+yyTop])); } -void case_361() -#line 2789 "cs-parser.jay" +void case_356() +#line 2763 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberName (lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_362() -#line 2795 "cs-parser.jay" +void case_357() +#line 2769 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -5736,34 +5716,34 @@ void case_362() lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_363() -#line 2803 "cs-parser.jay" +void case_358() +#line 2777 "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); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_365() -#line 2813 "cs-parser.jay" +void case_360() +#line 2787 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); yyVal = yyVals[-1+yyTop]; lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_366() -#line 2824 "cs-parser.jay" +void case_361() +#line 2798 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression)yyVals[0+yyTop]); yyVal = type_args; } -void case_367() -#line 2830 "cs-parser.jay" +void case_362() +#line 2804 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression)yyVals[0+yyTop]); @@ -5771,15 +5751,15 @@ void case_367() lbag.AddLocation (yyVals[0+yyTop], GetLocation (yyVals[0+yyTop])); } -void case_368() -#line 2840 "cs-parser.jay" +void case_363() +#line 2814 "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_369() -#line 2845 "cs-parser.jay" +void case_364() +#line 2819 "cs-parser.jay" { if (GetTokenName (yyToken) == "type") Report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type"); @@ -5789,29 +5769,29 @@ void case_369() yyVal = new TypeParameterName ("", null, lexer.Location); } -void case_374() -#line 2879 "cs-parser.jay" +void case_369() +#line 2853 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), Report); - yyVal = new TypeExpression (TypeManager.void_type, GetLocation (yyVals[0+yyTop])); + yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_376() -#line 2888 "cs-parser.jay" +void case_371() +#line 2862 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), Report); - yyVal = new TypeExpression (TypeManager.void_type, GetLocation (yyVals[0+yyTop])); + yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_378() -#line 2897 "cs-parser.jay" +void case_373() +#line 2871 "cs-parser.jay" { Report.Error (1536, GetLocation (yyVals[0+yyTop]), "Invalid parameter type `void'"); - yyVal = new TypeExpression (TypeManager.void_type, GetLocation (yyVals[0+yyTop])); + yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_381() -#line 2913 "cs-parser.jay" +void case_376() +#line 2887 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-1+yyTop]; @@ -5825,31 +5805,31 @@ void case_381() } } -void case_383() -#line 2930 "cs-parser.jay" +void case_378() +#line 2904 "cs-parser.jay" { if (yyVals[0+yyTop] != null) yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_386() -#line 2946 "cs-parser.jay" +void case_381() +#line 2920 "cs-parser.jay" { var types = new List (2); types.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = types; } -void case_387() -#line 2952 "cs-parser.jay" +void case_382() +#line 2926 "cs-parser.jay" { var types = (List) yyVals[-2+yyTop]; types.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = types; } -void case_388() -#line 2961 "cs-parser.jay" +void case_383() +#line 2935 "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 ()); @@ -5857,60 +5837,60 @@ void case_388() yyVal = yyVals[0+yyTop]; } -void case_389() -#line 2968 "cs-parser.jay" +void case_384() +#line 2942 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } -void case_425() -#line 3029 "cs-parser.jay" +void case_421() +#line 3004 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_426() -#line 3033 "cs-parser.jay" +void case_422() +#line 3008 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location); } -void case_437() -#line 3074 "cs-parser.jay" +void case_433() +#line 3049 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_439() -#line 3086 "cs-parser.jay" +void case_435() +#line 3061 "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); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_440() -#line 3092 "cs-parser.jay" +void case_436() +#line 3067 "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); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_441() -#line 3098 "cs-parser.jay" +void case_437() +#line 3073 "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); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_442() -#line 3104 "cs-parser.jay" +void case_438() +#line 3079 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5918,29 +5898,29 @@ void case_442() yyVal = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) yyVals[0+yyTop], lt1.Location); } -void case_444() -#line 3113 "cs-parser.jay" +void case_440() +#line 3088 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_446() -#line 3121 "cs-parser.jay" +void case_442() +#line 3096 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_447() -#line 3129 "cs-parser.jay" +void case_443() +#line 3104 "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_450() -#line 3142 "cs-parser.jay" +void case_446() +#line 3117 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) { yyVal = CollectionOrObjectInitializers.Empty; @@ -5951,46 +5931,46 @@ void case_450() } } -void case_451() -#line 3152 "cs-parser.jay" +void case_447() +#line 3127 "cs-parser.jay" { yyVal = new CollectionOrObjectInitializers ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_454() -#line 3168 "cs-parser.jay" +void case_450() +#line 3143 "cs-parser.jay" { var a = new List (); a.Add ((Expression) yyVals[0+yyTop]); yyVal = a; } -void case_455() -#line 3174 "cs-parser.jay" +void case_451() +#line 3149 "cs-parser.jay" { var a = (List)yyVals[-2+yyTop]; a.Add ((Expression) yyVals[0+yyTop]); yyVal = a; } -void case_456() -#line 3179 "cs-parser.jay" +void case_452() +#line 3154 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_457() -#line 3187 "cs-parser.jay" +void case_453() +#line 3162 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new ElementInitializer (lt.Value, (Expression)yyVals[0+yyTop], lt.Location); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_459() -#line 3196 "cs-parser.jay" +void case_455() +#line 3171 "cs-parser.jay" { CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName; if (csn == null) @@ -5999,32 +5979,32 @@ void case_459() yyVal = new CompletionElementInitializer (csn.Prefix, csn.Location); } -void case_460() -#line 3204 "cs-parser.jay" -{ +void case_456() +#line 3179 "cs-parser.jay" +{ if (yyVals[-1+yyTop] == null) yyVal = null; else yyVal = new CollectionElementInitializer ((List)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_461() -#line 3211 "cs-parser.jay" +void case_457() +#line 3186 "cs-parser.jay" { Report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty"); yyVal = null; } -void case_466() -#line 3229 "cs-parser.jay" +void case_462() +#line 3204 "cs-parser.jay" { Arguments list = new Arguments (4); list.Add ((Argument) yyVals[0+yyTop]); yyVal = list; } -void case_467() -#line 3235 "cs-parser.jay" +void case_463() +#line 3210 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; if (list [list.Count - 1] is NamedArgument) @@ -6035,8 +6015,8 @@ void case_467() yyVal = list; } -void case_468() -#line 3245 "cs-parser.jay" +void case_464() +#line 3220 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; NamedArgument a = (NamedArgument) yyVals[0+yyTop]; @@ -6052,65 +6032,65 @@ void case_468() yyVal = list; } -void case_469() -#line 3260 "cs-parser.jay" +void case_465() +#line 3235 "cs-parser.jay" { Report.Error (839, GetLocation (yyVals[0+yyTop]), "An argument is missing"); yyVal = yyVals[-1+yyTop]; } -void case_470() -#line 3265 "cs-parser.jay" +void case_466() +#line 3240 "cs-parser.jay" { Report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } -void case_475() -#line 3286 "cs-parser.jay" +void case_471() +#line 3261 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_476() -#line 3291 "cs-parser.jay" +void case_472() +#line 3266 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_477() -#line 3296 "cs-parser.jay" +void case_473() +#line 3271 "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_478() -#line 3301 "cs-parser.jay" +void case_474() +#line 3276 "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_480() -#line 3313 "cs-parser.jay" +void case_476() +#line 3288 "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_481() -#line 3321 "cs-parser.jay" +void case_477() +#line 3296 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_482() -#line 3327 "cs-parser.jay" +void case_478() +#line 3302 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6118,23 +6098,23 @@ void case_482() yyVal = list; } -void case_483() -#line 3333 "cs-parser.jay" +void case_479() +#line 3308 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_484() -#line 3341 "cs-parser.jay" +void case_480() +#line 3316 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); yyVal = args; } -void case_485() -#line 3347 "cs-parser.jay" +void case_481() +#line 3322 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6145,26 +6125,26 @@ void case_485() yyVal = args; } -void case_489() -#line 3375 "cs-parser.jay" +void case_485() +#line 3350 "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_490() -#line 3380 "cs-parser.jay" +void case_486() +#line 3355 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } -void case_493() -#line 3402 "cs-parser.jay" +void case_489() +#line 3377 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-5+yyTop]), "object initializers"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-5+yyTop]), "object initializers"); yyVal = new NewInitialize ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])); } else { @@ -6174,17 +6154,17 @@ void case_493() lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_494() -#line 3415 "cs-parser.jay" +void case_490() +#line 3390 "cs-parser.jay" { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); yyVal = new NewInitialize ((FullNamedExpression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_495() -#line 3427 "cs-parser.jay" +void case_491() +#line 3402 "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])) { @@ -6193,8 +6173,8 @@ void case_495() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_496() -#line 3435 "cs-parser.jay" +void case_492() +#line 3410 "cs-parser.jay" { if (yyVals[0+yyTop] == null) Report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6202,41 +6182,41 @@ void case_496() yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); } -void case_497() -#line 3442 "cs-parser.jay" +void case_493() +#line 3417 "cs-parser.jay" { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); yyVal = new ImplicitlyTypedArrayCreation ((ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_498() -#line 3449 "cs-parser.jay" +void case_494() +#line 3424 "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_499() -#line 3454 "cs-parser.jay" +void case_495() +#line 3429 "cs-parser.jay" { Error_SyntaxError (1526, yyToken, "Unexpected symbol"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } -void case_501() -#line 3465 "cs-parser.jay" +void case_497() +#line 3440 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } -void case_502() -#line 3473 "cs-parser.jay" +void case_498() +#line 3448 "cs-parser.jay" { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); yyVal = new NewAnonymousType ((List) yyVals[-1+yyTop], current_container, GetLocation (yyVals[-3+yyTop])); @@ -6244,76 +6224,76 @@ void case_502() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_507() -#line 3496 "cs-parser.jay" +void case_503() +#line 3471 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); yyVal = a; } -void case_508() -#line 3502 "cs-parser.jay" +void case_504() +#line 3477 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); yyVal = a; } -void case_509() -#line 3511 "cs-parser.jay" +void case_505() +#line 3486 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop]; yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_510() -#line 3517 "cs-parser.jay" +void case_506() +#line 3492 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location), lt.Value, lt.Location); } -void case_511() -#line 3523 "cs-parser.jay" +void case_507() +#line 3498 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } -void case_512() -#line 3528 "cs-parser.jay" +void case_508() +#line 3503 "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"); yyVal = null; } -void case_516() -#line 3543 "cs-parser.jay" +void case_512() +#line 3518 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_517() -#line 3551 "cs-parser.jay" +void case_513() +#line 3526 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_518() -#line 3556 "cs-parser.jay" +void case_514() +#line 3531 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_523() -#line 3586 "cs-parser.jay" +void case_519() +#line 3561 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6321,8 +6301,8 @@ void case_523() yyVal = ai; } -void case_524() -#line 3593 "cs-parser.jay" +void case_520() +#line 3568 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6334,16 +6314,16 @@ void case_524() yyVal = ai; } -void case_525() -#line 3607 "cs-parser.jay" +void case_521() +#line 3582 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_526() -#line 3613 "cs-parser.jay" +void case_522() +#line 3588 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6351,31 +6331,31 @@ void case_526() yyVal = list; } -void case_528() -#line 3627 "cs-parser.jay" +void case_524() +#line 3602 "cs-parser.jay" { lexer.TypeOfParsing = false; yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_531() -#line 3638 "cs-parser.jay" +void case_527() +#line 3613 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } -void case_532() -#line 3646 "cs-parser.jay" +void case_528() +#line 3621 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_533() -#line 3652 "cs-parser.jay" +void case_529() +#line 3627 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6383,24 +6363,24 @@ void case_533() yyVal = new QualifiedAliasMember (lt1.Value, lt2.Value, (int) yyVals[0+yyTop], lt1.Location); } -void case_534() -#line 3659 "cs-parser.jay" +void case_530() +#line 3634 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-2+yyTop], lt.Value, lt.Location); } -void case_535() -#line 3665 "cs-parser.jay" +void case_531() +#line 3640 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_536() -#line 3671 "cs-parser.jay" +void case_532() +#line 3646 "cs-parser.jay" { var te = ((MemberName) yyVals[-3+yyTop]).GetTypeExpression (); if (te.HasTypeArguments) @@ -6410,291 +6390,291 @@ void case_536() yyVal = new MemberAccess (te, lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_537() -#line 3683 "cs-parser.jay" +void case_533() +#line 3658 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); yyVal = yyVals[0+yyTop]; } -void case_538() -#line 3693 "cs-parser.jay" +void case_534() +#line 3668 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; - if (RootContext.Version == LanguageVersion.ISO_1) - Report.FeatureIsNotAvailable (lt.Location, "namespace alias qualifier"); + if (lang_version == LanguageVersion.ISO_1) + FeatureIsNotAvailable (lt.Location, "namespace alias qualifier"); yyVal = lt; } -void case_539() -#line 3704 "cs-parser.jay" +void case_535() +#line 3679 "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_540() -#line 3712 "cs-parser.jay" +void case_536() +#line 3687 "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_541() -#line 3720 "cs-parser.jay" +void case_537() +#line 3695 "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_542() -#line 3728 "cs-parser.jay" +void case_538() +#line 3703 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-2+yyTop], GetLocation (yyVals[-1+yyTop])), lt.Value, lt.Location); } -void case_548() -#line 3759 "cs-parser.jay" +void case_544() +#line 3734 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; } -void case_549() -#line 3767 "cs-parser.jay" +void case_545() +#line 3742 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_554() -#line 3791 "cs-parser.jay" +void case_550() +#line 3766 "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_563() -#line 3832 "cs-parser.jay" +void case_559() +#line 3807 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_564() -#line 3837 "cs-parser.jay" +void case_560() +#line 3812 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_565() -#line 3842 "cs-parser.jay" +void case_561() +#line 3817 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_567() -#line 3851 "cs-parser.jay" +void case_563() +#line 3826 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_569() -#line 3860 "cs-parser.jay" +void case_565() +#line 3835 "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_573() -#line 3877 "cs-parser.jay" +void case_569() +#line 3852 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_574() -#line 3882 "cs-parser.jay" +void case_570() +#line 3857 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_576() -#line 3891 "cs-parser.jay" +void case_572() +#line 3866 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_577() -#line 3896 "cs-parser.jay" +void case_573() +#line 3871 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_578() -#line 3901 "cs-parser.jay" +void case_574() +#line 3876 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_579() -#line 3906 "cs-parser.jay" +void case_575() +#line 3881 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_581() -#line 3915 "cs-parser.jay" +void case_577() +#line 3890 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_582() -#line 3920 "cs-parser.jay" +void case_578() +#line 3895 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_584() -#line 3929 "cs-parser.jay" +void case_580() +#line 3904 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_586() -#line 3938 "cs-parser.jay" +void case_582() +#line 3913 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_588() -#line 3947 "cs-parser.jay" +void case_584() +#line 3922 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_590() -#line 3956 "cs-parser.jay" +void case_586() +#line 3931 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_592() -#line 3965 "cs-parser.jay" +void case_588() +#line 3940 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_594() -#line 3974 "cs-parser.jay" +void case_590() +#line 3949 "cs-parser.jay" { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_596() -#line 3985 "cs-parser.jay" +void case_592() +#line 3960 "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_598() -#line 3997 "cs-parser.jay" +void case_594() +#line 3972 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_599() -#line 4002 "cs-parser.jay" +void case_595() +#line 3977 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_600() -#line 4007 "cs-parser.jay" +void case_596() +#line 3982 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_601() -#line 4012 "cs-parser.jay" +void case_597() +#line 3987 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_602() -#line 4017 "cs-parser.jay" +void case_598() +#line 3992 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_603() -#line 4022 "cs-parser.jay" +void case_599() +#line 3997 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_604() -#line 4027 "cs-parser.jay" +void case_600() +#line 4002 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_605() -#line 4032 "cs-parser.jay" +void case_601() +#line 4007 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_606() -#line 4037 "cs-parser.jay" +void case_602() +#line 4012 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_607() -#line 4042 "cs-parser.jay" +void case_603() +#line 4017 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_608() -#line 4050 "cs-parser.jay" +void case_604() +#line 4025 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -6702,8 +6682,8 @@ void case_608() yyVal = pars; } -void case_609() -#line 4057 "cs-parser.jay" +void case_605() +#line 4032 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -6715,134 +6695,161 @@ void case_609() yyVal = pars; } -void case_610() -#line 4071 "cs-parser.jay" +void case_606() +#line 4046 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Parameter.Modifier) yyVals[-2+yyTop], null, lt.Location); } -void case_611() -#line 4077 "cs-parser.jay" +void case_607() +#line 4052 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, Parameter.Modifier.NONE, null, lt.Location); } -void case_612() -#line 4083 "cs-parser.jay" +void case_608() +#line 4058 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } -void case_614() -#line 4091 "cs-parser.jay" +void case_610() +#line 4066 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); } -void case_618() -#line 4107 "cs-parser.jay" +void case_614() +#line 4082 "cs-parser.jay" { Block b = end_block (lexer.Location); + b.IsCompilerGenerated = true; b.AddStatement (new ContextualReturn ((Expression) yyVals[0+yyTop])); yyVal = b; } -void case_620() -#line 4117 "cs-parser.jay" +void case_616() +#line 4093 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } -void case_621() -#line 4125 "cs-parser.jay" +void case_617() +#line 4101 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); start_anonymous (true, new ParametersCompiled (p), GetLocation (yyVals[-1+yyTop])); } -void case_622() -#line 4131 "cs-parser.jay" +void case_618() +#line 4107 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_623() -#line 4136 "cs-parser.jay" +void case_619() +#line 4112 "cs-parser.jay" { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "lambda expressions"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "lambda expressions"); valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } -void case_624() -#line 4143 "cs-parser.jay" +void case_620() +#line 4119 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop])); } -void case_625() -#line 4148 "cs-parser.jay" +void case_621() +#line 4124 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_635() -#line 4192 "cs-parser.jay" +void case_628() +#line 4147 "cs-parser.jay" +{ + yyVal = new RefValueExpr ((Expression) yyVals[-3+yyTop], (FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); + } + +void case_629() +#line 4152 "cs-parser.jay" +{ + yyVal = new RefTypeExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); + } + +void case_630() +#line 4157 "cs-parser.jay" +{ + yyVal = new MakeRefExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); + } + +void case_634() +#line 4186 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); - push_current_class (new Class (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); + Class c = new Class (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]); + if (((c.ModFlags & Modifiers.STATIC) != 0) && lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (c.Location, "static classes"); + } + + push_current_class (c, yyVals[-3+yyTop]); } -void case_636() -#line 4198 "cs-parser.jay" +void case_635() +#line 4197 "cs-parser.jay" { lexer.ConstraintsParsing = false; current_class.SetParameterInfo ((List) yyVals[0+yyTop]); lbag.AddMember (current_class, GetModifierLocations (), GetLocation (yyVals[-5+yyTop])); - if (RootContext.Documentation != null) { + if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } } -void case_637() -#line 4210 "cs-parser.jay" +void case_636() +#line 4209 "cs-parser.jay" { --lexer.parsing_declaration; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_638() -#line 4216 "cs-parser.jay" +void case_637() +#line 4215 "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_641() -#line 4231 "cs-parser.jay" +void case_640() +#line 4230 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; } -void case_644() -#line 4241 "cs-parser.jay" +void case_643() +#line 4240 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -6859,133 +6866,133 @@ void case_644() yyVal = m1 | m2; } -void case_645() -#line 4260 "cs-parser.jay" +void case_644() +#line 4259 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); - if (current_container == RootContext.ToplevelTypes) + if (current_container == module) Report.Error (1530, GetLocation (yyVals[0+yyTop]), "Keyword `new' is not allowed on namespace elements"); } -void case_646() -#line 4268 "cs-parser.jay" +void case_645() +#line 4267 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_647() -#line 4273 "cs-parser.jay" +void case_646() +#line 4272 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_648() -#line 4278 "cs-parser.jay" +void case_647() +#line 4277 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_649() -#line 4283 "cs-parser.jay" +void case_648() +#line 4282 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_650() -#line 4288 "cs-parser.jay" +void case_649() +#line 4287 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_651() -#line 4293 "cs-parser.jay" +void case_650() +#line 4292 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_652() -#line 4298 "cs-parser.jay" +void case_651() +#line 4297 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_653() -#line 4303 "cs-parser.jay" +void case_652() +#line 4302 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_654() -#line 4308 "cs-parser.jay" +void case_653() +#line 4307 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_655() -#line 4313 "cs-parser.jay" +void case_654() +#line 4312 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_656() -#line 4318 "cs-parser.jay" +void case_655() +#line 4317 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_657() -#line 4323 "cs-parser.jay" +void case_656() +#line 4322 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_658() -#line 4328 "cs-parser.jay" +void case_657() +#line 4327 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); - if (!RootContext.Unsafe) + if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_659() -#line 4335 "cs-parser.jay" +void case_658() +#line 4334 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_664() -#line 4356 "cs-parser.jay" +void case_663() +#line 4355 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_665() -#line 4364 "cs-parser.jay" +void case_664() +#line 4363 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); yyVal = constraints; } -void case_666() -#line 4370 "cs-parser.jay" +void case_665() +#line 4369 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7002,23 +7009,23 @@ void case_666() yyVal = constraints; } -void case_667() -#line 4389 "cs-parser.jay" +void case_666() +#line 4388 "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_668() -#line 4397 "cs-parser.jay" +void case_667() +#line 4396 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = constraints; } -void case_669() -#line 4403 "cs-parser.jay" +void case_668() +#line 4402 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7042,8 +7049,8 @@ void case_669() yyVal = constraints; } -void case_670() -#line 4429 "cs-parser.jay" +void case_669() +#line 4428 "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 ()); @@ -7051,94 +7058,94 @@ void case_670() yyVal = yyVals[0+yyTop]; } -void case_671() -#line 4436 "cs-parser.jay" +void case_670() +#line 4435 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Constructor, GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_675() -#line 4456 "cs-parser.jay" +void case_674() +#line 4455 "cs-parser.jay" { - if (RootContext.Version <= LanguageVersion.V_3) - Report.FeatureIsNotAvailable (lexer.Location, "generic type variance"); + if (lang_version <= LanguageVersion.V_3) + FeatureIsNotAvailable (lexer.Location, "generic type variance"); yyVal = yyVals[0+yyTop]; } -void case_678() -#line 4490 "cs-parser.jay" +void case_677() +#line 4489 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } -void case_680() -#line 4502 "cs-parser.jay" +void case_679() +#line 4501 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_681() -#line 4507 "cs-parser.jay" +void case_680() +#line 4506 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } -void case_682() -#line 4516 "cs-parser.jay" +void case_681() +#line 4515 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } -void case_683() -#line 4521 "cs-parser.jay" +void case_682() +#line 4520 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_691() -#line 4548 "cs-parser.jay" +void case_690() +#line 4547 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_724() -#line 4612 "cs-parser.jay" +void case_723() +#line 4611 "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_725() -#line 4617 "cs-parser.jay" +void case_724() +#line 4616 "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_726() -#line 4622 "cs-parser.jay" +void case_725() +#line 4621 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_727() -#line 4630 "cs-parser.jay" +void case_726() +#line 4629 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } -void case_728() -#line 4638 "cs-parser.jay" +void case_727() +#line 4637 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7147,8 +7154,8 @@ void case_728() current_block.AddStatement (labeled); } -void case_731() -#line 4651 "cs-parser.jay" +void case_730() +#line 4650 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7156,8 +7163,8 @@ void case_731() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_732() -#line 4667 "cs-parser.jay" +void case_731() +#line 4666 "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*/ @@ -7188,8 +7195,8 @@ void case_732() } } -void case_733() -#line 4697 "cs-parser.jay" +void case_732() +#line 4696 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7201,8 +7208,8 @@ void case_733() } } -void case_734() -#line 4708 "cs-parser.jay" +void case_733() +#line 4707 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7210,22 +7217,22 @@ void case_734() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_737() -#line 4723 "cs-parser.jay" +void case_736() +#line 4722 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), Report); - yyVal = new TypeExpression (TypeManager.void_type, GetLocation (yyVals[0+yyTop])); + yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_739() -#line 4732 "cs-parser.jay" +void case_738() +#line 4731 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_741() -#line 4747 "cs-parser.jay" +void case_740() +#line 4746 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7233,16 +7240,16 @@ void case_741() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_742() -#line 4754 "cs-parser.jay" +void case_741() +#line 4753 "cs-parser.jay" { yyVal = current_variable; current_variable = null; lbag.AppendTo (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_743() -#line 4760 "cs-parser.jay" +void case_742() +#line 4759 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7250,23 +7257,27 @@ void case_743() current_variable = new BlockConstantDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_744() -#line 4767 "cs-parser.jay" +void case_743() +#line 4766 "cs-parser.jay" { - yyVal = current_variable; + if (current_variable.Initializer != null) { + lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); + } else { + lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop])); + } + yyVal = current_variable;; current_variable = null; - lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_746() -#line 4777 "cs-parser.jay" +void case_745() +#line 4780 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } -void case_747() -#line 4782 "cs-parser.jay" +void case_746() +#line 4785 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { Report.Error (650, lexer.Location, @@ -7276,8 +7287,8 @@ void case_747() } } -void case_752() -#line 4804 "cs-parser.jay" +void case_751() +#line 4807 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7287,8 +7298,8 @@ void case_752() lbag.AddLocation (d, GetLocation (yyVals[-1+yyTop])); } -void case_753() -#line 4813 "cs-parser.jay" +void case_752() +#line 4816 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7298,8 +7309,15 @@ void case_753() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_760() -#line 4846 "cs-parser.jay" +void case_754() +#line 4832 "cs-parser.jay" +{ + savedLocation = GetLocation (yyVals[-1+yyTop]); + current_variable.Initializer = (Expression) yyVals[0+yyTop]; + } + +void case_759() +#line 4850 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7309,29 +7327,29 @@ void case_760() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_762() -#line 4859 "cs-parser.jay" +void case_761() +#line 4863 "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_763() -#line 4864 "cs-parser.jay" +void case_762() +#line 4868 "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_764() -#line 4872 "cs-parser.jay" +void case_763() +#line 4876 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_768() -#line 4890 "cs-parser.jay" +void case_767() +#line 4894 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { @@ -7342,8 +7360,8 @@ void case_768() yyVal = new StatementExpression (s); } -void case_769() -#line 4903 "cs-parser.jay" +void case_768() +#line 4907 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7352,15 +7370,15 @@ void case_769() yyVal = new StatementExpression (s); } -void case_770() -#line 4911 "cs-parser.jay" +void case_769() +#line 4915 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_773() -#line 4925 "cs-parser.jay" +void case_772() +#line 4929 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7369,8 +7387,8 @@ void case_773() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_774() -#line 4934 "cs-parser.jay" +void case_773() +#line 4938 "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])); @@ -7381,23 +7399,23 @@ void case_774() Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_776() -#line 4951 "cs-parser.jay" +void case_775() +#line 4955 "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])); lbag.AddStatement (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_777() -#line 4960 "cs-parser.jay" +void case_776() +#line 4964 "cs-parser.jay" { Report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } -void case_779() -#line 4969 "cs-parser.jay" +void case_778() +#line 4973 "cs-parser.jay" { var sections = new List (4); @@ -7405,8 +7423,8 @@ void case_779() yyVal = sections; } -void case_780() -#line 4976 "cs-parser.jay" +void case_779() +#line 4980 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -7414,24 +7432,24 @@ void case_780() yyVal = sections; } -void case_781() -#line 4983 "cs-parser.jay" +void case_780() +#line 4987 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } -void case_784() -#line 5002 "cs-parser.jay" +void case_783() +#line 5006 "cs-parser.jay" { - var labels = new List (4); + var labels = new List (2); labels.Add ((SwitchLabel) yyVals[0+yyTop]); yyVal = labels; } -void case_785() -#line 5009 "cs-parser.jay" +void case_784() +#line 5013 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -7439,15 +7457,15 @@ void case_785() yyVal = labels; } -void case_786() -#line 5019 "cs-parser.jay" +void case_785() +#line 5023 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_792() -#line 5038 "cs-parser.jay" +void case_791() +#line 5042 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7456,22 +7474,22 @@ void case_792() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_793() -#line 5050 "cs-parser.jay" +void case_792() +#line 5054 "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_794() -#line 5058 "cs-parser.jay" +void case_793() +#line 5062 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; } -void case_796() -#line 5074 "cs-parser.jay" +void case_795() +#line 5078 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7484,15 +7502,15 @@ void case_796() yyVal = end_block (GetLocation (yyVals[-5+yyTop])); } -void case_797() -#line 5086 "cs-parser.jay" +void case_796() +#line 5090 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } -void case_800() -#line 5099 "cs-parser.jay" +void case_799() +#line 5103 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7500,15 +7518,15 @@ void case_800() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_801() -#line 5106 "cs-parser.jay" +void case_800() +#line 5110 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_809() -#line 5130 "cs-parser.jay" +void case_808() +#line 5134 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -7522,15 +7540,15 @@ void case_809() yyVal = sl; } -void case_810() -#line 5146 "cs-parser.jay" +void case_809() +#line 5150 "cs-parser.jay" { Report.Error (230, GetLocation (yyVals[-5+yyTop]), "Type and identifier are both required in a foreach statement"); yyVal = null; } -void case_811() -#line 5151 "cs-parser.jay" +void case_810() +#line 5155 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -7540,8 +7558,8 @@ void case_811() yyVal = li; } -void case_812() -#line 5160 "cs-parser.jay" +void case_811() +#line 5164 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7553,58 +7571,58 @@ void case_812() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_819() -#line 5183 "cs-parser.jay" +void case_818() +#line 5187 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_820() -#line 5191 "cs-parser.jay" +void case_819() +#line 5195 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_821() -#line 5199 "cs-parser.jay" +void case_820() +#line 5203 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new Goto (lt.Value, GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_822() -#line 5205 "cs-parser.jay" +void case_821() +#line 5209 "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_823() -#line 5210 "cs-parser.jay" +void case_822() +#line 5214 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_824() -#line 5218 "cs-parser.jay" +void case_823() +#line 5222 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_825() -#line 5226 "cs-parser.jay" +void case_824() +#line 5230 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_826() -#line 5234 "cs-parser.jay" +void case_825() +#line 5238 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -7612,8 +7630,8 @@ void case_826() Report.Error (1003, lt.Location, "; expected"); } else if (yyVals[-1+yyTop] == null) { Report.Error (1627, GetLocation (yyVals[0+yyTop]), "Expression expected after yield return"); - } else if (RootContext.Version == LanguageVersion.ISO_1){ - Report.FeatureIsNotAvailable (lt.Location, "iterators"); + } else if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (lt.Location, "iterators"); } current_block.ParametersBlock.TopBlock.IsIterator = true; @@ -7621,15 +7639,15 @@ void case_826() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_827() -#line 5250 "cs-parser.jay" +void case_826() +#line 5254 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; if (s != "yield"){ Report.Error (1003, lt.Location, "; expected"); - } else if (RootContext.Version == LanguageVersion.ISO_1){ - Report.FeatureIsNotAvailable (lt.Location, "iterators"); + } else if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (lt.Location, "iterators"); } current_block.ParametersBlock.TopBlock.IsIterator = true; @@ -7637,29 +7655,29 @@ void case_827() lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_831() -#line 5276 "cs-parser.jay" +void case_830() +#line 5280 "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_832() -#line 5281 "cs-parser.jay" +void case_831() +#line 5285 "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_833() -#line 5286 "cs-parser.jay" +void case_832() +#line 5290 "cs-parser.jay" { Report.Error (1524, GetLocation (yyVals[-2+yyTop]), "Expected catch or finally"); yyVal = null; } -void case_834() -#line 5294 "cs-parser.jay" +void case_833() +#line 5298 "cs-parser.jay" { var l = new List (2); @@ -7667,8 +7685,8 @@ void case_834() yyVal = l; } -void case_835() -#line 5301 "cs-parser.jay" +void case_834() +#line 5305 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -7685,8 +7703,8 @@ void case_835() yyVal = l; } -void case_839() -#line 5329 "cs-parser.jay" +void case_838() +#line 5333 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -7702,8 +7720,8 @@ void case_839() yyVal = c; } -void case_841() -#line 5348 "cs-parser.jay" +void case_840() +#line 5352 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { Report.Error (1015, lexer.Location, @@ -7715,15 +7733,15 @@ void case_841() yyVal = new Catch (null, GetLocation (yyVals[-2+yyTop])); } -void case_844() -#line 5376 "cs-parser.jay" +void case_843() +#line 5380 "cs-parser.jay" { - if (!RootContext.Unsafe) + if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_846() -#line 5386 "cs-parser.jay" +void case_845() +#line 5390 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7732,8 +7750,8 @@ void case_846() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_847() -#line 5397 "cs-parser.jay" +void case_846() +#line 5401 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -7744,15 +7762,15 @@ void case_847() current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_848() -#line 5407 "cs-parser.jay" +void case_847() +#line 5411 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_849() -#line 5412 "cs-parser.jay" +void case_848() +#line 5416 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7763,8 +7781,8 @@ void case_849() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_850() -#line 5425 "cs-parser.jay" +void case_849() +#line 5429 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -7775,15 +7793,15 @@ void case_850() current_variable = new Using.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_851() -#line 5435 "cs-parser.jay" +void case_850() +#line 5439 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_852() -#line 5440 "cs-parser.jay" +void case_851() +#line 5444 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7794,8 +7812,8 @@ void case_852() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_853() -#line 5450 "cs-parser.jay" +void case_852() +#line 5454 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7805,15 +7823,15 @@ void case_853() yyVal = u; } -void case_855() -#line 5466 "cs-parser.jay" +void case_854() +#line 5470 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; yyVal = current_variable; } -void case_856() -#line 5477 "cs-parser.jay" +void case_855() +#line 5481 "cs-parser.jay" { lexer.query_parsing = false; @@ -7826,8 +7844,8 @@ void case_856() current_block = current_block.Parent; } -void case_857() -#line 5489 "cs-parser.jay" +void case_856() +#line 5493 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -7838,8 +7856,8 @@ void case_857() current_block = current_block.Parent; } -void case_858() -#line 5500 "cs-parser.jay" +void case_857() +#line 5504 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -7848,28 +7866,28 @@ void case_858() current_block = current_block.Parent; } -void case_859() -#line 5507 "cs-parser.jay" +void case_858() +#line 5511 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; } -void case_860() -#line 5516 "cs-parser.jay" +void case_859() +#line 5520 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); yyVal = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop]))); } -void case_861() -#line 5524 "cs-parser.jay" +void case_860() +#line 5528 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); @@ -7880,20 +7898,20 @@ void case_861() ); } -void case_862() -#line 5539 "cs-parser.jay" +void case_861() +#line 5543 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); yyVal = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop]))); } -void case_863() -#line 5547 "cs-parser.jay" +void case_862() +#line 5551 "cs-parser.jay" { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); @@ -7904,8 +7922,8 @@ void case_863() ); } -void case_865() -#line 5566 "cs-parser.jay" +void case_864() +#line 5570 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -7917,8 +7935,8 @@ void case_865() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_867() -#line 5581 "cs-parser.jay" +void case_866() +#line 5585 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -7933,8 +7951,8 @@ void case_867() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_868() -#line 5598 "cs-parser.jay" +void case_867() +#line 5602 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -7950,15 +7968,15 @@ void case_868() yyVal = head; } -void case_870() -#line 5614 "cs-parser.jay" +void case_869() +#line 5618 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_872() -#line 5626 "cs-parser.jay" +void case_871() +#line 5630 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -7966,27 +7984,27 @@ void case_872() current_block = current_block.Parent; } -void case_873() -#line 5633 "cs-parser.jay" +void case_872() +#line 5637 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock)current_block); } -void case_874() -#line 5641 "cs-parser.jay" +void case_873() +#line 5645 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_875() -#line 5648 "cs-parser.jay" +void case_874() +#line 5652 "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])); @@ -7994,15 +8012,15 @@ void case_875() current_block = current_block.Parent; } -void case_879() -#line 5664 "cs-parser.jay" +void case_878() +#line 5668 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_886() -#line 5684 "cs-parser.jay" +void case_885() +#line 5688 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8014,47 +8032,47 @@ void case_886() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_888() -#line 5702 "cs-parser.jay" +void case_887() +#line 5706 "cs-parser.jay" { - yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (BooleanExpression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); + yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; } -void case_889() -#line 5712 "cs-parser.jay" +void case_888() +#line 5716 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_890() -#line 5720 "cs-parser.jay" +void case_889() +#line 5724 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_891() -#line 5728 "cs-parser.jay" +void case_890() +#line 5732 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_892() -#line 5736 "cs-parser.jay" +void case_891() +#line 5740 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8091,38 +8109,38 @@ void case_892() ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_893() -#line 5772 "cs-parser.jay" +void case_892() +#line 5776 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_894() -#line 5780 "cs-parser.jay" +void case_893() +#line 5784 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_895() -#line 5788 "cs-parser.jay" +void case_894() +#line 5792 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_896() -#line 5796 "cs-parser.jay" +void case_895() +#line 5800 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8163,8 +8181,8 @@ void case_896() ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_900() -#line 5851 "cs-parser.jay" +void case_899() +#line 5855 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8172,40 +8190,40 @@ void case_900() yyVal = yyVals[0+yyTop]; } -void case_902() -#line 5862 "cs-parser.jay" +void case_901() +#line 5866 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_903() -#line 5869 "cs-parser.jay" +void case_902() +#line 5873 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_905() -#line 5878 "cs-parser.jay" +void case_904() +#line 5882 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, (Linq.QueryBlock) current_block, lexer.Location); + current_block = new Linq.QueryBlock ((Linq.QueryBlock) current_block, lexer.Location); } -void case_906() -#line 5885 "cs-parser.jay" +void case_905() +#line 5889 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_914() -#line 5925 "cs-parser.jay" +void case_913() +#line 5929 "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*/ @@ -8214,7 +8232,7 @@ void case_914() current_block.SetEndLocation (GetLocation (yyVals[-1+yyTop])); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8222,8 +8240,8 @@ void case_914() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_915() -#line 5941 "cs-parser.jay" +void case_914() +#line 5945 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -8233,2240 +8251,2315 @@ void case_915() }; } -void case_918() -#line 5967 "cs-parser.jay" +void case_917() +#line 5972 "cs-parser.jay" { - Evaluator.LoadAliases (current_namespace); - - push_current_class (new Class (current_namespace, current_class, new MemberName ("Class" + class_count++), - Modifiers.PUBLIC, null), null); - - var baseclass_list = new List (); - baseclass_list.Add (new TypeExpression (Evaluator.InteractiveBaseClass, lexer.Location)); - current_container.AddBasesForPart (current_class, baseclass_list); + current_container = new Class (current_namespace, current_class, new MemberName (""), Modifiers.PUBLIC, null); + current_class = current_container; /* (ref object retval)*/ Parameter [] mpar = new Parameter [1]; - mpar [0] = new Parameter (new TypeExpression (TypeManager.object_type, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null); + mpar [0] = new Parameter (new TypeExpression (compiler.BuiltinTypes.Object, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null); ParametersCompiled pars = new ParametersCompiled (mpar); + var mods = Modifiers.PUBLIC | Modifiers.STATIC; + if (settings.Unsafe) + mods |= Modifiers.UNSAFE; + current_local_parameters = pars; Method method = new Method ( current_class, null, /* generic*/ - new TypeExpression (TypeManager.void_type, Location.Null), - Modifiers.PUBLIC | Modifiers.STATIC, + new TypeExpression (compiler.BuiltinTypes.Void, Location.Null), + mods, new MemberName ("Host"), pars, null /* attributes */); + + current_container.AddMethod (method); oob_stack.Push (method); - ++lexer.parsing_block; + ++lexer.parsing_block; start_block (lexer.Location); } -void case_919() -#line 5997 "cs-parser.jay" +void case_918() +#line 6002 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); method.Block = (ToplevelBlock) end_block(lexer.Location); - current_container.AddMethod (method); - --lexer.parsing_declaration; - InteractiveResult = pop_current_class (); + InteractiveResult = (Class) pop_current_class (); current_local_parameters = null; } #line default static readonly short [] yyLhs = { -1, - 0, 0, 0, 0, 5, 0, 2, 2, 1, 1, - 6, 6, 6, 10, 10, 7, 7, 11, 11, 8, - 8, 12, 12, 13, 20, 16, 18, 18, 18, 21, - 21, 22, 22, 15, 24, 19, 25, 25, 23, 23, - 26, 26, 27, 27, 9, 9, 9, 28, 28, 28, - 28, 28, 3, 17, 17, 34, 34, 35, 35, 36, - 38, 38, 38, 38, 37, 37, 42, 39, 40, 41, - 41, 43, 43, 43, 43, 43, 44, 44, 48, 45, - 47, 49, 49, 49, 50, 50, 51, 51, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 65, - 67, 70, 71, 30, 30, 73, 69, 72, 72, 74, - 74, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 78, 53, 79, 79, 80, 80, 81, 83, 77, - 77, 82, 82, 88, 54, 92, 54, 54, 87, 95, - 87, 89, 89, 96, 96, 97, 98, 97, 93, 93, - 99, 99, 100, 101, 91, 91, 94, 94, 94, 104, - 55, 107, 108, 102, 109, 110, 102, 102, 103, 103, - 106, 106, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 114, 114, 117, 117, 117, 120, 117, 118, - 118, 121, 121, 122, 122, 122, 115, 115, 115, 123, - 123, 123, 116, 125, 127, 128, 56, 130, 131, 132, - 58, 126, 126, 126, 126, 126, 136, 133, 137, 134, - 135, 135, 135, 138, 139, 140, 142, 31, 31, 141, - 141, 143, 143, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 147, 59, 146, 146, 148, 148, 151, 145, - 145, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 153, 152, 154, 152, 152, 152, 60, - 157, 159, 155, 156, 156, 158, 158, 163, 161, 164, - 161, 161, 165, 61, 167, 57, 170, 171, 57, 166, - 173, 166, 168, 168, 174, 174, 175, 176, 175, 177, - 172, 169, 169, 169, 169, 169, 181, 178, 182, 179, - 180, 180, 184, 186, 187, 32, 183, 183, 183, 185, - 185, 185, 188, 188, 189, 190, 189, 191, 192, 193, - 33, 194, 194, 14, 14, 195, 195, 198, 197, 197, - 197, 199, 199, 201, 64, 124, 105, 105, 129, 129, - 202, 202, 202, 200, 200, 203, 203, 204, 204, 206, - 206, 86, 76, 76, 90, 90, 119, 119, 149, 149, - 207, 207, 207, 207, 207, 211, 211, 212, 212, 210, - 210, 210, 210, 210, 210, 210, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 215, 215, 215, 216, 216, 216, - 235, 235, 236, 236, 237, 237, 218, 218, 234, 234, - 234, 234, 234, 234, 234, 234, 220, 238, 238, 239, - 239, 240, 240, 242, 242, 242, 243, 243, 243, 243, - 243, 244, 244, 162, 162, 248, 248, 248, 248, 248, - 250, 250, 249, 249, 251, 251, 251, 251, 252, 221, - 247, 247, 247, 253, 253, 254, 254, 222, 223, 223, - 224, 225, 226, 226, 217, 217, 217, 217, 217, 259, - 255, 227, 260, 260, 261, 261, 262, 262, 263, 263, - 263, 263, 256, 256, 208, 208, 258, 258, 264, 264, - 257, 257, 85, 85, 265, 265, 266, 228, 267, 267, - 267, 268, 268, 268, 268, 268, 269, 196, 229, 230, - 231, 232, 271, 233, 270, 270, 273, 272, 219, 274, - 274, 274, 274, 276, 275, 275, 275, 275, 275, 275, - 275, 277, 277, 277, 277, 278, 278, 278, 278, 278, - 278, 279, 279, 279, 280, 280, 280, 280, 280, 281, - 281, 281, 282, 282, 283, 283, 284, 284, 285, 285, - 286, 286, 287, 287, 288, 288, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 290, 290, 291, - 291, 291, 292, 292, 293, 293, 296, 294, 295, 295, - 298, 297, 299, 300, 297, 46, 46, 245, 245, 245, - 245, 84, 302, 303, 304, 305, 306, 29, 63, 63, - 62, 62, 111, 111, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 66, - 66, 68, 68, 68, 308, 308, 309, 310, 310, 311, - 311, 311, 311, 205, 205, 312, 312, 314, 112, 315, - 315, 316, 160, 313, 313, 317, 317, 318, 318, 318, - 318, 322, 322, 323, 323, 323, 320, 320, 320, 320, - 320, 320, 320, 320, 320, 320, 320, 320, 320, 324, + 0, 4, 0, 1, 1, 1, 1, 2, 2, 10, + 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, + 20, 21, 18, 19, 19, 19, 23, 23, 24, 24, + 17, 6, 6, 5, 5, 22, 22, 7, 7, 25, + 25, 26, 26, 26, 26, 26, 8, 8, 9, 9, + 34, 32, 37, 33, 33, 35, 35, 35, 35, 36, + 36, 41, 38, 39, 40, 40, 42, 42, 42, 42, + 42, 43, 43, 47, 44, 46, 48, 48, 48, 49, + 49, 50, 50, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 64, 66, 69, 70, 28, 28, + 72, 68, 71, 71, 73, 73, 74, 74, 74, 74, + 74, 74, 74, 74, 74, 74, 77, 52, 78, 78, + 79, 79, 80, 82, 76, 76, 81, 81, 87, 53, + 91, 53, 53, 86, 94, 86, 88, 88, 95, 95, + 96, 97, 96, 92, 92, 98, 98, 99, 100, 90, + 90, 93, 93, 93, 103, 54, 106, 107, 101, 108, + 109, 101, 101, 102, 102, 105, 105, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 113, 113, 116, + 116, 116, 119, 116, 117, 117, 120, 120, 121, 121, + 121, 114, 114, 114, 122, 122, 122, 115, 124, 126, + 127, 55, 129, 130, 131, 57, 125, 125, 125, 125, + 125, 135, 132, 136, 133, 134, 134, 134, 137, 138, + 139, 141, 29, 29, 140, 140, 142, 142, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 146, 58, 145, + 145, 147, 147, 150, 144, 144, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 152, 151, + 153, 151, 151, 151, 59, 156, 158, 154, 155, 155, + 157, 157, 162, 160, 163, 160, 160, 164, 60, 166, + 56, 169, 170, 56, 165, 172, 165, 167, 167, 173, + 173, 174, 175, 174, 176, 171, 168, 168, 168, 168, + 168, 180, 177, 181, 178, 179, 179, 183, 185, 186, + 30, 182, 182, 182, 184, 184, 184, 187, 187, 188, + 189, 188, 190, 191, 192, 31, 193, 193, 16, 16, + 194, 194, 197, 196, 196, 196, 198, 198, 200, 63, + 123, 104, 104, 128, 128, 201, 201, 201, 199, 199, + 202, 202, 203, 203, 205, 205, 85, 75, 75, 89, + 89, 118, 118, 148, 148, 206, 206, 206, 206, 206, + 210, 210, 211, 211, 209, 209, 209, 209, 209, 209, + 209, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, + 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, + 214, 214, 214, 215, 215, 215, 235, 235, 236, 236, + 237, 237, 217, 217, 234, 234, 234, 234, 234, 234, + 234, 234, 219, 238, 238, 239, 239, 240, 240, 242, + 242, 242, 243, 243, 243, 243, 243, 244, 244, 161, + 161, 248, 248, 248, 248, 248, 250, 250, 249, 249, + 251, 251, 251, 251, 252, 220, 247, 247, 247, 253, + 253, 254, 254, 221, 222, 222, 223, 224, 225, 225, + 216, 216, 216, 216, 216, 259, 255, 226, 260, 260, + 261, 261, 262, 262, 263, 263, 263, 263, 256, 256, + 207, 207, 258, 258, 264, 264, 257, 257, 84, 84, + 265, 265, 266, 227, 267, 267, 267, 268, 268, 268, + 268, 268, 269, 195, 228, 229, 230, 231, 271, 232, + 270, 270, 273, 272, 218, 274, 274, 274, 274, 276, + 275, 275, 275, 275, 275, 275, 275, 277, 277, 277, + 277, 278, 278, 278, 278, 278, 278, 279, 279, 279, + 280, 280, 280, 280, 280, 281, 281, 281, 282, 282, + 283, 283, 284, 284, 285, 285, 286, 286, 287, 287, + 288, 288, 289, 289, 289, 289, 289, 289, 289, 289, + 289, 289, 289, 290, 290, 291, 291, 291, 292, 292, + 293, 293, 296, 294, 295, 295, 298, 297, 299, 300, + 297, 45, 45, 245, 245, 245, 245, 233, 233, 233, + 83, 302, 303, 304, 305, 306, 27, 62, 62, 61, + 61, 110, 110, 307, 307, 307, 307, 307, 307, 307, + 307, 307, 307, 307, 307, 307, 307, 307, 65, 65, + 67, 67, 67, 308, 308, 309, 310, 310, 311, 311, + 311, 311, 204, 204, 312, 312, 314, 111, 315, 315, + 316, 159, 313, 313, 317, 317, 318, 318, 318, 318, + 322, 322, 323, 323, 323, 320, 320, 320, 320, 320, + 320, 320, 320, 320, 320, 320, 320, 320, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, - 324, 324, 338, 338, 338, 338, 325, 339, 321, 340, - 340, 341, 341, 341, 341, 341, 341, 209, 209, 342, - 344, 319, 347, 319, 343, 343, 343, 345, 345, 350, - 350, 351, 351, 346, 346, 348, 348, 352, 352, 353, - 349, 349, 349, 326, 326, 337, 337, 354, 355, 355, - 327, 327, 356, 356, 359, 357, 358, 358, 360, 360, - 360, 363, 361, 362, 362, 364, 364, 328, 328, 328, - 328, 365, 366, 370, 367, 369, 369, 371, 371, 375, - 374, 374, 372, 372, 373, 373, 377, 376, 376, 368, - 378, 368, 329, 329, 329, 329, 329, 329, 379, 380, - 381, 381, 381, 382, 383, 384, 384, 385, 385, 330, - 330, 330, 330, 386, 386, 388, 388, 387, 389, 387, - 387, 331, 332, 390, 335, 333, 392, 393, 336, 394, - 395, 334, 334, 391, 391, 301, 301, 301, 301, 396, - 396, 398, 398, 400, 399, 401, 399, 397, 397, 397, - 405, 403, 406, 407, 403, 402, 402, 408, 408, 409, - 409, 409, 409, 409, 414, 410, 415, 411, 416, 417, - 418, 412, 420, 421, 422, 412, 419, 419, 424, 413, - 423, 427, 423, 426, 429, 426, 425, 425, 425, 428, - 428, 428, 404, 430, 404, 4, 4, 431, 4, 433, - 4, 432, 432, 432, 432, 246, 246, 241, 241, + 324, 338, 338, 338, 338, 325, 339, 321, 340, 340, + 341, 341, 341, 341, 341, 341, 208, 208, 342, 344, + 319, 347, 319, 343, 343, 343, 345, 345, 350, 350, + 351, 351, 346, 346, 348, 348, 352, 352, 353, 349, + 349, 349, 326, 326, 337, 337, 354, 355, 355, 327, + 327, 356, 356, 359, 357, 358, 358, 360, 360, 360, + 363, 361, 362, 362, 364, 364, 328, 328, 328, 328, + 365, 366, 370, 367, 369, 369, 371, 371, 375, 374, + 374, 372, 372, 373, 373, 377, 376, 376, 368, 378, + 368, 329, 329, 329, 329, 329, 329, 379, 380, 381, + 381, 381, 382, 383, 384, 384, 385, 385, 330, 330, + 330, 330, 386, 386, 388, 388, 387, 389, 387, 387, + 331, 332, 390, 335, 333, 392, 393, 336, 394, 395, + 334, 334, 391, 391, 301, 301, 301, 301, 396, 396, + 398, 398, 400, 399, 401, 399, 397, 397, 397, 405, + 403, 406, 407, 403, 402, 402, 408, 408, 409, 409, + 409, 409, 409, 414, 410, 415, 411, 416, 417, 418, + 412, 420, 421, 422, 412, 419, 419, 424, 413, 423, + 427, 423, 426, 429, 426, 425, 425, 425, 428, 428, + 428, 404, 430, 404, 3, 3, 431, 3, 3, 432, + 432, 246, 246, 241, 241, }; static readonly short [] yyLen = { 2, - 2, 3, 2, 1, 0, 3, 0, 1, 1, 2, - 1, 1, 1, 1, 2, 4, 2, 1, 2, 1, - 1, 5, 2, 3, 0, 6, 1, 3, 1, 0, - 1, 0, 1, 1, 0, 6, 0, 1, 0, 1, - 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 1, 1, 2, 5, 4, 2, - 1, 1, 1, 1, 1, 3, 0, 3, 1, 0, - 3, 0, 1, 1, 3, 3, 1, 1, 0, 4, - 4, 0, 1, 1, 0, 1, 1, 2, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 13, 5, 0, 4, 0, 1, 1, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 9, 0, 1, 1, 2, 3, 0, 3, - 1, 1, 1, 0, 8, 0, 9, 6, 0, 0, - 3, 0, 1, 1, 2, 2, 0, 5, 0, 1, - 1, 2, 3, 0, 4, 2, 1, 1, 1, 0, - 3, 0, 0, 10, 0, 0, 11, 8, 1, 1, - 0, 1, 1, 3, 3, 3, 5, 3, 5, 1, - 1, 1, 1, 3, 4, 6, 4, 0, 7, 0, - 1, 1, 2, 1, 1, 1, 4, 6, 4, 1, - 2, 2, 1, 0, 0, 0, 10, 0, 0, 0, - 13, 1, 2, 1, 2, 1, 0, 5, 0, 5, - 1, 1, 1, 0, 0, 0, 0, 15, 5, 0, + 2, 0, 3, 2, 4, 3, 1, 0, 1, 1, + 2, 4, 2, 1, 2, 1, 1, 5, 2, 3, + 0, 0, 11, 1, 3, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 2, + 0, 3, 0, 6, 3, 1, 1, 1, 1, 1, + 3, 0, 3, 1, 0, 3, 0, 1, 1, 3, + 3, 1, 1, 0, 4, 4, 0, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 5, 1, 1, 1, 1, 0, 7, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 13, 5, + 0, 4, 0, 1, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 9, 0, 1, + 1, 2, 3, 0, 3, 1, 1, 1, 0, 8, + 0, 9, 6, 0, 0, 3, 0, 1, 1, 2, + 2, 0, 5, 0, 1, 1, 2, 3, 0, 4, + 2, 1, 1, 1, 0, 3, 0, 0, 10, 0, + 0, 11, 8, 1, 1, 0, 1, 1, 3, 3, + 3, 5, 3, 5, 1, 1, 1, 1, 3, 4, + 6, 4, 0, 7, 0, 1, 1, 2, 1, 1, + 1, 4, 6, 4, 1, 2, 2, 1, 0, 0, + 0, 10, 0, 0, 0, 13, 1, 2, 1, 2, + 1, 0, 5, 0, 5, 1, 1, 1, 0, 0, + 0, 0, 15, 5, 0, 1, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 5, 1, + 1, 1, 1, 0, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 7, 0, 7, 2, 2, 2, - 0, 0, 9, 1, 1, 0, 1, 0, 6, 0, - 6, 1, 0, 8, 0, 9, 0, 0, 10, 0, - 0, 3, 0, 1, 1, 2, 2, 0, 5, 0, - 2, 2, 2, 1, 1, 1, 0, 5, 0, 5, - 1, 1, 0, 0, 0, 12, 0, 2, 2, 0, - 1, 2, 1, 3, 2, 0, 5, 0, 0, 0, - 13, 0, 1, 1, 3, 1, 4, 2, 0, 3, - 2, 1, 3, 0, 3, 1, 1, 3, 1, 2, - 3, 4, 4, 0, 3, 1, 3, 3, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 2, 1, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 7, + 0, 7, 2, 2, 2, 0, 0, 9, 1, 1, + 0, 1, 0, 6, 0, 6, 1, 0, 8, 0, + 9, 0, 0, 10, 0, 0, 3, 0, 1, 1, + 2, 2, 0, 5, 0, 2, 2, 2, 1, 1, + 1, 0, 5, 0, 5, 1, 1, 0, 0, 0, + 12, 0, 2, 2, 0, 1, 2, 1, 3, 2, + 0, 5, 0, 0, 0, 13, 0, 1, 1, 3, + 1, 4, 2, 0, 3, 2, 1, 3, 0, 3, + 1, 1, 3, 1, 2, 3, 4, 4, 0, 3, + 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, - 4, 3, 3, 4, 3, 4, 4, 0, 1, 3, - 4, 0, 1, 1, 3, 2, 3, 1, 2, 3, - 2, 1, 1, 0, 1, 1, 3, 3, 2, 2, - 1, 1, 1, 1, 2, 2, 4, 3, 1, 4, - 1, 3, 2, 1, 3, 1, 1, 1, 4, 3, - 2, 2, 6, 3, 7, 4, 3, 7, 3, 0, - 2, 4, 1, 2, 0, 1, 1, 3, 3, 1, - 1, 1, 0, 1, 1, 2, 2, 3, 1, 2, - 0, 1, 2, 4, 1, 3, 0, 5, 1, 1, - 1, 2, 3, 3, 4, 4, 1, 2, 4, 4, - 4, 3, 0, 4, 0, 1, 0, 4, 4, 1, - 2, 2, 1, 4, 1, 2, 2, 2, 2, 2, - 2, 1, 3, 3, 3, 1, 3, 3, 3, 3, - 3, 1, 3, 3, 1, 3, 3, 3, 3, 1, - 3, 3, 1, 3, 1, 3, 1, 3, 1, 3, - 1, 3, 1, 3, 1, 5, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, - 2, 1, 0, 1, 1, 1, 0, 2, 1, 1, - 0, 4, 0, 0, 7, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 15, 0, 1, - 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 2, 0, 1, 1, 1, 2, 4, 1, 3, 1, - 3, 1, 1, 0, 1, 1, 1, 0, 4, 1, - 1, 0, 4, 0, 1, 1, 2, 1, 1, 1, + 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 3, 4, 4, 4, 3, 3, 4, + 3, 4, 4, 0, 1, 3, 4, 0, 1, 1, + 3, 2, 3, 1, 2, 3, 2, 1, 1, 0, + 1, 1, 3, 3, 2, 2, 1, 1, 1, 1, + 2, 2, 4, 3, 1, 4, 1, 3, 2, 1, + 3, 1, 1, 1, 4, 3, 2, 2, 6, 3, + 7, 4, 3, 7, 3, 0, 2, 4, 1, 2, + 0, 1, 1, 3, 3, 1, 1, 1, 0, 1, + 1, 2, 2, 3, 1, 2, 0, 1, 2, 4, + 1, 3, 0, 5, 1, 1, 1, 2, 3, 3, + 4, 4, 1, 2, 4, 4, 4, 3, 0, 4, + 0, 1, 0, 4, 4, 1, 2, 2, 1, 4, + 1, 2, 2, 2, 2, 2, 2, 1, 3, 3, + 3, 1, 3, 3, 3, 3, 3, 1, 3, 3, + 1, 3, 3, 3, 3, 1, 3, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, + 1, 5, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 1, 3, 3, 2, 1, 0, 1, + 1, 1, 0, 2, 1, 1, 0, 4, 0, 0, + 7, 1, 1, 1, 1, 1, 1, 6, 4, 4, + 1, 1, 0, 0, 0, 0, 15, 0, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, + 0, 1, 1, 1, 2, 4, 1, 3, 1, 3, + 1, 1, 0, 1, 1, 1, 0, 4, 1, 1, + 0, 4, 0, 1, 1, 2, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 4, 1, - 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, - 0, 6, 0, 7, 0, 2, 1, 0, 1, 1, - 2, 2, 4, 0, 2, 0, 1, 1, 2, 4, - 1, 5, 2, 2, 2, 2, 2, 1, 1, 1, - 1, 1, 5, 7, 0, 8, 0, 1, 1, 2, - 1, 0, 3, 1, 2, 3, 1, 1, 1, 1, - 1, 5, 7, 0, 4, 7, 1, 0, 1, 0, - 5, 1, 0, 1, 0, 1, 1, 1, 3, 6, - 0, 9, 1, 1, 1, 1, 1, 1, 2, 2, - 3, 4, 3, 3, 3, 4, 3, 0, 1, 3, - 4, 5, 3, 1, 2, 0, 1, 2, 0, 7, - 3, 2, 2, 0, 3, 5, 0, 0, 10, 0, - 0, 10, 5, 0, 2, 2, 2, 2, 2, 4, - 5, 4, 5, 0, 5, 0, 6, 3, 2, 1, - 0, 3, 0, 0, 6, 0, 1, 1, 2, 1, - 1, 1, 1, 1, 0, 5, 0, 3, 0, 0, - 0, 12, 0, 0, 0, 13, 0, 2, 0, 3, - 1, 0, 4, 1, 0, 4, 1, 2, 2, 1, - 2, 2, 0, 0, 4, 2, 3, 0, 4, 0, - 3, 1, 2, 1, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 4, 1, 2, + 2, 2, 2, 2, 2, 1, 1, 2, 1, 0, + 6, 0, 7, 0, 2, 1, 0, 1, 1, 2, + 2, 4, 0, 2, 0, 1, 1, 2, 4, 1, + 5, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 1, 5, 7, 0, 8, 0, 1, 1, 2, 1, + 0, 3, 1, 2, 3, 1, 1, 1, 1, 1, + 5, 7, 0, 4, 7, 1, 0, 1, 0, 5, + 1, 0, 1, 0, 1, 1, 1, 3, 6, 0, + 9, 1, 1, 1, 1, 1, 1, 2, 2, 3, + 4, 3, 3, 3, 4, 3, 0, 1, 3, 4, + 5, 3, 1, 2, 0, 1, 2, 0, 7, 3, + 2, 2, 0, 3, 5, 0, 0, 10, 0, 0, + 10, 5, 0, 2, 2, 2, 2, 2, 4, 5, + 4, 5, 0, 5, 0, 6, 3, 2, 1, 0, + 3, 0, 0, 6, 0, 1, 1, 2, 1, 1, + 1, 1, 1, 0, 5, 0, 3, 0, 0, 0, + 12, 0, 0, 0, 13, 0, 2, 0, 3, 1, + 0, 4, 1, 0, 4, 1, 2, 2, 1, 2, + 2, 0, 0, 4, 2, 3, 0, 4, 2, 2, + 3, 0, 1, 1, 1, }; static readonly short [] yyDefRed = { 0, - 47, 8, 0, 0, 0, 0, 920, 0, 0, 0, - 4, 0, 5, 9, 11, 12, 13, 20, 21, 46, - 0, 45, 48, 49, 50, 51, 52, 0, 56, 23, - 0, 0, 0, 344, 0, 346, 17, 0, 64, 62, - 63, 0, 0, 0, 0, 0, 65, 67, 916, 0, - 0, 18, 0, 1, 0, 10, 3, 0, 650, 656, - 648, 0, 645, 655, 649, 647, 646, 653, 651, 652, - 658, 654, 657, 659, 0, 0, 643, 57, 0, 538, - 0, 348, 0, 24, 0, 0, 0, 0, 0, 0, - 60, 0, 770, 0, 392, 0, 398, 405, 0, 0, - 0, 393, 0, 0, 0, 395, 432, 0, 394, 0, - 0, 0, 0, 401, 0, 403, 0, 430, 390, 0, - 397, 399, 0, 391, 0, 488, 0, 431, 0, 527, - 402, 404, 0, 844, 400, 0, 0, 0, 631, 0, - 0, 678, 0, 727, 0, 0, 0, 0, 0, 0, - 0, 0, 429, 0, 623, 0, 769, 710, 0, 0, - 396, 0, 0, 407, 408, 0, 410, 411, 412, 413, - 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, - 424, 427, 428, 627, 555, 0, 553, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 628, 626, - 629, 630, 694, 696, 0, 692, 695, 711, 713, 714, - 715, 716, 717, 718, 719, 720, 721, 722, 712, 0, - 0, 0, 771, 772, 788, 789, 790, 791, 813, 814, - 815, 816, 817, 818, 0, 0, 0, 924, 921, 927, - 19, 917, 2, 6, 29, 27, 0, 0, 0, 640, - 0, 644, 0, 351, 0, 0, 352, 373, 0, 0, - 0, 0, 345, 16, 0, 66, 59, 0, 68, 0, - 0, 0, 819, 433, 434, 842, 0, 0, 0, 0, - 0, 409, 0, 820, 0, 547, 543, 546, 726, 768, - 697, 724, 723, 725, 698, 699, 700, 701, 702, 703, - 704, 705, 706, 707, 708, 709, 0, 0, 0, 794, + 7, 0, 0, 0, 0, 0, 0, 2, 0, 0, + 10, 13, 0, 915, 0, 0, 919, 0, 0, 14, + 16, 17, 9, 1, 0, 0, 0, 11, 0, 769, + 0, 387, 0, 393, 400, 0, 0, 0, 388, 0, + 0, 0, 390, 428, 0, 389, 0, 0, 0, 0, + 396, 0, 398, 0, 426, 385, 0, 392, 394, 0, + 386, 0, 484, 0, 427, 0, 523, 397, 399, 0, + 843, 395, 0, 0, 0, 627, 0, 0, 0, 0, + 0, 677, 0, 726, 0, 0, 0, 0, 0, 0, + 0, 0, 425, 0, 619, 0, 768, 709, 0, 0, + 391, 0, 0, 402, 403, 0, 405, 406, 407, 408, + 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, + 419, 420, 423, 424, 623, 551, 0, 549, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 624, + 622, 625, 626, 693, 695, 0, 691, 694, 710, 712, + 713, 714, 715, 716, 717, 718, 719, 720, 721, 711, + 0, 0, 0, 770, 771, 787, 788, 789, 790, 812, + 813, 814, 815, 816, 817, 0, 0, 0, 19, 0, + 0, 0, 339, 0, 341, 923, 15, 916, 3, 51, + 0, 0, 0, 41, 38, 40, 42, 43, 44, 45, + 46, 49, 12, 0, 0, 0, 818, 429, 430, 841, + 0, 0, 0, 0, 0, 404, 0, 819, 0, 543, + 539, 542, 725, 767, 696, 723, 722, 724, 697, 698, + 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, + 0, 0, 0, 793, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 828, 0, 401, 0, + 0, 0, 0, 0, 0, 842, 0, 0, 0, 739, + 735, 0, 0, 0, 0, 0, 0, 368, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 548, 552, 553, + 547, 557, 556, 554, 555, 0, 0, 617, 727, 534, + 0, 422, 421, 0, 0, 0, 0, 338, 0, 733, + 734, 0, 487, 488, 0, 0, 0, 731, 732, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 829, 0, 406, 0, 0, 0, 0, 0, - 0, 843, 0, 0, 0, 740, 736, 0, 0, 0, - 0, 0, 0, 0, 0, 552, 556, 557, 551, 561, - 560, 558, 559, 0, 0, 621, 728, 426, 425, 0, - 0, 0, 343, 0, 734, 735, 0, 491, 492, 0, - 0, 0, 732, 733, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 919, 693, - 741, 731, 0, 766, 767, 870, 887, 0, 0, 0, - 899, 858, 856, 880, 0, 0, 878, 881, 882, 883, - 884, 859, 857, 923, 0, 0, 0, 0, 370, 372, - 354, 0, 634, 0, 0, 22, 385, 381, 382, 0, - 350, 380, 383, 384, 347, 58, 0, 0, 73, 74, - 77, 78, 490, 0, 0, 486, 487, 0, 484, 0, - 743, 0, 0, 0, 0, 764, 765, 0, 0, 0, - 632, 0, 823, 821, 633, 0, 0, 512, 0, 0, - 0, 503, 0, 507, 517, 519, 0, 499, 0, 0, - 0, 0, 0, 494, 0, 497, 0, 501, 375, 824, - 0, 0, 825, 833, 0, 0, 0, 834, 0, 0, - 845, 0, 0, 739, 0, 0, 0, 0, 0, 691, - 0, 0, 686, 688, 689, 690, 437, 438, 827, 0, - 0, 0, 195, 194, 196, 0, 0, 0, 0, 377, - 0, 608, 0, 0, 442, 0, 445, 0, 443, 542, - 0, 0, 0, 0, 0, 471, 474, 0, 0, 466, - 473, 472, 562, 0, 597, 598, 599, 600, 601, 602, - 603, 604, 605, 607, 606, 563, 565, 564, 570, 571, + 0, 0, 0, 918, 692, 740, 730, 0, 765, 766, + 869, 886, 0, 0, 0, 898, 857, 855, 879, 0, + 0, 877, 880, 881, 882, 883, 858, 856, 0, 0, + 0, 343, 0, 20, 0, 0, 0, 39, 649, 655, + 647, 0, 644, 654, 648, 646, 645, 652, 650, 651, + 657, 653, 656, 658, 0, 0, 642, 50, 486, 0, + 0, 482, 483, 0, 480, 0, 742, 0, 0, 0, + 0, 763, 764, 0, 0, 0, 631, 0, 822, 820, + 632, 0, 0, 508, 0, 0, 0, 499, 0, 503, + 513, 515, 0, 495, 0, 0, 0, 0, 0, 490, + 0, 493, 0, 497, 370, 823, 0, 0, 824, 832, + 0, 0, 0, 833, 0, 0, 844, 0, 0, 738, + 0, 380, 0, 376, 377, 0, 375, 378, 379, 0, + 0, 0, 558, 0, 0, 690, 0, 0, 685, 687, + 688, 689, 433, 434, 826, 0, 0, 0, 346, 347, + 0, 190, 189, 191, 0, 0, 0, 0, 372, 0, + 604, 0, 0, 438, 0, 441, 0, 439, 538, 0, + 0, 0, 0, 0, 467, 470, 0, 0, 462, 469, + 468, 0, 593, 594, 595, 596, 597, 598, 599, 600, + 601, 603, 602, 559, 561, 560, 566, 567, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 594, 0, 0, 516, 0, - 0, 0, 0, 0, 0, 0, 871, 873, 869, 0, - 879, 28, 35, 0, 0, 0, 0, 323, 0, 229, - 0, 105, 0, 353, 0, 79, 71, 0, 441, 489, - 0, 540, 0, 549, 182, 203, 0, 0, 0, 172, - 0, 0, 0, 183, 544, 0, 847, 797, 0, 808, - 795, 0, 799, 0, 0, 0, 822, 0, 0, 0, - 502, 0, 518, 520, 0, 0, 458, 0, 0, 454, - 0, 0, 481, 0, 522, 496, 0, 159, 523, 157, - 158, 525, 0, 539, 0, 838, 0, 831, 0, 835, - 531, 0, 0, 0, 529, 0, 0, 541, 0, 850, - 0, 862, 0, 860, 0, 680, 681, 679, 687, 826, - 616, 622, 615, 0, 729, 611, 0, 0, 0, 554, - 446, 440, 444, 439, 480, 479, 476, 475, 0, 470, - 435, 436, 447, 0, 0, 747, 0, 0, 888, 864, - 0, 889, 0, 885, 0, 900, 0, 0, 0, 0, - 868, 0, 31, 26, 338, 0, 355, 329, 328, 0, - 635, 225, 101, 84, 83, 0, 0, 75, 76, 485, - 0, 0, 0, 0, 0, 192, 0, 548, 0, 0, - 0, 0, 0, 800, 0, 0, 0, 0, 0, 846, - 509, 508, 461, 0, 0, 928, 929, 450, 456, 0, - 459, 0, 483, 0, 0, 0, 0, 0, 775, 841, - 0, 832, 537, 532, 0, 0, 528, 0, 853, 0, - 792, 863, 861, 620, 619, 618, 610, 609, 624, 478, - 0, 468, 467, 596, 0, 761, 746, 0, 0, 0, - 750, 0, 866, 0, 893, 0, 908, 909, 902, 872, - 874, 914, 14, 0, 0, 0, 369, 0, 0, 366, - 324, 0, 0, 0, 81, 80, 755, 132, 133, 0, - 0, 0, 758, 201, 202, 0, 193, 0, 0, 0, - 175, 184, 176, 178, 0, 0, 0, 0, 804, 0, - 809, 810, 0, 0, 460, 462, 463, 457, 451, 455, - 0, 514, 0, 482, 493, 449, 526, 524, 0, 837, - 0, 0, 533, 0, 0, 0, 477, 0, 0, 742, - 751, 865, 0, 0, 0, 886, 0, 0, 0, 15, - 0, 0, 0, 677, 676, 0, 675, 0, 365, 0, - 0, 0, 0, 0, 0, 744, 759, 187, 0, 199, - 0, 0, 0, 793, 855, 0, 0, 0, 811, 774, - 498, 495, 781, 0, 787, 0, 0, 779, 0, 784, - 839, 536, 535, 0, 625, 0, 0, 867, 890, 0, - 0, 0, 904, 0, 915, 43, 0, 0, 339, 368, - 367, 0, 325, 0, 333, 389, 388, 0, 386, 664, - 0, 636, 0, 665, 226, 102, 0, 0, 188, 0, - 179, 177, 848, 801, 0, 0, 806, 0, 0, 776, - 780, 0, 785, 0, 851, 0, 753, 0, 894, 911, - 912, 905, 875, 36, 44, 0, 0, 0, 0, 0, - 0, 0, 666, 0, 0, 760, 186, 0, 198, 0, - 0, 812, 786, 0, 682, 840, 0, 762, 0, 0, - 0, 340, 0, 0, 334, 387, 0, 0, 0, 106, - 103, 189, 849, 796, 0, 852, 891, 0, 906, 0, - 0, 326, 672, 0, 673, 670, 0, 668, 99, 0, - 98, 0, 0, 87, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 160, 0, 0, 242, 234, 235, 236, - 237, 238, 239, 240, 241, 0, 0, 232, 0, 0, - 0, 0, 895, 341, 337, 0, 0, 0, 637, 88, - 0, 285, 280, 284, 0, 227, 233, 120, 112, 113, - 114, 115, 116, 117, 118, 119, 121, 0, 0, 110, - 104, 683, 0, 0, 671, 669, 0, 0, 0, 0, - 0, 0, 0, 293, 0, 0, 243, 0, 0, 251, - 0, 170, 161, 169, 0, 107, 111, 0, 892, 0, - 0, 0, 279, 0, 0, 278, 0, 0, 0, 0, - 359, 0, 357, 0, 0, 204, 0, 0, 0, 0, - 0, 638, 228, 898, 896, 122, 0, 356, 0, 0, - 0, 0, 136, 0, 0, 0, 0, 0, 0, 162, - 0, 0, 208, 0, 360, 0, 246, 245, 244, 257, - 256, 253, 258, 259, 252, 271, 270, 263, 264, 260, - 262, 261, 265, 254, 255, 266, 267, 273, 272, 268, - 269, 0, 0, 297, 0, 276, 138, 0, 274, 165, - 0, 0, 140, 0, 361, 0, 0, 205, 0, 0, - 0, 358, 249, 131, 129, 0, 0, 301, 0, 0, - 0, 0, 0, 0, 0, 282, 0, 0, 0, 0, - 144, 0, 0, 0, 0, 362, 363, 0, 0, 0, - 0, 0, 126, 316, 0, 298, 0, 0, 310, 0, - 0, 0, 305, 0, 156, 0, 0, 0, 0, 151, - 0, 0, 294, 0, 141, 0, 135, 145, 163, 168, - 216, 0, 206, 0, 0, 0, 0, 130, 0, 123, - 127, 0, 0, 0, 312, 0, 313, 302, 0, 0, - 296, 306, 277, 0, 0, 137, 152, 275, 166, 292, - 0, 283, 287, 147, 0, 0, 0, 213, 215, 209, - 250, 128, 317, 319, 299, 0, 0, 311, 308, 155, - 153, 0, 0, 0, 0, 164, 217, 219, 207, 0, - 0, 0, 310, 167, 288, 290, 148, 0, 0, 210, - 321, 322, 318, 320, 309, 0, 0, 223, 222, 221, - 218, 220, 0, 0, 0, 211, 289, 291, + 0, 0, 0, 590, 0, 0, 512, 0, 0, 0, + 0, 0, 0, 0, 870, 872, 868, 0, 878, 0, + 0, 340, 59, 57, 58, 0, 0, 52, 0, 0, + 60, 62, 26, 24, 0, 0, 0, 639, 0, 643, + 437, 0, 485, 0, 536, 0, 545, 177, 198, 0, + 0, 167, 0, 0, 0, 178, 540, 0, 846, 796, + 0, 807, 794, 0, 798, 0, 0, 0, 821, 0, + 0, 0, 498, 0, 514, 516, 0, 0, 454, 0, + 0, 450, 0, 0, 477, 0, 518, 492, 0, 154, + 519, 152, 153, 521, 0, 535, 0, 837, 0, 830, + 0, 834, 527, 0, 0, 0, 365, 0, 525, 0, + 0, 537, 0, 849, 0, 861, 0, 859, 0, 0, + 629, 630, 679, 680, 678, 686, 825, 612, 618, 611, + 0, 728, 0, 345, 607, 0, 0, 0, 550, 442, + 436, 440, 435, 476, 475, 472, 471, 0, 466, 431, + 432, 443, 0, 0, 746, 0, 0, 887, 863, 0, + 888, 0, 884, 0, 899, 0, 0, 0, 0, 867, + 18, 342, 53, 0, 0, 0, 0, 0, 0, 367, + 349, 0, 633, 0, 0, 79, 78, 0, 481, 0, + 0, 0, 0, 0, 187, 0, 544, 0, 0, 0, + 0, 0, 799, 0, 0, 0, 0, 0, 845, 505, + 504, 457, 0, 0, 924, 925, 446, 452, 0, 455, + 0, 479, 0, 0, 0, 0, 0, 774, 840, 0, + 831, 533, 528, 0, 0, 524, 0, 852, 0, 791, + 862, 860, 0, 616, 615, 614, 348, 606, 605, 620, + 474, 0, 464, 463, 592, 0, 760, 745, 0, 0, + 0, 749, 0, 865, 0, 892, 0, 907, 908, 901, + 871, 873, 913, 0, 61, 55, 0, 63, 25, 22, + 0, 0, 0, 318, 0, 224, 0, 100, 0, 76, + 754, 127, 128, 0, 0, 0, 757, 196, 197, 0, + 188, 0, 0, 0, 170, 179, 171, 173, 0, 0, + 0, 0, 803, 0, 808, 809, 0, 0, 456, 458, + 459, 453, 447, 451, 0, 510, 0, 478, 489, 445, + 522, 520, 0, 836, 0, 0, 529, 0, 0, 628, + 0, 473, 0, 0, 741, 750, 864, 0, 0, 0, + 885, 0, 0, 0, 0, 0, 0, 68, 69, 72, + 73, 0, 333, 0, 350, 324, 323, 0, 634, 220, + 96, 0, 743, 758, 182, 0, 194, 0, 0, 0, + 792, 854, 0, 0, 0, 810, 773, 494, 491, 780, + 0, 786, 0, 0, 778, 0, 783, 838, 532, 531, + 0, 621, 0, 0, 866, 889, 0, 0, 0, 903, + 0, 914, 0, 74, 66, 0, 0, 0, 364, 0, + 0, 361, 319, 0, 0, 0, 0, 0, 183, 0, + 174, 172, 847, 800, 0, 0, 805, 0, 0, 775, + 779, 0, 784, 0, 850, 0, 752, 0, 893, 910, + 911, 904, 874, 54, 0, 70, 71, 0, 0, 676, + 675, 0, 674, 0, 360, 0, 0, 0, 0, 0, + 759, 181, 0, 193, 0, 0, 811, 785, 0, 681, + 839, 0, 761, 0, 0, 0, 75, 0, 0, 334, + 363, 362, 0, 320, 0, 328, 384, 383, 0, 381, + 663, 0, 635, 0, 664, 221, 97, 184, 848, 795, + 0, 851, 890, 0, 905, 0, 0, 0, 0, 0, + 0, 0, 0, 665, 0, 0, 0, 0, 894, 28, + 23, 335, 0, 0, 329, 382, 0, 0, 0, 101, + 98, 682, 0, 0, 0, 0, 321, 671, 0, 672, + 669, 0, 667, 94, 0, 93, 0, 0, 82, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 155, 0, + 0, 237, 229, 230, 231, 232, 233, 234, 235, 236, + 0, 0, 227, 0, 0, 0, 891, 0, 336, 332, + 0, 0, 0, 636, 83, 0, 280, 275, 279, 0, + 222, 228, 115, 107, 108, 109, 110, 111, 112, 113, + 114, 116, 0, 0, 105, 99, 897, 895, 670, 668, + 0, 0, 0, 0, 0, 0, 0, 288, 0, 0, + 238, 0, 0, 246, 0, 165, 156, 164, 0, 102, + 106, 0, 0, 274, 0, 0, 273, 0, 0, 0, + 0, 354, 0, 352, 0, 0, 199, 0, 0, 0, + 0, 0, 637, 223, 117, 0, 351, 0, 0, 0, + 0, 131, 0, 0, 0, 0, 0, 0, 157, 0, + 0, 203, 0, 355, 0, 241, 240, 239, 252, 251, + 248, 253, 254, 247, 266, 265, 258, 259, 255, 257, + 256, 260, 249, 250, 261, 262, 268, 267, 263, 264, + 0, 0, 292, 0, 271, 133, 0, 269, 160, 0, + 0, 135, 0, 356, 0, 0, 200, 0, 0, 0, + 353, 244, 126, 124, 0, 0, 296, 0, 0, 0, + 0, 0, 0, 0, 277, 0, 0, 0, 0, 139, + 0, 0, 0, 0, 357, 358, 0, 0, 0, 0, + 0, 121, 311, 0, 293, 0, 0, 305, 0, 0, + 0, 300, 0, 151, 0, 0, 0, 0, 146, 0, + 0, 289, 0, 136, 0, 130, 140, 158, 163, 211, + 0, 201, 0, 0, 0, 0, 125, 0, 118, 122, + 0, 0, 0, 307, 0, 308, 297, 0, 0, 291, + 301, 272, 0, 0, 132, 147, 270, 161, 287, 0, + 278, 282, 142, 0, 0, 0, 208, 210, 204, 245, + 123, 312, 314, 294, 0, 0, 306, 303, 150, 148, + 0, 0, 0, 0, 159, 212, 214, 202, 0, 0, + 0, 305, 162, 283, 285, 143, 0, 0, 205, 316, + 317, 313, 315, 304, 0, 0, 218, 217, 216, 213, + 215, 0, 0, 0, 206, 284, 286, }; - protected static readonly short [] yyDgoto = { 9, - 10, 11, 12, 13, 58, 14, 15, 16, 17, 864, - 53, 18, 19, 256, 33, 20, 647, 247, 624, 436, - 1411, 90, 865, 762, 942, 997, 998, 22, 23, 24, - 25, 26, 27, 648, 29, 44, 45, 46, 47, 48, - 269, 92, 458, 459, 460, 290, 567, 777, 776, 1102, - 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, - 1113, 75, 251, 1203, 633, 952, 874, 1012, 1081, 1055, - 1130, 1158, 1129, 1159, 1160, 1007, 1286, 1263, 1311, 1312, - 1313, 877, 1309, 878, 691, 1176, 1274, 1228, 1299, 508, - 1292, 1268, 1328, 846, 1297, 1300, 1301, 1395, 1329, 1330, - 1326, 1114, 1183, 1141, 1204, 649, 1276, 1375, 1294, 1392, - 76, 291, 650, 651, 652, 653, 654, 784, 548, 1058, - 785, 549, 787, 1206, 1232, 1343, 1304, 1377, 1207, 1279, - 1400, 1423, 1344, 1345, 1421, 1408, 1409, 631, 873, 1054, - 1126, 1185, 1127, 1128, 1177, 1239, 1210, 1178, 258, 1262, - 1308, 1180, 1293, 1290, 1115, 1143, 1200, 1372, 1334, 1066, - 1373, 568, 1416, 1417, 1199, 1289, 1265, 1321, 1316, 1287, - 1353, 1358, 1319, 1322, 1323, 1403, 1359, 1317, 1318, 1413, - 1401, 1402, 628, 770, 1003, 950, 1048, 1004, 1005, 1073, - 866, 1046, 1090, 448, 34, 159, 82, 36, 259, 767, - 626, 1220, 869, 870, 946, 440, 260, 412, 447, 324, - 1008, 1009, 161, 162, 325, 164, 165, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, - 179, 180, 181, 182, 183, 277, 743, 915, 504, 678, - 808, 679, 680, 908, 184, 242, 684, 569, 570, 571, - 572, 737, 468, 469, 319, 913, 686, 413, 321, 491, - 492, 493, 494, 497, 693, 331, 706, 707, 824, 287, - 474, 288, 473, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 551, - 552, 553, 722, 723, 836, 724, 201, 541, 360, 926, - 202, 486, 629, 872, 1052, 1181, 77, 1013, 1014, 1097, - 1098, 947, 531, 344, 718, 1085, 532, 533, 292, 293, - 294, 205, 206, 207, 295, 296, 297, 298, 299, 300, - 301, 302, 303, 304, 305, 306, 219, 307, 542, 220, - 221, 338, 748, 608, 849, 782, 643, 881, 847, 850, - 851, 882, 883, 308, 222, 223, 224, 976, 919, 977, - 978, 979, 1032, 980, 225, 226, 227, 228, 661, 479, - 662, 900, 1025, 663, 898, 664, 1027, 1028, 229, 230, - 231, 232, 233, 234, 326, 517, 518, 921, 1034, 334, - 897, 793, 1060, 830, 1067, 235, 423, 236, 424, 852, - 933, 425, 620, 761, 758, 759, 938, 426, 427, 428, - 429, 430, 431, 856, 610, 854, 1038, 1132, 1189, 935, - 1070, 1164, 756, 616, 757, 992, 937, 993, 1071, 939, - 50, 239, 51, + protected static readonly short [] yyDgoto = { 6, + 7, 24, 8, 25, 9, 26, 191, 610, 380, 10, + 11, 27, 20, 21, 22, 276, 182, 194, 595, 738, + 922, 1049, 1420, 735, 195, 196, 197, 198, 199, 200, + 201, 202, 588, 386, 589, 590, 834, 591, 592, 838, + 736, 917, 918, 919, 224, 526, 1015, 748, 1117, 1118, + 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, + 405, 599, 1214, 849, 1028, 986, 1063, 1101, 1086, 1145, + 1173, 1144, 1174, 1175, 1058, 1295, 1272, 1320, 1321, 1322, + 851, 1318, 852, 653, 1190, 1283, 1237, 1308, 454, 1301, + 1277, 1337, 817, 1306, 1309, 1310, 1404, 1338, 1339, 1335, + 1129, 1197, 1156, 1215, 611, 1285, 1384, 1303, 1401, 406, + 225, 612, 613, 614, 615, 616, 753, 507, 1033, 754, + 508, 756, 1217, 1241, 1352, 1313, 1386, 1218, 1288, 1409, + 1432, 1353, 1354, 1430, 1417, 1418, 847, 985, 1085, 1141, + 1199, 1142, 1143, 1191, 1248, 1221, 1192, 278, 1271, 1317, + 1194, 1302, 1299, 1130, 1158, 1211, 1381, 1343, 1041, 1382, + 527, 1425, 1426, 1210, 1298, 1274, 1330, 1325, 1296, 1362, + 1367, 1328, 1331, 1332, 1412, 1368, 1326, 1327, 1422, 1410, + 1411, 844, 928, 1054, 1026, 1079, 1055, 1056, 1093, 978, + 1077, 1105, 474, 183, 99, 382, 185, 501, 925, 842, + 1229, 981, 982, 1022, 740, 279, 357, 472, 258, 1059, + 1060, 101, 102, 259, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 211, 712, 889, 450, 640, + 777, 641, 642, 882, 125, 188, 646, 528, 529, 530, + 531, 706, 414, 415, 253, 887, 648, 358, 255, 437, + 438, 439, 440, 443, 655, 265, 670, 671, 793, 221, + 420, 222, 419, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 510, + 511, 512, 689, 690, 806, 691, 142, 497, 304, 901, + 143, 432, 845, 984, 1083, 1195, 407, 1064, 1065, 1112, + 1113, 1023, 487, 286, 685, 1071, 488, 489, 226, 227, + 228, 146, 147, 148, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 160, 241, 498, 161, + 162, 272, 717, 566, 820, 751, 606, 855, 818, 821, + 822, 856, 857, 242, 163, 164, 165, 953, 893, 954, + 955, 956, 1002, 957, 166, 167, 168, 169, 623, 425, + 624, 874, 995, 625, 872, 626, 997, 998, 170, 171, + 172, 173, 174, 175, 260, 463, 464, 895, 1004, 268, + 871, 762, 1035, 799, 1042, 176, 368, 177, 369, 823, + 908, 370, 578, 730, 727, 728, 913, 371, 372, 373, + 374, 375, 376, 827, 568, 825, 1008, 1088, 1147, 910, + 1045, 1104, 725, 574, 726, 969, 912, 970, 1046, 914, + 15, 17, }; - protected static readonly short [] yySindex = { -125, - 0, 0, -182, -180, -185, -26, 0, -50, 0, 165, - 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, -11770, 0, 0, 0, 0, 0, 0, -208, 0, 0, - 314, 141, 62, 0, 123, 0, 0, 161, 0, 0, - 0, -257, 141, 178, 236, 264, 0, 0, 0, 5948, - 67, 0, -244, 0, 47, 0, 0, 47, 0, 0, - 0, -170, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 142, 9590, 0, 0, 178, 0, - 902, 0, 234, 0, 296, 348, -257, 236, 178, 377, - 0, 404, 0, 196, 0, 418, 0, 0, -213,10437, - 441, 0, -89, 428, 6101, 0, 0, -89, 0, -89, - -89, -154, -89, 0, -89, 0, 630, 0, 0, 9564, - 0, 0, -89, 0, -89, 0, 9564, 0, 466, 0, - 0, 0, -213, 0, 0, -89, 436, -89, 0, 6730, - 7495, 0, 9564, 0,10224,10224,10224,10224,10224,10224, -10224,10224, 0, 60, 0, 8657, 0, 0, 421, 327, - 0, 754, 157, 0, 0, 475, 0, 0, 0, 0, + protected static readonly short [] yySindex = { -151, + 0, -209, -107, 23, 140, 0, 328, 0, 140, 23, + 0, 0, 198, 0, 6308, 140, 0, -171, -32, 0, + 0, 0, 0, 0, 328, 268, 140, 0, 286, 0, + -20, 0, 348, 0, 0, 185,10950, 378, 0, -227, + 315, 6464, 0, 0, -227, 0, -227, -227, -157, -227, + 0, -227, 0, 142, 0, 0,10045, 0, 0, -227, + 0, -227, 0,10045, 0, 343, 0, 0, 0, 185, + 0, 0, -227, 420, -227, 0, 7729, 7885, 449, -227, + -227, 0,10045, 0,10720,10720,10720,10720,10720,10720, +10720,10720, 0, 92, 0,10791, 0, 0, 410, 334, + 0, 634, 340, 0, 0, 456, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 892, 0, 305, 91, -69, - 541, 652, 499, 508, 518, 534, 17, 527, 0, 0, - 0, 0, 0, 0, 2268, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 490, - 572, -251, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -175, -147, 67, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 585,10953, 564, 0, - 338, 0, 468, 0, 436, 486, 0, 0, 134, 572, - 157, 296, 0, 0, 582, 0, 0, 9696, 0, 732, - 593, 9828, 0, 0, 0, 0, 9564, -89, -89, 255, - 754, 0, 596, 0, 8657, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 826, 0, 672, 124, + 524, 504, 571, 454, 469, 514, 471, -264, 523, 0, + 0, 0, 0, 0, 0, 2538, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 660, 206,10437, 0, - 8657, 9564, 696, 710, 9564, 9564, 7896, 449, -197, 735, -11007, 185, 0, 653, 0, 730, 8657, 9564, 755, 471, - -89, 0, 9564, 466, 9036, 0, 0, 436, 9564, -100, - 731, -94, 738, 6254, 3, 0, 0, 0, 0, 0, - 0, 0, 0, 777, 9564, 0, 0, 0, 0,10882, - 791, 296, 0, -249, 0, 0, 104, 0, 0, 750, - 9828, 8772, 0, 0,10224, 9564, 9564, 9564, 9564, 9564, - 9564, 9564, 9564, 9564, 9564, 9564,10224,10224,10224, 8657, - 8657,10224,10224,10224,10224,10224,10224,10224,10224,10224, -10224,10224,10224,10224,10224,10224,10224, 9564, 0, 0, - 0, 0, 572, 0, 0, 0, 0,11024,11078, 761, - 0, 0, 0, 0, 9, 718, 0, 0, 0, 0, - 0, 0, 0, 0, 765, 805, 436, 564, 0, 0, - 0, 800, 0, 927, 932, 0, 0, 0, 0, 8657, - 0, 0, 0, 0, 0, 0, 189, 647, 0, 0, - 0, 0, 0, 296, 193, 0, 0, 515, 0, 823, - 0, 830, 95, 466, -89, 0, 0, 790, 7019, -177, - 0, 845, 0, 0, 0, 843, 851, 0, 410, 0, - 857, 0, 859, 0, 0, 0, 614, 0, 7742, 624, - 9564, 735, 8772, 0, 6713, 0, 436, 0, 0, 0, - 862, 869, 0, 0, -213, 466, -134, 0, 2980, 870, - 0, 872, 813, 0, 873, 9564, 948, 9564, 949, 0, - -239, 6254, 0, 0, 0, 0, 0, 0, 0, 874, - 466, 6254, 0, 0, 0, 436, -257, 840,11095, 0, - 878, 0, 876,10224, 0, -103, 0, 128, 0, 0, - 662, 9564, 9564, 888, 1000, 0, 0, 24, 887, 0, - 0, 0, 0, 305, 0, 0, 0, 0, 0, 0, + 458, 535, 118, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -186, -183, 268, 0, 119, + 562, 577, 0, 530, 0, 0, 0, 0, 0, 0, + 268, 4841, 268, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 760, 605,10180, 0, 0, 0, 0, +10045, -227, -227, 298, 634, 0, 618, 0,10791, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 305, 305, 91, 91, -69, -69, -69, -69, 541, 541, - 652, 499, 508, 518, 534, 0, 890, -195, 0, 9564, - -93, 844, -42, 850, 882, 9564, 0, 0, 0, 907, - 0, 0, 0, 893, 899, 856, 3135, 0, 564, 0, - 564, 0, 564, 0, 84, 0, 0, 9696, 0, 0, - 9828, 0, 891, 0, 0, 0, 679, -208, 903, 0, - 900, 904, 905, 0, 0, 9564, 0, 0, 863, 0, - 0, 901, 0, 906, 9564, 984, 0, 6101, 6101, 7172, - 0, 7896, 0, 0, 9168, 148, 0, -20, -158, 0, - 858, 864, 0, 46, 0, 0, 913, 0, 0, 0, - 0, 0, 914, 0, 922, 0, 3290, 0, 466, 0, - 0, 443, 523, 886, 0, 918, 933, 0, 6101, 0, - 6101, 0, 9564, 0, 9564, 0, 0, 0, 0, 0, - 0, 0, 0, 7325, 0, 0, 889,10882, 944, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 8640, 0, - 0, 0, 0, 8904, 9564, 0, 6866, 936, 0, 0, - 1013, 0, 1014, 0, 721, 0, 939, 9564, 9564, 896, - 0, 953, 0, 0, 0, -111, 0, 0, 0, 950, - 0, 0, 0, 0, 0, 9564, 9564, 0, 0, 0, - 9300, 945, 679,11095, 450, 0, 8657, 0, -198, 1058, - 1061, 952, 946, 0, 9564, 9564, 954, 9564, 1041, 0, - 0, 0, 0, -128, 9432, 0, 0, 0, 0, 7610, - 0, 1068, 0, 572, 9564, 962, 7172, 964, 0, 0, - 912, 0, 0, 0, 915, 203, 0, 916, 0, 946, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 670, 0, 0, 0,11007, 0, 0, 917, 955, 936, - 0, 9564, 0, 9564, 0, 9564, 0, 0, 0, 0, - 0, 0, 0, 953, -50, 95, 0, 455, 137, 0, - 0, 961, 961, 961, 0, 0, 0, 0, 0, 919, - 965, 945, 0, 0, 0, -169, 0, -168, 966, 969, - 0, 0, 0, 0, 968, 7172, 936, -195, 0, 970, - 0, 0, 967, 6101, 0, 0, 0, 0, 0, 0, - 975, 0, 735, 0, 0, 0, 0, 0, -202, 0, - 976, 203, 0, 926, 936, 466, 0, 928, 957, 0, - 0, 0, 9564, 1002, 9564, 0, 9564, 1003, 201, 0, - -50, -108, 985, 0, 0, 947, 0, -111, 0, -208, - 3445, 44, 44, 44, 982, 0, 0, 0, 389, 0, - 983, 1110, 1111, 0, 0, 1004, 936, 9564, 0, 0, - 0, 0, 0, 9564, 0, 1007, -190, 0, -190, 0, - 0, 0, 0, 1005, 0, 9564, 6866, 0, 0, 1021, - 739, 1008, 0, 9564, 0, 0, 1010, -108, 0, 0, - 0, 986, 0, 1009, 0, 0, 0, 1026, 0, 0, - 990, 0, 1060, 0, 0, 0, 9300, 1039, 0, 9564, - 0, 0, 0, 0, 1042, 906, 0, 6101, 1036, 0, - 0, 6254, 0, 1046, 0, 1049, 0, 9564, 0, 0, - 0, 0, 0, 0, 0, 44, 0, 1048, -208, 3445, - 1055, 1054, 0, 1056, 1064, 0, 0, 9564, 0, 6101, - 6101, 0, 0, 6254, 0, 0, 6101, 0, 1082, 9564, - 9564, 0, 1062, 893, 0, 0,10936, -54, -208, 0, - 0, 0, 0, 0, 6254, 0, 0, 1084, 0, 1063, - 9564, 0, 0, 1066, 0, 0, 1070, 0, 0, 9590, - 0, 1080, -54, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 280, 9590, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1083, -208, 0, -208, 893, - 1085, 9564, 0, 0, 0, 1078,10936,10655, 0, 0, - 469, 0, 0, 0,10687, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1090, -208, 0, - 0, 0, 1099, 9564, 0, 0, 8657, 8657, 224,11007, - 351, 436, 1119, 0, -257, 6892, 0, 1155, 0, 0, - 893, 0, 0, 0, 893, 0, 0, 1047, 0, 1099, - 1051, 1052, 0, 8657, -166, 0, 8657, 1052, 1053, 1102, - 0, -257, 0, 1103, 7198, 0, 1115, 1067, -188, 494, - 1146, 0, 0, 0, 0, 0, -257, 0, 1121, 1071, - 1122, 1114, 0, 1123, 1124, 1125, 95, 1105, 1126, 0, - 1127, 1130, 0, 296, 0, 650, 0, 0, 0, 0, + 711, 145,10950, 0,10791,10045, 691, 697,10045,10045, + 8295, 489, 93, 709,11395, 281, 0, 714, 0, 718, +10791,10045, 722, 492, -227, 0,10045, 343, 9505, 0, + 0, 420,10045, 420, -203, 382, 683, 0, 535, 340, + -114, 687,10045,10045,10045, 6620, -256, 0, 0, 0, + 0, 0, 0, 0, 0, 734,10045, 0, 0, 0, + 4110, 0, 0,11363, 126, 753, 729, 0, -271, 0, + 0, 77, 0, 0, 728,10180, 9235, 0, 0,10720, +10045,10045,10045,10045,10045,10045,10045,10045,10045,10045, +10045,10720,10720,10720,10791,10791,10720,10720,10720,10720, +10720,10720,10720,10720,10720,10720,10720,10720,10720,10720, +10720,10720,10045, 0, 0, 0, 0, 535, 0, 0, + 0, 0,11439,11463, 743, 0, 0, 0, 0, -226, + 598, 0, 0, 0, 0, 0, 0, 0, 268, 268, + 750, 0, 759, 0, 729, -181, 4841, 0, 0, 0, + 0, -168, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -174,12240, 0, 0, 0, 729, + 194, 0, 0, 623, 0, 801, 0, 809, 6, 343, + -227, 0, 0, 764, 7400, -223, 0, 795, 0, 0, + 0, 811, 813, 0, 279, 0, 818, 0, 814, 0, + 0, 0, 639, 0, 8138, 644,10045, 709, 9235, 0, + 7088, 0, 420, 0, 0, 0, 815, 820, 0, 0, + 185, 343, 101, 0, 7105, 823, 0, 827, 772, 0, + 828, 0,10045, 0, 0, 903, 0, 0, 0,10045, + 907, 829, 0, 834, 836, 0, -250, 6620, 0, 0, + 0, 0, 0, 0, 0, 837, 343, 6620, 0, 0, + -232, 0, 0, 0, 420, 126, 787,11507, 0, 838, + 0, 839,10720, 0, 205, 0, 373, 0, 0, 650, +10045,10045, 843, 952, 0, 0, -66, 841, 0, 0, + 0, 672, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 672, 672, + 124, 124, 524, 524, 524, 524, 504, 504, 571, 454, + 469, 514, 471, 0, 842, -201, 0,10045, -28, 798, + 1, 821, 857,10045, 0, 0, 0, 883, 0, -16, + 729, 0, 0, 0, 0, 126, 562, 0, 866, 869, + 0, 0, 0, 0, 871,11531, 830, 0, -147, 0, + 0, 466, 0,10180, 0, 868, 0, 0, 0, 507, + 875, 0, 877, 878, 879, 0, 0,10045, 0, 0, + 840, 0, 0, 880, 0, 881,10045, 959, 0, 6464, + 6464, 7556, 0, 8295, 0, 0, 9640, 270, 0, -230, + -148, 0, 831, 844, 0, -38, 0, 0, 885, 0, + 0, 0, 0, 0, 886, 0, 895, 0, 7261, 0, + 343, 0, 0, 420, 355, 416, 0, 845, 0, 892, + 896, 0, 6464, 0, 6464, 0,10045, 0,10045,10791, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7712, 0,10791, 0, 0, 847,11363, 924, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 9100, 0, 0, + 0, 0, 9370,10045, 0, 7244, 897, 0, 0, 977, + 0, 979, 0, 626, 0, 901,10045,10045, 858, 0, + 0, 0, 0, 750, 909, 906, 862, 914, 830, 0, + 0, 912, 0, 1027, 1031, 0, 0,10045, 0, 9775, + 915, 507,11507, 510, 0,10791, 0, 28, 1037, 1040, + 930, 922, 0,10045,10045, 933,10045, 1026, 0, 0, + 0, 0, 71, 9910, 0, 0, 0, 0, 8003, 0, + 1054, 0, 535,10045, 946, 7556, 947, 0, 0, 900, + 0, 0, 0, 902, 363, 0, 905, 0, 922, 0, + 0, 0, 942, 0, 0, 0, 0, 0, 0, 0, + 0, 167, 0, 0, 0,11395, 0, 0, 908, 943, + 897, 0,10045, 0,10045, 0,10045, 0, 0, 0, + 0, 0, 0, 750, 0, 0,10315, 0, 0, 0, + 957, 917, 7417, 0, 830, 0, 830, 0, 830, 0, + 0, 0, 0, 911, 954, 915, 0, 0, 0, -167, + 0, -150, 960, 963, 0, 0, 0, 0, 962, 7556, + 897, -201, 0, 964, 0, 0, 961, 6464, 0, 0, + 0, 0, 0, 0, 969, 0, 709, 0, 0, 0, + 0, 0, -199, 0, 970, 363, 0, 920, 897, 0, + 343, 0, 921, 965, 0, 0, 0,10045, 995,10045, + 0,10045, 997, 208, 869, 168, 481, 0, 0, 0, + 0, 23, 0, -138, 0, 0, 0, 980, 0, 0, + 0, 971, 0, 0, 0, 273, 0, 972, 1093, 1094, + 0, 0, 983, 897,10045, 0, 0, 0, 0, 0, +10045, 0, 990, -194, 0, -194, 0, 0, 0, 0, + 991, 0,10045, 7244, 0, 0, 1012, 708, 993, 0, +10045, 0, 992, 0, 0,10315, 140, 6, 0, 508, + 316, 0, 0, 989, 989, 989, 9775, 998, 0,10045, + 0, 0, 0, 0, 999, 881, 0, 6464, 1000, 0, + 0, 6620, 0, 1003, 0, 1002, 0,10045, 0, 0, + 0, 0, 0, 0,10045, 0, 0, 268, 1004, 0, + 0, 956, 0, -138, 0, 268, 7573, 108, 108, 108, + 0, 0,10045, 0, 6464, 6464, 0, 0, 6620, 0, + 0, 6464, 0, 1016,10045,10045, 0, 268, 1009, 0, + 0, 0, 967, 0, 1006, 0, 0, 0, 1007, 0, + 0, 968, 0, 1038, 0, 0, 0, 0, 0, 0, + 6620, 0, 0, 1033, 0, 1011, 108, 0, 1020, 268, + 7573, 1017, 1028, 0, 1030, 1034, 1035,10045, 0, 0, + 0, 0, 1013, 1011, 0, 0, 321, -81, 268, 0, + 0, 0, 1041,10045, 1029,10045, 0, 0, 1039, 0, + 0, 1042, 0, 0,12240, 0, 1036, -81, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, +12240, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1047, 268, 0, 268, 1011, 984, 0, 1041, 0, 0, + 1048, 321,11135, 0, 0, 235, 0, 0, 0,11203, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1129, -193, 0, 1120, 0, 0, 1133, 0, 0, - 1134, 1135, 0, 1118, 0, 95, 95, 0, 95, 1132, - 1138, 0, 0, 0, 0, 1139, 94, 0, 1140, 95, - 1248, 1142, 95, 95, 469, 0, 7172, 1094, 1143, 1118, - 0, 1145, 1148, 96, 1152, 0, 0, 95, 9300, 1097, - 1151, 1139, 0, 0, 9590, 0, -208, -208, 0, 1137, - 1160, 1140, 0, 1165, 0, 9564, 1149, 1171, 1142, 0, - 1176, 1179, 0, -163, 0, 1175, 0, 0, 0, 0, - 0, 9590, 0, 96, 96, 1185, 1186, 0, -193, 0, - 0, 321, 1189, 9590, 0, 9590, 0, 0, 7172, 1180, - 0, 0, 0, 1190, 1133, 0, 0, 0, 0, 0, - 115, 0, 0, 0, 44, 759, 1195, 0, 0, 0, - 0, 0, 0, 0, 0, 1245, 1299, 0, 0, 0, - 0, 44, 1197, 1198, 7172, 0, 0, 0, 0, 96, - 500, 500, 0, 0, 0, 0, 0, -105, -105, 0, - 0, 0, 0, 0, 0, 8772, 8772, 0, 0, 0, - 0, 0, 1204, 1201, 1203, 0, 0, 0, + 0, 0, 1057, 268, 0, 0, 0, 0, 0, 0, +10791,10791, 98,11395, 294, 420, 1088, 0, 126, 8225, + 0, 1121, 0, 0, 1011, 0, 0, 0, 1011, 0, + 0, 1010, 1014, 0,10791, -146, 0,10791, 1014, 1018, + 1059, 0, 126, 0, 1060, 9051, 0, 1065, 1019, -235, + 260, 1352, 0, 0, 0, 126, 0, 1071, 1022, 1070, + 1067, 0, 1073, 1075, 1076, 6, 1068, 1078, 0, 1081, + 1086, 0, 729, 0, 597, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1085, -180, 0, 1077, 0, 0, 1090, 0, 0, 1089, + 1091, 0, 1083, 0, 6, 6, 0, 6, 1087, 1092, + 0, 0, 0, 0, 1096, -78, 0, 1114, 6, 1205, + 1115, 6, 6, 235, 0, 7556, 1046, 1116, 1083, 0, + 1118, 1119, 69, 1123, 0, 0, 6, 9775, 1079, 1120, + 1096, 0, 0,12240, 0, 268, 268, 0, 1100, 1125, + 1114, 0, 1122, 0,10045, 1101, 1127, 1115, 0, 1132, + 1148, 0, -170, 0, 1140, 0, 0, 0, 0, 0, +12240, 0, 69, 69, 1099, 1150, 0, -180, 0, 0, + 251, 1131,12240, 0,12240, 0, 0, 7556, 1142, 0, + 0, 0, 1136, 1090, 0, 0, 0, 0, 0, -160, + 0, 0, 0, 108, 719, 1156, 0, 0, 0, 0, + 0, 0, 0, 0, 1179, 1261, 0, 0, 0, 0, + 108, 1155, 1162, 7556, 0, 0, 0, 0, 69, 376, + 376, 0, 0, 0, 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 9235, 9235, 0, 0, 0, 0, + 0, 1159, 1165, 1166, 0, 0, 0, }; - protected static readonly short [] yyRindex = { 1905, - 0, 0, 0, 0, 0, 6407, 0, 0, 0, 1905, - 0, 1572, 0, 0, 0, 0, 0, 0, 0, 0, - 451, 0, 0, 0, 0, 0, 0, 1289, 0, 0, - 542, 1202, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 575, 586, 0, 1209, 0, 0, 0, 0, 0, - 1781, 0, 42, 0, 1572, 0, 0, 1572, 0, 0, + protected static readonly short [] yyRindex = { 1870, + 0, 0, 6776, 1870, 0, 0, 1530, 0, 2055, 988, + 0, 0, 0, 0, 0, 2055, 0, 0, 43, 0, + 0, 0, 0, 0, 1530, 1111, 1939, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 423,10369, 0, 0, 0, 0, - 0, 0, 0, 0, 2107, 0, 3751, 1209, 1210, 0, - 0, 686, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1216, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0,11149, 0, 0, 1208, - 0, 0, 0, 0, 0, 0, 1208, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 246, 0, 0, 0, + 1174, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,11575, 0, 0, 1167, 0, 0, 0, + 0, 0, 0, 1167, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5678, 0, 0, 0, 0, 0, 256, - 0, 3599, 5731, 0, 0, 3444, 0, 0, 0, 0, + 0, 0, 0, 3543, 0, 0, 0, 0, 0, 240, + 0, 4109, 3701, 0, 0, 3951, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3933, 0, 3997, 4283, 4475, - 4849, 5041, 5169, 5297, 5425, 5553, 3686, 3563, 0, 0, - 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4497, 0, 4564, 4904, + 5105, 5440, 5641, 5775, 5909, 6043, 494, 4196, 1160, 0, + 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1124, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 782, 782, 2128, 0, 405, 1168, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 757, 757, 1852, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1220, 0, 0, 0, - 0, 0, 0, 0, 3830, 2368, 0, 0, 0, 2745, - 2368, 2107, 0, 0, 0, 0, 0, 699, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2589, + 2195, 713, 2264, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3054, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1177, 0, 0, 0, 0, 3054, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1223, 0, 0, 0, - 0, 2589, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2510, 0, 407, - 0, 407, 0, 20, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1208, 0, 0, 0, 0, 1221, - 0, 2589, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2786, 0, 4394, -228, 2931, 0, 0, 3213, 2931, + -228, 0, 0, 0, 0, -43, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1167, 0, 0, 0, + 0, 0, 0, 1180, 4264, 0, 3054, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1948, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -258, 0, 0, 0, - 0, 1225, 0, 1178, 1181, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7876, 0, 0, 0, - 0, 0, 0, 2589, 5792, 0, 0, 0, 0, 0, - 0, 0,10737, 0, 0, 0, 0, 0, 1231, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 415, 684, - 0, 0, 1229, 0, 0, 0, 0, 0, 53, 0, - 0, 3134, 1236, 0, 0, 0, 154, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1403, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2374, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, - 7478, 0, 0, 0, 0, -161, 644, 0, 0, 0, - 1237, 0, 0, 0, 0, 2589, 0, 2589, 0, 0, - 0, 0, 0, 69, 0, 0, 0, 0, 120, 0, - 0, 0, 0, 4076, 0, 0, 0, 0, 0, 0, + 29, 0, 0, 0, 0, 0, 0, 0, 2331, 1497, + 0, 0, 0, 0, 2641, 0, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4140, 4219, 4347, 4411, 4539, 4603, 4667, 4731, 4913, 4977, - 5105, 5233, 5361, 5489, 5617, 0, 0, 729, 0, 0, - 407, 0, 407, 0, 0, 0, 0, 0, 0, 611, - 0, 0, 0, 1708, 0, -184, 0, 0, 0, 0, - 0, 0, 0, 0, 9960, 0, 0, 0, 0, 0, - 0, 0, 746, 0, 0, 0,11166, 8041, 0, 0, - 758, 782, 789, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1235, 0, 0, 0, 0, 0, 0, - 0, 1233, 0, 0, 0, 4768, 0, 0, 126, 0, - -58, 2824, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1244, 0, 0, 0, 0, 0, 0, 0, - 0, 651, 603, 0, 0, 0, 1241, 0, 0, 0, + 0, 0, 0, 0, 310,10868, 0, 0, 0, 3054, + 3859, 0, 0, 0, 0, 0, 0, 0,11235, 0, + 0, 0, 0, 0, 1170, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 374, 735, 0, 0, 1187, 0, + 0, 0, 0, 0, -34, 0, 0, 3635, 1193, 0, + 0, 0, -154, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1282, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -14, 0, 0, + 0, 0, 0, 0, 0, 0, 7868, 0, 0, 0, + 0, 0, 0, 0, -140, 630, 0, 0, 0, 1194, + 0, 0, 0, 0, 3054, 0, 3054, 0, 0, 0, + 0, 0, 56, 0, 0, 0, 0, 117, 0, 0, + 0, 4667, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4734, 4837, + 4971, 5038, 5172, 5239, 5306, 5373, 5507, 5574, 5708, 5842, + 5976, 6110, 6177, 0, 0, 679, 0, 0, -228, 0, + -228, 0, 0, 0, 0, 0, 0, 3017, 0, 0, + 2641, 0, 0, 0, 0, 670, 100, 0, 0, 1197, + 0, 0, 0, 0, 1202, 0, 0, 0, 0, 0, + 0,10450, 0, 0, 0, 694, 0, 0, 0,11599, + 0, 0, 707, 723, 727, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1200, 0, 0, 0, 0, + 0, 0, 0, 1209, 0, 0, 0, 3385, 0, 0, + 57, 0, 73, 3319, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1211, 0, 0, 0, 0, 0, + 0, 0, 0, -243, 539, 656, 0, 0, 0, 0, + 1212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 217, 0, 0, 0, 1239, 0, 0, - 0, 0, 0, 0, 301, 0, 364, 0, 0, 0, - 0,11288, 0, 0, 0, -167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1242,11220, 0,11237, 0, 0, 0,10850, 0, - 0, 0, 806, 0, 1243, 0, 0, 0, 1558, 0, + 0, 0, 203, 0, 0, 0, 1213, 0, 0, 0, + 0, 0, 0, 329, 0, 538, 0, 0, 0, 0, + 0, 0, 0, 1220, 0, 665, 0, 0, 0, 0, + 0, 1214, 0, 1173, 1175, 0, 0, 0, 0, 0, + 1216,11643, 0,11667, 0, 0, 0,11319, 0, 0, + 0, 730, 0, 1218, 0, 0, 0, 1630, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 2979, 0, 3289, 1249, 0, 0, 0, - 1250, 0, 0, 0, 0, 651, 0, 0, 0, 806, + 0, 0, 3477, 0, 3793, 1227, 0, 0, 0, 1224, + 0, 0, 0, 0, 539, 0, 0, 0, 730, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0,11359,11430,10737, 0, 1205, 0, 0, - 0, 28, 28, 28, 0, 0, 0, 0, 0, 0, - 0, 1251, 0, 0, 0, 0, 0, 0, 812, 816, - 0, 0, 0, 0, 0, 0, 1252, 729, 0, 0, + 675, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 745, 0, 0, 0, + 0, 161, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1222, 0, 0, 0, 0, + 0, 0, 748, 751, 0, 0, 0, 0, 0, 0, + 1228, 679, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3635, 0, 0, 0, + 0, 0, 1235, 0, 0, 539, 0, 777, 1228, 0, + 7868, 0, 505, 560, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 129, 1197, 8291, 0, 0, 0, 0, + 0,11730, 0, -121, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 572, 0, 586, 0, 0, + 0, 0, 0, 1213, 1232, 0, 0, 0, 0, 0, + 0, 0, 0, 1238, 0, 6932, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 445, 570, 0, + 0, 0, 0, 0, 0, 0,11798,11235, 0, 1201, + 0, 0, 0, 151, 151, 151, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3134, 0, 0, 0, 0, 0, 1253, 0, - 0, 651, 0, 839, 1252, 7478, 0, 554, 604, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, -11501,11572, 0, 0, 0, 0, 0, -167, 0, -15, - 0, 1258, 1258, 1258, 0, 0, 0, 0, 659, 0, - 675, 0, 0, 0, 0, 0, 1239, 1256, 0, 0, - 0, 0, 0, 0, 0, 0, 1262, 0, 6560, 0, + 0, 0, 0, 0, 0, 0, 0,11952, 0, 0, + 0, 0, 0, -121, 0, -275, 0, 1255, 1255, 1255, + 0, 0, 0, 0, 0, 0, 0, 0, -222, 0, + 0, 0, 0, 0, 0, 0, 0,11995, 0, 0, + 0, 0, 0, 0, 1257, 0, 0, 0, 153, 0, + 0, 0, 0, 451, 0, 0, 0, 0, 0, 0, + 1258, 0, 0, 0, 0, 1982, 1253, 486, 0, -255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 392, 545, 0, 0, 0, 0, 0,11641, 0, 0, - 0, 0, 0, 1264, 0, 0, 0, 113, 0, 0, - 0, 0, 524, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1261, 0, 0, 0, 0, + 0, 0, 0, 1802, 0, 0, 0, 8453, 8817, 0, + 0, 0, 614, 0, 0, 0, 0, 0, 0, 0, + 0, 351, 0, 0,11021, 0, 0, 8544, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1260, 316, 0, 99, 0, +11103, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 8908, 0, 8635, 1802, 0, 0, 614, 0, 0, + 0, 0, 310, 0, 0, 0, 0, 0, 0, 310, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -204, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1141, 0, 0, 0, 8150, 8446, 0, - 0, 0, 0, 0, 1266, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 473, 0, 0,10505, - 0, 0, 8224, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0,10587, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 8520, 0, 8298, 1141, - 0, 0, 0, 0, 0, 0, 0, 423, 0, 0, - 0, 0, 0, 0, 423, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 8372, 0, - 0, 0, 579, 0, 0, 0, 0, 0, 0, 0, - 0, 2715, 430, 0, 489, 0, 0, 0, 8564, 0, - 1141, 0, 0, 0, 1141, 0, 0, 0, 0, 579, + 0, 0, 0, 8726, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4393, 391, 0, 8952, 0, + 0, 0, 9021, 0, 1802, 0, 0, 0, 1802, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 506, 0, 1270, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 784, 0, 313, 0, - 0, 0, 0, 0, 0, 0,10737, 817, 0, 0, - 0, 0, 0, 1247, 0, 714, 0, 0, 0, 0, + 0, 0, 715, 0, 1263, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 786, 0, 552, 0, 0, + 0, 0, 0, 0, 0,11235, 755, 0, 0, 0, + 0, 0, 1259, 0, 604, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 824, 0, 0, 0, 0, 0, - 0, 0, 0, 1265, 0,10737,10737, 0,10777, 0, - 0, 0, 0, 0, 0, 1267,11730, 0, 1268,10737, -10092, 1269,10737,10737, 0, 0, 0, 0, 0, 1271, - 0, 0, 0, 9458, 0, 0, 0,10737, 0, 0, - 0, 1272, 0, 0, 334, 0,11700, 9326, 0, 0, - 0, 1273, 0, 0, 0, 0, 0, 0, 1274, 0, - 0, 0, 0, 538, 0, 829, 0, 0, 0, 0, - 0, 849, 0, 8798, 8930, 0, 0, 0, 0, 0, - 0, 0, 0, 1319, 0, 1373, 0, 0, 0, 833, + 0, 0, 0, 762, 0, 0, 0, 0, 0, 0, + 0, 0, 1260, 0,11235,11235, 0,11279, 0, 0, + 0, 0, 0, 0, 1264, 4671, 0, 1265,11235,10585, + 1266,11235,11235, 0, 0, 0, 0, 0, 1270, 0, + 0, 0,12205, 0, 0, 0,11235, 0, 0, 0, + 1271, 0, 0, 317, 0,12132,12162, 0, 0, 0, + 1275, 0, 0, 0, 0, 0, 0, 1276, 0, 0, + 0, 0, 485, 0, 763, 0, 0, 0, 0, 0, + 799, 0,12038,12073, 0, 0, 0, 0, 0, 0, + 0, 0, 1317, 0, 1370, 0, 0, 0, 768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 549, 0, 0, 0, 0, 0, + 0, 0, 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 549, 0, 0, 0, 0, 0, 0, 0, 9458, -10250, 7768, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1236, 1236, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 526, 0, 0, 0, 0, 0, 0, 0,12205,11841, +11884, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1193, 1193, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, }; protected static readonly short [] yyGindex = { 0, - 1587, 723, 52, 0, 0, 34, -649, -3, -436, 0, - 785, 0, 0, 23, 0, 0, 1, 0, 0, 0, - -599, -67, 0, 0, 0, 0, 0, -570, 0, 0, - 0, 0, 0, 43, -11, 0, 1598, 0, 1560, 0, - 0, 0, 0, 1015, 1018, -47, -233, 0, 0, 0, - 0, 544, -987, -527, -500, -496, -483, -465, -460, -455, - -996,-1000, 0, -220, 0, 339, 0, -897, 0, 0, - 0, 0, 0, 0, 492, -72, 303, 0, 0, 0, - 345, -966, 0, -299, -312, 1410, 0, 0, 0, -813, - 298, 0, 0, -489, 0, 0, 361, 0, 0, 335, - 0, 0, 370, 0, -381, -826, 0, 0, 0, 0, - 496, -44, 0, 0, 877, 897, 908, 0, -502, 0, - 0, -542, 921, 483, 0, -902, 0, 0, 0, 0, - 0, 0, 0, 0, 287, 0, 0, 0, 0, 0, - 0, 0, 0, 562, 0, 0, 0, 0, -236, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 584, - 0, -501, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 297, 0, 0, 379, 0, 0, 391, 393, 310, - 0, 0, 0, 0, 0, 0, 0, 0, 664, 0, - 0, 0, 0, -37, 0, 55, -71, 0, 0, 479, - 0, 540, 0, 770, 0, 1207, -311, -237, -115, 517, - 0, 673, 0, -82, -30, 0, 0, 963, 0, 0, + 0, 1609, 0, 0, 7, -4, -162, -19, 1610, 0, + 1628, 1648, 701, 0, 0, 2, 0, 0, 0, 0, + 0, 0, -719, -617, -177, -569, 0, 0, 0, 0, + 0, -141, 0, 0, 0, 822, 0, 928, 0, 0, + 0, 0, 678, 688, -15, -189, 0, 0, 0, 0, + 537, -723, -646, -504, -497, -488, -470, -384, -335,-1023, +-1071, 0, -513, 0, 179, 0, -990, 0, 0, 0, + 0, 0, 0, 495, 36, 305, 0, 0, 0, 345, + -953, 0, -233, -253, 1072, 0, 0, 0, -786, 296, + 0, 0, -442, 0, 0, 362, 0, 0, 337, 0, + 0, 368, 0, -301, -831, 0, 0, 0, 0, 487, + -12, 0, 0, 918, 923, 926, 0, -467, 0, 0, + -549, 934, 475, 0, -964, 0, 0, 0, 0, 0, + 0, 0, 0, 262, 0, 0, 0, 0, 0, 0, + 0, 0, 540, 0, 0, 0, 0, -279, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 555, 0, + -443, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 276, 0, 0, 358, 0, 0, 364, 366, 282, 0, + 0, 0, 0, 0, 0, 0, 0, 610, 0, 0, + 0, 0, -37, 0, -13, -92, 0, 0, 450, 0, + 506, 0, 673, 0, 1229, -245, -220, -52, 685, 0, + 621, 0, -6, 35, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -284, 0, 262, 0, 0, -36, 0, - 0, 0, 910, 0, -469, -178, 1074, 1006, 0, 980, - 0, 1183, 1368, 1100, 0, 0, 837, 1625, 0, 0, - 0, 0, 1079, 0, 0, 0, 0, 0, -562, 0, - 0, 0, 0, 0, 988, 0, 472, 821, 691, 834, - 1350, 1351, 1349, 1352, 1353, 0, 1348, 0, 0, 0, - 1028, 0, 832, 0, 0, 0, 0, 0, 0, 0, - 0, -301, 0, 0, 0, 0, -76, 0, 747, 0, - 625, 0, 676, 0, 0, 0, 733, -508, -46, -325, - -43, 0, 1559, 0, -1, 0, 15, 51, 54, 56, - 57, 58, 61, 65, 68, 70, 0, -632, 0, -59, - 0, 0, 865, 0, -778, 0, 0, 0, 781, 0, - 923, 0, 898, -448, 0, 0, 0, 0, 0, 0, - 792, 0, 0, 793, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 803, 0, 0, 0, 0, - 0, 0, 0, 0, -81, 0, 1257, 0, 0, 0, - 956, 0, 0, 0, 0, 0, -221, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1356, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 594, 0, - 0, 0, 0, 0, 0, 0, 0, 716, 0, 0, - 0, 0, 0, + 0, 0, 0, -224, 0, 517, 0, 0, -419, 0, + 0, 0, 925, 0, -257, -118, 1069, 1005, 0, 994, + 0, 1183, 1392, 1106, 0, 0, 824, 1660, 0, 0, + 0, 0, 1082, 0, 0, 0, 0, 0, -465, 0, + 0, 0, 0, 0, 1134, 0, 491, 835, 771, 833, + 1368, 1369, 1373, 1375, 1367, 0, 1371, 0, 0, 0, + 1044, 0, 825, 0, 0, 0, 0, 0, 0, 0, + 0, -238, 0, 0, 0, 0, -391, 0, 655, 0, + 580, 0, 671, 0, 0, 0, 749, -469, -11, -265, + -7, 0, 1606, 0, 38, 0, 47, 52, 63, 65, + 67, 94, 111, 115, 137, 139, 0, -594, 0, -5, + 0, 0, 887, 0, -532, 0, 0, 0, 789, 0, + 936, 0, 899, -402, 0, 0, 0, 0, 0, 0, + 807, 0, 0, 812, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 832, 0, 0, 0, 0, + 0, 0, 0, 0, -8, 0, 1300, 0, 0, 0, + 966, 0, 0, 0, 0, 0, -159, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1400, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 625, 0, + 0, 0, 0, 0, 0, 0, 0, 737, 0, 0, + 0, 0, }; - protected static readonly short [] yyTable = { 252, - 21, 687, 157, 203, 52, 158, 204, 506, 257, 509, - 21, 439, 482, 263, 433, 692, 78, 281, 535, 163, - 265, 337, 452, 719, 764, 32, 409, 43, 442, 681, - 660, 928, 490, 725, 462, 799, 800, 525, 467, 943, - 283, 926, 28, 56, 366, 329, 727, 374, 208, 241, - 1056, 21, 28, 973, 276, 1015, 1016, 35, 498, 35, - 746, 55, 1284, 783, 209, 974, 43, 341, 343, 163, - 39, 364, 323, 30, 163, 37, 829, 974, 831, 323, - 416, 502, 359, 361, 330, 245, 958, 960, 332, 1222, - 3, 1118, 1370, 28, 378, 345, 40, 809, 35, 1138, - 210, 253, 238, 211, 786, 212, 213, 214, 416, 371, - 215, 43, 863, 312, 216, 1145, 665, 217, 966, 218, - 414, 313, 365, 550, 716, 373, 54, 813, 41, 80, - 1, 2, 1157, 35, 515, 35, 1235, 467, 54, 1118, - 449, 1149, 889, 35, 867, 454, 984, 1, 1072, 142, - 1418, 699, 81, 274, 364, 371, 5, 157, 203, 783, - 158, 204, 1157, 417, 556, 499, 5, 500, 418, 274, - 419, 1149, 415, 557, 163, 609, 420, 421, 364, 240, - 801, 747, 364, 1285, 717, 364, 364, 364, 1024, 685, - 455, 417, 364, 526, 35, 35, 418, 926, 419, 528, - 750, 1099, 275, 208, 420, 421, 535, 1371, 359, 3, - 35, 810, 472, 783, 940, 975, 535, 625, 275, 209, - 461, 501, 524, 453, 466, 1236, 281, 975, 42, 470, - 49, 31, 4, 38, 281, 905, 666, 21, 480, 5, - 884, 815, 887, 246, 959, 961, 54, 1223, 422, 478, - 359, 752, 378, 5, 511, 210, 5, 142, 211, 314, - 212, 213, 214, 923, 481, 215, 1419, 485, 487, 216, - 56, 970, 217, 540, 218, 523, 432, 274, 163, 28, - 512, 886, 439, 660, 3, 520, 80, 522, 434, 521, - 555, 485, 80, 80, 6, 7, 8, 534, 926, 1010, - 536, 813, 35, 2, 163, 926, 81, 323, 749, 81, - 5, 926, 550, 163, 1352, 81, 81, 589, 590, 731, - 394, 395, 1, 466, 566, 354, 275, 917, 575, 576, - 577, 578, 579, 580, 581, 582, 583, 584, 585, 35, - 681, 1376, 1348, 806, 80, 612, 614, 901, 330, 1314, - 645, 1341, 390, 1386, 792, 1387, 1195, 617, 618, 982, - 607, 983, 877, 877, 285, 35, 660, 81, 661, 309, - 537, 310, 311, 355, 315, 35, 316, 634, 1393, 876, - 876, 35, 1011, 684, 327, 359, 328, 490, 391, 774, - 660, 741, 639, 359, 333, 1062, 775, 335, 54, 339, - 1272, 3, 356, 807, 462, 464, 965, 467, 771, 376, - 772, 814, 773, 406, 35, 815, 452, 359, 248, 659, - 1, 2, 249, 372, 4, 407, 538, 1083, 1084, 655, - 357, 5, 619, 84, 1086, 646, 631, 877, 631, 1394, - 685, 1378, 1379, 684, 35, 35, 80, 742, 163, 1302, - 1303, 661, 1305, 683, 876, 566, 416, 690, 5, 5, - 5, 464, 332, 1324, 392, 393, 1331, 1332, 879, 81, - 696, 698, 35, 35, 1092, 661, 452, 1396, 712, 1193, - 714, 1347, 358, 250, 732, 534, 734, 465, 536, 453, - 356, 550, 631, 899, 1404, 534, 721, 1410, 536, 3, - 685, 163, 811, 450, 35, 996, 948, 1101, 1117, 83, - 842, 163, 54, 363, 736, 736, 376, 558, 376, 660, - 376, 376, 4, 376, 805, 376, 559, 356, 1194, 5, - 1161, 356, 1101, 509, 80, 356, 85, 81, 336, 417, - 333, 703, 372, 465, 418, 451, 419, 550, 949, 453, - 733, 1119, 420, 421, 769, 719, 1117, 81, 1148, 635, - 270, 1045, 485, 635, 271, 636, 160, 376, 755, 376, - 358, 80, 376, 704, 86, 80, 912, 476, 1120, 80, - 503, 1212, 1121, 1383, 469, 1213, 469, 449, 1148, 281, - 461, 87, 519, 466, 81, 1122, 641, 261, 81, 1119, - 685, 1150, 81, 35, 359, 89, 1196, 358, 485, 443, - 737, 358, 81, 1123, 272, 358, 160, 797, 1124, 823, - 342, 160, 690, 1125, 821, 818, 1120, 683, 1151, 477, - 1121, 1150, 1152, 444, 91, 1384, 78, 163, 163, 907, - 469, 80, 1065, 1122, 907, 1153, 907, 262, 641, 907, - 907, 1142, 907, 907, 822, 1197, 261, 261, 1151, 737, - 445, 1123, 1152, 1154, 81, 832, 1124, 833, 1155, 342, - 907, 1125, 261, 1156, 1029, 1153, 835, 358, 163, 335, - 163, 35, 295, 363, 295, 335, 387, 388, 389, 295, - 79, 566, 336, 1154, 639, 364, 566, 844, 1155, 690, - 80, 640, 901, 1156, 879, 81, 535, 901, 336, 901, - 860, 861, 901, 901, 888, 901, 901, 995, 639, 264, - 1059, 160, 641, 81, 907, 640, 514, 641, 875, 876, - 910, 641, 54, 481, 57, 910, 656, 910, 535, 515, - 910, 910, 267, 910, 910, 639, 641, 485, 944, 349, - 903, 35, 640, 1018, 263, 543, 516, 906, 1082, 535, - 945, 910, 544, 349, 261, 1019, 868, 914, 907, 690, - 268, 349, 349, 641, 545, 349, 697, 243, 510, 916, - 244, 349, 35, 349, 510, 349, 670, 901, 349, 273, - 349, 1135, 641, 349, 286, 349, 80, 349, 349, 349, - 349, 261, 349, 349, 932, 349, 934, 1335, 936, 349, - 1218, 667, 284, 349, 495, 910, 1225, 336, 496, 81, - 349, 349, 349, 1231, 349, 160, 349, 261, 142, 80, - 349, 142, 358, 349, 362, 667, 83, 261, 35, 446, - 1182, 35, 363, 261, 667, 349, 574, 349, 690, 375, - 455, 160, 81, 349, 83, 281, 142, 349, 509, 823, - 160, 52, 142, 591, 592, 1237, 913, 336, 354, 1388, - 349, 763, 354, 163, 349, 134, 261, 134, 402, 363, - 640, 721, 134, 903, 641, 988, 663, 990, 903, 991, - 903, 825, 403, 903, 903, 663, 903, 903, 404, 35, - 286, 1179, 349, 411, 336, 1407, 261, 261, 1179, 286, - 349, 662, 408, 349, 1424, 1425, 354, 897, 396, 397, - 662, 763, 897, 763, 897, 763, 481, 897, 897, 405, - 897, 897, 398, 399, 261, 261, 318, 241, 1036, 690, - 349, 349, 21, 349, 349, 61, 1043, 456, 868, 913, - 1002, 69, 69, 435, 913, 69, 913, 913, 913, 913, - 913, 913, 913, 913, 913, 913, 261, 342, 903, 481, - 342, 752, 481, 752, 913, 752, 913, 441, 913, 673, - 913, 913, 913, 674, 543, 534, 783, 463, 536, 682, - 1069, 544, 317, 496, 318, 160, 879, 163, 21, 475, - 349, 163, 897, 545, 1096, 35, 464, 349, 349, 471, - 481, 612, 349, 612, 637, 349, 638, 534, 349, 349, - 536, 364, 1088, 991, 185, 349, 185, 735, 185, 163, - 163, 641, 349, 163, 913, 261, 163, 927, 534, 744, - 197, 536, 197, 481, 197, 400, 401, 511, 160, 1002, - 427, 70, 427, 511, 163, 70, 417, 349, 160, 81, - 766, 418, 282, 419, 1096, 261, 72, 483, 72, 420, - 421, 427, 427, 749, 857, 858, 364, 749, 1100, 1116, - 364, 484, 349, 364, 1163, 364, 595, 596, 597, 598, - 364, 427, 1040, 1041, 1191, 1192, 1184, 505, 745, 427, - 745, 510, 427, 1100, 35, 876, 876, 282, 282, 282, - 282, 282, 282, 282, 282, 754, 1190, 754, 1397, 1398, - 274, 1221, 367, 173, 1224, 173, 513, 1116, 252, 1100, - 1229, 35, 346, 347, 348, 349, 350, 351, 352, 353, - 30, 368, 369, 261, 527, 1229, 354, 180, 539, 180, - 354, 529, 349, 354, 181, 354, 181, 254, 554, 1100, - 354, 370, 1280, 560, 1281, 1238, 95, 623, 97, 275, - 627, 98, 371, 854, 615, 854, 102, 203, 622, 203, - 106, 174, 630, 174, 160, 160, 139, 632, 139, 109, - 642, 35, 35, 300, 354, 300, 114, 644, 146, 35, - 146, 116, 307, 657, 307, 119, 534, 534, 641, 641, - 668, 953, 954, 261, 593, 594, 667, 121, 669, 122, - 671, 35, 35, 124, 35, 160, 710, 160, 672, 694, - 1208, 131, 132, 599, 600, 135, 695, 708, 255, 709, - 711, 713, 715, 729, 261, 720, 1208, 728, 35, 690, - 1184, 35, 1208, 726, 739, 740, 744, 751, 754, 1208, - 745, 481, 760, 753, 763, 765, 766, 781, 376, 789, - 788, 282, 795, 790, 791, 796, 794, 798, 1364, 282, - 816, 240, 812, 817, 819, 827, 839, 1315, 53, 377, - 378, 379, 380, 381, 382, 383, 384, 385, 386, 826, - 261, 828, 837, 261, 1342, 848, 853, 855, 859, 862, - 4, 690, 871, 893, 880, 87, 894, 1354, 1356, 895, - 904, 902, 896, 911, 499, 920, 930, 918, 922, 924, - 929, 951, 955, 987, 969, 962, 956, 282, 963, 964, - 971, 968, 823, 981, 1342, 1342, 986, 690, 989, 282, - 282, 282, 999, 994, 282, 282, 1412, 1412, 1017, 1020, - 1000, 261, 573, 1420, 1420, 1021, 1022, 1039, 566, 566, - 1030, 1023, 1035, 1044, 586, 587, 588, 1042, 1049, 573, - 573, 573, 573, 573, 573, 573, 573, 573, 573, 573, - 573, 573, 573, 573, 573, 1050, 30, 30, 1011, 1047, - 1342, 30, 830, 1051, 1057, 30, 1063, 30, 1065, 1061, - 30, 1074, 30, 30, 1068, 30, 1078, 30, 1079, 30, - 160, 30, 30, 30, 30, 1077, 1080, 30, 30, 1087, - 1240, 1133, 1136, 30, 1134, 30, 30, 30, 1091, 1137, - 30, 30, 30, 1139, 30, 1165, 1146, 30, 1162, 30, - 30, 30, 30, 1186, 1188, 1198, 30, 30, 30, 1211, - 1214, 30, 30, 30, 1216, 1217, 1226, 261, 1227, 1230, - 30, 30, 1241, 30, 30, 30, 30, 30, 30, 1233, - 1234, 1273, 30, 1264, 1236, 1267, 573, 1298, 1266, 1269, - 1270, 1271, 1278, 1277, 1275, 1283, 1288, 1291, 30, 30, - 1306, 1295, 1296, 1325, 30, 30, 1307, 1336, 1310, 1320, - 1349, 1327, 1339, 30, 1337, 1340, 282, 1346, 1242, 1243, - 1244, 1245, 1350, 1246, 1247, 1248, 1249, 1250, 1251, 1252, - 1253, 1361, 1363, 1254, 1255, 1256, 1257, 1258, 1259, 1260, - 1261, 730, 1366, 1368, 160, 53, 1369, 1380, 160, 55, - 1360, 1374, 1385, 1381, 30, 1390, 1389, 773, 1399, 1384, - 55, 1383, 1365, 1405, 1406, 55, 261, 1426, 1427, 55, - 1428, 7, 55, 34, 32, 33, 160, 160, 545, 828, - 160, 730, 25, 160, 55, 55, 505, 327, 613, 55, - 55, 224, 506, 261, 100, 55, 504, 55, 55, 55, - 55, 160, 798, 464, 614, 55, 802, 32, 530, 55, - 748, 55, 33, 756, 803, 349, 777, 836, 674, 748, - 662, 55, 757, 805, 55, 778, 55, 331, 807, 684, - 55, 662, 356, 641, 282, 641, 142, 237, 124, 303, - 149, 88, 143, 125, 304, 150, 1140, 55, 266, 941, - 1187, 1382, 778, 261, 261, 779, 1351, 438, 830, 830, - 1338, 261, 1391, 1367, 1333, 890, 830, 830, 830, 830, - 830, 1205, 830, 830, 1219, 830, 830, 830, 830, 830, - 830, 830, 830, 261, 261, 891, 261, 830, 1147, 830, - 830, 830, 830, 830, 830, 1422, 892, 830, 1144, 1415, - 1362, 830, 830, 885, 830, 830, 830, 30, 1357, 1355, - 261, 1414, 1075, 261, 1282, 1209, 830, 1001, 830, 910, - 830, 830, 1076, 843, 830, 705, 830, 830, 830, 830, - 830, 830, 830, 830, 830, 830, 830, 830, 561, 830, - 780, 320, 830, 830, 841, 738, 830, 830, 804, 972, - 802, 601, 603, 602, 606, 838, 604, 985, 605, 1053, - 1131, 1166, 967, 410, 1064, 830, 830, 1037, 1031, 830, - 1026, 1033, 931, 700, 830, 830, 830, 830, 830, 957, - 925, 621, 830, 1215, 830, 925, 1089, 0, 0, 0, - 830, 830, 0, 0, 0, 0, 0, 573, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 773, 773, 830, 830, 830, 830, 0, - 830, 773, 773, 773, 773, 773, 830, 773, 773, 0, - 773, 773, 773, 773, 773, 773, 773, 0, 0, 0, - 0, 0, 773, 0, 773, 773, 773, 773, 773, 773, - 0, 922, 773, 0, 0, 0, 773, 773, 0, 773, - 773, 773, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 773, 0, 773, 0, 773, 773, 0, 0, 773, - 0, 773, 773, 773, 773, 773, 773, 773, 773, 773, - 773, 773, 773, 0, 773, 0, 0, 773, 773, 0, - 0, 773, 773, 0, 7, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 773, 773, 0, 0, 773, 0, 0, 0, 0, 773, - 773, 773, 773, 773, 0, 0, 0, 773, 0, 773, - 0, 0, 0, 0, 0, 773, 773, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 30, 30, 0, 0, 0, 30, 0, - 773, 773, 773, 773, 0, 773, 0, 0, 0, 30, - 0, 773, 0, 0, 30, 0, 0, 0, 30, 0, - 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 30, 30, 0, 0, 0, 30, 30, - 0, 0, 0, 0, 30, 0, 30, 30, 30, 30, - 0, 0, 0, 0, 30, 0, 0, 0, 30, 0, - 30, 0, 0, 0, 0, 0, 0, 925, 0, 0, - 30, 54, 30, 30, 0, 30, 0, 0, 0, 30, - 0, 0, 54, 0, 0, 0, 0, 54, 0, 0, - 0, 54, 0, 0, 54, 30, 30, 0, 0, 0, - 0, 30, 30, 0, 0, 0, 54, 54, 0, 0, - 0, 54, 54, 0, 0, 0, 0, 54, 0, 54, - 54, 54, 54, 0, 0, 0, 0, 54, 0, 0, - 0, 54, 0, 54, 0, 0, 0, 0, 922, 0, - 0, 0, 54, 54, 0, 0, 54, 0, 54, 0, - 0, 0, 54, 54, 0, 0, 0, 0, 54, 0, - 0, 0, 54, 0, 0, 54, 0, 0, 0, 54, - 0, 0, 0, 0, 0, 0, 0, 54, 54, 0, - 0, 0, 54, 54, 0, 0, 0, 0, 54, 0, - 54, 54, 54, 54, 0, 54, 0, 0, 54, 0, - 0, 0, 54, 0, 54, 0, 54, 0, 0, 0, - 0, 54, 0, 0, 54, 54, 0, 54, 54, 54, - 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, - 54, 54, 0, 515, 0, 54, 54, 0, 515, 515, - 54, 54, 0, 54, 54, 54, 54, 0, 0, 0, - 0, 54, 0, 0, 0, 54, 0, 54, 0, 0, - 0, 515, 0, 0, 0, 0, 0, 54, 0, 0, - 54, 515, 54, 0, 515, 515, 54, 0, 0, 515, - 0, 0, 515, 0, 515, 0, 515, 515, 515, 515, - 0, 0, 0, 54, 515, 0, 0, 0, 515, 0, - 0, 0, 515, 0, 0, 0, 0, 0, 0, 0, - 515, 0, 0, 515, 0, 515, 515, 0, 0, 0, - 0, 515, 0, 515, 515, 515, 515, 515, 515, 515, - 515, 515, 515, 515, 0, 0, 515, 0, 0, 0, - 515, 515, 0, 515, 515, 515, 515, 515, 515, 515, - 0, 515, 515, 0, 515, 515, 515, 515, 515, 515, - 515, 515, 515, 515, 0, 515, 515, 515, 515, 515, - 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - 515, 515, 515, 515, 515, 515, 515, 0, 0, 515, - 0, 515, 349, 515, 0, 0, 515, 349, 349, 0, - 0, 515, 0, 0, 0, 0, 0, 0, 0, 0, + protected static readonly short [] yyTable = { 97, + 452, 303, 98, 144, 184, 649, 192, 145, 654, 455, + 16, 178, 428, 388, 600, 379, 413, 378, 686, 181, + 491, 271, 622, 210, 509, 482, 436, 354, 692, 903, + 215, 217, 448, 1031, 471, 768, 769, 787, 1066, 1067, + 696, 257, 922, 1153, 216, 782, 12, 311, 257, 103, + 319, 408, 149, 264, 715, 263, 950, 266, 477, 1160, + 755, 150, 310, 184, 184, 318, 151, 287, 951, 361, + 627, 103, 361, 951, 583, 1293, 103, 152, 798, 153, + 800, 154, 184, 742, 179, 1379, 1092, 593, 935, 1244, + 473, 325, 216, 216, 216, 216, 216, 216, 216, 216, + 584, 371, 596, 1402, 1, 937, 597, 778, 155, 1231, + 246, 327, 277, 282, 493, 373, 683, 979, 247, 5, + 1172, 303, 575, 576, 743, 156, 413, 366, 344, 157, + 97, 306, 585, 98, 144, 351, 775, 567, 145, 344, + 693, 47, 208, 344, 782, 515, 1019, 352, 744, 14, + 1172, 158, 362, 159, 516, 362, 344, 363, 192, 364, + 363, 47, 364, 303, 1403, 365, 366, 598, 365, 366, + 494, 387, 47, 366, 1114, 745, 684, 1323, 716, 480, + 103, 1245, 694, 149, 47, 667, 300, 643, 344, 770, + 412, 209, 150, 628, 647, 416, 776, 151, 782, 1294, + 577, 388, 858, 1380, 861, 184, 2, 13, 152, 301, + 153, 371, 154, 371, 514, 371, 371, 782, 371, 470, + 371, 952, 491, 475, 779, 841, 952, 479, 509, 190, + 427, 184, 491, 431, 433, 586, 215, 424, 408, 155, + 367, 184, 478, 377, 215, 180, 458, 184, 594, 936, + 216, 466, 1361, 468, 418, 467, 156, 431, 216, 248, + 157, 608, 371, 469, 371, 719, 938, 371, 484, 485, + 1232, 3, 4, 5, 490, 300, 373, 103, 492, 1385, + 426, 257, 158, 947, 159, 860, 190, 184, 496, 190, + 184, 1395, 582, 1396, 721, 47, 457, 973, 301, 922, + 412, 525, 18, 103, 710, 533, 534, 535, 536, 537, + 538, 539, 540, 541, 542, 543, 667, 601, 303, 1427, + 103, 184, 184, 683, 1350, 460, 782, 216, 922, 897, + 783, 929, 448, 930, 784, 931, 500, 565, 943, 216, + 216, 216, 303, 891, 216, 216, 609, 204, 444, 184, + 184, 205, 684, 1204, 881, 383, 1091, 296, 731, 192, + 711, 300, 875, 1061, 1357, 890, 961, 184, 863, 461, + 547, 548, 184, 190, 1107, 1133, 5, 876, 876, 761, + 2, 460, 580, 683, 301, 335, 661, 587, 1387, 1388, + 300, 640, 448, 1405, 186, 190, 640, 1206, 570, 572, + 640, 206, 1205, 1037, 1281, 297, 659, 617, 660, 436, + 1413, 994, 684, 301, 413, 640, 359, 509, 1133, 621, + 1164, 336, 701, 449, 703, 1176, 627, 942, 627, 82, + 959, 645, 960, 525, 298, 652, 190, 879, 1428, 922, + 1069, 1070, 640, 784, 1419, 922, 1062, 1072, 658, 660, + 1164, 668, 1134, 1311, 1312, 876, 1314, 676, 445, 103, + 446, 640, 208, 361, 678, 299, 666, 1333, 64, 64, + 1340, 1341, 64, 509, 18, 1223, 490, 875, 875, 1224, + 492, 300, 627, 449, 688, 1356, 490, 461, 732, 659, + 492, 660, 359, 517, 184, 1134, 853, 1165, 381, 359, + 337, 338, 518, 1040, 301, 705, 705, 251, 300, 252, + 298, 209, 1157, 1392, 447, 300, 659, 302, 660, 422, + 216, 643, 103, 813, 780, 873, 359, 1165, 1116, 1132, + 359, 301, 103, 359, 359, 359, 298, 902, 301, 713, + 359, 602, 622, 461, 360, 303, 362, 974, 1116, 1207, + 82, 363, 718, 364, 208, 875, 219, 300, 724, 365, + 366, 243, 886, 244, 245, 1393, 249, 602, 250, 686, + 455, 423, 1132, 465, 1163, 465, 261, 736, 262, 640, + 301, 638, 184, 300, 23, 32, 267, 34, 412, 269, + 35, 273, 1108, 302, 1135, 39, 284, 285, 1208, 43, + 82, 1136, 431, 209, 1163, 638, 301, 337, 46, 1196, + 1137, 766, 298, 475, 29, 51, 652, 301, 317, 302, + 53, 645, 1109, 298, 56, 82, 736, 215, 1138, 465, + 700, 640, 638, 647, 1246, 190, 58, 1135, 59, 1166, + 988, 216, 61, 1110, 1136, 184, 1167, 921, 791, 774, + 68, 69, 989, 1137, 72, 1168, 337, 274, 632, 300, + 203, 801, 639, 802, 103, 103, 184, 906, 300, 1166, + 300, 1138, 906, 1169, 906, 805, 1167, 906, 906, 184, + 906, 906, 301, 184, 220, 1168, 639, 300, 1024, 666, + 308, 301, 525, 301, 790, 302, 308, 525, 815, 100, + 652, 906, 582, 1169, 302, 309, 302, 103, 82, 103, + 301, 831, 832, 639, 1139, 803, 666, 999, 270, 187, + 184, 100, 207, 302, 270, 666, 100, 187, 807, 267, + 1025, 317, 850, 853, 427, 587, 491, 305, 308, 184, + 506, 82, 184, 344, 300, 344, 506, 460, 431, 587, + 1090, 877, 218, 383, 972, 906, 1034, 1139, 880, 1170, + 461, 280, 280, 1140, 344, 344, 270, 301, 888, 449, + 652, 746, 308, 491, 792, 301, 344, 462, 747, 344, + 280, 465, 792, 909, 344, 301, 921, 794, 909, 1170, + 909, 862, 344, 909, 909, 344, 909, 909, 702, 1068, + 270, 1020, 184, 732, 270, 491, 1140, 907, 1171, 909, + 532, 911, 502, 1021, 752, 502, 662, 909, 283, 503, + 184, 920, 503, 303, 600, 662, 307, 549, 550, 184, + 100, 504, 587, 320, 504, 587, 347, 587, 1171, 587, + 587, 587, 587, 587, 587, 587, 587, 587, 587, 587, + 281, 975, 330, 976, 652, 1048, 348, 441, 330, 281, + 587, 442, 587, 1344, 587, 331, 587, 587, 587, 350, + 388, 909, 1150, 1193, 356, 762, 900, 762, 927, 762, + 1193, 900, 587, 900, 341, 342, 900, 900, 688, 900, + 900, 661, 965, 587, 967, 344, 968, 349, 343, 344, + 661, 1227, 252, 280, 980, 587, 344, 1234, 902, 344, + 344, 353, 103, 902, 1240, 902, 339, 340, 902, 902, + 587, 902, 902, 344, 290, 1397, 290, 100, 977, 280, + 751, 290, 751, 383, 751, 427, 362, 618, 455, 280, + 180, 363, 180, 364, 180, 280, 385, 1006, 652, 365, + 366, 384, 896, 100, 192, 1013, 192, 896, 192, 896, + 920, 1416, 896, 896, 900, 896, 896, 345, 346, 359, + 100, 427, 1018, 359, 427, 344, 359, 659, 359, 828, + 829, 1433, 1434, 359, 640, 280, 344, 35, 280, 640, + 490, 603, 1044, 640, 492, 604, 902, 344, 192, 1047, + 608, 344, 608, 208, 980, 312, 1053, 635, 640, 301, + 924, 636, 644, 184, 344, 409, 442, 427, 704, 280, + 280, 410, 604, 337, 313, 314, 337, 490, 192, 1074, + 968, 492, 103, 65, 417, 640, 103, 65, 344, 344, + 896, 344, 344, 56, 315, 748, 344, 280, 280, 748, + 421, 744, 209, 744, 640, 316, 332, 333, 334, 490, + 1053, 1010, 1011, 492, 853, 429, 753, 184, 753, 103, + 103, 430, 1103, 103, 451, 168, 103, 168, 1115, 1131, + 349, 1406, 1407, 184, 349, 309, 344, 129, 1148, 129, + 427, 175, 456, 175, 129, 176, 459, 176, 1115, 476, + 853, 507, 853, 481, 423, 103, 423, 507, 495, 100, + 4, 553, 554, 555, 556, 67, 198, 67, 198, 169, + 1238, 169, 1131, 513, 1115, 423, 423, 134, 349, 134, + 875, 875, 1111, 1238, 295, 141, 295, 141, 184, 184, + 302, 301, 302, 1198, 519, 423, 184, 530, 530, 280, + 1289, 349, 1290, 423, 1115, 349, 423, 344, 349, 573, + 349, 640, 640, 1029, 1030, 349, 305, 184, 184, 629, + 184, 605, 100, 551, 552, 581, 1219, 557, 558, 607, + 619, 630, 100, 631, 633, 656, 634, 1111, 674, 1219, + 657, 184, 280, 672, 184, 1219, 677, 673, 675, 349, + 679, 680, 1219, 695, 681, 321, 682, 709, 1247, 698, + 697, 687, 708, 713, 720, 714, 1202, 1203, 288, 289, + 290, 291, 292, 293, 294, 295, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, 723, 722, 729, 733, + 1230, 734, 737, 1233, 35, 757, 741, 750, 35, 758, + 759, 760, 767, 765, 764, 785, 763, 186, 786, 35, + 788, 795, 796, 808, 35, 781, 810, 797, 35, 819, + 824, 35, 826, 830, 833, 837, 1324, 836, 839, 840, + 280, 829, 846, 35, 35, 843, 848, 854, 35, 35, + 652, 1198, 867, 1351, 35, 868, 35, 35, 35, 35, + 869, 870, 427, 876, 35, 878, 1363, 1365, 35, 885, + 35, 445, 900, 892, 100, 100, 894, 905, 896, 1373, + 35, 898, 35, 35, 904, 35, 923, 932, 933, 35, + 924, 946, 939, 1351, 1351, 940, 941, 948, 945, 792, + 958, 966, 963, 280, 964, 983, 35, 971, 991, 992, + 987, 990, 652, 993, 35, 35, 1000, 100, 1009, 100, + 1014, 1005, 1027, 1073, 280, 1012, 1032, 4, 1040, 1036, + 1043, 47, 1051, 1038, 1050, 1076, 1062, 280, 1080, 1081, + 1089, 280, 47, 1078, 1082, 1090, 1094, 47, 652, 1351, + 1097, 47, 1106, 1098, 47, 1099, 1146, 1421, 1421, 1100, + 1177, 1102, 1154, 1149, 1429, 1429, 47, 47, 1151, 525, + 525, 47, 47, 1161, 1152, 591, 483, 47, 1179, 47, + 47, 47, 47, 1200, 1209, 1222, 1225, 47, 1236, 1239, + 1226, 47, 1242, 47, 1235, 1243, 1273, 280, 1245, 1275, + 280, 1276, 1278, 47, 1279, 1280, 47, 1282, 47, 1284, + 1286, 1287, 47, 483, 1292, 1307, 1297, 1300, 1315, 1304, + 1334, 1305, 1345, 1316, 1389, 544, 545, 546, 1319, 47, + 483, 483, 483, 483, 483, 483, 483, 483, 483, 483, + 483, 483, 483, 483, 483, 483, 1329, 1336, 1348, 1349, + 1346, 1355, 1372, 1393, 1359, 1358, 48, 1394, 591, 1370, + 280, 1375, 1377, 591, 1399, 591, 591, 591, 591, 591, + 591, 591, 591, 591, 591, 591, 1369, 1374, 1378, 1383, + 1390, 1398, 1408, 1392, 1414, 1435, 591, 280, 591, 8, + 591, 1415, 591, 591, 591, 1436, 1437, 829, 829, 541, + 729, 827, 31, 501, 797, 829, 829, 829, 829, 829, + 609, 829, 829, 502, 829, 829, 829, 829, 829, 829, + 829, 829, 100, 460, 610, 29, 829, 21, 829, 829, + 829, 829, 829, 829, 801, 500, 829, 29, 483, 322, + 829, 829, 526, 829, 829, 829, 591, 747, 30, 219, + 755, 95, 802, 30, 835, 829, 756, 829, 747, 829, + 829, 776, 804, 829, 777, 829, 829, 829, 829, 829, + 829, 829, 829, 829, 829, 829, 829, 673, 829, 806, + 661, 829, 829, 326, 683, 829, 829, 661, 351, 772, + 344, 640, 640, 189, 137, 193, 1249, 28, 119, 298, + 144, 829, 829, 829, 138, 120, 699, 829, 829, 299, + 145, 829, 19, 1016, 1155, 915, 829, 829, 829, 829, + 829, 835, 1391, 1017, 829, 1360, 829, 739, 1201, 1400, + 1347, 1342, 829, 829, 1376, 864, 1216, 1228, 1250, 1431, + 865, 1162, 100, 866, 1159, 859, 100, 1424, 1371, 1095, + 1366, 1364, 1423, 669, 1291, 1220, 1052, 829, 829, 829, + 829, 1096, 829, 884, 707, 773, 814, 520, 829, 749, + 949, 280, 812, 254, 559, 771, 560, 563, 1084, 100, + 100, 561, 564, 100, 562, 962, 100, 1251, 1252, 1253, + 1254, 1180, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, + 809, 1087, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, + 1039, 355, 1007, 48, 934, 100, 906, 48, 944, 48, + 1001, 48, 662, 48, 899, 280, 48, 1003, 48, 48, + 579, 48, 1178, 48, 0, 48, 996, 48, 48, 48, + 48, 280, 1075, 48, 48, 0, 0, 0, 0, 48, + 48, 48, 48, 48, 0, 0, 48, 48, 48, 0, + 48, 27, 48, 48, 48, 48, 48, 48, 48, 48, + 0, 48, 48, 48, 48, 0, 0, 48, 48, 48, + 0, 48, 0, 0, 0, 0, 48, 48, 0, 48, + 48, 0, 48, 48, 48, 0, 280, 280, 48, 0, + 0, 0, 0, 0, 280, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 48, 0, 0, 0, 48, + 48, 0, 0, 0, 0, 280, 280, 0, 280, 34, + 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 772, 772, 0, 0, 280, + 0, 0, 280, 772, 772, 772, 772, 772, 0, 772, + 772, 0, 772, 772, 772, 772, 772, 772, 772, 0, + 0, 0, 483, 48, 772, 0, 772, 772, 772, 772, + 772, 772, 0, 0, 772, 0, 0, 0, 772, 772, + 0, 772, 772, 772, 0, 0, 0, 0, 33, 0, + 0, 0, 0, 772, 0, 772, 0, 772, 772, 0, + 0, 772, 0, 772, 772, 772, 772, 772, 772, 772, + 772, 772, 772, 772, 772, 0, 772, 0, 0, 772, + 772, 0, 0, 772, 772, 0, 0, 0, 0, 0, + 0, 27, 0, 0, 0, 0, 0, 0, 0, 772, + 772, 772, 0, 0, 0, 772, 772, 0, 0, 772, + 0, 0, 0, 0, 772, 772, 772, 772, 772, 0, + 0, 0, 772, 0, 772, 0, 0, 0, 0, 0, + 772, 772, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 349, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 349, 0, 0, 349, 349, 0, 0, 0, 349, 0, - 0, 349, 0, 349, 0, 349, 349, 349, 349, 0, - 0, 0, 0, 349, 0, 0, 0, 349, 0, 0, - 0, 349, 0, 0, 0, 0, 0, 0, 0, 349, - 0, 0, 349, 0, 349, 349, 0, 0, 0, 0, - 349, 0, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 0, 349, 0, 0, 0, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 0, - 349, 349, 0, 0, 349, 349, 349, 349, 349, 0, - 0, 349, 349, 0, 0, 0, 349, 349, 349, 349, - 349, 349, 349, 349, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 349, 0, 0, 349, 0, - 349, 0, 349, 93, 0, 349, 0, 0, 0, 0, - 349, 94, 95, 96, 97, 0, 0, 98, 99, 0, - 100, 101, 102, 103, 104, 105, 106, 0, 0, 0, - 0, 0, 107, 0, 108, 109, 110, 111, 112, 113, - 0, 0, 114, 0, 0, 0, 115, 116, 0, 117, - 118, 119, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 120, 0, 121, 0, 122, 123, 0, 0, 124, - 0, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 0, 137, 0, 0, 138, 139, 0, - 0, 140, 141, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 342, 0, 0, 0, 0, 342, 342, - 142, 0, 0, 0, 143, 0, 0, 0, 0, 144, - 145, 146, 147, 148, 0, 0, 0, 149, 0, 150, - 0, 342, 0, 0, 0, 151, 152, 0, 0, 0, - 0, 342, 0, 0, 342, 342, 0, 0, 0, 342, - 0, 0, 342, 0, 342, 0, 342, 342, 342, 342, - 153, 154, 155, 156, 342, 0, 0, 0, 342, 0, - 0, 240, 342, 0, 0, 0, 0, 0, 0, 0, - 342, 0, 0, 342, 0, 342, 342, 0, 0, 0, - 0, 342, 0, 342, 342, 342, 342, 342, 342, 342, - 342, 342, 342, 342, 0, 0, 342, 0, 0, 0, - 342, 342, 342, 342, 342, 342, 0, 342, 342, 342, - 0, 342, 342, 0, 0, 342, 342, 342, 342, 0, - 0, 0, 342, 342, 0, 0, 0, 342, 342, 342, - 342, 342, 342, 342, 342, 738, 0, 0, 0, 0, - 738, 738, 0, 0, 0, 0, 342, 0, 0, 342, - 0, 342, 0, 342, 0, 0, 342, 0, 0, 0, - 0, 342, 0, 738, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 738, 0, 0, 738, 738, 0, 0, - 0, 738, 0, 0, 738, 0, 738, 0, 738, 738, - 738, 738, 0, 0, 0, 0, 738, 0, 0, 0, - 738, 0, 0, 0, 738, 0, 0, 0, 0, 0, - 0, 0, 738, 0, 349, 738, 0, 738, 738, 0, - 349, 0, 0, 738, 0, 738, 738, 738, 738, 738, - 738, 738, 738, 738, 738, 738, 0, 0, 738, 0, - 0, 0, 738, 738, 738, 738, 738, 738, 0, 738, - 738, 738, 0, 738, 738, 0, 349, 738, 738, 738, - 738, 0, 0, 0, 738, 738, 0, 0, 0, 738, - 738, 738, 738, 738, 738, 738, 738, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 738, 0, - 0, 738, 0, 738, 0, 738, 0, 349, 738, 0, - 0, 0, 349, 738, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 0, 0, 0, 0, - 0, 0, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 0, 349, 349, 0, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 371, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 371, 0, - 379, 0, 349, 0, 349, 379, 379, 349, 0, 0, - 0, 371, 349, 0, 0, 0, 371, 0, 0, 248, - 0, 371, 0, 371, 371, 371, 371, 0, 379, 0, - 0, 371, 0, 0, 0, 371, 0, 0, 379, 371, - 0, 379, 379, 0, 0, 0, 379, 371, 0, 379, - 371, 379, 371, 379, 379, 379, 379, 0, 0, 0, - 0, 379, 0, 0, 0, 379, 0, 0, 0, 379, - 0, 0, 0, 371, 0, 0, 0, 379, 0, 517, - 379, 0, 379, 379, 0, 517, 0, 0, 379, 0, - 379, 379, 379, 379, 379, 379, 379, 379, 379, 379, - 379, 0, 0, 379, 0, 0, 0, 379, 379, 0, - 379, 379, 379, 0, 379, 379, 379, 0, 379, 379, - 0, 517, 379, 379, 379, 379, 0, 0, 371, 379, - 379, 0, 0, 0, 379, 379, 379, 379, 379, 379, - 379, 379, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 379, 0, 0, 379, 0, 379, 0, - 0, 0, 517, 0, 0, 0, 0, 517, 379, 517, - 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, - 0, 0, 0, 0, 0, 0, 517, 517, 517, 517, - 517, 517, 517, 517, 517, 517, 0, 517, 517, 0, - 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, - 0, 517, 517, 517, 517, 517, 517, 517, 517, 517, - 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, - 517, 517, 517, 0, 513, 701, 0, 0, 0, 517, - 513, 0, 0, 0, 95, 0, 97, 517, 0, 98, - 0, 0, 0, 0, 102, 0, 0, 0, 106, 0, - 0, 0, 0, 0, 0, 0, 0, 109, 0, 0, - 0, 0, 0, 0, 114, 0, 513, 0, 0, 116, - 0, 0, 0, 119, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 121, 0, 122, 0, 0, - 0, 124, 0, 0, 0, 0, 0, 0, 0, 131, - 132, 0, 0, 135, 0, 0, 437, 513, 0, 0, + 0, 0, 0, 0, 0, 772, 772, 772, 772, 0, + 772, 0, 0, 0, 32, 0, 772, 27, 27, 0, + 0, 0, 27, 0, 0, 0, 27, 0, 27, 0, + 0, 27, 0, 27, 27, 0, 27, 0, 27, 0, + 27, 0, 27, 27, 27, 27, 0, 0, 27, 27, + 0, 0, 0, 0, 27, 0, 27, 27, 27, 0, + 0, 27, 27, 27, 0, 27, 0, 0, 27, 0, + 27, 27, 27, 27, 0, 0, 0, 27, 27, 27, + 0, 0, 27, 27, 27, 0, 34, 920, 0, 0, + 34, 27, 27, 0, 27, 27, 0, 27, 27, 27, + 0, 34, 0, 27, 0, 0, 34, 0, 0, 0, + 34, 0, 0, 34, 0, 0, 0, 0, 0, 0, + 27, 0, 0, 0, 0, 34, 34, 0, 27, 27, + 34, 34, 0, 0, 0, 0, 34, 27, 34, 34, + 34, 34, 0, 0, 0, 0, 34, 0, 0, 0, + 34, 0, 34, 0, 47, 33, 0, 0, 0, 33, + 0, 0, 34, 0, 34, 34, 0, 34, 0, 0, + 33, 34, 0, 0, 0, 33, 0, 0, 27, 33, + 0, 0, 33, 0, 0, 0, 0, 0, 34, 0, + 0, 0, 0, 0, 33, 33, 0, 34, 27, 33, + 33, 0, 27, 0, 0, 33, 0, 33, 33, 33, + 33, 0, 0, 27, 0, 33, 0, 0, 27, 33, + 0, 33, 27, 6, 0, 27, 0, 0, 0, 0, + 0, 33, 0, 0, 33, 0, 33, 27, 27, 0, + 33, 0, 27, 27, 0, 0, 0, 0, 27, 0, + 27, 27, 27, 27, 0, 0, 0, 33, 27, 0, + 0, 0, 27, 0, 27, 33, 33, 0, 0, 0, + 0, 32, 0, 0, 27, 32, 0, 27, 0, 27, + 0, 0, 0, 27, 0, 0, 32, 0, 0, 0, + 921, 32, 0, 0, 0, 32, 0, 0, 32, 0, + 27, 0, 0, 0, 0, 0, 0, 0, 27, 27, + 32, 32, 0, 0, 0, 32, 32, 0, 0, 0, + 0, 32, 0, 32, 32, 32, 32, 0, 0, 0, + 0, 32, 0, 0, 0, 32, 0, 32, 0, 0, + 0, 0, 0, 0, 920, 0, 0, 32, 47, 0, + 32, 0, 32, 0, 0, 0, 32, 0, 0, 47, + 0, 0, 0, 0, 47, 0, 0, 0, 47, 0, + 0, 47, 0, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 32, 47, 47, 0, 0, 0, 47, 47, + 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, + 0, 0, 0, 0, 47, 0, 0, 0, 47, 0, + 47, 47, 0, 0, 0, 47, 0, 0, 0, 0, + 47, 0, 0, 47, 0, 47, 47, 0, 0, 47, + 0, 47, 0, 0, 0, 47, 0, 0, 47, 0, + 0, 0, 0, 0, 0, 0, 47, 0, 0, 0, + 47, 47, 0, 0, 0, 47, 47, 0, 0, 0, + 0, 47, 0, 47, 47, 47, 47, 0, 0, 0, + 0, 47, 0, 0, 0, 47, 0, 47, 0, 0, + 6, 0, 0, 0, 48, 0, 0, 47, 0, 0, + 47, 0, 47, 0, 0, 48, 47, 0, 0, 0, + 48, 0, 0, 0, 48, 0, 0, 48, 0, 0, + 0, 0, 0, 47, 0, 0, 0, 0, 0, 48, + 48, 0, 0, 0, 48, 48, 0, 0, 0, 0, + 48, 0, 48, 48, 48, 48, 0, 0, 0, 0, + 48, 0, 0, 0, 48, 0, 48, 921, 0, 0, + 0, 47, 0, 0, 0, 0, 48, 0, 0, 48, + 0, 48, 47, 0, 0, 48, 0, 47, 0, 0, + 0, 47, 0, 0, 47, 0, 0, 0, 0, 0, + 0, 0, 48, 0, 0, 0, 47, 47, 0, 511, + 0, 47, 47, 0, 511, 511, 0, 47, 0, 47, + 47, 47, 47, 0, 0, 0, 0, 47, 0, 0, + 0, 47, 0, 47, 0, 0, 0, 511, 0, 0, + 0, 0, 0, 47, 0, 0, 47, 511, 47, 0, + 511, 511, 47, 0, 0, 511, 0, 0, 511, 0, + 511, 0, 511, 511, 511, 511, 0, 0, 0, 47, + 511, 0, 0, 0, 511, 0, 0, 0, 511, 0, + 0, 0, 0, 0, 0, 0, 511, 0, 0, 511, + 0, 511, 511, 0, 0, 0, 0, 511, 0, 511, + 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, + 0, 0, 511, 0, 0, 0, 0, 0, 0, 511, + 511, 0, 511, 511, 511, 511, 511, 511, 511, 0, + 511, 511, 0, 511, 511, 511, 511, 511, 511, 511, + 511, 511, 511, 0, 511, 511, 511, 511, 511, 511, + 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, + 511, 511, 511, 511, 511, 511, 0, 0, 511, 0, + 511, 0, 511, 30, 0, 511, 0, 0, 0, 0, + 511, 31, 32, 33, 34, 0, 0, 35, 36, 0, + 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, + 0, 0, 44, 0, 45, 46, 47, 48, 49, 50, + 0, 0, 51, 0, 0, 0, 52, 53, 0, 54, + 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 57, 0, 58, 0, 59, 60, 0, 0, 61, + 0, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 0, 74, 0, 0, 75, 76, 0, + 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 344, 79, 80, 81, + 0, 344, 344, 82, 0, 0, 0, 83, 0, 0, + 0, 0, 84, 85, 86, 87, 88, 0, 0, 0, + 89, 0, 90, 0, 344, 0, 0, 0, 91, 92, + 0, 0, 0, 0, 344, 0, 0, 344, 344, 0, + 0, 0, 344, 0, 0, 344, 0, 344, 0, 344, + 344, 344, 344, 93, 94, 95, 96, 344, 0, 0, + 0, 344, 0, 0, 186, 344, 0, 0, 0, 0, + 0, 0, 0, 344, 0, 0, 344, 0, 344, 344, + 0, 0, 0, 0, 344, 0, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 0, 344, + 0, 0, 0, 0, 0, 0, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 0, 344, 344, 0, + 0, 344, 344, 344, 344, 344, 0, 0, 344, 344, + 0, 0, 0, 344, 344, 344, 344, 344, 344, 344, + 344, 737, 0, 0, 0, 0, 737, 737, 0, 0, + 0, 0, 344, 0, 0, 344, 0, 344, 0, 344, + 0, 0, 344, 0, 0, 0, 0, 344, 0, 737, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 737, + 0, 0, 737, 737, 0, 0, 0, 737, 0, 0, + 737, 0, 737, 0, 737, 737, 737, 737, 0, 0, + 0, 0, 737, 0, 0, 0, 737, 0, 0, 0, + 737, 0, 0, 0, 0, 0, 0, 0, 737, 0, + 0, 737, 0, 737, 737, 0, 0, 0, 0, 737, + 0, 737, 737, 737, 737, 737, 737, 737, 737, 737, + 737, 737, 0, 0, 737, 0, 0, 0, 0, 0, + 0, 737, 737, 737, 737, 737, 737, 0, 737, 737, + 737, 0, 737, 737, 0, 0, 737, 737, 737, 737, + 0, 0, 0, 737, 737, 0, 0, 0, 737, 737, + 737, 737, 737, 737, 737, 737, 337, 0, 0, 0, + 0, 337, 337, 0, 0, 0, 0, 737, 0, 0, + 737, 0, 737, 0, 737, 0, 0, 737, 0, 0, + 0, 0, 737, 0, 337, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 337, 0, 0, 337, 337, 0, + 0, 0, 337, 0, 0, 337, 0, 337, 0, 337, + 337, 337, 337, 0, 0, 0, 0, 337, 0, 0, + 0, 337, 0, 0, 0, 337, 0, 0, 0, 0, + 0, 0, 0, 337, 0, 0, 337, 0, 337, 337, + 0, 0, 912, 0, 337, 0, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 0, 0, 337, + 0, 0, 0, 0, 0, 0, 337, 337, 337, 337, + 337, 337, 0, 337, 337, 337, 0, 337, 337, 344, + 0, 337, 337, 337, 337, 344, 0, 0, 337, 337, + 0, 0, 0, 337, 337, 337, 337, 337, 337, 337, + 337, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 337, 0, 0, 337, 0, 337, 0, 337, + 0, 344, 337, 0, 0, 912, 0, 337, 0, 0, + 912, 0, 912, 912, 912, 912, 912, 912, 912, 912, + 912, 912, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 912, 0, 912, 0, 912, 0, 912, + 912, 912, 344, 0, 0, 0, 0, 344, 0, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 0, + 344, 344, 0, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 912, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 0, 0, 374, 0, + 344, 0, 344, 374, 374, 344, 0, 0, 0, 0, + 344, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 374, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 374, 0, 0, 374, + 374, 0, 0, 0, 374, 0, 0, 374, 0, 374, + 0, 374, 374, 374, 374, 0, 0, 0, 0, 374, + 0, 0, 0, 374, 0, 0, 0, 374, 0, 0, + 0, 0, 0, 0, 0, 374, 0, 0, 374, 0, + 374, 374, 0, 0, 0, 0, 374, 0, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 0, + 0, 374, 0, 0, 513, 0, 0, 0, 374, 374, + 513, 374, 374, 374, 0, 374, 374, 374, 0, 374, + 374, 0, 0, 374, 374, 374, 374, 0, 0, 0, + 374, 374, 0, 0, 0, 374, 374, 374, 374, 374, + 374, 374, 374, 0, 0, 0, 513, 0, 0, 0, + 0, 0, 0, 0, 374, 0, 0, 374, 0, 374, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 374, + 344, 0, 0, 0, 0, 0, 344, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 513, 0, 0, 0, 0, 513, 0, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 0, 0, 0, 0, 0, - 0, 513, 513, 0, 513, 513, 513, 513, 513, 513, - 513, 0, 513, 513, 0, 513, 513, 513, 513, 513, - 513, 513, 513, 513, 513, 0, 513, 513, 513, 513, + 0, 0, 344, 0, 513, 513, 513, 513, 513, 513, + 513, 513, 513, 513, 0, 513, 513, 0, 513, 513, + 513, 513, 513, 513, 513, 513, 513, 513, 0, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, - 513, 513, 513, 513, 513, 513, 513, 513, 0, 521, - 768, 0, 0, 702, 513, 521, 0, 513, 0, 95, - 0, 97, 513, 0, 98, 0, 0, 0, 0, 102, - 0, 0, 0, 106, 0, 0, 0, 0, 0, 0, - 0, 0, 109, 0, 0, 0, 0, 0, 0, 114, - 0, 521, 0, 0, 116, 0, 0, 0, 119, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 121, 0, 122, 0, 0, 0, 124, 0, 0, 0, - 0, 0, 0, 0, 131, 132, 0, 0, 135, 0, - 0, 255, 521, 0, 0, 0, 0, 521, 0, 521, - 521, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 0, 0, 0, 0, 0, 0, 0, 521, 0, 521, - 521, 521, 521, 521, 521, 521, 0, 521, 521, 0, - 521, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 0, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 521, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 521, 521, 521, 0, 448, 820, 0, 0, 87, 521, - 448, 0, 521, 0, 95, 0, 97, 521, 0, 98, - 0, 0, 0, 0, 102, 0, 0, 0, 106, 0, - 0, 0, 0, 0, 0, 0, 0, 109, 0, 0, - 0, 0, 0, 0, 114, 0, 448, 0, 0, 116, - 0, 0, 0, 119, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 121, 0, 122, 0, 0, - 0, 124, 0, 0, 0, 0, 0, 0, 0, 131, - 132, 0, 0, 135, 0, 0, 255, 448, 0, 0, - 0, 0, 448, 0, 448, 448, 448, 448, 448, 448, - 448, 448, 448, 448, 448, 0, 0, 0, 0, 0, - 0, 0, 448, 0, 448, 448, 448, 448, 448, 448, - 448, 0, 448, 448, 0, 448, 448, 448, 448, 448, - 448, 448, 448, 448, 448, 0, 448, 448, 448, 448, - 448, 448, 448, 448, 448, 448, 448, 448, 448, 448, - 448, 448, 448, 448, 448, 448, 448, 448, 0, 409, - 1006, 0, 0, 87, 448, 409, 0, 448, 0, 95, - 0, 97, 448, 0, 98, 0, 0, 0, 0, 102, - 0, 0, 0, 106, 0, 0, 0, 0, 0, 0, - 0, 0, 109, 0, 0, 0, 0, 0, 0, 114, - 0, 409, 0, 0, 116, 0, 0, 0, 119, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 121, 0, 122, 0, 0, 0, 124, 0, 0, 0, - 0, 0, 0, 0, 131, 132, 0, 0, 135, 0, - 0, 255, 409, 0, 0, 0, 0, 409, 0, 409, - 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 0, 0, 0, 0, 0, 0, 0, 409, 0, 409, - 409, 409, 409, 409, 409, 409, 0, 409, 595, 0, - 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 0, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 409, 409, 0, 550, 0, 0, 0, 87, 409, - 550, 0, 409, 0, 0, 0, 0, 409, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 550, 0, 0, 0, - 0, 595, 0, 0, 0, 0, 595, 0, 595, 595, - 595, 595, 595, 595, 595, 595, 595, 595, 595, 0, - 0, 0, 0, 0, 0, 0, 595, 0, 595, 0, - 595, 0, 595, 595, 595, 0, 0, 550, 0, 0, - 0, 593, 550, 0, 550, 550, 550, 550, 550, 550, - 550, 550, 550, 550, 550, 0, 0, 0, 0, 0, - 0, 0, 550, 0, 550, 0, 550, 0, 550, 550, - 550, 0, 550, 550, 0, 550, 550, 550, 550, 550, - 550, 550, 550, 550, 550, 0, 595, 0, 550, 550, - 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, - 550, 550, 550, 550, 550, 550, 349, 550, 0, 0, - 0, 0, 349, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 550, 0, 593, 0, 0, 0, 0, 593, - 0, 593, 593, 593, 593, 593, 593, 593, 593, 593, - 593, 593, 0, 0, 349, 0, 0, 0, 349, 593, - 0, 593, 0, 593, 0, 593, 593, 593, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 593, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 374, 0, 0, 0, 349, - 0, 374, 0, 0, 349, 0, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 0, 593, - 0, 0, 0, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 374, 349, 349, 0, 374, 349, 349, - 349, 349, 349, 0, 0, 349, 349, 0, 0, 0, - 349, 349, 349, 349, 349, 349, 349, 349, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 349, - 0, 0, 349, 0, 349, 0, 349, 0, 374, 349, - 0, 0, 0, 374, 349, 374, 374, 374, 374, 374, - 374, 374, 374, 374, 374, 374, 0, 0, 562, 0, - 0, 0, 374, 374, 562, 374, 374, 374, 0, 374, - 374, 374, 0, 374, 374, 0, 0, 374, 374, 374, - 374, 0, 0, 0, 374, 374, 0, 0, 0, 374, - 374, 374, 374, 374, 374, 374, 374, 0, 0, 0, - 562, 0, 0, 0, 0, 0, 0, 0, 374, 0, - 0, 374, 0, 374, 0, 0, 0, 0, 0, 0, - 0, 0, 566, 374, 0, 0, 0, 0, 566, 0, + 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, + 513, 0, 509, 0, 0, 0, 0, 513, 509, 0, + 0, 0, 0, 0, 0, 513, 0, 0, 0, 0, + 0, 344, 0, 0, 344, 0, 344, 344, 0, 0, + 0, 344, 344, 0, 0, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 509, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 344, 344, 0, 0, 0, + 0, 0, 0, 344, 344, 0, 344, 0, 0, 0, + 0, 344, 0, 0, 0, 509, 0, 0, 0, 0, + 509, 0, 509, 509, 509, 509, 509, 509, 509, 509, + 509, 509, 509, 0, 0, 0, 0, 0, 0, 0, + 344, 0, 509, 509, 0, 509, 509, 509, 509, 509, + 509, 509, 0, 509, 509, 0, 509, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 0, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 509, 509, 509, 0, + 517, 0, 0, 0, 0, 509, 517, 0, 509, 344, + 0, 0, 0, 509, 0, 0, 0, 0, 0, 0, + 344, 0, 344, 0, 344, 0, 0, 344, 0, 344, + 344, 0, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 517, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 0, 0, 0, 0, 344, + 0, 344, 401, 0, 344, 0, 0, 0, 0, 344, + 0, 0, 0, 517, 0, 0, 0, 0, 517, 0, + 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, + 517, 0, 0, 0, 0, 0, 0, 0, 401, 0, + 0, 517, 0, 517, 517, 517, 517, 517, 517, 517, + 0, 517, 517, 0, 517, 517, 517, 517, 517, 517, + 517, 517, 517, 517, 0, 517, 517, 517, 517, 517, + 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, + 517, 517, 517, 517, 517, 517, 517, 0, 444, 0, + 0, 0, 0, 517, 444, 0, 517, 0, 0, 0, + 0, 517, 0, 0, 0, 0, 0, 0, 337, 0, + 401, 401, 401, 401, 0, 401, 0, 401, 401, 0, + 401, 401, 401, 401, 401, 0, 401, 401, 401, 401, + 444, 401, 401, 401, 401, 401, 401, 401, 401, 401, + 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, + 401, 401, 401, 0, 0, 0, 0, 337, 0, 401, + 344, 0, 401, 0, 0, 0, 0, 401, 0, 0, + 0, 444, 0, 0, 0, 0, 444, 0, 444, 444, + 444, 444, 444, 444, 444, 444, 444, 444, 444, 0, + 0, 0, 0, 0, 0, 0, 344, 0, 0, 444, + 0, 444, 444, 444, 444, 444, 444, 444, 0, 444, + 444, 0, 444, 444, 444, 444, 444, 444, 444, 444, + 444, 444, 0, 444, 444, 444, 444, 444, 444, 444, + 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, + 444, 444, 444, 444, 444, 0, 404, 0, 0, 0, + 0, 444, 404, 0, 444, 0, 0, 0, 0, 444, + 0, 0, 0, 0, 0, 0, 0, 344, 344, 344, + 344, 344, 0, 0, 0, 344, 344, 0, 344, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 404, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 0, 0, 0, 0, 0, 0, 344, 0, 0, + 344, 0, 0, 0, 0, 344, 0, 0, 0, 404, + 0, 0, 0, 0, 404, 0, 404, 404, 404, 404, + 404, 404, 404, 404, 404, 404, 404, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 404, 0, 404, + 404, 404, 404, 404, 404, 404, 0, 404, 0, 0, + 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, + 0, 404, 404, 404, 404, 404, 404, 404, 404, 404, + 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, + 404, 404, 404, 0, 546, 499, 0, 0, 0, 404, + 546, 0, 404, 0, 32, 0, 34, 404, 0, 35, + 0, 0, 0, 0, 39, 0, 0, 0, 43, 0, + 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, + 0, 0, 0, 0, 51, 0, 546, 0, 0, 53, + 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 58, 0, 59, 0, 0, + 0, 61, 0, 0, 0, 0, 0, 0, 0, 68, + 69, 0, 0, 72, 0, 0, 274, 546, 0, 0, + 0, 589, 546, 0, 546, 546, 546, 546, 546, 546, + 546, 546, 546, 546, 546, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 546, 0, 546, 0, 546, + 0, 546, 546, 546, 0, 546, 546, 0, 546, 546, + 546, 546, 546, 546, 546, 546, 546, 546, 0, 0, + 0, 546, 546, 546, 546, 546, 546, 546, 546, 546, + 546, 546, 546, 546, 546, 546, 546, 546, 546, 344, + 546, 0, 0, 0, 0, 344, 305, 0, 0, 0, + 0, 0, 0, 0, 589, 546, 0, 0, 0, 589, + 0, 589, 589, 589, 589, 589, 589, 589, 589, 589, + 589, 589, 0, 0, 0, 0, 0, 344, 0, 0, + 0, 344, 589, 0, 589, 0, 589, 0, 589, 589, + 589, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 589, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 562, 0, 0, 0, 0, 562, 0, 562, 562, - 562, 562, 562, 562, 562, 562, 562, 562, 562, 0, - 0, 0, 0, 0, 566, 0, 562, 0, 562, 0, - 562, 0, 562, 562, 562, 0, 562, 562, 0, 0, - 562, 562, 562, 562, 562, 562, 562, 562, 562, 0, - 0, 0, 562, 562, 562, 562, 562, 562, 562, 562, - 0, 569, 0, 0, 0, 566, 0, 569, 0, 0, - 566, 562, 566, 566, 566, 566, 566, 566, 566, 566, - 566, 566, 566, 0, 0, 0, 562, 0, 0, 0, - 566, 0, 566, 0, 566, 0, 566, 566, 566, 0, - 566, 566, 0, 569, 566, 566, 566, 566, 0, 0, - 0, 566, 566, 0, 0, 0, 566, 566, 566, 566, - 566, 566, 566, 566, 0, 567, 0, 0, 0, 0, - 0, 567, 0, 0, 0, 566, 0, 0, 0, 0, - 0, 0, 0, 0, 569, 0, 0, 0, 0, 569, - 566, 569, 569, 569, 569, 569, 569, 569, 569, 569, - 569, 569, 0, 0, 0, 0, 0, 567, 0, 569, - 0, 569, 0, 569, 0, 569, 569, 569, 0, 569, - 569, 0, 0, 569, 569, 569, 569, 0, 0, 0, - 569, 569, 0, 0, 0, 569, 569, 569, 569, 569, - 569, 569, 569, 0, 568, 0, 0, 0, 567, 0, - 568, 0, 0, 567, 569, 567, 567, 567, 567, 567, - 567, 567, 567, 567, 567, 567, 0, 0, 0, 569, - 0, 0, 0, 567, 0, 567, 0, 567, 0, 567, - 567, 567, 0, 567, 567, 0, 568, 567, 567, 567, - 567, 0, 0, 0, 567, 567, 0, 0, 0, 567, - 567, 567, 567, 567, 567, 567, 567, 0, 572, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 567, 0, - 0, 0, 0, 0, 0, 0, 0, 568, 0, 0, - 0, 0, 568, 567, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 568, 568, 0, 0, 0, 0, 0, - 0, 0, 568, 0, 568, 0, 568, 0, 568, 568, - 568, 0, 568, 568, 0, 0, 568, 568, 568, 568, - 0, 0, 573, 568, 568, 0, 0, 0, 568, 568, - 568, 568, 568, 568, 568, 568, 0, 0, 0, 0, - 0, 572, 0, 0, 0, 0, 572, 568, 572, 572, - 572, 572, 572, 572, 572, 572, 572, 572, 572, 0, - 0, 0, 568, 0, 0, 0, 572, 0, 572, 0, - 572, 0, 572, 572, 572, 0, 0, 0, 0, 0, - 572, 572, 572, 572, 0, 0, 574, 572, 572, 0, - 0, 0, 572, 572, 572, 572, 572, 572, 572, 572, - 0, 0, 0, 0, 0, 573, 0, 0, 0, 0, - 573, 572, 573, 573, 573, 573, 573, 573, 573, 573, - 573, 573, 573, 0, 0, 0, 572, 0, 0, 0, - 573, 0, 573, 0, 573, 0, 573, 573, 573, 0, - 0, 0, 0, 0, 573, 573, 573, 573, 0, 0, - 575, 573, 573, 0, 0, 0, 573, 573, 573, 573, - 573, 573, 573, 573, 0, 0, 0, 0, 0, 574, - 0, 0, 0, 0, 574, 573, 574, 574, 574, 574, - 574, 574, 574, 574, 574, 574, 574, 0, 0, 0, - 573, 0, 0, 0, 574, 0, 574, 0, 574, 0, - 574, 574, 574, 0, 0, 0, 0, 0, 574, 574, - 574, 574, 0, 0, 576, 574, 574, 0, 0, 0, - 574, 574, 574, 574, 574, 574, 574, 574, 0, 0, - 0, 0, 0, 575, 0, 0, 0, 0, 575, 574, - 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, - 575, 0, 0, 0, 574, 0, 0, 0, 575, 0, - 575, 0, 575, 0, 575, 575, 575, 0, 0, 0, - 0, 0, 575, 575, 575, 575, 0, 0, 577, 575, - 575, 0, 0, 0, 0, 0, 575, 575, 575, 575, - 575, 575, 0, 0, 0, 0, 0, 576, 0, 0, - 0, 0, 576, 575, 576, 576, 576, 576, 576, 576, - 576, 576, 576, 576, 576, 0, 0, 0, 575, 0, - 0, 0, 576, 0, 576, 0, 576, 0, 576, 576, - 576, 0, 0, 0, 0, 0, 576, 576, 576, 576, - 0, 0, 578, 576, 576, 0, 0, 0, 0, 0, - 576, 576, 576, 576, 576, 576, 0, 0, 0, 0, - 0, 577, 0, 0, 0, 0, 577, 576, 577, 577, - 577, 577, 577, 577, 577, 577, 577, 577, 577, 0, - 0, 0, 576, 0, 0, 0, 577, 0, 577, 0, - 577, 0, 577, 577, 577, 0, 0, 0, 0, 0, - 577, 577, 577, 577, 0, 0, 579, 577, 577, 0, - 0, 0, 0, 0, 577, 577, 577, 577, 577, 577, - 0, 0, 0, 0, 0, 578, 0, 0, 0, 0, - 578, 577, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 349, 0, 0, 577, 0, 0, 349, + 0, 0, 344, 0, 0, 0, 0, 344, 0, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 0, 589, 0, 0, 0, 0, 0, 0, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 0, + 344, 344, 0, 0, 344, 344, 344, 344, 344, 369, + 0, 344, 344, 366, 0, 369, 344, 344, 344, 344, + 344, 344, 344, 344, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 344, 366, 0, 344, 0, + 344, 0, 344, 0, 0, 344, 0, 369, 0, 366, + 344, 369, 0, 0, 366, 0, 0, 243, 0, 366, + 0, 366, 366, 366, 366, 0, 0, 0, 0, 366, + 0, 0, 0, 366, 0, 0, 0, 366, 0, 0, + 0, 0, 0, 0, 0, 366, 0, 0, 366, 0, + 366, 0, 369, 0, 0, 0, 0, 369, 0, 369, + 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, + 0, 366, 558, 0, 0, 0, 0, 0, 558, 369, + 369, 0, 369, 369, 369, 0, 369, 369, 369, 0, + 369, 369, 0, 0, 369, 369, 369, 369, 0, 0, + 0, 369, 369, 0, 0, 0, 369, 369, 369, 369, + 369, 369, 369, 369, 558, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 369, 0, 0, 369, 366, + 369, 0, 0, 0, 0, 0, 0, 0, 0, 562, + 369, 0, 0, 0, 0, 562, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 558, 0, 0, 0, 0, + 558, 0, 558, 558, 558, 558, 558, 558, 558, 558, + 558, 558, 558, 0, 0, 0, 0, 0, 0, 0, + 0, 562, 0, 558, 0, 558, 0, 558, 0, 558, + 558, 558, 0, 558, 558, 0, 0, 558, 558, 558, + 558, 558, 558, 558, 558, 558, 0, 0, 0, 558, + 558, 558, 558, 558, 558, 558, 558, 0, 0, 0, + 0, 0, 562, 0, 0, 0, 0, 562, 558, 562, + 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, + 0, 0, 565, 558, 0, 0, 0, 0, 565, 0, + 562, 47, 562, 47, 562, 0, 562, 562, 562, 0, + 562, 562, 0, 0, 562, 562, 562, 562, 0, 0, + 0, 562, 562, 0, 47, 0, 562, 562, 562, 562, + 562, 562, 562, 562, 565, 0, 0, 47, 0, 0, + 0, 0, 47, 0, 0, 562, 0, 47, 0, 47, + 47, 47, 47, 0, 0, 47, 0, 47, 0, 563, + 562, 47, 0, 0, 0, 563, 0, 0, 0, 0, + 0, 0, 0, 47, 0, 565, 47, 0, 47, 0, + 565, 0, 565, 565, 565, 565, 565, 565, 565, 565, + 565, 565, 565, 0, 0, 0, 0, 0, 0, 47, + 0, 563, 0, 565, 0, 565, 0, 565, 0, 565, + 565, 565, 0, 565, 565, 0, 0, 565, 565, 565, + 565, 0, 0, 0, 565, 565, 0, 0, 0, 565, + 565, 565, 565, 565, 565, 565, 565, 0, 0, 0, + 0, 0, 563, 0, 0, 0, 0, 563, 565, 563, + 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, + 0, 0, 564, 565, 0, 0, 0, 0, 564, 0, + 563, 389, 563, 0, 563, 0, 563, 563, 563, 0, + 563, 563, 0, 0, 563, 563, 563, 563, 0, 0, + 0, 563, 563, 0, 390, 0, 563, 563, 563, 563, + 563, 563, 563, 563, 564, 0, 0, 391, 0, 0, + 0, 392, 393, 0, 0, 563, 0, 394, 0, 395, + 396, 397, 398, 0, 0, 0, 0, 399, 0, 568, + 563, 400, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 401, 0, 564, 402, 0, 403, 0, + 564, 0, 564, 564, 564, 564, 564, 564, 564, 564, + 564, 564, 564, 0, 0, 0, 0, 0, 0, 404, + 0, 0, 0, 564, 0, 564, 0, 564, 0, 564, + 564, 564, 0, 564, 564, 0, 0, 564, 564, 564, + 564, 0, 0, 0, 564, 564, 569, 0, 0, 564, + 564, 564, 564, 564, 564, 564, 564, 0, 0, 0, + 0, 0, 568, 0, 0, 0, 0, 568, 564, 568, + 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, + 0, 0, 0, 564, 0, 0, 0, 0, 0, 0, + 568, 0, 568, 0, 568, 0, 568, 568, 568, 0, + 0, 0, 0, 0, 568, 568, 568, 568, 0, 0, + 0, 568, 568, 570, 0, 0, 568, 568, 568, 568, + 568, 568, 568, 568, 0, 0, 0, 0, 0, 569, + 0, 0, 0, 0, 569, 568, 569, 569, 569, 569, + 569, 569, 569, 569, 569, 569, 569, 0, 0, 0, + 568, 0, 0, 0, 0, 0, 0, 569, 0, 569, + 0, 569, 0, 569, 569, 569, 0, 0, 0, 0, + 0, 569, 569, 569, 569, 0, 0, 0, 569, 569, + 571, 0, 0, 569, 569, 569, 569, 569, 569, 569, + 569, 0, 0, 0, 0, 0, 570, 0, 0, 0, + 0, 570, 569, 570, 570, 570, 570, 570, 570, 570, + 570, 570, 570, 570, 0, 0, 0, 569, 0, 0, + 0, 0, 0, 0, 570, 0, 570, 0, 570, 0, + 570, 570, 570, 0, 0, 0, 0, 0, 570, 570, + 570, 570, 0, 0, 0, 570, 570, 572, 0, 0, + 570, 570, 570, 570, 570, 570, 570, 570, 0, 0, + 0, 0, 0, 571, 0, 0, 0, 0, 571, 570, + 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, + 571, 0, 0, 0, 570, 0, 0, 0, 0, 0, + 0, 571, 0, 571, 0, 571, 0, 571, 571, 571, + 0, 0, 0, 0, 0, 571, 571, 571, 571, 0, + 0, 0, 571, 571, 573, 0, 0, 0, 0, 571, + 571, 571, 571, 571, 571, 0, 0, 0, 0, 0, + 572, 0, 0, 0, 0, 572, 571, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 0, 0, + 0, 571, 0, 0, 0, 0, 0, 0, 572, 0, + 572, 0, 572, 0, 572, 572, 572, 0, 0, 0, + 0, 0, 572, 572, 572, 572, 0, 0, 0, 572, + 572, 574, 0, 0, 0, 0, 572, 572, 572, 572, + 572, 572, 0, 0, 0, 0, 0, 573, 0, 0, + 0, 0, 573, 572, 573, 573, 573, 573, 573, 573, + 573, 573, 573, 573, 573, 0, 0, 0, 572, 0, + 0, 0, 0, 0, 0, 573, 0, 573, 0, 573, + 0, 573, 573, 573, 0, 0, 0, 0, 0, 573, + 573, 573, 573, 0, 0, 0, 573, 573, 575, 0, + 0, 0, 0, 573, 573, 573, 573, 573, 573, 0, + 0, 0, 0, 0, 574, 0, 0, 0, 0, 574, + 573, 574, 574, 574, 574, 574, 574, 574, 574, 574, + 574, 574, 0, 0, 0, 573, 0, 0, 0, 0, + 0, 0, 574, 0, 574, 0, 574, 0, 574, 574, + 574, 0, 0, 0, 0, 0, 574, 574, 574, 574, + 0, 0, 0, 574, 574, 576, 0, 0, 0, 0, + 574, 574, 574, 574, 574, 574, 0, 0, 0, 0, + 0, 575, 0, 0, 0, 0, 575, 574, 575, 575, + 575, 575, 575, 575, 575, 575, 575, 575, 575, 0, + 0, 0, 574, 0, 0, 0, 0, 0, 0, 575, + 0, 575, 0, 575, 0, 575, 575, 575, 0, 0, + 0, 0, 0, 575, 575, 575, 575, 0, 0, 0, + 575, 575, 577, 0, 0, 0, 0, 575, 575, 575, + 575, 575, 575, 0, 0, 0, 0, 0, 576, 0, + 0, 0, 0, 576, 575, 576, 576, 576, 576, 576, + 576, 576, 576, 576, 576, 576, 0, 0, 0, 575, + 0, 0, 0, 0, 0, 0, 576, 0, 576, 0, + 576, 0, 576, 576, 576, 0, 0, 0, 0, 0, + 0, 0, 576, 576, 0, 0, 0, 576, 576, 578, + 0, 0, 0, 0, 0, 0, 576, 576, 576, 576, + 0, 0, 0, 0, 0, 577, 0, 0, 0, 0, + 577, 576, 577, 577, 577, 577, 577, 577, 577, 577, + 577, 577, 577, 0, 0, 0, 576, 0, 0, 0, + 0, 0, 0, 577, 0, 577, 0, 577, 0, 577, + 577, 577, 0, 0, 0, 0, 0, 0, 0, 577, + 577, 0, 0, 0, 577, 577, 579, 0, 0, 0, + 0, 0, 0, 577, 577, 577, 577, 0, 0, 0, + 0, 0, 578, 0, 0, 0, 0, 578, 577, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 0, 0, 0, 577, 0, 0, 0, 0, 0, 0, 578, 0, 578, 0, 578, 0, 578, 578, 578, 0, - 0, 0, 0, 0, 578, 578, 578, 578, 0, 0, - 0, 578, 578, 0, 0, 0, 0, 0, 578, 578, - 578, 578, 578, 578, 0, 349, 0, 0, 0, 579, + 0, 0, 0, 0, 0, 0, 578, 578, 0, 0, + 0, 578, 578, 580, 0, 0, 0, 0, 0, 0, + 578, 578, 578, 578, 0, 0, 0, 0, 0, 579, 0, 0, 0, 0, 579, 578, 579, 579, 579, 579, 579, 579, 579, 579, 579, 579, 579, 0, 0, 0, - 578, 0, 0, 0, 579, 0, 579, 0, 579, 0, - 579, 579, 579, 0, 580, 0, 0, 0, 579, 579, - 579, 579, 0, 0, 0, 579, 579, 0, 0, 0, - 0, 0, 579, 579, 579, 579, 579, 579, 0, 0, - 0, 349, 0, 0, 349, 0, 349, 349, 0, 579, - 0, 349, 349, 0, 0, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 579, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 0, 0, 0, 581, 0, - 0, 0, 0, 0, 0, 349, 349, 0, 0, 0, - 0, 0, 0, 349, 0, 0, 349, 580, 0, 0, - 0, 349, 580, 0, 580, 580, 580, 580, 580, 580, - 580, 580, 580, 580, 580, 0, 0, 0, 0, 0, - 0, 0, 580, 0, 580, 0, 580, 0, 580, 580, - 580, 0, 0, 0, 0, 0, 0, 0, 580, 580, - 0, 0, 582, 580, 580, 0, 0, 0, 0, 0, - 0, 0, 580, 580, 580, 580, 0, 0, 0, 0, - 0, 581, 0, 0, 0, 0, 581, 580, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 0, - 0, 0, 580, 0, 0, 0, 581, 0, 581, 0, - 581, 0, 581, 581, 581, 0, 0, 0, 0, 0, - 0, 0, 581, 581, 0, 0, 583, 581, 581, 0, - 0, 0, 0, 0, 0, 0, 581, 581, 581, 581, - 0, 0, 0, 0, 0, 582, 0, 0, 0, 0, - 582, 581, 582, 582, 582, 582, 582, 582, 582, 582, - 582, 582, 582, 0, 0, 0, 581, 0, 0, 0, - 582, 0, 582, 0, 582, 0, 582, 582, 582, 0, - 0, 0, 0, 0, 0, 0, 582, 582, 0, 0, - 584, 582, 582, 0, 0, 0, 0, 0, 0, 0, - 582, 582, 582, 582, 0, 0, 0, 0, 0, 583, - 0, 0, 0, 0, 583, 582, 583, 583, 583, 583, - 583, 583, 583, 583, 583, 583, 583, 0, 0, 0, - 582, 0, 0, 0, 583, 0, 583, 0, 583, 0, - 583, 583, 583, 0, 0, 0, 0, 0, 0, 0, - 583, 583, 0, 0, 585, 583, 583, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 583, 583, 0, 0, - 0, 0, 0, 584, 0, 0, 0, 0, 584, 583, - 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, - 584, 0, 0, 0, 583, 0, 0, 0, 584, 0, - 584, 0, 584, 0, 584, 584, 584, 0, 0, 0, - 0, 0, 0, 0, 584, 584, 0, 0, 586, 584, - 584, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 584, 584, 0, 0, 0, 0, 0, 585, 0, 0, - 0, 0, 585, 584, 585, 585, 585, 585, 585, 585, - 585, 585, 585, 585, 585, 0, 0, 0, 584, 0, - 0, 0, 585, 0, 585, 0, 585, 0, 585, 585, - 585, 0, 0, 0, 0, 0, 0, 0, 0, 585, - 0, 0, 587, 585, 585, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 585, 585, 0, 0, 0, 0, - 0, 586, 0, 0, 0, 0, 586, 585, 586, 586, - 586, 586, 586, 586, 586, 586, 586, 586, 586, 0, - 0, 0, 585, 0, 0, 0, 586, 0, 586, 0, + 578, 0, 0, 0, 0, 0, 0, 579, 0, 579, + 0, 579, 0, 579, 579, 579, 0, 0, 0, 0, + 0, 0, 0, 579, 579, 0, 0, 0, 579, 579, + 581, 0, 0, 0, 0, 0, 0, 0, 0, 579, + 579, 0, 0, 0, 0, 0, 580, 0, 0, 0, + 0, 580, 579, 580, 580, 580, 580, 580, 580, 580, + 580, 580, 580, 580, 0, 0, 0, 579, 0, 0, + 0, 0, 0, 0, 580, 0, 580, 0, 580, 0, + 580, 580, 580, 0, 0, 0, 0, 0, 0, 0, + 580, 580, 0, 0, 0, 580, 580, 582, 0, 0, + 0, 0, 0, 0, 0, 0, 580, 580, 0, 0, + 0, 0, 0, 581, 0, 0, 0, 0, 581, 580, + 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, + 581, 0, 0, 0, 580, 0, 0, 0, 0, 0, + 0, 581, 0, 581, 0, 581, 0, 581, 581, 581, + 0, 0, 0, 0, 0, 0, 0, 0, 581, 0, + 0, 0, 581, 581, 583, 0, 0, 0, 0, 0, + 0, 0, 0, 581, 581, 0, 0, 0, 0, 0, + 582, 0, 0, 0, 0, 582, 581, 582, 582, 582, + 582, 582, 582, 582, 582, 582, 582, 582, 0, 0, + 0, 581, 0, 0, 0, 0, 0, 0, 582, 0, + 582, 0, 582, 0, 582, 582, 582, 0, 0, 0, + 0, 0, 0, 0, 0, 582, 0, 0, 0, 582, + 582, 584, 0, 0, 0, 0, 0, 0, 0, 0, + 582, 582, 0, 0, 0, 0, 0, 583, 0, 0, + 0, 0, 583, 582, 583, 583, 583, 583, 583, 583, + 583, 583, 583, 583, 583, 0, 0, 0, 582, 0, + 0, 0, 0, 0, 0, 583, 0, 583, 0, 583, + 0, 583, 583, 583, 0, 0, 0, 0, 0, 0, + 0, 0, 583, 0, 0, 0, 0, 583, 585, 0, + 0, 0, 0, 0, 0, 0, 0, 583, 583, 0, + 0, 0, 0, 0, 584, 0, 0, 0, 0, 584, + 583, 584, 584, 584, 584, 584, 584, 584, 584, 584, + 584, 584, 0, 0, 0, 583, 0, 0, 0, 0, + 0, 0, 584, 0, 584, 0, 584, 0, 584, 584, + 584, 0, 0, 0, 0, 0, 0, 0, 0, 584, + 0, 0, 0, 0, 584, 586, 0, 0, 0, 0, + 0, 0, 0, 0, 584, 584, 0, 0, 0, 0, + 0, 585, 0, 0, 0, 0, 585, 584, 585, 585, + 585, 585, 585, 585, 585, 585, 585, 585, 585, 0, + 0, 0, 584, 0, 0, 0, 0, 0, 0, 585, + 0, 585, 0, 585, 0, 585, 585, 585, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 585, 588, 0, 0, 0, 0, 0, 0, 0, + 0, 585, 585, 0, 0, 0, 0, 0, 586, 0, + 0, 0, 0, 586, 585, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 0, 0, 0, 585, + 0, 0, 0, 0, 0, 0, 586, 0, 586, 0, 586, 0, 586, 586, 586, 0, 0, 0, 0, 0, - 0, 0, 0, 586, 0, 0, 588, 586, 586, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 586, 0, 0, 0, 0, 0, 0, 0, 0, 0, 586, 586, - 0, 0, 0, 0, 0, 587, 0, 0, 0, 0, - 587, 586, 587, 587, 587, 587, 587, 587, 587, 587, - 587, 587, 587, 0, 0, 0, 586, 0, 0, 0, - 587, 0, 587, 0, 587, 0, 587, 587, 587, 0, - 0, 0, 0, 0, 0, 0, 0, 587, 0, 0, - 589, 0, 587, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 587, 587, 0, 0, 0, 0, 0, 588, - 0, 0, 0, 0, 588, 587, 588, 588, 588, 588, - 588, 588, 588, 588, 588, 588, 588, 0, 0, 0, - 587, 0, 0, 0, 588, 0, 588, 0, 588, 0, - 588, 588, 588, 0, 0, 0, 0, 0, 0, 0, - 0, 588, 0, 0, 590, 0, 588, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 588, 588, 0, 0, - 0, 0, 0, 589, 0, 0, 0, 0, 589, 588, - 589, 589, 589, 589, 589, 589, 589, 589, 589, 589, - 589, 0, 0, 0, 588, 0, 0, 0, 589, 0, - 589, 0, 589, 0, 589, 589, 589, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 591, 0, - 589, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 589, 589, 0, 0, 0, 0, 0, 590, 0, 0, - 0, 0, 590, 589, 590, 590, 590, 590, 590, 590, - 590, 590, 590, 590, 590, 0, 0, 0, 589, 0, - 0, 0, 590, 0, 590, 0, 590, 0, 590, 590, - 590, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 592, 0, 590, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 590, 590, 0, 0, 0, 0, - 0, 591, 0, 0, 0, 0, 591, 590, 591, 591, - 591, 591, 591, 591, 591, 591, 591, 591, 591, 0, - 0, 0, 590, 0, 0, 0, 591, 0, 591, 0, - 591, 0, 591, 591, 591, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 591, 349, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 591, - 0, 0, 0, 0, 0, 592, 0, 0, 0, 0, - 592, 591, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 0, 0, 349, 591, 0, 0, 0, - 592, 0, 592, 0, 592, 0, 592, 592, 592, 0, - 0, 0, 406, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 592, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 592, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 592, 0, 0, 406, 0, - 0, 0, 0, 0, 349, 0, 0, 0, 0, 0, - 592, 0, 349, 0, 349, 0, 349, 0, 0, 349, - 0, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 0, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 0, 0, 349, - 0, 349, 0, 349, 0, 342, 349, 406, 406, 406, - 406, 349, 406, 0, 406, 406, 0, 406, 406, 406, - 406, 406, 0, 406, 406, 406, 406, 0, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 0, 0, 0, 0, 342, 0, 406, 0, 0, 406, - 0, 0, 0, 0, 406, 0, 0, 349, 349, 349, - 349, 349, 0, 0, 0, 349, 349, 0, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 0, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 0, 0, 93, 0, 0, 0, 349, 0, 0, - 349, 94, 95, 96, 97, 349, 0, 98, 99, 0, - 100, 101, 102, 103, 104, 105, 106, 0, 0, 0, - 0, 0, 107, 0, 108, 109, 110, 111, 112, 113, - 0, 0, 114, 0, 0, 0, 115, 116, 0, 117, - 118, 119, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 120, 0, 121, 0, 122, 123, 0, 0, 124, - 0, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 0, 137, 0, 0, 138, 139, 0, - 0, 140, 141, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 142, 0, 0, 0, 143, 0, 0, 0, 0, 144, - 145, 146, 147, 148, 0, 0, 0, 149, 0, 150, - 0, 0, 0, 0, 0, 151, 152, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 289, 0, 0, 0, - 153, 154, 155, 156, 94, 95, 96, 97, 0, 0, - 98, 99, 0, 100, 101, 102, 103, 104, 105, 106, - 0, 0, 0, 0, 0, 107, 0, 108, 109, 110, - 111, 112, 113, 0, 0, 114, 0, 0, 0, 115, - 116, 0, 117, 118, 119, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 120, 0, 121, 0, 122, 123, - 0, 0, 124, 0, 125, 126, 127, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 0, 137, 0, 0, - 138, 139, 0, 0, 140, 141, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 142, 0, 0, 0, 143, 0, 0, - 0, 0, 144, 145, 146, 147, 148, 0, 0, 0, - 149, 0, 150, 0, 0, 0, 0, 0, 151, 152, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 530, - 0, 0, 0, 153, 154, 155, 156, 94, 95, 96, - 97, 0, 0, 98, 99, 0, 100, 101, 102, 103, - 104, 105, 106, 0, 0, 0, 0, 0, 107, 0, - 108, 109, 110, 111, 112, 113, 0, 0, 114, 0, - 0, 0, 115, 116, 0, 117, 118, 119, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 120, 0, 121, - 0, 122, 123, 0, 0, 124, 0, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 0, - 137, 0, 0, 138, 139, 0, 0, 140, 141, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 142, 0, 0, 0, - 143, 0, 0, 0, 0, 144, 145, 146, 147, 148, - 0, 0, 0, 149, 0, 150, 0, 0, 0, 0, - 0, 151, 152, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 918, 0, 0, 0, 153, 154, 155, 156, - 918, 918, 918, 918, 0, 0, 918, 918, 0, 918, - 918, 918, 918, 918, 918, 918, 0, 0, 0, 0, - 0, 918, 0, 918, 918, 918, 918, 918, 918, 0, - 0, 918, 0, 0, 0, 918, 918, 0, 918, 918, - 918, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 918, 0, 918, 0, 918, 918, 0, 0, 918, 0, - 918, 918, 918, 918, 918, 918, 918, 918, 918, 918, - 918, 918, 0, 918, 0, 0, 918, 918, 0, 0, - 918, 918, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 918, - 0, 0, 0, 918, 0, 0, 0, 0, 918, 918, - 918, 918, 918, 0, 0, 0, 918, 0, 918, 0, - 0, 0, 0, 0, 918, 918, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 782, 0, 0, 0, 918, - 918, 918, 918, 782, 782, 782, 782, 0, 0, 782, - 782, 0, 782, 782, 782, 782, 782, 782, 782, 0, - 0, 0, 0, 0, 782, 0, 782, 782, 782, 782, - 782, 782, 0, 0, 782, 0, 0, 0, 782, 782, - 0, 782, 782, 782, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 782, 0, 782, 0, 782, 782, 0, - 0, 782, 0, 782, 782, 782, 782, 782, 782, 782, - 782, 782, 782, 782, 782, 0, 782, 0, 0, 782, - 782, 0, 0, 782, 782, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 588, 0, 0, 0, 0, + 588, 586, 588, 588, 588, 588, 588, 588, 588, 588, + 588, 588, 588, 0, 0, 0, 586, 0, 0, 0, + 0, 0, 0, 588, 0, 588, 0, 588, 0, 588, + 588, 588, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 30, 0, 588, 0, 0, 0, 0, + 0, 31, 32, 33, 34, 0, 588, 35, 36, 0, + 37, 38, 39, 40, 41, 42, 43, 0, 588, 0, + 0, 0, 44, 0, 45, 46, 47, 48, 49, 50, + 0, 0, 51, 588, 0, 0, 52, 53, 0, 54, + 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 57, 0, 58, 0, 59, 60, 0, 0, 61, + 0, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 0, 74, 0, 0, 75, 76, 0, + 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 80, 81, + 0, 0, 0, 82, 0, 0, 0, 83, 0, 0, + 0, 0, 84, 85, 86, 87, 88, 0, 0, 0, + 89, 0, 90, 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 782, 0, 0, 0, 782, 0, 0, 0, - 0, 782, 782, 782, 782, 782, 0, 0, 0, 782, - 0, 782, 0, 0, 0, 0, 0, 782, 782, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, + 0, 0, 0, 93, 94, 95, 96, 31, 32, 33, + 34, 0, 0, 35, 36, 0, 37, 38, 39, 40, + 41, 42, 43, 0, 0, 0, 0, 0, 44, 0, + 45, 46, 47, 48, 49, 50, 0, 0, 51, 0, + 0, 0, 52, 53, 0, 54, 55, 56, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 57, 0, 58, + 0, 59, 60, 0, 0, 61, 0, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 0, + 74, 0, 0, 75, 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 688, 0, - 0, 0, 782, 782, 782, 782, 94, 95, 0, 97, - 0, 0, 98, 278, 0, 0, 0, 102, 103, 104, - 0, 106, 0, 0, 95, 0, 97, 107, 0, 98, - 109, 0, 0, 0, 102, 0, 0, 114, 106, 0, - 0, 0, 116, 0, 117, 118, 119, 109, 0, 0, - 0, 0, 0, 0, 114, 0, 0, 0, 121, 116, - 122, 123, 0, 119, 124, 0, 0, 126, 0, 128, - 0, 130, 131, 132, 279, 121, 135, 122, 0, 0, - 0, 124, 0, 139, 0, 0, 140, 141, 0, 131, - 132, 0, 0, 135, 0, 0, 255, 0, 0, 0, - 0, 0, 0, 0, 0, 505, 689, 0, 0, 143, - 0, 0, 0, 0, 0, 145, 146, 147, 148, 0, - 0, 0, 149, 0, 150, 0, 0, 0, 0, 0, - 151, 152, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 80, 81, 0, 0, 0, 82, + 0, 0, 0, 83, 0, 0, 0, 0, 84, 85, + 86, 87, 88, 0, 0, 0, 89, 0, 90, 0, + 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 688, 0, 0, 0, 153, 322, 155, 156, 94, - 95, 0, 97, 0, 0, 98, 278, 0, 0, 0, - 102, 103, 104, 340, 106, 0, 0, 0, 0, 0, - 107, 0, 59, 109, 0, 0, 0, 0, 0, 0, - 114, 0, 0, 0, 0, 116, 0, 117, 118, 119, - 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, - 0, 121, 0, 122, 123, 845, 0, 124, 61, 0, - 126, 0, 128, 63, 130, 131, 132, 279, 64, 135, - 65, 66, 67, 68, 0, 0, 139, 0, 69, 140, - 141, 0, 70, 0, 0, 0, 1201, 0, 0, 0, - 0, 0, 0, 0, 71, 0, 0, 72, 505, 73, - 0, 0, 143, 0, 0, 0, 0, 0, 145, 146, - 147, 148, 0, 0, 0, 149, 0, 150, 0, 0, - 74, 0, 0, 151, 152, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 486, 0, 0, 0, 93, + 94, 95, 96, 31, 32, 33, 34, 0, 0, 35, + 36, 0, 37, 38, 39, 40, 41, 42, 43, 0, + 0, 0, 0, 0, 44, 0, 45, 46, 47, 48, + 49, 50, 0, 0, 51, 0, 0, 0, 52, 53, + 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 57, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 0, 74, 0, 0, 75, + 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 82, 0, 0, 0, 83, + 0, 0, 0, 0, 84, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 658, 0, 0, 0, 153, 322, - 155, 156, 94, 95, 0, 97, 0, 0, 98, 278, - 0, 0, 0, 102, 103, 104, 0, 106, 0, 0, - 0, 0, 0, 107, 0, 1202, 109, 0, 0, 0, - 0, 0, 0, 114, 0, 0, 0, 0, 116, 0, - 117, 118, 119, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 121, 0, 122, 123, 0, 0, - 124, 0, 0, 126, 0, 128, 0, 130, 131, 132, - 279, 0, 135, 0, 0, 137, 0, 0, 0, 139, - 0, 0, 140, 141, 0, 0, 0, 0, 0, 0, + 0, 917, 0, 0, 0, 93, 94, 95, 96, 917, + 917, 917, 917, 0, 0, 917, 917, 0, 917, 917, + 917, 917, 917, 917, 917, 0, 0, 0, 0, 0, + 917, 0, 917, 917, 917, 917, 917, 917, 0, 0, + 917, 0, 0, 0, 917, 917, 0, 917, 917, 917, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 917, + 0, 917, 0, 917, 917, 0, 0, 917, 0, 917, + 917, 917, 917, 917, 917, 917, 917, 917, 917, 917, + 917, 0, 917, 0, 0, 917, 917, 0, 0, 917, + 917, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 917, 917, 917, 0, 0, + 0, 917, 0, 0, 0, 917, 0, 0, 0, 0, + 917, 917, 917, 917, 917, 0, 0, 0, 917, 0, + 917, 0, 0, 0, 0, 0, 917, 917, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 143, 0, 0, 0, 0, - 0, 145, 146, 147, 148, 0, 0, 0, 149, 0, - 150, 0, 0, 0, 0, 0, 151, 152, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 781, 0, 0, + 0, 917, 917, 917, 917, 781, 781, 781, 781, 0, + 0, 781, 781, 0, 781, 781, 781, 781, 781, 781, + 781, 0, 0, 0, 0, 0, 781, 0, 781, 781, + 781, 781, 781, 781, 0, 0, 781, 0, 0, 0, + 781, 781, 0, 781, 781, 781, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 781, 0, 781, 0, 781, + 781, 0, 0, 781, 0, 781, 781, 781, 781, 781, + 781, 781, 781, 781, 781, 781, 781, 0, 781, 0, + 0, 781, 781, 0, 0, 781, 781, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 688, 0, 0, - 0, 153, 322, 155, 156, 94, 95, 0, 97, 0, - 0, 98, 278, 0, 0, 0, 102, 103, 104, 0, - 106, 0, 0, 0, 0, 0, 107, 0, 59, 109, - 0, 0, 0, 0, 0, 0, 114, 0, 0, 0, - 0, 116, 0, 117, 118, 119, 0, 0, 0, 0, - 0, 60, 0, 0, 0, 0, 0, 121, 0, 122, - 123, 0, 0, 124, 61, 0, 126, 0, 128, 63, - 130, 131, 132, 279, 64, 135, 65, 66, 67, 68, - 0, 0, 139, 0, 69, 140, 141, 0, 70, 0, + 0, 781, 781, 781, 0, 0, 0, 781, 0, 0, + 0, 781, 0, 0, 0, 0, 781, 781, 781, 781, + 781, 0, 0, 0, 781, 0, 781, 0, 0, 0, + 0, 0, 781, 781, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 71, 0, 0, 72, 505, 73, 0, 0, 143, 0, - 0, 0, 0, 0, 145, 146, 147, 148, 0, 0, - 0, 149, 0, 150, 0, 0, 74, 0, 0, 151, - 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 650, 0, 0, 0, 781, 781, 781, + 781, 31, 32, 0, 34, 0, 0, 35, 212, 0, + 663, 0, 39, 40, 41, 0, 43, 0, 0, 32, + 0, 34, 44, 0, 35, 46, 0, 0, 0, 39, + 0, 0, 51, 43, 0, 0, 0, 53, 0, 54, + 55, 56, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 58, 53, 59, 60, 0, 56, 61, + 0, 0, 63, 0, 65, 0, 67, 68, 69, 213, + 58, 72, 59, 0, 0, 0, 61, 0, 76, 0, + 0, 77, 78, 0, 68, 69, 0, 0, 72, 0, + 0, 664, 0, 0, 0, 0, 0, 79, 80, 81, + 0, 0, 0, 451, 651, 0, 0, 83, 0, 0, + 0, 0, 0, 85, 86, 87, 88, 0, 0, 0, + 89, 0, 90, 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 834, 0, 0, 0, 153, 322, 155, 156, 94, 95, - 0, 97, 0, 0, 98, 278, 0, 0, 0, 102, - 103, 104, 0, 106, 0, 0, 0, 0, 0, 107, - 0, 1217, 109, 0, 0, 0, 0, 0, 0, 114, - 0, 0, 0, 0, 116, 0, 117, 118, 119, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 650, + 0, 0, 0, 93, 256, 95, 96, 31, 32, 0, + 34, 0, 0, 35, 212, 0, 789, 0, 39, 40, + 41, 665, 43, 0, 0, 32, 0, 34, 44, 0, + 35, 46, 0, 0, 0, 39, 0, 0, 51, 43, + 0, 0, 0, 53, 0, 54, 55, 56, 46, 0, + 0, 0, 0, 0, 0, 51, 0, 0, 0, 58, + 53, 59, 60, 816, 56, 61, 0, 0, 63, 0, + 65, 0, 67, 68, 69, 213, 58, 72, 59, 0, + 0, 0, 61, 0, 76, 0, 0, 77, 78, 0, + 68, 69, 0, 0, 72, 0, 0, 274, 0, 0, + 0, 0, 0, 79, 80, 81, 0, 0, 0, 451, + 0, 0, 0, 83, 0, 0, 0, 0, 0, 85, + 86, 87, 88, 0, 0, 0, 89, 0, 90, 0, + 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 121, 0, 122, 123, 0, 0, 124, 0, 0, 126, - 0, 128, 0, 130, 131, 132, 279, 0, 135, 0, - 0, 0, 0, 0, 0, 139, 0, 0, 140, 141, + 0, 0, 0, 0, 0, 620, 0, 0, 0, 93, + 256, 95, 96, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 926, 0, 39, 40, 41, 305, 43, 0, + 0, 32, 0, 34, 44, 0, 35, 46, 0, 0, + 0, 39, 0, 0, 51, 43, 0, 0, 0, 53, + 0, 54, 55, 56, 46, 0, 0, 0, 0, 0, + 0, 51, 0, 0, 0, 58, 53, 59, 60, 0, + 56, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 58, 72, 59, 0, 74, 0, 61, 0, + 76, 0, 0, 77, 78, 0, 68, 69, 0, 0, + 72, 0, 0, 274, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 0, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 650, 0, 0, 0, 93, 256, 95, 96, 31, + 32, 0, 34, 0, 0, 35, 212, 0, 1057, 0, + 39, 40, 41, 305, 43, 0, 0, 32, 0, 34, + 44, 0, 35, 46, 0, 0, 0, 39, 0, 0, + 51, 43, 0, 0, 0, 53, 0, 54, 55, 56, + 46, 0, 0, 0, 0, 0, 0, 51, 0, 0, + 0, 58, 53, 59, 60, 0, 56, 61, 0, 0, + 63, 0, 65, 0, 67, 68, 69, 213, 58, 72, + 59, 0, 0, 0, 61, 0, 76, 0, 0, 77, + 78, 0, 68, 69, 0, 0, 72, 0, 0, 274, + 0, 0, 0, 0, 0, 79, 80, 81, 0, 0, + 0, 451, 0, 0, 0, 83, 0, 0, 0, 0, + 0, 85, 86, 87, 88, 0, 0, 0, 89, 0, + 90, 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 143, 0, 0, 0, 0, 0, 145, 146, 147, - 148, 0, 0, 0, 149, 0, 150, 0, 0, 0, - 0, 0, 151, 152, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 804, 0, 0, + 0, 93, 256, 95, 96, 31, 32, 0, 34, 0, + 0, 35, 212, 0, 0, 0, 39, 40, 41, 305, + 43, 0, 0, 32, 0, 34, 44, 0, 35, 46, + 0, 0, 0, 39, 0, 0, 51, 43, 0, 0, + 0, 53, 0, 54, 55, 56, 46, 0, 0, 0, + 0, 0, 0, 51, 0, 0, 0, 58, 53, 59, + 60, 0, 56, 61, 0, 0, 63, 0, 65, 0, + 67, 68, 69, 213, 58, 72, 59, 0, 0, 0, + 61, 0, 76, 0, 0, 77, 78, 0, 68, 69, + 0, 0, 72, 0, 0, 274, 0, 0, 0, 0, + 0, 79, 80, 81, 0, 0, 0, 0, 0, 0, + 0, 83, 0, 0, 0, 0, 0, 85, 86, 87, + 88, 0, 0, 0, 89, 0, 90, 0, 0, 0, + 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 617, 0, 0, 0, 153, 322, 155, - 156, 617, 617, 0, 617, 0, 0, 617, 617, 0, - 0, 0, 617, 617, 617, 0, 617, 0, 0, 95, - 0, 97, 617, 0, 98, 617, 0, 0, 0, 102, - 0, 0, 617, 106, 0, 0, 0, 617, 0, 617, - 617, 617, 109, 0, 0, 0, 0, 0, 0, 114, - 0, 0, 0, 617, 116, 617, 617, 0, 119, 617, - 0, 0, 617, 0, 617, 0, 617, 617, 617, 617, - 121, 617, 122, 0, 0, 0, 124, 0, 617, 0, - 0, 617, 617, 0, 131, 132, 0, 0, 135, 0, - 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 617, 0, 0, 0, 0, 0, - 617, 617, 617, 617, 0, 0, 0, 617, 0, 617, - 0, 0, 0, 0, 0, 617, 617, 0, 0, 0, - 0, 0, 0, 94, 95, 0, 97, 0, 0, 98, - 278, 0, 0, 0, 102, 103, 104, 0, 106, 0, - 617, 617, 617, 617, 107, 0, 0, 109, 0, 0, - 0, 0, 0, 0, 114, 0, 0, 0, 342, 116, - 0, 117, 118, 119, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 121, 0, 122, 123, 0, - 0, 124, 0, 0, 126, 0, 128, 0, 130, 131, - 132, 279, 0, 135, 0, 0, 0, 0, 0, 0, - 139, 0, 0, 140, 141, 0, 0, 0, 0, 0, + 0, 0, 0, 613, 0, 0, 0, 93, 256, 95, + 96, 613, 613, 0, 613, 0, 0, 613, 613, 0, + 0, 0, 613, 613, 613, 275, 613, 0, 0, 32, + 0, 34, 613, 0, 35, 613, 0, 0, 0, 39, + 0, 0, 613, 43, 0, 0, 0, 613, 0, 613, + 613, 613, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 613, 53, 613, 613, 0, 56, 613, + 0, 0, 613, 0, 613, 0, 613, 613, 613, 613, + 58, 613, 59, 0, 0, 0, 61, 0, 613, 0, + 0, 613, 613, 0, 68, 69, 0, 0, 72, 0, + 0, 274, 0, 0, 0, 0, 0, 613, 613, 613, + 0, 0, 0, 0, 0, 0, 0, 613, 0, 0, + 0, 0, 0, 613, 613, 613, 613, 0, 0, 0, + 613, 0, 613, 0, 0, 0, 0, 0, 613, 613, + 0, 0, 0, 0, 0, 0, 31, 32, 0, 34, + 0, 0, 35, 212, 0, 0, 0, 39, 40, 41, + 0, 43, 0, 613, 613, 613, 613, 44, 0, 0, + 46, 0, 0, 0, 0, 0, 0, 51, 0, 0, + 0, 281, 53, 0, 54, 55, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 58, 0, + 59, 60, 0, 0, 61, 0, 0, 63, 0, 65, + 0, 67, 68, 69, 213, 0, 72, 0, 0, 0, + 0, 0, 0, 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 675, 909, 0, 0, 143, 0, 0, 0, - 0, 0, 145, 146, 147, 148, 0, 0, 0, 149, - 0, 150, 0, 0, 0, 0, 0, 151, 152, 0, - 0, 0, 0, 0, 0, 94, 95, 0, 97, 0, - 0, 98, 278, 0, 0, 0, 102, 103, 104, 0, - 106, 0, 153, 676, 155, 156, 107, 0, 30, 109, - 30, 0, 677, 0, 0, 0, 114, 0, 0, 0, - 0, 116, 0, 117, 118, 119, 0, 0, 0, 0, - 0, 30, 0, 0, 0, 0, 0, 121, 0, 122, - 123, 0, 0, 124, 30, 0, 126, 0, 128, 30, - 130, 131, 132, 279, 30, 135, 30, 30, 30, 30, - 0, 0, 139, 0, 30, 140, 141, 0, 30, 0, + 0, 0, 79, 80, 81, 0, 0, 0, 637, 883, + 0, 0, 83, 0, 0, 0, 0, 0, 85, 86, + 87, 88, 0, 0, 0, 89, 0, 90, 0, 0, + 0, 0, 0, 91, 92, 0, 0, 0, 0, 0, + 0, 31, 32, 0, 34, 0, 0, 35, 212, 0, + 0, 0, 39, 40, 41, 0, 43, 0, 93, 638, + 95, 96, 44, 0, 0, 46, 0, 0, 639, 0, + 0, 0, 51, 0, 0, 0, 0, 53, 0, 54, + 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 58, 0, 59, 60, 0, 0, 61, + 0, 0, 63, 0, 65, 0, 67, 68, 69, 213, + 0, 72, 0, 0, 0, 0, 0, 0, 76, 0, + 0, 77, 78, 0, 0, 389, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 80, 81, + 0, 0, 0, 637, 0, 0, 0, 83, 390, 0, + 0, 0, 0, 85, 86, 87, 88, 0, 0, 0, + 89, 391, 90, 0, 0, 0, 393, 0, 91, 92, + 0, 394, 0, 395, 396, 397, 398, 0, 0, 0, + 0, 399, 0, 0, 0, 400, 0, 0, 0, 1212, + 434, 0, 344, 93, 638, 95, 96, 401, 31, 32, + 402, 34, 403, 639, 35, 212, 0, 0, 0, 39, + 40, 41, 0, 43, 0, 0, 0, 0, 0, 44, + 0, 0, 46, 404, 0, 0, 0, 0, 344, 51, + 0, 0, 0, 0, 53, 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 30, 0, 0, 30, 675, 30, 0, 0, 143, 0, - 0, 0, 0, 0, 145, 146, 147, 148, 0, 0, - 0, 149, 0, 150, 0, 0, 30, 0, 0, 151, - 152, 30, 30, 0, 0, 0, 0, 349, 0, 0, + 58, 0, 59, 60, 0, 0, 61, 0, 0, 63, + 0, 65, 0, 67, 68, 69, 213, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 488, 0, 0, 153, 676, 155, 156, 0, 94, - 95, 0, 97, 0, 677, 98, 278, 0, 0, 0, - 102, 103, 104, 349, 106, 0, 0, 0, 0, 0, - 107, 0, 0, 109, 0, 0, 0, 0, 0, 0, - 114, 0, 0, 0, 0, 116, 0, 117, 118, 119, + 0, 1213, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 80, 81, 0, 0, 0, + 344, 344, 344, 344, 83, 0, 0, 344, 344, 0, + 0, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 0, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, + 344, 344, 344, 0, 0, 0, 0, 0, 0, 344, + 93, 435, 344, 47, 0, 0, 0, 47, 0, 47, + 0, 0, 47, 0, 47, 47, 0, 47, 0, 47, + 0, 47, 0, 47, 47, 47, 47, 0, 0, 47, + 47, 0, 0, 0, 0, 47, 0, 47, 47, 47, + 0, 0, 47, 0, 47, 0, 47, 0, 0, 47, + 0, 47, 47, 47, 47, 0, 0, 0, 47, 47, + 47, 0, 0, 47, 47, 47, 0, 0, 0, 0, + 0, 0, 47, 47, 0, 47, 47, 0, 47, 47, + 47, 0, 0, 0, 47, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 47, 0, 0, 0, 47, 0, + 47, 47, 0, 47, 0, 47, 47, 0, 47, 80, + 47, 0, 47, 0, 47, 47, 47, 47, 47, 0, + 47, 47, 0, 0, 0, 0, 47, 0, 47, 47, + 47, 0, 0, 47, 0, 47, 0, 47, 0, 0, + 47, 0, 47, 47, 47, 47, 0, 0, 0, 47, + 47, 47, 0, 0, 47, 47, 47, 0, 0, 47, + 0, 0, 0, 47, 47, 0, 47, 47, 0, 47, + 47, 47, 0, 0, 0, 47, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 47, 0, 0, 0, 47, + 0, 47, 47, 0, 47, 0, 47, 47, 0, 47, + 81, 47, 0, 47, 0, 47, 47, 47, 47, 47, + 0, 47, 47, 0, 0, 0, 0, 47, 0, 47, + 47, 47, 0, 0, 47, 0, 47, 0, 47, 0, + 0, 47, 0, 47, 47, 47, 47, 0, 0, 0, + 47, 47, 47, 0, 0, 47, 47, 47, 0, 0, + 47, 0, 0, 0, 47, 47, 0, 47, 47, 0, + 47, 47, 47, 0, 0, 0, 47, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 47, 0, 0, 0, + 47, 0, 47, 47, 0, 47, 0, 47, 47, 0, + 47, 103, 47, 0, 47, 0, 47, 47, 47, 47, + 47, 0, 47, 47, 0, 0, 0, 0, 47, 0, + 47, 47, 47, 0, 0, 47, 0, 47, 0, 47, + 0, 0, 47, 0, 47, 47, 47, 47, 0, 0, + 0, 47, 47, 47, 0, 0, 47, 47, 47, 0, + 0, 47, 0, 0, 0, 47, 47, 0, 47, 47, + 0, 47, 47, 47, 0, 0, 0, 47, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, + 0, 47, 0, 47, 47, 0, 47, 0, 47, 47, + 0, 47, 104, 47, 0, 47, 0, 47, 47, 47, + 47, 47, 0, 47, 47, 0, 0, 0, 0, 47, + 0, 47, 47, 47, 0, 0, 47, 0, 47, 0, + 47, 0, 0, 47, 0, 47, 47, 47, 47, 0, + 0, 0, 47, 47, 47, 0, 0, 47, 47, 47, + 0, 0, 47, 0, 0, 0, 47, 47, 0, 47, + 47, 0, 47, 47, 47, 0, 0, 0, 47, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, + 0, 0, 47, 0, 47, 47, 0, 47, 0, 47, + 47, 0, 47, 225, 47, 0, 47, 0, 47, 47, + 47, 47, 0, 0, 47, 47, 0, 0, 0, 0, + 47, 0, 47, 47, 47, 0, 0, 47, 0, 47, + 0, 47, 344, 0, 47, 0, 47, 47, 47, 47, + 0, 0, 0, 47, 47, 47, 0, 0, 47, 47, + 47, 0, 0, 47, 0, 344, 0, 47, 47, 0, + 47, 47, 0, 47, 47, 47, 0, 0, 344, 47, + 0, 0, 0, 344, 0, 0, 344, 0, 344, 0, + 344, 344, 344, 344, 0, 0, 47, 0, 344, 0, + 0, 0, 344, 0, 226, 0, 344, 0, 0, 0, + 0, 365, 0, 0, 344, 0, 0, 344, 0, 344, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 121, 0, 122, 123, 0, 0, 124, 0, 0, - 126, 0, 128, 0, 130, 131, 132, 279, 0, 135, + 0, 0, 0, 0, 365, 0, 0, 0, 344, 0, + 344, 389, 0, 0, 0, 0, 0, 365, 0, 344, + 0, 276, 365, 344, 47, 242, 0, 365, 0, 365, + 365, 365, 365, 0, 390, 0, 344, 365, 0, 0, + 0, 365, 0, 0, 0, 365, 0, 391, 0, 0, + 0, 0, 393, 365, 0, 0, 365, 394, 365, 395, + 396, 397, 398, 31, 32, 0, 34, 399, 344, 35, + 212, 400, 0, 0, 39, 40, 41, 0, 43, 365, + 0, 0, 0, 401, 44, 0, 402, 46, 403, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 521, 0, 0, 0, 404, + 0, 0, 522, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 0, 0, 0, 365, 0, 0, + 523, 0, 0, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 0, 0, 1226, 0, 83, + 811, 0, 524, 0, 0, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 31, 32, + 0, 34, 0, 0, 35, 212, 0, 0, 0, 39, + 40, 41, 0, 43, 0, 93, 411, 95, 96, 44, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 0, 53, 0, 54, 55, 56, 0, + 521, 0, 0, 0, 0, 0, 0, 522, 0, 0, + 58, 0, 59, 60, 0, 0, 61, 0, 0, 63, + 0, 65, 0, 67, 68, 69, 213, 0, 72, 0, + 0, 0, 0, 0, 0, 523, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 349, 349, 349, 349, 0, 0, 0, 349, - 349, 0, 0, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 143, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 0, 0, 0, 0, 0, - 0, 349, 0, 0, 349, 0, 0, 0, 0, 0, - 0, 55, 0, 55, 0, 55, 0, 55, 153, 489, - 55, 0, 55, 55, 0, 55, 0, 55, 0, 55, - 0, 55, 55, 55, 55, 0, 0, 55, 55, 0, - 0, 0, 0, 55, 55, 55, 55, 55, 0, 0, - 55, 55, 55, 0, 55, 0, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, - 0, 55, 55, 55, 0, 55, 0, 0, 0, 0, - 55, 55, 0, 55, 55, 0, 55, 55, 55, 0, - 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, - 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, - 54, 0, 0, 55, 54, 0, 54, 0, 0, 54, - 0, 54, 54, 0, 54, 0, 54, 0, 54, 0, - 54, 54, 54, 54, 0, 0, 54, 54, 0, 0, - 0, 0, 54, 0, 54, 54, 54, 0, 0, 54, - 0, 54, 0, 54, 55, 0, 54, 0, 54, 54, - 54, 54, 0, 0, 0, 54, 54, 54, 0, 0, - 54, 54, 54, 0, 0, 0, 0, 0, 0, 54, - 54, 0, 54, 54, 54, 54, 54, 54, 54, 0, - 54, 54, 0, 54, 0, 54, 54, 0, 54, 0, - 54, 0, 54, 0, 54, 54, 54, 54, 54, 0, - 54, 54, 0, 85, 0, 0, 54, 0, 54, 54, - 54, 0, 54, 54, 0, 54, 0, 54, 0, 0, - 54, 0, 54, 54, 54, 54, 0, 0, 0, 54, - 54, 54, 0, 0, 54, 54, 54, 0, 0, 0, - 0, 0, 0, 54, 54, 0, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 0, 54, 0, 54, - 54, 0, 54, 0, 54, 0, 54, 0, 54, 54, - 54, 54, 54, 0, 54, 54, 0, 86, 0, 0, - 54, 0, 54, 54, 54, 0, 54, 54, 0, 54, - 0, 54, 0, 0, 54, 0, 54, 54, 54, 54, - 0, 0, 0, 54, 54, 54, 0, 0, 54, 54, - 54, 0, 0, 0, 0, 0, 0, 54, 54, 0, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 0, 54, 0, 54, 54, 0, 54, 0, 54, 0, - 54, 0, 54, 54, 54, 54, 54, 0, 54, 54, - 0, 108, 0, 0, 54, 0, 54, 54, 54, 0, - 54, 54, 0, 54, 0, 54, 0, 0, 54, 0, - 54, 54, 54, 54, 0, 0, 0, 54, 54, 54, - 0, 0, 54, 54, 54, 0, 0, 0, 0, 0, - 0, 54, 54, 0, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 0, 54, 0, 54, 54, 0, - 54, 0, 54, 0, 54, 0, 54, 54, 54, 54, - 54, 0, 54, 54, 0, 109, 0, 0, 54, 0, - 54, 54, 54, 0, 54, 54, 0, 54, 0, 54, - 0, 0, 54, 0, 54, 54, 54, 54, 0, 0, - 0, 54, 54, 54, 0, 0, 54, 54, 54, 0, - 0, 0, 0, 0, 0, 54, 54, 0, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 0, 54, - 0, 54, 54, 0, 54, 0, 54, 0, 54, 0, - 54, 54, 54, 54, 54, 0, 54, 54, 0, 230, - 0, 0, 54, 0, 54, 54, 54, 0, 0, 54, - 0, 54, 0, 54, 370, 0, 54, 0, 54, 54, - 54, 54, 0, 0, 0, 54, 54, 54, 0, 0, - 54, 54, 54, 0, 0, 0, 0, 370, 0, 54, - 54, 0, 54, 54, 0, 54, 54, 54, 0, 54, - 370, 54, 0, 0, 0, 370, 0, 0, 247, 0, - 370, 0, 370, 370, 370, 370, 0, 0, 54, 0, - 370, 0, 0, 231, 370, 0, 0, 0, 370, 0, - 0, 0, 0, 0, 0, 0, 370, 0, 0, 370, - 0, 370, 0, 94, 95, 0, 97, 0, 0, 98, - 278, 0, 0, 0, 102, 103, 104, 0, 106, 0, - 0, 95, 370, 97, 107, 0, 98, 109, 0, 0, - 0, 102, 0, 54, 114, 106, 0, 0, 0, 116, - 0, 117, 118, 119, 109, 562, 0, 0, 0, 0, - 0, 114, 563, 0, 0, 121, 116, 122, 123, 0, - 119, 124, 0, 0, 126, 0, 128, 0, 130, 131, - 132, 279, 121, 135, 122, 0, 0, 370, 124, 0, - 564, 0, 0, 140, 141, 0, 131, 132, 0, 0, - 135, 0, 0, 255, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 143, 840, 0, 565, - 0, 0, 145, 146, 147, 148, 0, 0, 0, 149, - 0, 150, 0, 0, 0, 0, 0, 151, 152, 0, - 0, 0, 0, 0, 0, 94, 95, 0, 97, 0, - 0, 98, 278, 0, 0, 0, 102, 103, 104, 0, - 106, 0, 153, 465, 155, 156, 107, 0, 54, 109, - 0, 0, 0, 0, 0, 0, 114, 0, 0, 0, - 87, 116, 0, 117, 118, 119, 0, 562, 0, 0, - 0, 54, 0, 0, 563, 0, 0, 121, 0, 122, - 123, 0, 0, 124, 54, 0, 126, 0, 128, 54, - 130, 131, 132, 279, 54, 135, 54, 54, 54, 54, - 0, 0, 564, 0, 54, 140, 141, 0, 54, 0, + 0, 0, 0, 0, 79, 80, 81, 0, 0, 0, + 0, 0, 0, 0, 83, 0, 0, 524, 0, 0, + 85, 86, 87, 88, 0, 0, 0, 89, 0, 90, + 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, + 0, 0, 0, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 0, 0, 39, 40, 41, 0, 43, 0, + 93, 411, 95, 96, 44, 0, 0, 46, 0, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 521, 0, 0, 0, 0, + 0, 0, 522, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 0, 0, 0, 0, 0, 0, + 523, 0, 0, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 0, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 31, 32, + 0, 34, 0, 0, 35, 212, 0, 0, 0, 39, + 40, 41, 0, 43, 0, 93, 411, 95, 96, 44, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 0, 53, 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 54, 0, 0, 54, 0, 54, 0, 0, 143, 0, - 0, 565, 0, 0, 145, 146, 147, 148, 0, 0, - 0, 149, 0, 150, 0, 0, 54, 54, 54, 151, - 152, 212, 0, 0, 0, 0, 0, 94, 95, 0, - 97, 0, 0, 98, 278, 0, 0, 0, 102, 103, - 104, 0, 106, 0, 153, 465, 155, 156, 107, 0, - 54, 109, 0, 0, 0, 0, 0, 0, 114, 0, - 0, 0, 0, 116, 0, 117, 118, 119, 0, 562, - 0, 0, 0, 54, 0, 0, 563, 0, 0, 121, - 0, 122, 123, 0, 0, 124, 54, 0, 126, 0, - 128, 54, 130, 131, 132, 279, 54, 135, 54, 54, - 54, 54, 0, 0, 564, 0, 54, 140, 141, 0, - 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 54, 0, 54, 0, 0, - 143, 0, 0, 0, 0, 0, 145, 146, 147, 148, - 0, 0, 0, 149, 0, 150, 0, 0, 54, 54, - 54, 151, 152, 214, 0, 0, 0, 0, 0, 94, - 95, 0, 97, 0, 0, 98, 278, 0, 0, 0, - 102, 103, 104, 0, 106, 0, 153, 465, 155, 156, - 107, 0, 0, 109, 0, 0, 0, 0, 0, 0, - 114, 0, 0, 0, 0, 116, 0, 117, 118, 119, + 58, 0, 59, 60, 0, 0, 61, 0, 0, 63, + 0, 65, 0, 67, 68, 69, 213, 0, 72, 0, + 0, 74, 0, 0, 0, 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 121, 0, 122, 123, 0, 0, 124, 0, 0, - 126, 0, 128, 0, 130, 131, 132, 279, 0, 135, - 0, 0, 137, 0, 0, 0, 139, 0, 0, 140, - 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 80, 81, 0, 0, 0, + 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, + 85, 86, 87, 88, 0, 0, 0, 89, 0, 90, + 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, + 0, 0, 0, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 0, 0, 39, 40, 41, 0, 43, 0, + 93, 256, 95, 96, 44, 0, 0, 46, 0, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 0, 0, 0, 0, 0, 0, + 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 0, 772, 0, 0, 83, + 0, 0, 0, 0, 0, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 31, 32, + 0, 34, 0, 0, 35, 212, 0, 0, 0, 39, + 40, 41, 0, 43, 0, 93, 256, 95, 96, 44, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 0, 53, 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 143, 0, 0, 0, 0, 0, 145, 146, - 147, 148, 0, 0, 0, 149, 0, 150, 0, 0, - 0, 0, 0, 151, 152, 0, 0, 0, 0, 0, - 0, 94, 95, 0, 97, 0, 0, 98, 278, 0, - 0, 0, 102, 103, 104, 0, 106, 0, 153, 322, - 155, 156, 107, 0, 0, 109, 0, 0, 0, 0, - 0, 0, 114, 0, 0, 0, 0, 116, 0, 117, - 118, 119, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 121, 0, 122, 123, 0, 0, 124, - 0, 0, 126, 0, 128, 0, 130, 131, 132, 279, - 0, 135, 0, 0, 0, 0, 0, 0, 139, 0, - 0, 140, 141, 0, 0, 0, 0, 0, 0, 0, + 58, 0, 59, 60, 0, 0, 61, 0, 0, 63, + 0, 65, 0, 67, 68, 69, 213, 0, 72, 0, + 0, 0, 0, 0, 0, 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 803, 0, 0, 143, 0, 0, 0, 0, 0, - 145, 146, 147, 148, 0, 0, 0, 149, 0, 150, - 0, 0, 0, 0, 0, 151, 152, 0, 0, 0, - 0, 0, 0, 94, 95, 0, 97, 0, 0, 98, - 278, 0, 0, 0, 102, 103, 104, 0, 106, 0, - 153, 322, 155, 156, 107, 0, 54, 109, 54, 0, - 0, 0, 0, 0, 114, 0, 0, 0, 0, 116, - 0, 117, 118, 119, 0, 0, 0, 0, 0, 54, - 0, 0, 0, 0, 0, 121, 0, 122, 123, 0, - 0, 124, 54, 0, 126, 0, 128, 54, 130, 131, - 132, 279, 54, 135, 54, 54, 54, 54, 0, 0, - 139, 0, 54, 140, 141, 0, 54, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, - 0, 54, 505, 54, 0, 0, 143, 0, 0, 0, - 0, 0, 145, 146, 147, 148, 0, 0, 0, 149, - 0, 150, 0, 0, 54, 0, 0, 151, 152, 315, - 0, 0, 0, 0, 0, 94, 95, 0, 97, 0, - 0, 98, 278, 0, 0, 0, 102, 103, 104, 0, - 106, 0, 153, 322, 155, 156, 107, 0, 54, 109, - 0, 0, 0, 0, 0, 0, 114, 0, 0, 0, - 0, 116, 0, 117, 118, 119, 0, 0, 0, 0, - 0, 54, 0, 0, 0, 0, 0, 121, 0, 122, - 123, 0, 0, 124, 54, 0, 126, 0, 128, 54, - 130, 131, 132, 279, 54, 135, 54, 54, 54, 54, - 0, 0, 139, 0, 54, 140, 141, 0, 54, 0, + 0, 0, 0, 0, 79, 80, 81, 0, 0, 0, + 451, 0, 0, 0, 83, 0, 0, 0, 0, 0, + 85, 86, 87, 88, 0, 0, 0, 89, 0, 90, + 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, + 0, 0, 0, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 0, 0, 39, 40, 41, 0, 43, 0, + 93, 256, 95, 96, 44, 0, 0, 46, 0, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 0, 0, 0, 0, 0, 0, + 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 445, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 31, 32, + 0, 34, 0, 0, 35, 212, 0, 0, 0, 39, + 40, 41, 0, 43, 0, 93, 256, 95, 96, 44, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 0, 53, 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 54, 0, 0, 54, 499, 54, 0, 0, 143, 0, - 0, 0, 0, 0, 145, 146, 147, 148, 0, 0, - 0, 149, 0, 150, 0, 0, 54, 54, 54, 151, - 152, 0, 0, 0, 0, 0, 0, 94, 95, 0, - 97, 0, 0, 98, 278, 0, 0, 0, 102, 103, - 104, 0, 106, 0, 153, 322, 155, 156, 107, 0, - 59, 109, 0, 0, 0, 0, 0, 0, 114, 0, - 0, 0, 0, 116, 0, 117, 118, 119, 0, 0, - 0, 0, 0, 60, 0, 0, 0, 0, 0, 121, - 0, 122, 123, 0, 0, 124, 61, 0, 126, 0, - 128, 63, 130, 131, 132, 279, 64, 135, 65, 66, - 67, 68, 0, 0, 139, 0, 69, 140, 141, 0, - 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 71, 0, 0, 72, 0, 73, 0, 0, - 143, 0, 0, 0, 0, 0, 145, 146, 147, 148, - 0, 0, 0, 149, 0, 150, 0, 0, 74, 0, - 0, 151, 152, 0, 0, 0, 0, 0, 0, 94, - 95, 0, 97, 0, 0, 98, 278, 0, 0, 0, - 102, 103, 104, 0, 106, 0, 153, 322, 155, 156, - 107, 0, 0, 109, 0, 0, 0, 0, 0, 0, - 114, 0, 0, 0, 0, 116, 0, 117, 118, 119, + 58, 0, 59, 60, 0, 0, 61, 0, 0, 63, + 0, 65, 0, 67, 68, 69, 213, 0, 72, 0, + 0, 0, 0, 0, 0, 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 121, 0, 122, 123, 0, 0, 124, 0, 0, - 126, 0, 128, 0, 130, 131, 132, 279, 0, 135, - 0, 0, 0, 0, 0, 0, 139, 0, 0, 140, - 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 80, 81, 0, 0, 0, + 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, + 85, 86, 87, 88, 0, 0, 0, 89, 0, 90, + 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, + 0, 0, 0, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 0, 0, 39, 40, 41, 0, 43, 0, + 93, 256, 95, 96, 44, 0, 0, 46, 0, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 0, 0, 0, 0, 0, 0, + 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 0, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 0, 0, 0, 0, + 91, 92, 0, 0, 0, 0, 0, 0, 31, 32, + 0, 34, 0, 0, 35, 212, 0, 0, 0, 39, + 40, 41, 0, 43, 0, 93, 411, 95, 96, 44, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 0, 0, 53, 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 143, 0, 0, 0, 0, 0, 145, 146, - 147, 148, 0, 0, 0, 149, 0, 150, 0, 0, - 0, 0, 0, 151, 152, 0, 0, 0, 0, 0, - 0, 94, 95, 0, 97, 0, 0, 98, 278, 0, - 0, 0, 102, 103, 104, 0, 106, 0, 153, 457, - 155, 156, 107, 0, 0, 109, 0, 0, 0, 0, - 0, 0, 114, 0, 0, 0, 0, 116, 0, 117, - 118, 119, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 121, 0, 122, 123, 0, 0, 124, - 0, 0, 126, 0, 128, 0, 130, 131, 132, 279, - 0, 135, 0, 0, 0, 0, 0, 0, 139, 0, - 0, 140, 141, 0, 0, 0, 0, 0, 0, 0, + 58, 0, 59, 60, 0, 0, 61, 0, 0, 63, + 0, 65, 0, 67, 68, 69, 213, 0, 72, 0, + 0, 0, 0, 0, 0, 76, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 143, 0, 0, 0, 0, 0, - 145, 146, 147, 148, 0, 0, 0, 149, 0, 150, - 0, 0, 0, 0, 0, 151, 152, 0, 0, 0, - 0, 0, 0, 82, 82, 0, 82, 0, 0, 82, - 82, 0, 0, 0, 82, 82, 82, 0, 82, 0, - 153, 465, 155, 156, 82, 0, 0, 82, 0, 0, - 0, 0, 0, 0, 82, 0, 0, 0, 0, 82, - 0, 82, 82, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 82, 0, 82, 82, 0, - 0, 82, 0, 0, 82, 0, 82, 0, 82, 82, - 82, 82, 0, 82, 0, 0, 0, 0, 0, 0, - 82, 0, 0, 82, 82, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 80, 81, 0, 0, 0, + 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, + 85, 86, 87, 88, 0, 0, 0, 89, 0, 90, + 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, + 0, 0, 0, 77, 77, 0, 77, 0, 0, 77, + 77, 0, 0, 0, 77, 77, 77, 0, 77, 0, + 93, 916, 95, 96, 77, 0, 0, 77, 0, 0, + 0, 0, 0, 0, 77, 0, 0, 0, 0, 77, + 0, 77, 77, 77, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 77, 0, 77, 77, 0, + 0, 77, 0, 0, 77, 0, 77, 0, 77, 77, + 77, 77, 0, 77, 0, 0, 0, 0, 0, 0, + 77, 0, 0, 77, 77, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, + 77, 77, 0, 0, 0, 0, 0, 0, 0, 77, + 0, 0, 0, 0, 0, 77, 77, 77, 77, 0, + 0, 0, 77, 0, 77, 0, 0, 0, 0, 0, + 77, 77, 0, 0, 0, 0, 0, 0, 149, 149, + 0, 149, 0, 0, 149, 149, 0, 0, 0, 149, + 149, 149, 0, 149, 0, 77, 77, 77, 77, 149, + 0, 0, 149, 0, 0, 0, 0, 0, 0, 149, + 0, 0, 0, 0, 149, 0, 149, 149, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, - 0, 0, 82, 82, 82, 82, 0, 0, 0, 82, - 0, 82, 0, 0, 0, 0, 0, 82, 82, 0, - 0, 0, 0, 0, 0, 154, 154, 0, 154, 0, - 0, 154, 154, 0, 0, 0, 154, 154, 154, 0, - 154, 0, 82, 82, 82, 82, 154, 0, 0, 154, - 0, 0, 0, 0, 0, 0, 154, 0, 0, 0, - 0, 154, 0, 154, 154, 154, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 154, 0, 154, - 154, 0, 0, 154, 0, 0, 154, 0, 154, 0, - 154, 154, 154, 154, 0, 154, 0, 0, 0, 0, - 0, 0, 154, 0, 0, 154, 154, 0, 0, 0, + 149, 0, 149, 149, 0, 0, 149, 0, 0, 149, + 0, 149, 0, 149, 149, 149, 149, 0, 149, 0, + 0, 0, 0, 0, 0, 149, 0, 0, 149, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 154, 0, - 0, 0, 0, 0, 154, 154, 154, 154, 0, 0, - 0, 154, 0, 154, 0, 0, 0, 0, 0, 154, - 154, 0, 0, 0, 0, 0, 0, 94, 95, 0, - 97, 0, 0, 98, 278, 0, 0, 0, 102, 103, - 104, 0, 106, 0, 154, 154, 154, 154, 107, 0, - 30, 109, 0, 0, 0, 0, 0, 0, 114, 0, - 0, 0, 0, 116, 0, 117, 118, 119, 0, 0, - 0, 0, 0, 30, 0, 0, 0, 0, 0, 121, - 0, 122, 123, 0, 0, 124, 30, 0, 126, 0, - 128, 30, 130, 131, 132, 279, 30, 135, 30, 30, - 30, 30, 0, 0, 30, 0, 30, 0, 0, 0, - 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 30, 0, 0, 30, 0, 30, 0, 0, - 143, 0, 0, 0, 0, 0, 145, 146, 147, 148, - 0, 0, 0, 149, 0, 150, 0, 0, 30, 0, - 0, 151, 152, 30, 30, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 149, 149, 149, 0, 0, 0, + 0, 0, 0, 0, 149, 0, 0, 0, 0, 0, + 149, 149, 149, 149, 0, 0, 0, 149, 0, 149, + 0, 0, 0, 0, 0, 149, 149, 0, 0, 0, + 0, 0, 0, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 0, 0, 39, 40, 41, 0, 43, 0, + 149, 149, 149, 149, 44, 0, 0, 46, 0, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 0, 32, 0, 34, 0, 0, + 35, 0, 0, 0, 0, 39, 0, 0, 0, 43, + 0, 0, 0, 0, 0, 0, 0, 0, 46, 79, + 80, 81, 0, 0, 0, 51, 0, 0, 0, 83, + 53, 0, 0, 0, 56, 85, 86, 87, 88, 0, + 0, 0, 89, 0, 90, 0, 58, 0, 59, 0, + 91, 92, 61, 0, 0, 0, 0, 0, 0, 0, + 68, 69, 0, 0, 72, 0, 0, 274, 0, 0, + 641, 0, 641, 0, 641, 93, 214, 641, 96, 641, + 641, 0, 641, 0, 641, 0, 641, 0, 641, 641, + 641, 0, 0, 0, 641, 641, 0, 0, 0, 0, + 641, 0, 641, 641, 0, 0, 0, 641, 0, 0, + 0, 641, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 641, 641, 0, 641, 0, 0, 0, 641, + 641, 0, 0, 0, 0, 0, 0, 641, 641, 0, + 0, 641, 0, 0, 641, 0, 0, 305, 0, 641, + 0, 0, 0, 31, 32, 0, 34, 0, 0, 35, + 212, 0, 0, 0, 39, 40, 41, 0, 43, 0, + 641, 641, 0, 0, 44, 0, 0, 46, 0, 0, + 0, 0, 0, 641, 51, 0, 0, 0, 0, 53, + 0, 54, 55, 56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 58, 0, 59, 60, 0, + 0, 61, 0, 0, 63, 0, 65, 0, 67, 68, + 69, 213, 0, 72, 641, 640, 74, 640, 0, 0, + 640, 0, 640, 640, 0, 640, 0, 640, 0, 640, + 0, 640, 640, 640, 0, 0, 0, 640, 640, 79, + 80, 81, 0, 640, 0, 640, 640, 0, 0, 83, + 640, 0, 0, 0, 640, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 640, 0, 640, 0, + 0, 0, 640, 640, 0, 0, 0, 0, 0, 0, + 640, 640, 0, 0, 640, 0, 0, 640, 0, 0, + 0, 0, 640, 0, 0, 93, 214, 640, 0, 640, + 0, 0, 640, 0, 640, 640, 0, 640, 0, 640, + 0, 640, 0, 640, 640, 640, 0, 0, 0, 640, + 640, 0, 0, 0, 0, 640, 640, 640, 640, 32, + 0, 34, 640, 0, 35, 0, 640, 1181, 0, 39, + 0, 596, 0, 43, 0, 597, 1182, 1183, 640, 0, + 640, 1184, 46, 0, 640, 640, 0, 1185, 0, 51, + 0, 0, 640, 640, 53, 0, 640, 640, 56, 640, + 0, 0, 0, 0, 640, 0, 0, 0, 0, 0, + 58, 0, 59, 0, 0, 0, 61, 0, 0, 0, + 0, 0, 0, 0, 68, 69, 0, 32, 72, 34, + 0, 1186, 35, 0, 0, 1181, 1187, 39, 0, 596, + 0, 43, 0, 597, 1182, 1183, 0, 0, 0, 1184, + 46, 0, 0, 0, 0, 1185, 0, 51, 0, 47, + 0, 47, 53, 0, 47, 0, 56, 0, 0, 47, + 1188, 0, 0, 47, 0, 0, 0, 0, 58, 640, + 59, 0, 47, 0, 61, 0, 0, 0, 0, 47, + 0, 0, 68, 69, 47, 0, 72, 0, 47, 1186, + 47, 0, 47, 47, 1187, 47, 0, 47, 47, 0, + 47, 1189, 47, 47, 0, 0, 47, 47, 0, 47, + 0, 0, 0, 0, 47, 47, 47, 0, 47, 0, + 0, 47, 0, 47, 0, 0, 0, 0, 47, 0, + 0, 0, 47, 47, 47, 47, 47, 0, 47, 0, + 0, 47, 0, 47, 47, 0, 47, 47, 0, 0, + 47, 0, 0, 47, 0, 166, 47, 0, 47, 47, + 0, 0, 47, 47, 0, 47, 0, 0, 47, 1189, + 0, 0, 47, 0, 47, 0, 47, 32, 0, 34, + 0, 47, 35, 0, 47, 0, 47, 39, 0, 0, + 47, 43, 0, 47, 0, 0, 0, 166, 47, 47, + 46, 47, 47, 0, 0, 47, 0, 51, 0, 32, + 0, 34, 53, 0, 35, 0, 56, 0, 502, 39, + 0, 0, 0, 43, 0, 503, 0, 0, 58, 0, + 59, 0, 46, 0, 61, 0, 0, 504, 0, 51, + 0, 0, 68, 69, 53, 47, 72, 0, 56, 505, + 0, 0, 0, 32, 0, 34, 0, 0, 35, 0, + 58, 0, 59, 39, 0, 0, 61, 43, 0, 0, + 0, 0, 0, 0, 68, 69, 46, 32, 72, 34, + 0, 453, 35, 51, 0, 47, 0, 39, 53, 0, + 0, 43, 56, 0, 0, 0, 0, 0, 0, 0, + 46, 0, 0, 0, 58, 0, 59, 51, 0, 0, + 61, 0, 53, 0, 0, 0, 56, 0, 68, 69, + 0, 32, 72, 34, 0, 274, 35, 0, 58, 506, + 59, 39, 0, 0, 61, 43, 0, 0, 0, 0, + 0, 0, 68, 69, 46, 32, 72, 34, 0, 274, + 35, 51, 0, 0, 0, 39, 53, 0, 0, 43, + 56, 305, 0, 0, 0, 0, 0, 0, 46, 0, + 0, 0, 58, 0, 59, 51, 0, 0, 61, 0, + 53, 0, 0, 0, 56, 0, 68, 69, 0, 496, + 72, 496, 0, 505, 496, 0, 58, 0, 59, 496, + 0, 0, 61, 496, 0, 569, 0, 0, 0, 0, + 68, 69, 496, 185, 72, 185, 0, 664, 185, 496, + 0, 0, 0, 185, 496, 0, 0, 185, 496, 571, + 0, 0, 0, 0, 0, 0, 185, 0, 0, 0, + 496, 0, 496, 185, 0, 0, 496, 0, 185, 0, + 0, 0, 185, 0, 496, 496, 0, 195, 496, 195, + 0, 496, 195, 0, 185, 0, 185, 195, 0, 0, + 185, 195, 0, 305, 0, 0, 0, 0, 185, 185, + 195, 186, 185, 186, 0, 185, 186, 195, 0, 0, + 0, 186, 195, 0, 0, 186, 195, 305, 0, 0, + 0, 0, 0, 0, 186, 0, 0, 0, 195, 0, + 195, 186, 0, 0, 195, 0, 186, 0, 0, 0, + 186, 0, 195, 195, 0, 0, 195, 0, 0, 195, + 0, 0, 186, 0, 186, 0, 0, 0, 186, 0, + 34, 496, 0, 0, 0, 0, 186, 186, 0, 0, + 186, 34, 0, 186, 0, 0, 34, 0, 0, 0, + 34, 0, 0, 34, 0, 185, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 34, 34, 0, 0, 0, + 34, 34, 0, 0, 0, 0, 34, 0, 34, 34, + 34, 34, 0, 0, 0, 0, 34, 0, 0, 0, + 34, 0, 34, 0, 0, 0, 0, 0, 32, 195, + 0, 0, 34, 0, 34, 34, 0, 34, 0, 32, + 0, 34, 0, 0, 32, 0, 0, 0, 32, 0, + 0, 32, 0, 186, 0, 0, 0, 0, 34, 0, + 0, 0, 0, 32, 32, 0, 34, 34, 32, 32, + 0, 27, 0, 0, 32, 0, 32, 32, 32, 32, + 0, 0, 0, 0, 32, 0, 0, 0, 32, 0, + 32, 0, 0, 0, 27, 0, 0, 0, 0, 0, + 32, 0, 0, 32, 0, 32, 0, 27, 0, 32, + 0, 0, 27, 0, 27, 0, 27, 27, 0, 27, + 27, 27, 27, 0, 0, 27, 32, 27, 0, 0, + 0, 27, 0, 0, 32, 32, 0, 27, 0, 0, + 0, 0, 0, 27, 0, 0, 27, 0, 27, 0, + 27, 0, 0, 0, 0, 27, 0, 0, 0, 0, + 27, 0, 27, 27, 27, 27, 0, 0, 0, 27, + 27, 0, 0, 0, 27, 0, 0, 27, 27, 0, + 0, 0, 47, 0, 0, 0, 27, 0, 0, 27, + 0, 27, 0, 47, 0, 0, 0, 0, 47, 0, + 0, 0, 47, 0, 0, 47, 0, 0, 0, 0, + 0, 0, 27, 0, 0, 0, 0, 47, 47, 0, + 27, 27, 47, 47, 0, 47, 0, 0, 47, 0, + 47, 47, 47, 47, 0, 0, 47, 0, 47, 0, + 0, 47, 47, 0, 47, 47, 0, 0, 47, 0, + 0, 0, 0, 0, 47, 0, 0, 47, 0, 47, + 47, 47, 0, 47, 0, 47, 47, 0, 47, 0, + 0, 47, 0, 47, 47, 47, 47, 0, 0, 0, + 47, 47, 0, 0, 0, 47, 0, 47, 36, 0, + 0, 47, 0, 0, 0, 0, 0, 47, 0, 0, + 47, 0, 47, 47, 47, 0, 47, 0, 0, 47, + 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, + 0, 0, 0, 47, 47, 0, 47, 0, 47, 0, + 0, 37, 0, 0, 0, 0, 0, 0, 0, 47, + 47, 0, 0, 47, 47, 47, 0, 0, 0, 47, + 0, 47, 47, 47, 47, 0, 0, 0, 0, 47, + 0, 0, 47, 47, 0, 0, 47, 0, 0, 0, + 47, 47, 0, 0, 207, 47, 0, 0, 47, 0, + 47, 0, 0, 0, 0, 47, 0, 0, 0, 0, + 0, 0, 47, 0, 47, 0, 0, 0, 47, 0, + 0, 47, 0, 47, 0, 47, 47, 0, 47, 209, + 47, 47, 47, 47, 0, 47, 47, 0, 47, 0, + 0, 0, 47, 0, 0, 0, 0, 0, 47, 0, + 0, 0, 0, 47, 47, 47, 0, 47, 47, 47, + 47, 47, 47, 47, 0, 0, 0, 0, 47, 0, + 0, 0, 47, 0, 0, 0, 0, 0, 47, 0, + 47, 0, 0, 0, 47, 0, 0, 47, 309, 47, + 389, 47, 0, 0, 0, 0, 47, 0, 0, 0, + 0, 47, 0, 47, 47, 47, 47, 0, 0, 0, + 47, 47, 0, 390, 0, 47, 0, 0, 310, 0, + 0, 0, 0, 0, 0, 0, 391, 47, 0, 0, + 47, 393, 47, 0, 0, 0, 394, 0, 395, 396, + 397, 398, 0, 0, 0, 0, 399, 0, 0, 0, + 400, 0, 0, 47, 0, 0, 0, 47, 47, 0, + 0, 0, 401, 0, 0, 402, 0, 403, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 642, 0, 642, 0, 642, 153, 280, 642, 156, - 642, 642, 0, 642, 0, 642, 0, 642, 0, 642, - 642, 642, 0, 0, 0, 642, 642, 0, 0, 0, - 0, 642, 0, 642, 642, 0, 0, 0, 642, 0, - 0, 0, 642, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 642, 642, 0, 642, 0, 0, 0, - 642, 642, 0, 0, 0, 0, 0, 0, 642, 642, - 94, 95, 642, 97, 0, 642, 98, 278, 0, 0, - 642, 102, 103, 104, 0, 106, 0, 0, 0, 0, - 0, 107, 0, 0, 109, 0, 0, 0, 642, 642, - 0, 114, 0, 0, 0, 0, 116, 0, 117, 118, - 119, 642, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 121, 0, 122, 123, 0, 0, 124, 0, - 0, 126, 0, 128, 0, 130, 131, 132, 279, 641, - 135, 641, 0, 137, 641, 0, 641, 641, 0, 641, - 0, 641, 642, 641, 0, 641, 641, 641, 0, 0, - 0, 641, 641, 0, 0, 0, 0, 641, 0, 641, - 641, 0, 0, 143, 641, 0, 0, 0, 641, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 641, 0, 641, 0, 0, 0, 641, 641, 0, 0, - 0, 0, 0, 0, 641, 641, 0, 0, 641, 0, - 0, 641, 0, 0, 0, 0, 641, 0, 0, 153, - 280, 641, 0, 641, 0, 0, 641, 0, 641, 641, - 0, 641, 0, 641, 0, 641, 0, 641, 641, 641, - 0, 0, 0, 641, 641, 0, 0, 641, 0, 641, - 0, 641, 641, 0, 0, 0, 641, 0, 0, 0, - 641, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 641, 0, 641, 0, 0, 0, 641, 641, - 0, 0, 0, 0, 0, 0, 641, 641, 641, 95, - 641, 97, 0, 641, 98, 0, 0, 1167, 641, 102, - 0, 248, 0, 106, 0, 249, 1168, 1169, 0, 0, - 0, 1170, 109, 0, 0, 0, 0, 1171, 0, 114, - 0, 95, 0, 97, 116, 0, 98, 0, 119, 1167, - 0, 102, 0, 248, 0, 106, 0, 249, 1168, 1169, - 121, 0, 122, 1170, 109, 0, 124, 0, 0, 1171, - 0, 114, 0, 0, 131, 132, 116, 0, 135, 0, - 119, 1172, 0, 0, 0, 0, 1173, 0, 0, 0, - 641, 54, 121, 54, 122, 0, 54, 0, 124, 0, - 0, 54, 0, 0, 0, 54, 131, 132, 0, 0, - 135, 0, 0, 1172, 54, 0, 0, 1174, 1173, 0, - 0, 54, 0, 0, 0, 0, 54, 0, 0, 0, - 54, 54, 54, 54, 54, 0, 54, 0, 0, 54, - 0, 54, 54, 0, 54, 54, 0, 0, 54, 0, - 0, 54, 0, 0, 54, 0, 54, 54, 1175, 0, - 54, 54, 0, 54, 0, 0, 54, 0, 0, 0, - 54, 0, 54, 0, 54, 0, 0, 0, 0, 54, - 0, 0, 54, 0, 54, 0, 0, 0, 54, 0, - 1175, 54, 0, 0, 171, 0, 54, 54, 0, 0, - 54, 0, 0, 54, 54, 0, 54, 0, 0, 54, - 0, 0, 0, 0, 54, 0, 0, 0, 54, 0, - 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, - 0, 0, 171, 0, 54, 0, 95, 0, 97, 54, - 54, 98, 0, 54, 0, 54, 102, 54, 0, 0, - 106, 0, 54, 0, 0, 54, 0, 54, 0, 109, - 0, 54, 0, 0, 54, 0, 114, 0, 0, 54, - 54, 116, 0, 54, 0, 119, 54, 543, 0, 0, - 54, 0, 0, 0, 544, 0, 0, 121, 0, 122, - 95, 0, 97, 124, 0, 98, 545, 1093, 0, 0, - 102, 131, 132, 0, 106, 135, 0, 95, 546, 97, - 0, 0, 98, 109, 0, 0, 0, 102, 0, 0, - 114, 106, 0, 0, 0, 116, 0, 1094, 0, 119, - 109, 0, 0, 0, 0, 0, 0, 114, 0, 0, - 0, 121, 116, 122, 0, 0, 119, 124, 1095, 0, - 0, 0, 0, 54, 0, 131, 132, 0, 121, 135, - 122, 95, 255, 97, 124, 0, 98, 0, 0, 0, - 0, 102, 131, 132, 0, 106, 135, 0, 95, 437, - 97, 0, 0, 98, 109, 547, 0, 0, 102, 0, - 0, 114, 106, 0, 0, 0, 116, 0, 0, 0, - 119, 109, 0, 0, 0, 0, 0, 0, 114, 0, - 0, 0, 121, 116, 122, 0, 0, 119, 124, 0, - 0, 0, 0, 0, 0, 0, 131, 132, 0, 121, - 135, 122, 95, 507, 97, 124, 0, 98, 0, 87, - 0, 0, 102, 131, 132, 0, 106, 135, 0, 95, - 255, 97, 0, 0, 98, 109, 87, 0, 0, 102, - 0, 0, 114, 106, 0, 0, 0, 116, 0, 0, - 0, 119, 109, 0, 0, 0, 0, 0, 0, 114, - 0, 0, 0, 121, 116, 122, 0, 0, 119, 124, - 0, 0, 0, 0, 0, 0, 0, 131, 132, 0, - 121, 135, 122, 500, 255, 500, 124, 0, 500, 0, - 87, 0, 0, 500, 131, 132, 0, 500, 135, 0, - 190, 546, 190, 0, 0, 190, 500, 611, 0, 0, - 190, 0, 0, 500, 190, 0, 0, 0, 500, 0, - 0, 0, 500, 190, 0, 0, 0, 0, 0, 0, - 190, 0, 0, 0, 500, 190, 500, 0, 0, 190, - 500, 0, 0, 0, 0, 0, 0, 0, 500, 500, - 0, 190, 500, 190, 200, 500, 200, 190, 0, 200, - 0, 613, 0, 0, 200, 190, 190, 0, 200, 190, - 0, 191, 190, 191, 0, 0, 191, 200, 87, 0, - 0, 191, 0, 0, 200, 191, 0, 0, 0, 200, - 0, 0, 0, 200, 191, 0, 0, 0, 0, 0, - 0, 191, 0, 0, 0, 200, 191, 200, 0, 0, - 191, 200, 0, 39, 0, 0, 0, 0, 39, 200, - 200, 0, 191, 200, 191, 0, 200, 0, 191, 39, - 0, 0, 500, 0, 39, 0, 191, 191, 39, 0, - 191, 39, 0, 191, 0, 0, 0, 0, 0, 190, - 0, 0, 0, 39, 39, 0, 0, 0, 39, 39, - 0, 0, 0, 0, 39, 0, 39, 39, 39, 39, - 0, 0, 0, 0, 39, 0, 0, 0, 39, 0, - 39, 0, 0, 0, 40, 0, 0, 0, 0, 40, - 39, 0, 39, 39, 0, 39, 0, 0, 0, 39, - 40, 0, 0, 200, 0, 40, 0, 0, 0, 40, - 0, 0, 40, 0, 0, 0, 39, 0, 0, 0, - 191, 39, 39, 0, 40, 40, 0, 0, 0, 40, - 40, 0, 0, 0, 0, 40, 0, 40, 40, 40, - 40, 0, 0, 0, 0, 40, 0, 0, 0, 40, - 0, 40, 0, 0, 0, 37, 0, 0, 0, 0, - 37, 40, 0, 40, 40, 0, 40, 0, 0, 0, - 40, 37, 0, 0, 0, 0, 37, 0, 0, 0, - 37, 0, 0, 37, 0, 0, 0, 40, 0, 0, - 0, 0, 40, 40, 0, 37, 37, 0, 0, 0, - 37, 37, 0, 0, 0, 0, 37, 0, 37, 37, - 37, 37, 0, 0, 0, 0, 37, 0, 0, 0, - 37, 0, 37, 0, 0, 0, 38, 0, 0, 0, - 0, 38, 37, 0, 0, 37, 0, 37, 0, 0, - 0, 37, 38, 0, 0, 0, 0, 38, 0, 0, - 0, 38, 0, 0, 38, 0, 0, 0, 37, 0, - 0, 0, 0, 37, 37, 0, 38, 38, 0, 0, - 0, 38, 38, 0, 0, 0, 0, 38, 0, 38, - 38, 38, 38, 0, 0, 0, 0, 38, 0, 0, - 0, 38, 0, 38, 0, 0, 0, 0, 0, 0, - 0, 0, 54, 38, 0, 0, 38, 0, 38, 0, - 0, 0, 38, 54, 0, 0, 0, 0, 54, 0, - 0, 0, 54, 0, 0, 54, 0, 0, 0, 38, - 0, 0, 0, 0, 38, 38, 0, 54, 54, 0, - 0, 0, 54, 54, 0, 0, 0, 0, 54, 0, - 54, 54, 54, 54, 0, 0, 0, 0, 54, 0, - 0, 0, 54, 0, 54, 0, 0, 0, 0, 0, - 0, 54, 0, 0, 54, 0, 0, 54, 0, 54, - 0, 0, 54, 54, 0, 0, 0, 54, 0, 0, - 0, 54, 0, 0, 54, 0, 0, 0, 0, 0, - 54, 0, 0, 0, 0, 41, 54, 54, 0, 0, - 0, 54, 54, 0, 0, 0, 0, 54, 0, 54, - 54, 54, 54, 0, 0, 0, 0, 54, 0, 0, - 54, 54, 0, 54, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 54, 0, 0, 54, 0, 54, 0, - 0, 0, 54, 54, 0, 0, 0, 0, 0, 0, - 54, 0, 54, 0, 0, 0, 54, 0, 0, 54, - 0, 54, 0, 0, 42, 0, 54, 0, 54, 54, - 54, 54, 0, 54, 54, 0, 54, 0, 0, 0, - 54, 0, 0, 0, 0, 0, 54, 0, 0, 0, - 59, 54, 54, 0, 0, 54, 54, 54, 54, 54, - 54, 54, 0, 0, 54, 0, 54, 0, 0, 0, - 54, 0, 0, 60, 0, 0, 0, 0, 54, 0, - 0, 0, 54, 314, 0, 54, 61, 54, 0, 0, - 62, 63, 0, 0, 0, 0, 64, 0, 65, 66, - 67, 68, 0, 0, 0, 0, 69, 0, 54, 0, - 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 71, 0, 0, 72, 0, 73, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 74, + 0, 0, 0, 0, 0, 0, 0, 0, 404, }; - protected static readonly short [] yyCheck = { 76, - 0, 503, 50, 50, 8, 50, 50, 320, 81, 321, - 10, 248, 312, 85, 236, 505, 28, 100, 344, 50, - 88, 137, 260, 532, 624, 3, 205, 5, 249, 499, - 479, 845, 317, 542, 268, 668, 669, 339, 272, 866, - 100, 0, 0, 10, 160, 127, 549, 163, 50, 53, - 1017, 51, 10, 256, 99, 953, 954, 3, 256, 5, - 256, 10, 256, 268, 50, 268, 44, 140, 141, 100, - 256, 256, 120, 256, 105, 256, 709, 268, 711, 127, - 256, 319, 154, 156, 129, 256, 256, 256, 133, 256, - 335, 1079, 256, 51, 256, 143, 282, 256, 44, 1100, - 50, 79, 51, 50, 647, 50, 50, 50, 256, 368, - 50, 89, 762, 268, 50, 1116, 294, 50, 897, 50, - 372, 276, 160, 360, 364, 163, 294, 256, 314, 387, - 256, 257, 1129, 79, 269, 81, 325, 371, 306, 1127, - 256, 1129, 341, 89, 256, 261, 925, 256, 1046, 363, - 256, 286, 410, 367, 339, 414, 365, 205, 205, 364, - 205, 205, 1159, 339, 414, 363, 365, 365, 344, 367, - 346, 1159, 424, 423, 205, 413, 352, 353, 363, 424, - 670, 377, 367, 377, 424, 370, 371, 372, 967, 502, - 262, 339, 377, 294, 140, 141, 344, 256, 346, 294, - 294, 256, 416, 205, 352, 353, 532, 371, 280, 335, - 156, 370, 285, 418, 864, 418, 542, 438, 416, 205, - 268, 419, 338, 261, 272, 414, 309, 418, 414, 277, - 257, 414, 358, 414, 317, 364, 414, 237, 311, 365, - 783, 370, 785, 414, 414, 414, 414, 414, 424, 309, - 322, 294, 414, 365, 327, 205, 365, 363, 205, 414, - 205, 205, 205, 826, 312, 205, 372, 315, 316, 205, - 237, 904, 205, 355, 205, 335, 424, 367, 309, 237, - 328, 784, 519, 256, 335, 333, 387, 335, 237, 334, - 362, 339, 387, 387, 420, 421, 422, 344, 257, 256, - 344, 256, 248, 257, 335, 364, 410, 355, 610, 410, - 365, 370, 549, 344, 1315, 410, 410, 390, 391, 423, - 390, 391, 256, 371, 372, 266, 416, 817, 376, 377, - 378, 379, 380, 381, 382, 383, 384, 385, 386, 285, - 810, 1342, 1309, 364, 387, 418, 419, 796, 364, 256, - 256, 256, 262, 1354, 656, 1356, 1170, 349, 350, 922, - 408, 924, 349, 350, 103, 311, 339, 410, 256, 108, - 368, 110, 111, 314, 113, 321, 115, 450, 264, 349, - 350, 327, 339, 364, 123, 457, 125, 672, 298, 306, - 363, 368, 464, 465, 133, 1028, 313, 136, 414, 138, - 1227, 335, 343, 424, 638, 368, 896, 641, 629, 256, - 631, 366, 633, 397, 360, 370, 364, 489, 277, 479, - 256, 257, 281, 162, 358, 409, 424, 1060, 1061, 474, - 371, 365, 424, 372, 1067, 341, 368, 424, 370, 325, - 364, 1344, 1345, 424, 390, 391, 387, 424, 479, 1276, - 1277, 339, 1279, 501, 424, 503, 256, 505, 365, 365, - 365, 424, 364, 1290, 374, 375, 1293, 1294, 781, 410, - 515, 516, 418, 419, 1074, 363, 424, 1375, 526, 256, - 528, 1308, 423, 342, 556, 532, 558, 368, 532, 364, - 343, 728, 424, 795, 1392, 542, 541, 1400, 542, 335, - 424, 532, 681, 370, 450, 942, 370, 1078, 1079, 369, - 744, 542, 414, 357, 562, 563, 363, 414, 365, 968, - 367, 368, 358, 370, 377, 372, 423, 343, 305, 365, - 1130, 343, 1103, 845, 387, 343, 414, 410, 382, 339, - 279, 519, 281, 424, 344, 412, 346, 784, 412, 424, - 423, 1079, 352, 353, 627, 1064, 1127, 410, 1129, 371, - 365, 998, 610, 371, 369, 377, 50, 414, 616, 416, - 423, 387, 419, 519, 414, 387, 814, 372, 1079, 387, - 319, 1181, 1079, 263, 368, 1185, 370, 703, 1159, 672, - 638, 414, 331, 641, 410, 1079, 263, 81, 410, 1127, - 913, 1129, 410, 549, 676, 370, 256, 423, 656, 272, - 365, 423, 410, 1079, 419, 423, 100, 665, 1079, 417, - 365, 105, 670, 1079, 697, 693, 1127, 675, 1129, 424, - 1127, 1159, 1129, 296, 371, 315, 648, 668, 669, 339, - 424, 387, 363, 1127, 344, 1129, 346, 414, 315, 349, - 350, 372, 352, 353, 699, 305, 140, 141, 1159, 414, - 323, 1127, 1159, 1129, 410, 713, 1127, 715, 1129, 414, - 370, 1127, 156, 1129, 974, 1159, 724, 423, 709, 364, - 711, 627, 370, 357, 372, 370, 382, 383, 384, 377, - 377, 739, 377, 1159, 272, 369, 744, 745, 1159, 747, - 387, 272, 339, 1159, 1017, 410, 1032, 344, 382, 346, - 758, 759, 349, 350, 787, 352, 353, 939, 296, 372, - 1020, 205, 272, 410, 424, 296, 256, 277, 776, 777, - 339, 281, 10, 781, 12, 344, 475, 346, 1064, 269, - 349, 350, 366, 352, 353, 323, 296, 795, 294, 261, - 798, 697, 323, 365, 826, 306, 286, 805, 1058, 1085, - 306, 370, 313, 357, 248, 377, 766, 815, 805, 817, - 367, 365, 284, 323, 325, 369, 515, 55, 364, 816, - 58, 367, 728, 369, 370, 297, 377, 424, 382, 372, - 302, 1091, 342, 305, 367, 307, 387, 309, 310, 311, - 312, 285, 388, 389, 852, 317, 854, 1297, 856, 321, - 1192, 339, 372, 325, 366, 424, 1198, 382, 370, 410, - 414, 333, 408, 1205, 336, 309, 338, 311, 363, 387, - 416, 363, 423, 419, 414, 363, 369, 321, 784, 372, - 372, 787, 357, 327, 372, 357, 375, 359, 896, 375, - 922, 335, 410, 365, 369, 367, 363, 369, 1170, 417, - 344, 865, 363, 392, 393, 372, 256, 382, 363, 1359, - 382, 372, 367, 904, 369, 370, 360, 372, 380, 357, - 366, 926, 377, 339, 370, 933, 363, 935, 344, 937, - 346, 369, 385, 349, 350, 372, 352, 353, 381, 845, - 363, 1138, 414, 414, 382, 1395, 390, 391, 1145, 372, - 369, 363, 386, 372, 1416, 1417, 411, 339, 378, 379, - 372, 368, 344, 370, 346, 372, 974, 349, 350, 396, - 352, 353, 392, 393, 418, 419, 365, 941, 986, 987, - 366, 367, 942, 369, 370, 371, 994, 366, 948, 339, - 950, 366, 367, 369, 344, 370, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 450, 365, 424, 1017, - 368, 368, 1020, 370, 364, 372, 366, 414, 368, 366, - 370, 371, 372, 370, 306, 1032, 308, 256, 1032, 366, - 1038, 313, 363, 370, 365, 479, 1309, 1028, 998, 340, - 357, 1032, 424, 325, 1077, 951, 414, 357, 365, 414, - 1058, 368, 369, 370, 368, 365, 370, 1064, 368, 369, - 1064, 369, 1070, 1071, 366, 382, 368, 366, 370, 1060, - 1061, 370, 382, 1064, 424, 519, 1067, 368, 1085, 370, - 366, 1085, 368, 1091, 370, 394, 395, 364, 532, 1049, - 367, 366, 369, 370, 1085, 370, 339, 414, 542, 410, - 411, 344, 100, 346, 1137, 549, 368, 372, 370, 352, - 353, 388, 389, 368, 354, 355, 363, 372, 1078, 1079, - 367, 372, 369, 370, 1132, 372, 396, 397, 398, 399, - 377, 408, 354, 355, 1167, 1168, 1141, 363, 370, 416, - 372, 372, 419, 1103, 1050, 349, 350, 145, 146, 147, - 148, 149, 150, 151, 152, 370, 1164, 372, 360, 361, - 367, 1194, 369, 366, 1197, 368, 372, 1127, 1205, 1129, - 1202, 1077, 145, 146, 147, 148, 149, 150, 151, 152, - 0, 388, 389, 627, 414, 1217, 363, 366, 372, 368, - 367, 414, 369, 370, 366, 372, 368, 256, 368, 1159, - 377, 408, 1234, 414, 1236, 1210, 265, 363, 267, 416, - 371, 270, 419, 368, 414, 370, 275, 366, 414, 368, - 279, 366, 256, 368, 668, 669, 370, 256, 372, 288, - 368, 1137, 1138, 370, 411, 372, 295, 368, 370, 1145, - 372, 300, 370, 414, 372, 304, 368, 369, 360, 361, - 368, 873, 874, 697, 394, 395, 372, 316, 368, 318, - 364, 1167, 1168, 322, 1170, 709, 414, 711, 370, 368, - 1176, 330, 331, 400, 401, 334, 368, 368, 337, 368, - 368, 294, 294, 368, 728, 372, 1192, 370, 1194, 1297, - 1295, 1197, 1198, 414, 367, 256, 370, 414, 377, 1205, - 371, 1309, 356, 414, 372, 367, 411, 377, 377, 370, - 368, 309, 372, 370, 370, 370, 414, 294, 1326, 317, - 368, 424, 419, 370, 363, 368, 343, 1287, 0, 398, - 399, 400, 401, 402, 403, 404, 405, 406, 407, 414, - 784, 369, 414, 787, 1304, 370, 294, 294, 370, 414, - 358, 1359, 363, 256, 370, 414, 256, 1317, 1318, 368, - 280, 368, 377, 256, 363, 414, 372, 364, 414, 414, - 414, 371, 414, 377, 368, 370, 372, 375, 370, 372, - 366, 372, 417, 368, 1344, 1345, 419, 1395, 347, 387, - 388, 389, 368, 351, 392, 393, 1401, 1402, 377, 377, - 414, 845, 375, 1408, 1409, 256, 256, 347, 1416, 1417, - 364, 368, 368, 364, 387, 388, 389, 370, 370, 392, - 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, - 403, 404, 405, 406, 407, 370, 256, 257, 339, 414, - 1400, 261, 0, 414, 366, 265, 371, 267, 363, 368, - 270, 364, 272, 273, 366, 275, 363, 277, 363, 279, - 904, 281, 282, 283, 284, 371, 363, 287, 288, 348, - 285, 348, 367, 293, 372, 295, 296, 297, 377, 370, - 300, 301, 302, 364, 304, 368, 364, 307, 364, 309, - 310, 311, 312, 364, 356, 337, 316, 317, 318, 305, - 414, 321, 322, 323, 414, 414, 414, 951, 367, 367, - 330, 331, 327, 333, 334, 335, 336, 337, 338, 365, - 414, 377, 342, 363, 414, 372, 499, 370, 367, 367, - 367, 367, 363, 367, 369, 367, 377, 365, 358, 359, - 369, 368, 368, 256, 364, 365, 369, 414, 370, 370, - 414, 370, 368, 373, 372, 368, 554, 366, 373, 374, - 375, 376, 372, 378, 379, 380, 381, 382, 383, 384, - 385, 372, 368, 388, 389, 390, 391, 392, 393, 394, - 395, 554, 372, 368, 1028, 257, 368, 363, 1032, 261, - 414, 377, 364, 368, 414, 366, 377, 0, 364, 315, - 272, 263, 414, 367, 367, 277, 1050, 364, 368, 281, - 368, 0, 284, 372, 366, 366, 1060, 1061, 363, 372, - 1064, 414, 363, 1067, 296, 297, 364, 363, 368, 301, - 302, 414, 364, 1077, 414, 307, 364, 309, 310, 311, - 312, 1085, 372, 368, 368, 317, 372, 364, 368, 321, - 372, 323, 364, 372, 372, 369, 364, 368, 414, 368, - 363, 333, 372, 368, 336, 364, 338, 364, 368, 364, - 342, 372, 363, 315, 672, 263, 372, 51, 372, 372, - 372, 44, 372, 372, 372, 372, 1103, 359, 89, 865, - 1159, 1349, 638, 1137, 1138, 638, 1312, 248, 256, 257, - 1300, 1145, 1365, 1329, 1295, 789, 264, 265, 266, 267, - 268, 1176, 270, 271, 1192, 273, 274, 275, 276, 277, - 278, 279, 280, 1167, 1168, 789, 1170, 285, 1127, 287, - 288, 289, 290, 291, 292, 1409, 789, 295, 1115, 1403, - 1322, 299, 300, 783, 302, 303, 304, 0, 1318, 1317, - 1194, 1402, 1049, 1197, 1236, 1176, 314, 948, 316, 810, - 318, 319, 1050, 744, 322, 519, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 334, 335, 371, 337, - 641, 117, 340, 341, 739, 563, 344, 345, 675, 913, - 672, 402, 404, 403, 407, 728, 405, 926, 406, 1013, - 1085, 1137, 898, 205, 1032, 363, 364, 987, 977, 367, - 968, 979, 850, 517, 372, 373, 374, 375, 376, 882, - 0, 426, 380, 1190, 382, 830, 1071, -1, -1, -1, - 388, 389, -1, -1, -1, -1, -1, 810, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 256, 257, 413, 414, 415, 416, -1, - 418, 264, 265, 266, 267, 268, 424, 270, 271, -1, - 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, - -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, - -1, 0, 295, -1, -1, -1, 299, 300, -1, 302, - 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 314, -1, 316, -1, 318, 319, -1, -1, 322, - -1, 324, 325, 326, 327, 328, 329, 330, 331, 332, - 333, 334, 335, -1, 337, -1, -1, 340, 341, -1, - -1, 344, 345, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 363, 364, -1, -1, 367, -1, -1, -1, -1, 372, - 373, 374, 375, 376, -1, -1, -1, 380, -1, 382, - -1, -1, -1, -1, -1, 388, 389, -1, -1, -1, + protected static readonly short [] yyCheck = { 15, + 254, 94, 15, 15, 18, 449, 26, 15, 451, 255, + 4, 16, 246, 191, 406, 178, 206, 177, 488, 18, + 286, 74, 425, 36, 304, 283, 251, 146, 498, 816, + 37, 37, 253, 987, 273, 630, 631, 655, 1029, 1030, + 508, 57, 0, 1115, 37, 268, 256, 100, 64, 15, + 103, 193, 15, 66, 256, 64, 256, 70, 279, 1131, + 610, 15, 100, 77, 78, 103, 15, 83, 268, 256, + 294, 37, 256, 268, 256, 256, 42, 15, 673, 15, + 675, 15, 96, 597, 256, 256, 1077, 256, 256, 325, + 294, 367, 85, 86, 87, 88, 89, 90, 91, 92, + 282, 256, 277, 264, 256, 256, 281, 256, 15, 256, + 268, 367, 77, 78, 371, 256, 367, 256, 276, 0, + 1144, 214, 349, 350, 272, 15, 316, 371, 357, 15, + 146, 96, 314, 146, 146, 400, 367, 358, 146, 368, + 373, 417, 370, 372, 367, 417, 978, 412, 296, 257, + 1174, 15, 339, 15, 426, 339, 385, 344, 178, 346, + 344, 417, 346, 256, 325, 352, 353, 342, 352, 353, + 427, 191, 294, 417, 256, 323, 427, 256, 380, 294, + 146, 417, 415, 146, 306, 465, 390, 445, 417, 632, + 206, 419, 146, 417, 448, 211, 427, 146, 421, 380, + 427, 379, 752, 374, 754, 219, 358, 417, 146, 413, + 146, 366, 146, 368, 307, 370, 371, 256, 373, 272, + 375, 421, 488, 276, 373, 739, 421, 280, 508, 368, + 246, 245, 498, 249, 250, 417, 243, 243, 380, 146, + 427, 255, 280, 427, 251, 417, 262, 261, 417, 417, + 243, 267, 1324, 269, 219, 268, 146, 273, 251, 417, + 146, 256, 417, 269, 419, 294, 417, 422, 284, 285, + 417, 423, 424, 425, 286, 390, 417, 243, 286, 1351, + 245, 297, 146, 878, 146, 753, 368, 301, 297, 368, + 304, 1363, 385, 1365, 294, 417, 261, 915, 413, 257, + 316, 317, 335, 269, 371, 321, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, 596, 410, 411, 256, + 286, 335, 336, 367, 256, 371, 256, 320, 256, 795, + 369, 845, 367, 847, 373, 849, 301, 353, 871, 332, + 333, 334, 435, 786, 337, 338, 341, 368, 256, 363, + 364, 372, 367, 256, 774, 372, 1076, 266, 375, 379, + 427, 390, 765, 256, 1318, 785, 899, 381, 341, 269, + 335, 336, 386, 368, 1094, 1099, 257, 349, 350, 618, + 358, 427, 381, 427, 413, 262, 286, 386, 1353, 1354, + 390, 272, 427, 1384, 427, 368, 277, 1184, 363, 364, + 281, 422, 305, 998, 1236, 314, 256, 420, 256, 634, + 1401, 944, 427, 413, 604, 296, 256, 697, 1142, 425, + 1144, 298, 515, 367, 517, 1145, 371, 870, 373, 366, + 896, 447, 898, 449, 343, 451, 368, 367, 375, 367, + 1035, 1036, 323, 373, 1409, 373, 339, 1042, 461, 462, + 1174, 465, 1099, 1285, 1286, 427, 1288, 473, 366, 425, + 368, 342, 370, 256, 480, 374, 465, 1299, 369, 370, + 1302, 1303, 373, 753, 335, 1195, 488, 349, 350, 1199, + 488, 390, 427, 427, 497, 1317, 498, 371, 581, 339, + 498, 339, 375, 417, 508, 1142, 750, 1144, 380, 339, + 377, 378, 426, 366, 413, 521, 522, 366, 390, 368, + 343, 419, 375, 263, 422, 390, 366, 426, 366, 375, + 513, 779, 488, 713, 643, 764, 366, 1174, 1098, 1099, + 370, 413, 498, 373, 374, 375, 343, 371, 413, 373, + 380, 374, 945, 427, 427, 638, 339, 380, 1118, 256, + 366, 344, 568, 346, 370, 427, 40, 390, 574, 352, + 353, 45, 783, 47, 48, 315, 50, 374, 52, 1039, + 816, 427, 1142, 371, 1144, 373, 60, 368, 62, 263, + 413, 272, 596, 390, 257, 265, 70, 267, 604, 73, + 270, 75, 272, 426, 1099, 275, 80, 81, 305, 279, + 366, 1099, 618, 419, 1174, 296, 413, 368, 288, 375, + 1099, 627, 343, 666, 417, 295, 632, 413, 102, 426, + 300, 637, 302, 343, 304, 366, 417, 634, 1099, 427, + 426, 315, 323, 887, 375, 368, 316, 1142, 318, 1144, + 368, 634, 322, 323, 1142, 659, 1144, 837, 661, 380, + 330, 331, 380, 1142, 334, 1144, 417, 337, 380, 390, + 375, 677, 272, 679, 630, 631, 680, 339, 390, 1174, + 390, 1142, 344, 1144, 346, 691, 1174, 349, 350, 693, + 352, 353, 413, 697, 370, 1174, 296, 390, 373, 339, + 357, 413, 708, 413, 659, 426, 357, 713, 714, 15, + 716, 373, 795, 1174, 426, 372, 426, 673, 366, 675, + 413, 727, 728, 323, 1099, 680, 366, 951, 385, 19, + 734, 37, 375, 426, 385, 375, 42, 27, 693, 213, + 415, 215, 748, 987, 750, 734, 1002, 417, 357, 753, + 367, 366, 756, 370, 390, 372, 373, 256, 764, 256, + 375, 767, 375, 372, 914, 427, 990, 1142, 774, 1144, + 269, 77, 78, 1099, 391, 392, 385, 413, 784, 253, + 786, 306, 357, 1039, 420, 413, 372, 286, 313, 375, + 96, 265, 420, 339, 411, 413, 976, 372, 344, 1174, + 346, 756, 419, 349, 350, 422, 352, 353, 426, 1033, + 385, 294, 816, 896, 385, 1071, 1142, 823, 1144, 825, + 320, 827, 306, 306, 308, 306, 366, 373, 370, 313, + 834, 837, 313, 916, 1216, 375, 417, 337, 338, 843, + 146, 325, 339, 378, 325, 834, 383, 344, 1174, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 366, 371, 367, 373, 870, 1018, 388, 369, 373, 375, + 367, 373, 369, 1306, 371, 380, 373, 374, 375, 399, + 1048, 427, 1106, 1153, 417, 371, 339, 373, 843, 375, + 1160, 344, 389, 346, 381, 382, 349, 350, 901, 352, + 353, 366, 908, 400, 910, 357, 912, 384, 395, 396, + 375, 1203, 368, 219, 924, 412, 368, 1209, 339, 371, + 372, 389, 878, 344, 1216, 346, 393, 394, 349, 350, + 427, 352, 353, 385, 373, 1368, 375, 243, 922, 245, + 371, 380, 373, 372, 375, 951, 339, 421, 1184, 255, + 369, 344, 371, 346, 373, 261, 417, 963, 964, 352, + 353, 375, 339, 269, 369, 971, 371, 344, 373, 346, + 976, 1404, 349, 350, 427, 352, 353, 397, 398, 366, + 286, 987, 977, 370, 990, 372, 373, 461, 375, 354, + 355, 1425, 1426, 380, 272, 301, 357, 0, 304, 277, + 1002, 369, 1008, 281, 1002, 373, 427, 368, 1018, 1015, + 371, 372, 373, 370, 1024, 372, 1026, 369, 296, 413, + 414, 373, 369, 1027, 385, 256, 373, 1033, 369, 335, + 336, 417, 373, 368, 391, 392, 371, 1039, 1048, 1045, + 1046, 1039, 998, 369, 417, 323, 1002, 373, 369, 370, + 427, 372, 373, 374, 411, 371, 417, 363, 364, 375, + 340, 373, 419, 375, 342, 422, 385, 386, 387, 1071, + 1080, 354, 355, 1071, 1318, 375, 373, 1081, 375, 1035, + 1036, 375, 1088, 1039, 366, 369, 1042, 371, 1098, 1099, + 366, 363, 364, 1097, 370, 372, 372, 373, 1104, 375, + 1106, 369, 375, 371, 380, 369, 375, 371, 1118, 417, + 371, 367, 373, 417, 370, 1071, 372, 373, 375, 425, + 0, 341, 342, 343, 344, 371, 369, 373, 371, 369, + 1213, 371, 1142, 371, 1144, 391, 392, 373, 414, 375, + 349, 350, 1097, 1226, 373, 373, 375, 375, 1152, 1153, + 373, 413, 375, 1156, 417, 411, 1160, 371, 372, 465, + 1243, 366, 1245, 419, 1174, 370, 422, 372, 373, 417, + 375, 363, 364, 985, 986, 380, 417, 1181, 1182, 375, + 1184, 371, 488, 339, 340, 417, 1190, 345, 346, 371, + 417, 371, 498, 371, 367, 371, 373, 1152, 417, 1203, + 371, 1205, 508, 371, 1208, 1209, 294, 371, 371, 414, + 294, 373, 1216, 417, 371, 380, 371, 256, 1221, 371, + 373, 375, 370, 373, 417, 374, 1181, 1182, 85, 86, + 87, 88, 89, 90, 91, 92, 401, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 380, 417, 356, 374, + 1205, 373, 372, 1208, 257, 371, 417, 380, 261, 373, + 373, 373, 294, 373, 375, 371, 417, 427, 373, 272, + 366, 417, 371, 417, 277, 422, 343, 372, 281, 373, + 294, 284, 294, 373, 417, 370, 1296, 369, 417, 366, + 596, 0, 256, 296, 297, 374, 256, 373, 301, 302, + 1306, 1304, 256, 1313, 307, 256, 309, 310, 311, 312, + 371, 380, 1318, 371, 317, 280, 1326, 1327, 321, 256, + 323, 366, 371, 367, 630, 631, 417, 375, 417, 1335, + 333, 417, 335, 336, 417, 338, 370, 417, 375, 342, + 414, 371, 373, 1353, 1354, 373, 375, 369, 375, 420, + 371, 347, 422, 659, 380, 366, 359, 351, 256, 256, + 380, 380, 1368, 371, 367, 368, 367, 673, 347, 675, + 369, 371, 374, 348, 680, 373, 369, 257, 366, 371, + 369, 261, 417, 374, 371, 367, 339, 693, 373, 373, + 348, 697, 272, 417, 417, 375, 367, 277, 1404, 1409, + 374, 281, 380, 366, 284, 366, 356, 1410, 1411, 366, + 417, 367, 367, 375, 1417, 1418, 296, 297, 370, 1425, + 1426, 301, 302, 367, 373, 256, 283, 307, 371, 309, + 310, 311, 312, 367, 337, 305, 417, 317, 370, 370, + 417, 321, 368, 323, 417, 417, 366, 753, 417, 370, + 756, 375, 370, 333, 370, 370, 336, 380, 338, 372, + 370, 366, 342, 320, 370, 373, 380, 368, 372, 371, + 256, 371, 417, 372, 366, 332, 333, 334, 373, 359, + 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, + 347, 348, 349, 350, 351, 352, 373, 373, 371, 371, + 375, 369, 371, 315, 375, 417, 0, 367, 339, 375, + 816, 375, 371, 344, 369, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 417, 417, 371, 380, + 371, 380, 367, 263, 370, 367, 367, 843, 369, 0, + 371, 370, 373, 374, 375, 371, 371, 256, 257, 366, + 417, 375, 375, 367, 375, 264, 265, 266, 267, 268, + 371, 270, 271, 367, 273, 274, 275, 276, 277, 278, + 279, 280, 878, 371, 371, 369, 285, 366, 287, 288, + 289, 290, 291, 292, 375, 367, 295, 367, 445, 366, + 299, 300, 371, 302, 303, 304, 427, 375, 369, 417, + 375, 417, 375, 367, 371, 314, 375, 316, 371, 318, + 319, 367, 371, 322, 367, 324, 325, 326, 327, 328, + 329, 330, 331, 332, 333, 334, 335, 417, 337, 371, + 366, 340, 341, 367, 367, 344, 345, 375, 366, 0, + 372, 315, 263, 25, 375, 26, 285, 10, 375, 375, + 375, 360, 361, 362, 375, 375, 513, 366, 367, 375, + 375, 370, 5, 976, 1118, 834, 375, 376, 377, 378, + 379, 734, 1358, 976, 383, 1321, 385, 596, 1174, 1374, + 1309, 1304, 391, 392, 1338, 758, 1190, 1203, 327, 1418, + 758, 1142, 998, 758, 1130, 752, 1002, 1412, 1331, 1080, + 1327, 1326, 1411, 465, 1245, 1190, 1024, 416, 417, 418, + 419, 1081, 421, 779, 522, 637, 713, 316, 427, 604, + 887, 1027, 708, 54, 347, 634, 348, 351, 1064, 1035, + 1036, 349, 352, 1039, 350, 901, 1042, 376, 377, 378, + 379, 1152, 381, 382, 383, 384, 385, 386, 387, 388, + 697, 1071, 391, 392, 393, 394, 395, 396, 397, 398, + 1002, 146, 964, 257, 856, 1071, 821, 261, 872, 263, + 954, 265, 463, 267, 799, 1081, 270, 956, 272, 273, + 371, 275, 1148, 277, -1, 279, 945, 281, 282, 283, + 284, 1097, 1046, 287, 288, -1, -1, -1, -1, 293, + 294, 295, 296, 297, -1, -1, 300, 301, 302, -1, + 304, 0, 306, 307, 308, 309, 310, 311, 312, 313, + -1, 315, 316, 317, 318, -1, -1, 321, 322, 323, + -1, 325, -1, -1, -1, -1, 330, 331, -1, 333, + 334, -1, 336, 337, 338, -1, 1152, 1153, 342, -1, + -1, -1, -1, -1, 1160, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 359, -1, -1, -1, 363, + 364, -1, -1, -1, -1, 1181, 1182, -1, 1184, 0, + -1, -1, 376, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, -1, -1, 1205, + -1, -1, 1208, 264, 265, 266, 267, 268, -1, 270, + 271, -1, 273, 274, 275, 276, 277, 278, 279, -1, + -1, -1, 779, 417, 285, -1, 287, 288, 289, 290, + 291, 292, -1, -1, 295, -1, -1, -1, 299, 300, + -1, 302, 303, 304, -1, -1, -1, -1, 0, -1, + -1, -1, -1, 314, -1, 316, -1, 318, 319, -1, + -1, 322, -1, 324, 325, 326, 327, 328, 329, 330, + 331, 332, 333, 334, 335, -1, 337, -1, -1, 340, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, 0, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, 366, 367, -1, -1, 370, + -1, -1, -1, -1, 375, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 256, 257, -1, -1, -1, 261, -1, - 413, 414, 415, 416, -1, 418, -1, -1, -1, 272, - -1, 424, -1, -1, 277, -1, -1, -1, 281, -1, - -1, 284, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 296, 297, -1, -1, -1, 301, 302, + -1, -1, -1, -1, -1, 416, 417, 418, 419, -1, + 421, -1, -1, -1, 0, -1, 427, 256, 257, -1, + -1, -1, 261, -1, -1, -1, 265, -1, 267, -1, + -1, 270, -1, 272, 273, -1, 275, -1, 277, -1, + 279, -1, 281, 282, 283, 284, -1, -1, 287, 288, + -1, -1, -1, -1, 293, -1, 295, 296, 297, -1, + -1, 300, 301, 302, -1, 304, -1, -1, 307, -1, + 309, 310, 311, 312, -1, -1, -1, 316, 317, 318, + -1, -1, 321, 322, 323, -1, 257, 0, -1, -1, + 261, 330, 331, -1, 333, 334, -1, 336, 337, 338, + -1, 272, -1, 342, -1, -1, 277, -1, -1, -1, + 281, -1, -1, 284, -1, -1, -1, -1, -1, -1, + 359, -1, -1, -1, -1, 296, 297, -1, 367, 368, + 301, 302, -1, -1, -1, -1, 307, 376, 309, 310, + 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, + 321, -1, 323, -1, 0, 257, -1, -1, -1, 261, + -1, -1, 333, -1, 335, 336, -1, 338, -1, -1, + 272, 342, -1, -1, -1, 277, -1, -1, 417, 281, + -1, -1, 284, -1, -1, -1, -1, -1, 359, -1, + -1, -1, -1, -1, 296, 297, -1, 368, 257, 301, + 302, -1, 261, -1, -1, 307, -1, 309, 310, 311, + 312, -1, -1, 272, -1, 317, -1, -1, 277, 321, + -1, 323, 281, 0, -1, 284, -1, -1, -1, -1, + -1, 333, -1, -1, 336, -1, 338, 296, 297, -1, + 342, -1, 301, 302, -1, -1, -1, -1, 307, -1, + 309, 310, 311, 312, -1, -1, -1, 359, 317, -1, + -1, -1, 321, -1, 323, 367, 368, -1, -1, -1, + -1, 257, -1, -1, 333, 261, -1, 336, -1, 338, + -1, -1, -1, 342, -1, -1, 272, -1, -1, -1, + 0, 277, -1, -1, -1, 281, -1, -1, 284, -1, + 359, -1, -1, -1, -1, -1, -1, -1, 367, 368, + 296, 297, -1, -1, -1, 301, 302, -1, -1, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + -1, 317, -1, -1, -1, 321, -1, 323, -1, -1, + -1, -1, -1, -1, 257, -1, -1, 333, 261, -1, + 336, -1, 338, -1, -1, -1, 342, -1, -1, 272, + -1, -1, -1, -1, 277, -1, -1, -1, 281, -1, + -1, 284, -1, 359, -1, -1, -1, -1, -1, -1, + -1, -1, 368, 296, 297, -1, -1, -1, 301, 302, -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, 321, -1, - 323, -1, -1, -1, -1, -1, -1, 257, -1, -1, - 333, 261, 335, 336, -1, 338, -1, -1, -1, 342, - -1, -1, 272, -1, -1, -1, -1, 277, -1, -1, - -1, 281, -1, -1, 284, 358, 359, -1, -1, -1, - -1, 364, 365, -1, -1, -1, 296, 297, -1, -1, - -1, 301, 302, -1, -1, -1, -1, 307, -1, 309, - 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, - -1, 321, -1, 323, -1, -1, -1, -1, 257, -1, - -1, -1, 261, 333, -1, -1, 336, -1, 338, -1, - -1, -1, 342, 272, -1, -1, -1, -1, 277, -1, - -1, -1, 281, -1, -1, 284, -1, -1, -1, 359, - -1, -1, -1, -1, -1, -1, -1, 296, 297, -1, - -1, -1, 301, 302, -1, -1, -1, -1, 307, -1, - 309, 310, 311, 312, -1, 261, -1, -1, 317, -1, - -1, -1, 321, -1, 323, -1, 272, -1, -1, -1, - -1, 277, -1, -1, 333, 281, -1, 336, 284, 338, - -1, -1, -1, 342, -1, -1, -1, -1, -1, -1, - 296, 297, -1, 256, -1, 301, 302, -1, 261, 262, - 359, 307, -1, 309, 310, 311, 312, -1, -1, -1, + 323, 257, -1, -1, -1, 261, -1, -1, -1, -1, + 333, -1, -1, 336, -1, 338, 272, -1, -1, 342, + -1, 277, -1, -1, -1, 281, -1, -1, 284, -1, + -1, -1, -1, -1, -1, -1, 359, -1, -1, -1, + 296, 297, -1, -1, -1, 301, 302, -1, -1, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, 321, -1, 323, -1, -1, - -1, 284, -1, -1, -1, -1, -1, 333, -1, -1, - 336, 294, 338, -1, 297, 298, 342, -1, -1, 302, - -1, -1, 305, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, 359, 317, -1, -1, -1, 321, -1, - -1, -1, 325, -1, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, -1, 338, 339, -1, -1, -1, - -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, -1, -1, 359, -1, -1, -1, - 363, 364, -1, 366, 367, 368, 369, 370, 371, 372, - -1, 374, 375, -1, 377, 378, 379, 380, 381, 382, - 383, 384, 385, 386, -1, 388, 389, 390, 391, 392, - 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, - 403, 404, 405, 406, 407, 408, 409, -1, -1, 412, - -1, 414, 256, 416, -1, -1, 419, 261, 262, -1, - -1, 424, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 284, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 294, -1, -1, 297, 298, -1, -1, -1, 302, -1, - -1, 305, -1, 307, -1, 309, 310, 311, 312, -1, - -1, -1, -1, 317, -1, -1, -1, 321, -1, -1, - -1, 325, -1, -1, -1, -1, -1, -1, -1, 333, - -1, -1, 336, -1, 338, 339, -1, -1, -1, -1, - 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, -1, 359, -1, -1, -1, 363, - 364, 365, 366, 367, 368, 369, 370, 371, 372, -1, - 374, 375, -1, -1, 378, 379, 380, 381, 382, -1, - -1, 385, 386, -1, -1, -1, 390, 391, 392, 393, - 394, 395, 396, 397, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 409, -1, -1, 412, -1, - 414, -1, 416, 256, -1, 419, -1, -1, -1, -1, - 424, 264, 265, 266, 267, -1, -1, 270, 271, -1, + 257, -1, -1, -1, 261, -1, -1, 333, -1, -1, + 336, -1, 338, -1, -1, 272, 342, -1, -1, -1, + 277, -1, -1, -1, 281, -1, -1, 284, -1, -1, + -1, -1, -1, 359, -1, -1, -1, -1, -1, 296, + 297, -1, -1, -1, 301, 302, -1, -1, -1, -1, + 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, + 317, -1, -1, -1, 321, -1, 323, 257, -1, -1, + -1, 261, -1, -1, -1, -1, 333, -1, -1, 336, + -1, 338, 272, -1, -1, 342, -1, 277, -1, -1, + -1, 281, -1, -1, 284, -1, -1, -1, -1, -1, + -1, -1, 359, -1, -1, -1, 296, 297, -1, 256, + -1, 301, 302, -1, 261, 262, -1, 307, -1, 309, + 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, + -1, 321, -1, 323, -1, -1, -1, 284, -1, -1, + -1, -1, -1, 333, -1, -1, 336, 294, 338, -1, + 297, 298, 342, -1, -1, 302, -1, -1, 305, -1, + 307, -1, 309, 310, 311, 312, -1, -1, -1, 359, + 317, -1, -1, -1, 321, -1, -1, -1, 325, -1, + -1, -1, -1, -1, -1, -1, 333, -1, -1, 336, + -1, 338, 339, -1, -1, -1, -1, 344, -1, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, 359, -1, -1, -1, -1, -1, -1, 366, + 367, -1, 369, 370, 371, 372, 373, 374, 375, -1, + 377, 378, -1, 380, 381, 382, 383, 384, 385, 386, + 387, 388, 389, -1, 391, 392, 393, 394, 395, 396, + 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, + 407, 408, 409, 410, 411, 412, -1, -1, 415, -1, + 417, -1, 419, 256, -1, 422, -1, -1, -1, -1, + 427, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, -1, -1, 295, -1, -1, -1, 299, 300, -1, 302, @@ -10475,100 +10568,155 @@ void case_919() -1, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, -1, 337, -1, -1, 340, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 256, -1, -1, -1, -1, 261, 262, - 363, -1, -1, -1, 367, -1, -1, -1, -1, 372, - 373, 374, 375, 376, -1, -1, -1, 380, -1, 382, - -1, 284, -1, -1, -1, 388, 389, -1, -1, -1, - -1, 294, -1, -1, 297, 298, -1, -1, -1, 302, - -1, -1, 305, -1, 307, -1, 309, 310, 311, 312, - 413, 414, 415, 416, 317, -1, -1, -1, 321, -1, - -1, 424, 325, -1, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, -1, 338, 339, -1, -1, -1, - -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, -1, -1, 359, -1, -1, -1, - 363, 364, 365, 366, 367, 368, -1, 370, 371, 372, - -1, 374, 375, -1, -1, 378, 379, 380, 381, -1, - -1, -1, 385, 386, -1, -1, -1, 390, 391, 392, - 393, 394, 395, 396, 397, 256, -1, -1, -1, -1, - 261, 262, -1, -1, -1, -1, 409, -1, -1, 412, - -1, 414, -1, 416, -1, -1, 419, -1, -1, -1, - -1, 424, -1, 284, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 294, -1, -1, 297, 298, -1, -1, - -1, 302, -1, -1, 305, -1, 307, -1, 309, 310, - 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, - 321, -1, -1, -1, 325, -1, -1, -1, -1, -1, - -1, -1, 333, -1, 256, 336, -1, 338, 339, -1, - 262, -1, -1, 344, -1, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, -1, -1, 359, -1, - -1, -1, 363, 364, 365, 366, 367, 368, -1, 370, - 371, 372, -1, 374, 375, -1, 298, 378, 379, 380, - 381, -1, -1, -1, 385, 386, -1, -1, -1, 390, - 391, 392, 393, 394, 395, 396, 397, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 409, -1, - -1, 412, -1, 414, -1, 416, -1, 339, 419, -1, - -1, -1, 344, 424, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, - -1, -1, 364, 365, 366, 367, 368, 369, 370, 371, - 372, -1, 374, 375, -1, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, 261, 388, 389, 390, 391, - 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, - 402, 403, 404, 405, 406, 407, 408, 409, 284, -1, - 256, -1, 414, -1, 416, 261, 262, 419, -1, -1, - -1, 297, 424, -1, -1, -1, 302, -1, -1, 305, - -1, 307, -1, 309, 310, 311, 312, -1, 284, -1, - -1, 317, -1, -1, -1, 321, -1, -1, 294, 325, - -1, 297, 298, -1, -1, -1, 302, 333, -1, 305, - 336, 307, 338, 309, 310, 311, 312, -1, -1, -1, - -1, 317, -1, -1, -1, 321, -1, -1, -1, 325, - -1, -1, -1, 359, -1, -1, -1, 333, -1, 256, - 336, -1, 338, 339, -1, 262, -1, -1, 344, -1, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, 359, -1, -1, -1, 363, 364, -1, - 366, 367, 368, -1, 370, 371, 372, -1, 374, 375, - -1, 298, 378, 379, 380, 381, -1, -1, 414, 385, - 386, -1, -1, -1, 390, 391, 392, 393, 394, 395, - 396, 397, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 409, -1, -1, 412, -1, 414, -1, - -1, -1, 339, -1, -1, -1, -1, 344, 424, 346, + -1, -1, -1, -1, -1, -1, 256, 360, 361, 362, + -1, 261, 262, 366, -1, -1, -1, 370, -1, -1, + -1, -1, 375, 376, 377, 378, 379, -1, -1, -1, + 383, -1, 385, -1, 284, -1, -1, -1, 391, 392, + -1, -1, -1, -1, 294, -1, -1, 297, 298, -1, + -1, -1, 302, -1, -1, 305, -1, 307, -1, 309, + 310, 311, 312, 416, 417, 418, 419, 317, -1, -1, + -1, 321, -1, -1, 427, 325, -1, -1, -1, -1, + -1, -1, -1, 333, -1, -1, 336, -1, 338, 339, + -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, 357, -1, 359, + -1, -1, -1, -1, -1, -1, 366, 367, 368, 369, + 370, 371, 372, 373, 374, 375, -1, 377, 378, -1, + -1, 381, 382, 383, 384, 385, -1, -1, 388, 389, + -1, -1, -1, 393, 394, 395, 396, 397, 398, 399, + 400, 256, -1, -1, -1, -1, 261, 262, -1, -1, + -1, -1, 412, -1, -1, 415, -1, 417, -1, 419, + -1, -1, 422, -1, -1, -1, -1, 427, -1, 284, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 294, + -1, -1, 297, 298, -1, -1, -1, 302, -1, -1, + 305, -1, 307, -1, 309, 310, 311, 312, -1, -1, + -1, -1, 317, -1, -1, -1, 321, -1, -1, -1, + 325, -1, -1, -1, -1, -1, -1, -1, 333, -1, + -1, 336, -1, 338, 339, -1, -1, -1, -1, 344, + -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, 359, -1, -1, -1, -1, -1, + -1, 366, 367, 368, 369, 370, 371, -1, 373, 374, + 375, -1, 377, 378, -1, -1, 381, 382, 383, 384, + -1, -1, -1, 388, 389, -1, -1, -1, 393, 394, + 395, 396, 397, 398, 399, 400, 256, -1, -1, -1, + -1, 261, 262, -1, -1, -1, -1, 412, -1, -1, + 415, -1, 417, -1, 419, -1, -1, 422, -1, -1, + -1, -1, 427, -1, 284, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 294, -1, -1, 297, 298, -1, + -1, -1, 302, -1, -1, 305, -1, 307, -1, 309, + 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, + -1, 321, -1, -1, -1, 325, -1, -1, -1, -1, + -1, -1, -1, 333, -1, -1, 336, -1, 338, 339, + -1, -1, 256, -1, 344, -1, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, -1, -1, 359, + -1, -1, -1, -1, -1, -1, 366, 367, 368, 369, + 370, 371, -1, 373, 374, 375, -1, 377, 378, 256, + -1, 381, 382, 383, 384, 262, -1, -1, 388, 389, + -1, -1, -1, 393, 394, 395, 396, 397, 398, 399, + 400, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 412, -1, -1, 415, -1, 417, -1, 419, + -1, 298, 422, -1, -1, 339, -1, 427, -1, -1, + 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 367, -1, 369, -1, 371, -1, 373, + 374, 375, 339, -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - -1, -1, -1, -1, -1, -1, 363, 364, 365, 366, - 367, 368, 369, 370, 371, 372, -1, 374, 375, -1, - 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, - -1, 388, 389, 390, 391, 392, 393, 394, 395, 396, + 357, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 367, 368, 369, 370, 371, 372, 373, 374, 375, -1, + 377, 378, -1, 380, 381, 382, 383, 384, 385, 386, + 387, 388, 389, 427, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, - 407, 408, 409, -1, 256, 256, -1, -1, -1, 416, - 262, -1, -1, -1, 265, -1, 267, 424, -1, 270, - -1, -1, -1, -1, 275, -1, -1, -1, 279, -1, - -1, -1, -1, -1, -1, -1, -1, 288, -1, -1, - -1, -1, -1, -1, 295, -1, 298, -1, -1, 300, - -1, -1, -1, 304, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 316, -1, 318, -1, -1, - -1, 322, -1, -1, -1, -1, -1, -1, -1, 330, - 331, -1, -1, 334, -1, -1, 337, 339, -1, -1, + 407, 408, 409, 410, 411, 412, -1, -1, 256, -1, + 417, -1, 419, 261, 262, 422, -1, -1, -1, -1, + 427, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 284, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 294, -1, -1, 297, + 298, -1, -1, -1, 302, -1, -1, 305, -1, 307, + -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, + -1, -1, -1, 321, -1, -1, -1, 325, -1, -1, + -1, -1, -1, -1, -1, 333, -1, -1, 336, -1, + 338, 339, -1, -1, -1, -1, 344, -1, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, + -1, 359, -1, -1, 256, -1, -1, -1, 366, 367, + 262, 369, 370, 371, -1, 373, 374, 375, -1, 377, + 378, -1, -1, 381, 382, 383, 384, -1, -1, -1, + 388, 389, -1, -1, -1, 393, 394, 395, 396, 397, + 398, 399, 400, -1, -1, -1, 298, -1, -1, -1, + -1, -1, -1, -1, 412, -1, -1, 415, -1, 417, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 427, + 256, -1, -1, -1, -1, -1, 262, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - -1, 363, 364, -1, 366, 367, 368, 369, 370, 371, - 372, -1, 374, 375, -1, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, -1, 388, 389, 390, 391, + -1, -1, 298, -1, 366, 367, 368, 369, 370, 371, + 372, 373, 374, 375, -1, 377, 378, -1, 380, 381, + 382, 383, 384, 385, 386, 387, 388, 389, -1, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, - 402, 403, 404, 405, 406, 407, 408, 409, -1, 256, - 256, -1, -1, 414, 416, 262, -1, 419, -1, 265, - -1, 267, 424, -1, 270, -1, -1, -1, -1, 275, - -1, -1, -1, 279, -1, -1, -1, -1, -1, -1, - -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, - -1, 298, -1, -1, 300, -1, -1, -1, 304, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 316, -1, 318, -1, -1, -1, 322, -1, -1, -1, - -1, -1, -1, -1, 330, 331, -1, -1, 334, -1, - -1, 337, 339, -1, -1, -1, -1, 344, -1, 346, - 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - -1, -1, -1, -1, -1, -1, -1, 364, -1, 366, - 367, 368, 369, 370, 371, 372, -1, 374, 375, -1, - 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, - -1, 388, 389, 390, 391, 392, 393, 394, 395, 396, - 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, - 407, 408, 409, -1, 256, 256, -1, -1, 414, 416, - 262, -1, 419, -1, 265, -1, 267, 424, -1, 270, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, + 412, -1, 256, -1, -1, -1, -1, 419, 262, -1, + -1, -1, -1, -1, -1, 427, -1, -1, -1, -1, + -1, 367, -1, -1, 370, -1, 372, 373, -1, -1, + -1, 377, 378, -1, -1, 381, 382, 383, 384, 385, + 386, 387, 388, 389, 298, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 411, 412, -1, -1, -1, + -1, -1, -1, 419, 262, -1, 422, -1, -1, -1, + -1, 427, -1, -1, -1, 339, -1, -1, -1, -1, + 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, -1, -1, -1, -1, + 298, -1, 366, 367, -1, 369, 370, 371, 372, 373, + 374, 375, -1, 377, 378, -1, 380, 381, 382, 383, + 384, 385, 386, 387, 388, 389, -1, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, + 404, 405, 406, 407, 408, 409, 410, 411, 412, -1, + 256, -1, -1, -1, -1, 419, 262, -1, 422, 357, + -1, -1, -1, 427, -1, -1, -1, -1, -1, -1, + 368, -1, 370, -1, 372, -1, -1, 375, -1, 377, + 378, -1, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 298, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, -1, -1, -1, -1, 417, + -1, 419, 262, -1, 422, -1, -1, -1, -1, 427, + -1, -1, -1, 339, -1, -1, -1, -1, 344, -1, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + 356, -1, -1, -1, -1, -1, -1, -1, 298, -1, + -1, 367, -1, 369, 370, 371, 372, 373, 374, 375, + -1, 377, 378, -1, 380, 381, 382, 383, 384, 385, + 386, 387, 388, 389, -1, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, + 406, 407, 408, 409, 410, 411, 412, -1, 256, -1, + -1, -1, -1, 419, 262, -1, 422, -1, -1, -1, + -1, 427, -1, -1, -1, -1, -1, -1, 368, -1, + 370, 371, 372, 373, -1, 375, -1, 377, 378, -1, + 380, 381, 382, 383, 384, -1, 386, 387, 388, 389, + 298, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, + 410, 411, 412, -1, -1, -1, -1, 417, -1, 419, + 262, -1, 422, -1, -1, -1, -1, 427, -1, -1, + -1, 339, -1, -1, -1, -1, 344, -1, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, + -1, -1, -1, -1, -1, -1, 298, -1, -1, 367, + -1, 369, 370, 371, 372, 373, 374, 375, -1, 377, + 378, -1, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, -1, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, -1, 256, -1, -1, -1, + -1, 419, 262, -1, 422, -1, -1, -1, -1, 427, + -1, -1, -1, -1, -1, -1, -1, 369, 370, 371, + 372, 373, -1, -1, -1, 377, 378, -1, 380, 381, + 382, 383, 384, 385, 386, 387, 388, 389, 298, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, + 412, -1, -1, -1, -1, -1, -1, 419, -1, -1, + 422, -1, -1, -1, -1, 427, -1, -1, -1, 339, + -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 367, -1, 369, + 370, 371, 372, 373, 374, 375, -1, 377, -1, -1, + 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, + -1, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, + 410, 411, 412, -1, 256, 256, -1, -1, -1, 419, + 262, -1, 422, -1, 265, -1, 267, 427, -1, 270, -1, -1, -1, -1, 275, -1, -1, -1, 279, -1, -1, -1, -1, -1, -1, -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, -1, 298, -1, -1, 300, @@ -10576,295 +10724,234 @@ void case_919() -1, -1, -1, -1, -1, 316, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, 330, 331, -1, -1, 334, -1, -1, 337, 339, -1, -1, - -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - -1, -1, 364, -1, 366, 367, 368, 369, 370, 371, - 372, -1, 374, 375, -1, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, -1, 388, 389, 390, 391, - 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, - 402, 403, 404, 405, 406, 407, 408, 409, -1, 256, - 256, -1, -1, 414, 416, 262, -1, 419, -1, 265, - -1, 267, 424, -1, 270, -1, -1, -1, -1, 275, - -1, -1, -1, 279, -1, -1, -1, -1, -1, -1, - -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, - -1, 298, -1, -1, 300, -1, -1, -1, 304, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 316, -1, 318, -1, -1, -1, 322, -1, -1, -1, - -1, -1, -1, -1, 330, 331, -1, -1, 334, -1, - -1, 337, 339, -1, -1, -1, -1, 344, -1, 346, - 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - -1, -1, -1, -1, -1, -1, -1, 364, -1, 366, - 367, 368, 369, 370, 371, 372, -1, 374, 256, -1, - 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, - -1, 388, 389, 390, 391, 392, 393, 394, 395, 396, - 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, - 407, 408, 409, -1, 256, -1, -1, -1, 414, 416, - 262, -1, 419, -1, -1, -1, -1, 424, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 298, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, -1, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, -1, -1, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, -1, 339, -1, -1, -1, 256, 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - -1, -1, 364, -1, 366, -1, 368, -1, 370, 371, - 372, -1, 374, 375, -1, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, -1, 424, -1, 390, 391, - 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, - 402, 403, 404, 405, 406, 407, 256, 409, -1, -1, - -1, -1, 262, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 424, -1, 339, -1, -1, -1, -1, 344, + -1, -1, -1, -1, -1, 367, -1, 369, -1, 371, + -1, 373, 374, 375, -1, 377, 378, -1, 380, 381, + 382, 383, 384, 385, 386, 387, 388, 389, -1, -1, + -1, 393, 394, 395, 396, 397, 398, 399, 400, 401, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 256, + 412, -1, -1, -1, -1, 262, 417, -1, -1, -1, + -1, -1, -1, -1, 339, 427, -1, -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, -1, -1, 294, -1, -1, -1, 298, 364, - -1, 366, -1, 368, -1, 370, 371, 372, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 386, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, -1, -1, -1, 339, - -1, 262, -1, -1, 344, -1, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, -1, 424, - -1, -1, -1, 363, 364, 365, 366, 367, 368, 369, - 370, 371, 372, 294, 374, 375, -1, 298, 378, 379, - 380, 381, 382, -1, -1, 385, 386, -1, -1, -1, - 390, 391, 392, 393, 394, 395, 396, 397, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 409, - -1, -1, 412, -1, 414, -1, 416, -1, 339, 419, - -1, -1, -1, 344, 424, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, -1, -1, 256, -1, - -1, -1, 363, 364, 262, 366, 367, 368, -1, 370, - 371, 372, -1, 374, 375, -1, -1, 378, 379, 380, - 381, -1, -1, -1, 385, 386, -1, -1, -1, 390, - 391, 392, 393, 394, 395, 396, 397, -1, -1, -1, - 298, -1, -1, -1, -1, -1, -1, -1, 409, -1, - -1, 412, -1, 414, -1, -1, -1, -1, -1, -1, - -1, -1, 256, 424, -1, -1, -1, -1, 262, -1, + 355, 356, -1, -1, -1, -1, -1, 294, -1, -1, + -1, 298, 367, -1, 369, -1, 371, -1, 373, 374, + 375, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 389, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, -1, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, -1, 298, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, 374, 375, -1, -1, - 378, 379, 380, 381, 382, 383, 384, 385, 386, -1, - -1, -1, 390, 391, 392, 393, 394, 395, 396, 397, - -1, 256, -1, -1, -1, 339, -1, 262, -1, -1, - 344, 409, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, 424, -1, -1, -1, - 364, -1, 366, -1, 368, -1, 370, 371, 372, -1, - 374, 375, -1, 298, 378, 379, 380, 381, -1, -1, - -1, 385, 386, -1, -1, -1, 390, 391, 392, 393, - 394, 395, 396, 397, -1, 256, -1, -1, -1, -1, - -1, 262, -1, -1, -1, 409, -1, -1, -1, -1, - -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, - 424, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, -1, -1, -1, -1, -1, 298, -1, 364, - -1, 366, -1, 368, -1, 370, 371, 372, -1, 374, - 375, -1, -1, 378, 379, 380, 381, -1, -1, -1, - 385, 386, -1, -1, -1, 390, 391, 392, 393, 394, - 395, 396, 397, -1, 256, -1, -1, -1, 339, -1, - 262, -1, -1, 344, 409, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, -1, -1, -1, 424, - -1, -1, -1, 364, -1, 366, -1, 368, -1, 370, - 371, 372, -1, 374, 375, -1, 298, 378, 379, 380, - 381, -1, -1, -1, 385, 386, -1, -1, -1, 390, - 391, 392, 393, 394, 395, 396, 397, -1, 256, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 409, -1, - -1, -1, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 424, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - -1, -1, 364, -1, 366, -1, 368, -1, 370, 371, - 372, -1, 374, 375, -1, -1, 378, 379, 380, 381, - -1, -1, 256, 385, 386, -1, -1, -1, 390, 391, - 392, 393, 394, 395, 396, 397, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 409, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 424, -1, -1, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, -1, -1, -1, -1, - 378, 379, 380, 381, -1, -1, 256, 385, 386, -1, - -1, -1, 390, 391, 392, 393, 394, 395, 396, 397, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 409, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, 424, -1, -1, -1, - 364, -1, 366, -1, 368, -1, 370, 371, 372, -1, - -1, -1, -1, -1, 378, 379, 380, 381, -1, -1, - 256, 385, 386, -1, -1, -1, 390, 391, 392, 393, - 394, 395, 396, 397, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 409, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - 424, -1, -1, -1, 364, -1, 366, -1, 368, -1, - 370, 371, 372, -1, -1, -1, -1, -1, 378, 379, - 380, 381, -1, -1, 256, 385, 386, -1, -1, -1, - 390, 391, 392, 393, 394, 395, 396, 397, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 409, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, 424, -1, -1, -1, 364, -1, - 366, -1, 368, -1, 370, 371, 372, -1, -1, -1, - -1, -1, 378, 379, 380, 381, -1, -1, 256, 385, - 386, -1, -1, -1, -1, -1, 392, 393, 394, 395, - 396, 397, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 409, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, 424, -1, - -1, -1, 364, -1, 366, -1, 368, -1, 370, 371, - 372, -1, -1, -1, -1, -1, 378, 379, 380, 381, - -1, -1, 256, 385, 386, -1, -1, -1, -1, -1, - 392, 393, 394, 395, 396, 397, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 409, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 424, -1, -1, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, -1, -1, -1, -1, - 378, 379, 380, 381, -1, -1, 256, 385, 386, -1, - -1, -1, -1, -1, 392, 393, 394, 395, 396, 397, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 409, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 256, -1, -1, 424, -1, -1, 262, - 364, -1, 366, -1, 368, -1, 370, 371, 372, -1, - -1, -1, -1, -1, 378, 379, 380, 381, -1, -1, - -1, 385, 386, -1, -1, -1, -1, -1, 392, 393, - 394, 395, 396, 397, -1, 298, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 409, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - 424, -1, -1, -1, 364, -1, 366, -1, 368, -1, - 370, 371, 372, -1, 256, -1, -1, -1, 378, 379, - 380, 381, -1, -1, -1, 385, 386, -1, -1, -1, - -1, -1, 392, 393, 394, 395, 396, 397, -1, -1, - -1, 364, -1, -1, 367, -1, 369, 370, -1, 409, - -1, 374, 375, -1, -1, 378, 379, 380, 381, 382, - 383, 384, 385, 386, 424, 388, 389, 390, 391, 392, - 393, 394, 395, 396, 397, -1, -1, -1, 256, -1, - -1, -1, -1, -1, -1, 408, 409, -1, -1, -1, - -1, -1, -1, 416, -1, -1, 419, 339, -1, -1, - -1, 424, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - -1, -1, 364, -1, 366, -1, 368, -1, 370, 371, - 372, -1, -1, -1, -1, -1, -1, -1, 380, 381, - -1, -1, 256, 385, 386, -1, -1, -1, -1, -1, - -1, -1, 394, 395, 396, 397, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 409, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 424, -1, -1, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, -1, -1, -1, -1, - -1, -1, 380, 381, -1, -1, 256, 385, 386, -1, - -1, -1, -1, -1, -1, -1, 394, 395, 396, 397, + -1, -1, 339, -1, -1, -1, -1, 344, -1, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 357, -1, 427, -1, -1, -1, -1, -1, -1, 366, + 367, 368, 369, 370, 371, 372, 373, 374, 375, -1, + 377, 378, -1, -1, 381, 382, 383, 384, 385, 256, + -1, 388, 389, 261, -1, 262, 393, 394, 395, 396, + 397, 398, 399, 400, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 412, 284, -1, 415, -1, + 417, -1, 419, -1, -1, 422, -1, 294, -1, 297, + 427, 298, -1, -1, 302, -1, -1, 305, -1, 307, + -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, + -1, -1, -1, 321, -1, -1, -1, 325, -1, -1, + -1, -1, -1, -1, -1, 333, -1, -1, 336, -1, + 338, -1, 339, -1, -1, -1, -1, 344, -1, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, 359, 256, -1, -1, -1, -1, -1, 262, 366, + 367, -1, 369, 370, 371, -1, 373, 374, 375, -1, + 377, 378, -1, -1, 381, 382, 383, 384, -1, -1, + -1, 388, 389, -1, -1, -1, 393, 394, 395, 396, + 397, 398, 399, 400, 298, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 412, -1, -1, 415, 417, + 417, -1, -1, -1, -1, -1, -1, -1, -1, 256, + 427, -1, -1, -1, -1, 262, -1, -1, -1, -1, -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 409, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, 424, -1, -1, -1, - 364, -1, 366, -1, 368, -1, 370, 371, 372, -1, - -1, -1, -1, -1, -1, -1, 380, 381, -1, -1, - 256, 385, 386, -1, -1, -1, -1, -1, -1, -1, - 394, 395, 396, 397, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 409, 346, 347, 348, 349, + 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, -1, -1, -1, -1, + -1, 298, -1, 367, -1, 369, -1, 371, -1, 373, + 374, 375, -1, 377, 378, -1, -1, 381, 382, 383, + 384, 385, 386, 387, 388, 389, -1, -1, -1, 393, + 394, 395, 396, 397, 398, 399, 400, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 412, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, 256, 427, -1, -1, -1, -1, 262, -1, + 367, 261, 369, 263, 371, -1, 373, 374, 375, -1, + 377, 378, -1, -1, 381, 382, 383, 384, -1, -1, + -1, 388, 389, -1, 284, -1, 393, 394, 395, 396, + 397, 398, 399, 400, 298, -1, -1, 297, -1, -1, + -1, -1, 302, -1, -1, 412, -1, 307, -1, 309, + 310, 311, 312, -1, -1, 315, -1, 317, -1, 256, + 427, 321, -1, -1, -1, 262, -1, -1, -1, -1, + -1, -1, -1, 333, -1, 339, 336, -1, 338, -1, + 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, -1, -1, -1, 359, + -1, 298, -1, 367, -1, 369, -1, 371, -1, 373, + 374, 375, -1, 377, 378, -1, -1, 381, 382, 383, + 384, -1, -1, -1, 388, 389, -1, -1, -1, 393, + 394, 395, 396, 397, 398, 399, 400, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 412, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, 256, 427, -1, -1, -1, -1, 262, -1, + 367, 261, 369, -1, 371, -1, 373, 374, 375, -1, + 377, 378, -1, -1, 381, 382, 383, 384, -1, -1, + -1, 388, 389, -1, 284, -1, 393, 394, 395, 396, + 397, 398, 399, 400, 298, -1, -1, 297, -1, -1, + -1, 301, 302, -1, -1, 412, -1, 307, -1, 309, + 310, 311, 312, -1, -1, -1, -1, 317, -1, 256, + 427, 321, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 333, -1, 339, 336, -1, 338, -1, + 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, -1, -1, -1, 359, + -1, -1, -1, 367, -1, 369, -1, 371, -1, 373, + 374, 375, -1, 377, 378, -1, -1, 381, 382, 383, + 384, -1, -1, -1, 388, 389, 256, -1, -1, 393, + 394, 395, 396, 397, 398, 399, 400, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 412, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, 427, -1, -1, -1, -1, -1, -1, + 367, -1, 369, -1, 371, -1, 373, 374, 375, -1, + -1, -1, -1, -1, 381, 382, 383, 384, -1, -1, + -1, 388, 389, 256, -1, -1, 393, 394, 395, 396, + 397, 398, 399, 400, -1, -1, -1, -1, -1, 339, + -1, -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - 424, -1, -1, -1, 364, -1, 366, -1, 368, -1, - 370, 371, 372, -1, -1, -1, -1, -1, -1, -1, - 380, 381, -1, -1, 256, 385, 386, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 396, 397, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 409, + 427, -1, -1, -1, -1, -1, -1, 367, -1, 369, + -1, 371, -1, 373, 374, 375, -1, -1, -1, -1, + -1, 381, 382, 383, 384, -1, -1, -1, 388, 389, + 256, -1, -1, 393, 394, 395, 396, 397, 398, 399, + 400, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, 427, -1, -1, + -1, -1, -1, -1, 367, -1, 369, -1, 371, -1, + 373, 374, 375, -1, -1, -1, -1, -1, 381, 382, + 383, 384, -1, -1, -1, 388, 389, 256, -1, -1, + 393, 394, 395, 396, 397, 398, 399, 400, -1, -1, + -1, -1, -1, 339, -1, -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, 424, -1, -1, -1, 364, -1, - 366, -1, 368, -1, 370, 371, 372, -1, -1, -1, - -1, -1, -1, -1, 380, 381, -1, -1, 256, 385, - 386, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 396, 397, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 409, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, 424, -1, - -1, -1, 364, -1, 366, -1, 368, -1, 370, 371, - 372, -1, -1, -1, -1, -1, -1, -1, -1, 381, - -1, -1, 256, 385, 386, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 396, 397, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 409, 346, 347, + 356, -1, -1, -1, 427, -1, -1, -1, -1, -1, + -1, 367, -1, 369, -1, 371, -1, 373, 374, 375, + -1, -1, -1, -1, -1, 381, 382, 383, 384, -1, + -1, -1, 388, 389, 256, -1, -1, -1, -1, 395, + 396, 397, 398, 399, 400, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 412, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, 427, -1, -1, -1, -1, -1, -1, 367, -1, + 369, -1, 371, -1, 373, 374, 375, -1, -1, -1, + -1, -1, 381, 382, 383, 384, -1, -1, -1, 388, + 389, 256, -1, -1, -1, -1, 395, 396, 397, 398, + 399, 400, -1, -1, -1, -1, -1, 339, -1, -1, + -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, 356, -1, -1, -1, 427, -1, + -1, -1, -1, -1, -1, 367, -1, 369, -1, 371, + -1, 373, 374, 375, -1, -1, -1, -1, -1, 381, + 382, 383, 384, -1, -1, -1, 388, 389, 256, -1, + -1, -1, -1, 395, 396, 397, 398, 399, 400, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, 427, -1, -1, -1, -1, + -1, -1, 367, -1, 369, -1, 371, -1, 373, 374, + 375, -1, -1, -1, -1, -1, 381, 382, 383, 384, + -1, -1, -1, 388, 389, 256, -1, -1, -1, -1, + 395, 396, 397, 398, 399, 400, -1, -1, -1, -1, + -1, 339, -1, -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 424, -1, -1, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, -1, -1, -1, -1, - -1, -1, -1, 381, -1, -1, 256, 385, 386, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 396, 397, + -1, -1, 427, -1, -1, -1, -1, -1, -1, 367, + -1, 369, -1, 371, -1, 373, 374, 375, -1, -1, + -1, -1, -1, 381, 382, 383, 384, -1, -1, -1, + 388, 389, 256, -1, -1, -1, -1, 395, 396, 397, + 398, 399, 400, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, 427, + -1, -1, -1, -1, -1, -1, 367, -1, 369, -1, + 371, -1, 373, 374, 375, -1, -1, -1, -1, -1, + -1, -1, 383, 384, -1, -1, -1, 388, 389, 256, + -1, -1, -1, -1, -1, -1, 397, 398, 399, 400, -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 409, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, 424, -1, -1, -1, - 364, -1, 366, -1, 368, -1, 370, 371, 372, -1, - -1, -1, -1, -1, -1, -1, -1, 381, -1, -1, - 256, -1, 386, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 396, 397, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 409, 346, 347, 348, 349, + 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, 427, -1, -1, -1, + -1, -1, -1, 367, -1, 369, -1, 371, -1, 373, + 374, 375, -1, -1, -1, -1, -1, -1, -1, 383, + 384, -1, -1, -1, 388, 389, 256, -1, -1, -1, + -1, -1, -1, 397, 398, 399, 400, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 412, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, 427, -1, -1, -1, -1, -1, -1, + 367, -1, 369, -1, 371, -1, 373, 374, 375, -1, + -1, -1, -1, -1, -1, -1, 383, 384, -1, -1, + -1, 388, 389, 256, -1, -1, -1, -1, -1, -1, + 397, 398, 399, 400, -1, -1, -1, -1, -1, 339, + -1, -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - 424, -1, -1, -1, 364, -1, 366, -1, 368, -1, - 370, 371, 372, -1, -1, -1, -1, -1, -1, -1, - -1, 381, -1, -1, 256, -1, 386, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 396, 397, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 409, + 427, -1, -1, -1, -1, -1, -1, 367, -1, 369, + -1, 371, -1, 373, 374, 375, -1, -1, -1, -1, + -1, -1, -1, 383, 384, -1, -1, -1, 388, 389, + 256, -1, -1, -1, -1, -1, -1, -1, -1, 399, + 400, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, 427, -1, -1, + -1, -1, -1, -1, 367, -1, 369, -1, 371, -1, + 373, 374, 375, -1, -1, -1, -1, -1, -1, -1, + 383, 384, -1, -1, -1, 388, 389, 256, -1, -1, + -1, -1, -1, -1, -1, -1, 399, 400, -1, -1, + -1, -1, -1, 339, -1, -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, 424, -1, -1, -1, 364, -1, - 366, -1, 368, -1, 370, 371, 372, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, - 386, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 396, 397, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 409, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, 424, -1, - -1, -1, 364, -1, 366, -1, 368, -1, 370, 371, - 372, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 256, -1, 386, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 396, 397, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 409, 346, 347, + 356, -1, -1, -1, 427, -1, -1, -1, -1, -1, + -1, 367, -1, 369, -1, 371, -1, 373, 374, 375, + -1, -1, -1, -1, -1, -1, -1, -1, 384, -1, + -1, -1, 388, 389, 256, -1, -1, -1, -1, -1, + -1, -1, -1, 399, 400, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 412, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, 427, -1, -1, -1, -1, -1, -1, 367, -1, + 369, -1, 371, -1, 373, 374, 375, -1, -1, -1, + -1, -1, -1, -1, -1, 384, -1, -1, -1, 388, + 389, 256, -1, -1, -1, -1, -1, -1, -1, -1, + 399, 400, -1, -1, -1, -1, -1, 339, -1, -1, + -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, 356, -1, -1, -1, 427, -1, + -1, -1, -1, -1, -1, 367, -1, 369, -1, 371, + -1, 373, 374, 375, -1, -1, -1, -1, -1, -1, + -1, -1, 384, -1, -1, -1, -1, 389, 256, -1, + -1, -1, -1, -1, -1, -1, -1, 399, 400, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, 427, -1, -1, -1, -1, + -1, -1, 367, -1, 369, -1, 371, -1, 373, 374, + 375, -1, -1, -1, -1, -1, -1, -1, -1, 384, + -1, -1, -1, -1, 389, 256, -1, -1, -1, -1, + -1, -1, -1, -1, 399, 400, -1, -1, -1, -1, + -1, 339, -1, -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 424, -1, -1, -1, 364, -1, 366, -1, - 368, -1, 370, 371, 372, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 386, 262, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 397, + -1, -1, 427, -1, -1, -1, -1, -1, -1, 367, + -1, 369, -1, 371, -1, 373, 374, 375, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 389, 256, -1, -1, -1, -1, -1, -1, -1, + -1, 399, 400, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 412, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, 427, + -1, -1, -1, -1, -1, -1, 367, -1, 369, -1, + 371, -1, 373, 374, 375, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 389, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 399, 400, -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 409, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, 298, 424, -1, -1, -1, - 364, -1, 366, -1, 368, -1, 370, 371, 372, -1, - -1, -1, 262, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 386, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 397, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 409, -1, -1, 298, -1, - -1, -1, -1, -1, 357, -1, -1, -1, -1, -1, - 424, -1, 365, -1, 367, -1, 369, -1, -1, 372, - -1, 374, 375, 262, 377, 378, 379, 380, 381, 382, - 383, 384, 385, 386, -1, 388, 389, 390, 391, 392, - 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, - 403, 404, 405, 406, 407, 408, 409, -1, -1, 298, - -1, 414, -1, 416, -1, 365, 419, 367, 368, 369, - 370, 424, 372, -1, 374, 375, -1, 377, 378, 379, - 380, 381, -1, 383, 384, 385, 386, -1, 388, 389, - 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, - -1, -1, -1, -1, 414, -1, 416, -1, -1, 419, - -1, -1, -1, -1, 424, -1, -1, 366, 367, 368, - 369, 370, -1, -1, -1, 374, 375, -1, 377, 378, - 379, 380, 381, 382, 383, 384, 385, 386, -1, 388, - 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, - 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, - 409, -1, -1, 256, -1, -1, -1, 416, -1, -1, - 419, 264, 265, 266, 267, 424, -1, 270, 271, -1, - 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, + 344, 412, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, 427, -1, -1, -1, + -1, -1, -1, 367, -1, 369, -1, 371, -1, 373, + 374, 375, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 256, -1, 389, -1, -1, -1, -1, + -1, 264, 265, 266, 267, -1, 400, 270, 271, -1, + 273, 274, 275, 276, 277, 278, 279, -1, 412, -1, -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, - -1, -1, 295, -1, -1, -1, 299, 300, -1, 302, + -1, -1, 295, 427, -1, -1, 299, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, 314, -1, 316, -1, 318, 319, -1, -1, 322, -1, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, -1, 337, -1, -1, 340, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 363, -1, -1, -1, 367, -1, -1, -1, -1, 372, - 373, 374, 375, 376, -1, -1, -1, 380, -1, 382, - -1, -1, -1, -1, -1, 388, 389, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, - 413, 414, 415, 416, 264, 265, 266, 267, -1, -1, - 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, - -1, -1, -1, -1, -1, 285, -1, 287, 288, 289, - 290, 291, 292, -1, -1, 295, -1, -1, -1, 299, - 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 314, -1, 316, -1, 318, 319, - -1, -1, 322, -1, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 334, 335, -1, 337, -1, -1, - 340, 341, -1, -1, 344, 345, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 363, -1, -1, -1, 367, -1, -1, - -1, -1, 372, 373, 374, 375, 376, -1, -1, -1, - 380, -1, 382, -1, -1, -1, -1, -1, 388, 389, + -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, + -1, -1, -1, 366, -1, -1, -1, 370, -1, -1, + -1, -1, 375, 376, 377, 378, 379, -1, -1, -1, + 383, -1, 385, -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, - -1, -1, -1, 413, 414, 415, 416, 264, 265, 266, + -1, -1, -1, 416, 417, 418, 419, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, -1, -1, 295, -1, @@ -10874,28 +10961,13 @@ void case_919() 327, 328, 329, 330, 331, 332, 333, 334, 335, -1, 337, -1, -1, 340, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 363, -1, -1, -1, - 367, -1, -1, -1, -1, 372, 373, 374, 375, 376, - -1, -1, -1, 380, -1, 382, -1, -1, -1, -1, - -1, 388, 389, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 256, -1, -1, -1, 413, 414, 415, 416, - 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, - 274, 275, 276, 277, 278, 279, -1, -1, -1, -1, - -1, 285, -1, 287, 288, 289, 290, 291, 292, -1, - -1, 295, -1, -1, -1, 299, 300, -1, 302, 303, - 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 314, -1, 316, -1, 318, 319, -1, -1, 322, -1, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 334, 335, -1, 337, -1, -1, 340, 341, -1, -1, - 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 363, - -1, -1, -1, 367, -1, -1, -1, -1, 372, 373, - 374, 375, 376, -1, -1, -1, 380, -1, 382, -1, - -1, -1, -1, -1, 388, 389, -1, -1, -1, -1, + -1, -1, -1, 360, 361, 362, -1, -1, -1, 366, + -1, -1, -1, 370, -1, -1, -1, -1, 375, 376, + 377, 378, 379, -1, -1, -1, 383, -1, 385, -1, + -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, -1, -1, -1, 413, - 414, 415, 416, 264, 265, 266, 267, -1, -1, 270, + -1, -1, -1, -1, -1, 256, -1, -1, -1, 416, + 417, 418, 419, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, -1, -1, 295, -1, -1, -1, 299, 300, @@ -10904,91 +10976,46 @@ void case_919() -1, 322, -1, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, -1, 337, -1, -1, 340, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, 366, -1, -1, -1, 370, + -1, -1, -1, -1, 375, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 363, -1, -1, -1, 367, -1, -1, -1, - -1, 372, 373, 374, 375, 376, -1, -1, -1, 380, - -1, 382, -1, -1, -1, -1, -1, 388, 389, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, - -1, -1, 413, 414, 415, 416, 264, 265, -1, 267, - -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, - -1, 279, -1, -1, 265, -1, 267, 285, -1, 270, - 288, -1, -1, -1, 275, -1, -1, 295, 279, -1, - -1, -1, 300, -1, 302, 303, 304, 288, -1, -1, - -1, -1, -1, -1, 295, -1, -1, -1, 316, 300, - 318, 319, -1, 304, 322, -1, -1, 325, -1, 327, - -1, 329, 330, 331, 332, 316, 334, 318, -1, -1, - -1, 322, -1, 341, -1, -1, 344, 345, -1, 330, - 331, -1, -1, 334, -1, -1, 337, -1, -1, -1, - -1, -1, -1, -1, -1, 363, 364, -1, -1, 367, - -1, -1, -1, -1, -1, 373, 374, 375, 376, -1, - -1, -1, 380, -1, 382, -1, -1, -1, -1, -1, - 388, 389, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 256, -1, -1, -1, 413, 414, 415, 416, 264, - 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, - 275, 276, 277, 414, 279, -1, -1, -1, -1, -1, - 285, -1, 261, 288, -1, -1, -1, -1, -1, -1, - 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, - -1, -1, -1, -1, -1, 284, -1, -1, -1, -1, - -1, 316, -1, 318, 319, 320, -1, 322, 297, -1, - 325, -1, 327, 302, 329, 330, 331, 332, 307, 334, - 309, 310, 311, 312, -1, -1, 341, -1, 317, 344, - 345, -1, 321, -1, -1, -1, 325, -1, -1, -1, - -1, -1, -1, -1, 333, -1, -1, 336, 363, 338, - -1, -1, 367, -1, -1, -1, -1, -1, 373, 374, - 375, 376, -1, -1, -1, 380, -1, 382, -1, -1, - 359, -1, -1, 388, 389, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 256, -1, -1, -1, 413, 414, - 415, 416, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, -1, - -1, -1, -1, 285, -1, 414, 288, -1, -1, -1, - -1, -1, -1, 295, -1, -1, -1, -1, 300, -1, - 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 316, -1, 318, 319, -1, -1, - 322, -1, -1, 325, -1, 327, -1, 329, 330, 331, - 332, -1, 334, -1, -1, 337, -1, -1, -1, 341, - -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 367, -1, -1, -1, -1, - -1, 373, 374, 375, 376, -1, -1, -1, 380, -1, - 382, -1, -1, -1, -1, -1, 388, 389, -1, -1, + -1, 256, -1, -1, -1, 416, 417, 418, 419, 264, + 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, + 275, 276, 277, 278, 279, -1, -1, -1, -1, -1, + 285, -1, 287, 288, 289, 290, 291, 292, -1, -1, + 295, -1, -1, -1, 299, 300, -1, 302, 303, 304, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 314, + -1, 316, -1, 318, 319, -1, -1, 322, -1, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, -1, 337, -1, -1, 340, 341, -1, -1, 344, + 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 360, 361, 362, -1, -1, + -1, 366, -1, -1, -1, 370, -1, -1, -1, -1, + 375, 376, 377, 378, 379, -1, -1, -1, 383, -1, + 385, -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, - -1, 413, 414, 415, 416, 264, 265, -1, 267, -1, - -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, - 279, -1, -1, -1, -1, -1, 285, -1, 261, 288, - -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, - -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, - -1, 284, -1, -1, -1, -1, -1, 316, -1, 318, - 319, -1, -1, 322, 297, -1, 325, -1, 327, 302, - 329, 330, 331, 332, 307, 334, 309, 310, 311, 312, - -1, -1, 341, -1, 317, 344, 345, -1, 321, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, 363, 338, -1, -1, 367, -1, - -1, -1, -1, -1, 373, 374, 375, 376, -1, -1, - -1, 380, -1, 382, -1, -1, 359, -1, -1, 388, - 389, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 256, -1, -1, -1, 413, 414, 415, 416, 264, 265, - -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, - 276, 277, -1, 279, -1, -1, -1, -1, -1, 285, - -1, 414, 288, -1, -1, -1, -1, -1, -1, 295, - -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, - -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, - -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 416, 417, 418, 419, 264, 265, 266, 267, -1, + -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, + 279, -1, -1, -1, -1, -1, 285, -1, 287, 288, + 289, 290, 291, 292, -1, -1, 295, -1, -1, -1, + 299, 300, -1, 302, 303, 304, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 314, -1, 316, -1, 318, + 319, -1, -1, 322, -1, 324, 325, 326, 327, 328, + 329, 330, 331, 332, 333, 334, 335, -1, 337, -1, + -1, 340, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 367, -1, -1, -1, -1, -1, 373, 374, 375, - 376, -1, -1, -1, 380, -1, 382, -1, -1, -1, - -1, -1, 388, 389, -1, -1, -1, -1, -1, -1, + -1, 360, 361, 362, -1, -1, -1, 366, -1, -1, + -1, 370, -1, -1, -1, -1, 375, 376, 377, 378, + 379, -1, -1, -1, 383, -1, 385, -1, -1, -1, + -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 256, -1, -1, -1, 413, 414, 415, - 416, 264, 265, -1, 267, -1, -1, 270, 271, -1, - -1, -1, 275, 276, 277, -1, 279, -1, -1, 265, + -1, -1, -1, 256, -1, -1, -1, 416, 417, 418, + 419, 264, 265, -1, 267, -1, -1, 270, 271, -1, + 256, -1, 275, 276, 277, -1, 279, -1, -1, 265, -1, 267, 285, -1, 270, 288, -1, -1, -1, 275, -1, -1, 295, 279, -1, -1, -1, 300, -1, 302, 303, 304, 288, -1, -1, -1, -1, -1, -1, 295, @@ -10996,439 +11023,525 @@ void case_919() -1, -1, 325, -1, 327, -1, 329, 330, 331, 332, 316, 334, 318, -1, -1, -1, 322, -1, 341, -1, -1, 344, 345, -1, 330, 331, -1, -1, 334, -1, - -1, 337, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 367, -1, -1, -1, -1, -1, - 373, 374, 375, 376, -1, -1, -1, 380, -1, 382, - -1, -1, -1, -1, -1, 388, 389, -1, -1, -1, - -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, - 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, - 413, 414, 415, 416, 285, -1, -1, 288, -1, -1, - -1, -1, -1, -1, 295, -1, -1, -1, 414, 300, - -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, - -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, - 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, - 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 363, 364, -1, -1, 367, -1, -1, -1, - -1, -1, 373, 374, 375, 376, -1, -1, -1, 380, - -1, 382, -1, -1, -1, -1, -1, 388, 389, -1, - -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, - -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, - 279, -1, 413, 414, 415, 416, 285, -1, 261, 288, - 263, -1, 423, -1, -1, -1, 295, -1, -1, -1, - -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, - -1, 284, -1, -1, -1, -1, -1, 316, -1, 318, - 319, -1, -1, 322, 297, -1, 325, -1, 327, 302, - 329, 330, 331, 332, 307, 334, 309, 310, 311, 312, - -1, -1, 341, -1, 317, 344, 345, -1, 321, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, 363, 338, -1, -1, 367, -1, - -1, -1, -1, -1, 373, 374, 375, 376, -1, -1, - -1, 380, -1, 382, -1, -1, 359, -1, -1, 388, - 389, 364, 365, -1, -1, -1, -1, 262, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 256, -1, -1, 413, 414, 415, 416, -1, 264, - 265, -1, 267, -1, 423, 270, 271, -1, -1, -1, - 275, 276, 277, 298, 279, -1, -1, -1, -1, -1, - 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, - 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, + -1, 337, -1, -1, -1, -1, -1, 360, 361, 362, + -1, -1, -1, 366, 367, -1, -1, 370, -1, -1, + -1, -1, -1, 376, 377, 378, 379, -1, -1, -1, + 383, -1, 385, -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, - 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, + -1, -1, -1, 416, 417, 418, 419, 264, 265, -1, + 267, -1, -1, 270, 271, -1, 256, -1, 275, 276, + 277, 417, 279, -1, -1, 265, -1, 267, 285, -1, + 270, 288, -1, -1, -1, 275, -1, -1, 295, 279, + -1, -1, -1, 300, -1, 302, 303, 304, 288, -1, + -1, -1, -1, -1, -1, 295, -1, -1, -1, 316, + 300, 318, 319, 320, 304, 322, -1, -1, 325, -1, + 327, -1, 329, 330, 331, 332, 316, 334, 318, -1, + -1, -1, 322, -1, 341, -1, -1, 344, 345, -1, + 330, 331, -1, -1, 334, -1, -1, 337, -1, -1, + -1, -1, -1, 360, 361, 362, -1, -1, -1, 366, + -1, -1, -1, 370, -1, -1, -1, -1, -1, 376, + 377, 378, 379, -1, -1, -1, 383, -1, 385, -1, + -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 367, 368, 369, 370, -1, -1, -1, 374, - 375, -1, -1, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 367, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 408, 409, -1, -1, -1, -1, -1, - -1, 416, -1, -1, 419, -1, -1, -1, -1, -1, - -1, 261, -1, 263, -1, 265, -1, 267, 413, 414, - 270, -1, 272, 273, -1, 275, -1, 277, -1, 279, - -1, 281, 282, 283, 284, -1, -1, 287, 288, -1, - -1, -1, -1, 293, 294, 295, 296, 297, -1, -1, - 300, 301, 302, -1, 304, -1, 306, 307, 308, 309, - 310, 311, 312, 313, -1, 315, 316, 317, 318, -1, - -1, 321, 322, 323, -1, 325, -1, -1, -1, -1, - 330, 331, -1, 333, 334, -1, 336, 337, 338, -1, - -1, -1, 342, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 359, - 360, 361, -1, -1, -1, -1, -1, -1, -1, -1, - 261, -1, -1, 373, 265, -1, 267, -1, -1, 270, - -1, 272, 273, -1, 275, -1, 277, -1, 279, -1, - 281, 282, 283, 284, -1, -1, 287, 288, -1, -1, - -1, -1, 293, -1, 295, 296, 297, -1, -1, 300, - -1, 302, -1, 304, 414, -1, 307, -1, 309, 310, - 311, 312, -1, -1, -1, 316, 317, 318, -1, -1, - 321, 322, 323, -1, -1, -1, -1, -1, -1, 330, - 331, -1, 333, 334, 261, 336, 337, 338, 265, -1, - 267, 342, -1, 270, -1, 272, 273, -1, 275, -1, - 277, -1, 279, -1, 281, 282, 283, 284, 359, -1, - 287, 288, -1, 364, -1, -1, 293, -1, 295, 296, - 297, -1, 373, 300, -1, 302, -1, 304, -1, -1, - 307, -1, 309, 310, 311, 312, -1, -1, -1, 316, - 317, 318, -1, -1, 321, 322, 323, -1, -1, -1, - -1, -1, -1, 330, 331, -1, 333, 334, 261, 336, - 337, 338, 265, 414, 267, 342, -1, 270, -1, 272, - 273, -1, 275, -1, 277, -1, 279, -1, 281, 282, - 283, 284, 359, -1, 287, 288, -1, 364, -1, -1, - 293, -1, 295, 296, 297, -1, 373, 300, -1, 302, - -1, 304, -1, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, 316, 317, 318, -1, -1, 321, 322, - 323, -1, -1, -1, -1, -1, -1, 330, 331, -1, - 333, 334, 261, 336, 337, 338, 265, 414, 267, 342, - -1, 270, -1, 272, 273, -1, 275, -1, 277, -1, - 279, -1, 281, 282, 283, 284, 359, -1, 287, 288, - -1, 364, -1, -1, 293, -1, 295, 296, 297, -1, - 373, 300, -1, 302, -1, 304, -1, -1, 307, -1, - 309, 310, 311, 312, -1, -1, -1, 316, 317, 318, - -1, -1, 321, 322, 323, -1, -1, -1, -1, -1, - -1, 330, 331, -1, 333, 334, 261, 336, 337, 338, - 265, 414, 267, 342, -1, 270, -1, 272, 273, -1, - 275, -1, 277, -1, 279, -1, 281, 282, 283, 284, - 359, -1, 287, 288, -1, 364, -1, -1, 293, -1, - 295, 296, 297, -1, 373, 300, -1, 302, -1, 304, - -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, - -1, 316, 317, 318, -1, -1, 321, 322, 323, -1, - -1, -1, -1, -1, -1, 330, 331, -1, 333, 334, - 261, 336, 337, 338, 265, 414, 267, 342, -1, 270, - -1, 272, 273, -1, 275, -1, 277, -1, 279, -1, - 281, 282, 283, 284, 359, -1, 287, 288, -1, 364, - -1, -1, 293, -1, 295, 296, 297, -1, -1, 300, - -1, 302, -1, 304, 261, -1, 307, -1, 309, 310, - 311, 312, -1, -1, -1, 316, 317, 318, -1, -1, - 321, 322, 323, -1, -1, -1, -1, 284, -1, 330, - 331, -1, 333, 334, -1, 336, 337, 338, -1, 414, - 297, 342, -1, -1, -1, 302, -1, -1, 305, -1, - 307, -1, 309, 310, 311, 312, -1, -1, 359, -1, - 317, -1, -1, 364, 321, -1, -1, -1, 325, -1, - -1, -1, -1, -1, -1, -1, 333, -1, -1, 336, - -1, 338, -1, 264, 265, -1, 267, -1, -1, 270, - 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, - -1, 265, 359, 267, 285, -1, 270, 288, -1, -1, - -1, 275, -1, 414, 295, 279, -1, -1, -1, 300, - -1, 302, 303, 304, 288, 306, -1, -1, -1, -1, - -1, 295, 313, -1, -1, 316, 300, 318, 319, -1, + -1, -1, -1, -1, -1, 256, -1, -1, -1, 416, + 417, 418, 419, 264, 265, -1, 267, -1, -1, 270, + 271, -1, 256, -1, 275, 276, 277, 417, 279, -1, + -1, 265, -1, 267, 285, -1, 270, 288, -1, -1, + -1, 275, -1, -1, 295, 279, -1, -1, -1, 300, + -1, 302, 303, 304, 288, -1, -1, -1, -1, -1, + -1, 295, -1, -1, -1, 316, 300, 318, 319, -1, 304, 322, -1, -1, 325, -1, 327, -1, 329, 330, - 331, 332, 316, 334, 318, -1, -1, 414, 322, -1, + 331, 332, 316, 334, 318, -1, 337, -1, 322, -1, 341, -1, -1, 344, 345, -1, 330, 331, -1, -1, - 334, -1, -1, 337, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 367, 368, -1, 370, - -1, -1, 373, 374, 375, 376, -1, -1, -1, 380, - -1, 382, -1, -1, -1, -1, -1, 388, 389, -1, - -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, - -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, - 279, -1, 413, 414, 415, 416, 285, -1, 261, 288, - -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, - 414, 300, -1, 302, 303, 304, -1, 306, -1, -1, - -1, 284, -1, -1, 313, -1, -1, 316, -1, 318, - 319, -1, -1, 322, 297, -1, 325, -1, 327, 302, - 329, 330, 331, 332, 307, 334, 309, 310, 311, 312, - -1, -1, 341, -1, 317, 344, 345, -1, 321, -1, + 334, -1, -1, 337, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, -1, -1, -1, -1, 370, + -1, -1, -1, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, -1, 338, -1, -1, 367, -1, - -1, 370, -1, -1, 373, 374, 375, 376, -1, -1, - -1, 380, -1, 382, -1, -1, 359, 360, 361, 388, - 389, 364, -1, -1, -1, -1, -1, 264, 265, -1, - 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, - 277, -1, 279, -1, 413, 414, 415, 416, 285, -1, - 261, 288, -1, -1, -1, -1, -1, -1, 295, -1, - -1, -1, -1, 300, -1, 302, 303, 304, -1, 306, - -1, -1, -1, 284, -1, -1, 313, -1, -1, 316, - -1, 318, 319, -1, -1, 322, 297, -1, 325, -1, - 327, 302, 329, 330, 331, 332, 307, 334, 309, 310, - 311, 312, -1, -1, 341, -1, 317, 344, 345, -1, - 321, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 333, -1, -1, 336, -1, 338, -1, -1, - 367, -1, -1, -1, -1, -1, 373, 374, 375, 376, - -1, -1, -1, 380, -1, 382, -1, -1, 359, 360, - 361, 388, 389, 364, -1, -1, -1, -1, -1, 264, - 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, - 275, 276, 277, -1, 279, -1, 413, 414, 415, 416, - 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, - 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, + -1, 256, -1, -1, -1, 416, 417, 418, 419, 264, + 265, -1, 267, -1, -1, 270, 271, -1, 256, -1, + 275, 276, 277, 417, 279, -1, -1, 265, -1, 267, + 285, -1, 270, 288, -1, -1, -1, 275, -1, -1, + 295, 279, -1, -1, -1, 300, -1, 302, 303, 304, + 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, + -1, 316, 300, 318, 319, -1, 304, 322, -1, -1, + 325, -1, 327, -1, 329, 330, 331, 332, 316, 334, + 318, -1, -1, -1, 322, -1, 341, -1, -1, 344, + 345, -1, 330, 331, -1, -1, 334, -1, -1, 337, + -1, -1, -1, -1, -1, 360, 361, 362, -1, -1, + -1, 366, -1, -1, -1, 370, -1, -1, -1, -1, + -1, 376, 377, 378, 379, -1, -1, -1, 383, -1, + 385, -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, - 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, - -1, -1, 337, -1, -1, -1, 341, -1, -1, 344, - 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, + -1, 416, 417, 418, 419, 264, 265, -1, 267, -1, + -1, 270, 271, -1, -1, -1, 275, 276, 277, 417, + 279, -1, -1, 265, -1, 267, 285, -1, 270, 288, + -1, -1, -1, 275, -1, -1, 295, 279, -1, -1, + -1, 300, -1, 302, 303, 304, 288, -1, -1, -1, + -1, -1, -1, 295, -1, -1, -1, 316, 300, 318, + 319, -1, 304, 322, -1, -1, 325, -1, 327, -1, + 329, 330, 331, 332, 316, 334, 318, -1, -1, -1, + 322, -1, 341, -1, -1, 344, 345, -1, 330, 331, + -1, -1, 334, -1, -1, 337, -1, -1, -1, -1, + -1, 360, 361, 362, -1, -1, -1, -1, -1, -1, + -1, 370, -1, -1, -1, -1, -1, 376, 377, 378, + 379, -1, -1, -1, 383, -1, 385, -1, -1, -1, + -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 367, -1, -1, -1, -1, -1, 373, 374, - 375, 376, -1, -1, -1, 380, -1, 382, -1, -1, - -1, -1, -1, 388, 389, -1, -1, -1, -1, -1, + -1, -1, -1, 256, -1, -1, -1, 416, 417, 418, + 419, 264, 265, -1, 267, -1, -1, 270, 271, -1, + -1, -1, 275, 276, 277, 417, 279, -1, -1, 265, + -1, 267, 285, -1, 270, 288, -1, -1, -1, 275, + -1, -1, 295, 279, -1, -1, -1, 300, -1, 302, + 303, 304, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, 316, 300, 318, 319, -1, 304, 322, + -1, -1, 325, -1, 327, -1, 329, 330, 331, 332, + 316, 334, 318, -1, -1, -1, 322, -1, 341, -1, + -1, 344, 345, -1, 330, 331, -1, -1, 334, -1, + -1, 337, -1, -1, -1, -1, -1, 360, 361, 362, + -1, -1, -1, -1, -1, -1, -1, 370, -1, -1, + -1, -1, -1, 376, 377, 378, 379, -1, -1, -1, + 383, -1, 385, -1, -1, -1, -1, -1, 391, 392, + -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, + -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, + -1, 279, -1, 416, 417, 418, 419, 285, -1, -1, + 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, + -1, 417, 300, -1, 302, 303, 304, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 316, -1, + 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, + -1, 329, 330, 331, 332, -1, 334, -1, -1, -1, + -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 360, 361, 362, -1, -1, -1, 366, 367, + -1, -1, 370, -1, -1, -1, -1, -1, 376, 377, + 378, 379, -1, -1, -1, 383, -1, 385, -1, -1, + -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, - -1, -1, 275, 276, 277, -1, 279, -1, 413, 414, - 415, 416, 285, -1, -1, 288, -1, -1, -1, -1, + -1, -1, 275, 276, 277, -1, 279, -1, 416, 417, + 418, 419, 285, -1, -1, 288, -1, -1, 426, -1, -1, -1, 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, 341, -1, - -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, + -1, 344, 345, -1, -1, 261, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, + -1, -1, -1, 366, -1, -1, -1, 370, 284, -1, + -1, -1, -1, 376, 377, 378, 379, -1, -1, -1, + 383, 297, 385, -1, -1, -1, 302, -1, 391, 392, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + -1, 317, -1, -1, -1, 321, -1, -1, -1, 325, + 256, -1, 262, 416, 417, 418, 419, 333, 264, 265, + 336, 267, 338, 426, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, -1, -1, -1, -1, 285, + -1, -1, 288, 359, -1, -1, -1, -1, 298, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 417, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + 370, 371, 372, 373, 370, -1, -1, 377, 378, -1, + -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, + -1, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, + 410, 411, 412, -1, -1, -1, -1, -1, -1, 419, + 416, 417, 422, 261, -1, -1, -1, 265, -1, 267, + -1, -1, 270, -1, 272, 273, -1, 275, -1, 277, + -1, 279, -1, 281, 282, 283, 284, -1, -1, 287, + 288, -1, -1, -1, -1, 293, -1, 295, 296, 297, + -1, -1, 300, -1, 302, -1, 304, -1, -1, 307, + -1, 309, 310, 311, 312, -1, -1, -1, 316, 317, + 318, -1, -1, 321, 322, 323, -1, -1, -1, -1, + -1, -1, 330, 331, -1, 333, 334, -1, 336, 337, + 338, -1, -1, -1, 342, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 261, -1, -1, -1, 265, -1, + 267, 359, -1, 270, -1, 272, 273, -1, 275, 367, + 277, -1, 279, -1, 281, 282, 283, 284, 376, -1, + 287, 288, -1, -1, -1, -1, 293, -1, 295, 296, + 297, -1, -1, 300, -1, 302, -1, 304, -1, -1, + 307, -1, 309, 310, 311, 312, -1, -1, -1, 316, + 317, 318, -1, -1, 321, 322, 323, -1, -1, 417, + -1, -1, -1, 330, 331, -1, 333, 334, -1, 336, + 337, 338, -1, -1, -1, 342, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 261, -1, -1, -1, 265, + -1, 267, 359, -1, 270, -1, 272, 273, -1, 275, + 367, 277, -1, 279, -1, 281, 282, 283, 284, 376, + -1, 287, 288, -1, -1, -1, -1, 293, -1, 295, + 296, 297, -1, -1, 300, -1, 302, -1, 304, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + 316, 317, 318, -1, -1, 321, 322, 323, -1, -1, + 417, -1, -1, -1, 330, 331, -1, 333, 334, -1, + 336, 337, 338, -1, -1, -1, 342, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 261, -1, -1, -1, + 265, -1, 267, 359, -1, 270, -1, 272, 273, -1, + 275, 367, 277, -1, 279, -1, 281, 282, 283, 284, + 376, -1, 287, 288, -1, -1, -1, -1, 293, -1, + 295, 296, 297, -1, -1, 300, -1, 302, -1, 304, + -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, + -1, 316, 317, 318, -1, -1, 321, 322, 323, -1, + -1, 417, -1, -1, -1, 330, 331, -1, 333, 334, + -1, 336, 337, 338, -1, -1, -1, 342, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 261, -1, -1, + -1, 265, -1, 267, 359, -1, 270, -1, 272, 273, + -1, 275, 367, 277, -1, 279, -1, 281, 282, 283, + 284, 376, -1, 287, 288, -1, -1, -1, -1, 293, + -1, 295, 296, 297, -1, -1, 300, -1, 302, -1, + 304, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, 316, 317, 318, -1, -1, 321, 322, 323, + -1, -1, 417, -1, -1, -1, 330, 331, -1, 333, + 334, -1, 336, 337, 338, -1, -1, -1, 342, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 261, -1, + -1, -1, 265, -1, 267, 359, -1, 270, -1, 272, + 273, -1, 275, 367, 277, -1, 279, -1, 281, 282, + 283, 284, -1, -1, 287, 288, -1, -1, -1, -1, + 293, -1, 295, 296, 297, -1, -1, 300, -1, 302, + -1, 304, 261, -1, 307, -1, 309, 310, 311, 312, + -1, -1, -1, 316, 317, 318, -1, -1, 321, 322, + 323, -1, -1, 417, -1, 284, -1, 330, 331, -1, + 333, 334, -1, 336, 337, 338, -1, -1, 297, 342, + -1, -1, -1, 302, -1, -1, 305, -1, 307, -1, + 309, 310, 311, 312, -1, -1, 359, -1, 317, -1, + -1, -1, 321, -1, 367, -1, 325, -1, -1, -1, + -1, 261, -1, -1, 333, -1, -1, 336, -1, 338, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 284, -1, -1, -1, 357, -1, + 359, 261, -1, -1, -1, -1, -1, 297, -1, 368, + -1, 370, 302, 372, 417, 305, -1, 307, -1, 309, + 310, 311, 312, -1, 284, -1, 385, 317, -1, -1, + -1, 321, -1, -1, -1, 325, -1, 297, -1, -1, + -1, -1, 302, 333, -1, -1, 336, 307, 338, 309, + 310, 311, 312, 264, 265, -1, 267, 317, 417, 270, + 271, 321, -1, -1, 275, 276, 277, -1, 279, 359, + -1, -1, -1, 333, 285, -1, 336, 288, 338, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, 306, -1, -1, -1, 359, + -1, -1, 313, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, 417, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, -1, -1, 417, -1, 370, + 371, -1, 373, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, + -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, 416, 417, 418, 419, 285, + -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, + 306, -1, -1, -1, -1, -1, -1, 313, -1, -1, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + -1, -1, -1, -1, 370, -1, -1, 373, -1, -1, + 376, 377, 378, 379, -1, -1, -1, 383, -1, 385, + -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 416, 417, 418, 419, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, 306, -1, -1, -1, -1, + -1, -1, 313, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, -1, -1, -1, -1, 370, + -1, -1, -1, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, + -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, 416, 417, 418, 419, 285, + -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 364, -1, -1, 367, -1, -1, -1, -1, -1, - 373, 374, 375, 376, -1, -1, -1, 380, -1, 382, - -1, -1, -1, -1, -1, 388, 389, -1, -1, -1, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, 337, -1, -1, -1, 341, -1, -1, 344, 345, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + -1, -1, -1, -1, 370, -1, -1, -1, -1, -1, + 376, 377, 378, 379, -1, -1, -1, 383, -1, 385, + -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, - 413, 414, 415, 416, 285, -1, 261, 288, 263, -1, + 416, 417, 418, 419, 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, - -1, 302, 303, 304, -1, -1, -1, -1, -1, 284, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, - -1, 322, 297, -1, 325, -1, 327, 302, 329, 330, - 331, 332, 307, 334, 309, 310, 311, 312, -1, -1, - 341, -1, 317, 344, 345, -1, 321, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 333, -1, - -1, 336, 363, 338, -1, -1, 367, -1, -1, -1, - -1, -1, 373, 374, 375, 376, -1, -1, -1, 380, - -1, 382, -1, -1, 359, -1, -1, 388, 389, 364, - -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, - -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, - 279, -1, 413, 414, 415, 416, 285, -1, 261, 288, - -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, - -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, - -1, 284, -1, -1, -1, -1, -1, 316, -1, 318, - 319, -1, -1, 322, 297, -1, 325, -1, 327, 302, - 329, 330, 331, 332, 307, 334, 309, 310, 311, 312, - -1, -1, 341, -1, 317, 344, 345, -1, 321, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, -1, 367, -1, -1, 370, + -1, -1, -1, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, + -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, 416, 417, 418, 419, 285, + -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, 363, 338, -1, -1, 367, -1, - -1, -1, -1, -1, 373, 374, 375, 376, -1, -1, - -1, 380, -1, 382, -1, -1, 359, 360, 361, 388, - 389, -1, -1, -1, -1, -1, -1, 264, 265, -1, - 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, - 277, -1, 279, -1, 413, 414, 415, 416, 285, -1, - 261, 288, -1, -1, -1, -1, -1, -1, 295, -1, - -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, - -1, -1, -1, 284, -1, -1, -1, -1, -1, 316, - -1, 318, 319, -1, -1, 322, 297, -1, 325, -1, - 327, 302, 329, 330, 331, 332, 307, 334, 309, 310, - 311, 312, -1, -1, 341, -1, 317, 344, 345, -1, - 321, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 333, -1, -1, 336, -1, 338, -1, -1, - 367, -1, -1, -1, -1, -1, 373, 374, 375, 376, - -1, -1, -1, 380, -1, 382, -1, -1, 359, -1, - -1, 388, 389, -1, -1, -1, -1, -1, -1, 264, - 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, - 275, 276, 277, -1, 279, -1, 413, 414, 415, 416, - 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, - 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, - 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, - -1, -1, -1, -1, -1, -1, 341, -1, -1, 344, - 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + 366, -1, -1, -1, 370, -1, -1, -1, -1, -1, + 376, 377, 378, 379, -1, -1, -1, 383, -1, 385, + -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 416, 417, 418, 419, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, 366, -1, -1, -1, 370, + -1, -1, -1, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, + -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, 416, 417, 418, 419, 285, + -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 367, -1, -1, -1, -1, -1, 373, 374, - 375, 376, -1, -1, -1, 380, -1, 382, -1, -1, - -1, -1, -1, 388, 389, -1, -1, -1, -1, -1, - -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, - -1, -1, 275, 276, 277, -1, 279, -1, 413, 414, - 415, 416, 285, -1, -1, 288, -1, -1, -1, -1, - -1, -1, 295, -1, -1, -1, -1, 300, -1, 302, - 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 316, -1, 318, 319, -1, -1, 322, - -1, -1, 325, -1, 327, -1, 329, 330, 331, 332, - -1, 334, -1, -1, -1, -1, -1, -1, 341, -1, - -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 367, -1, -1, -1, -1, -1, - 373, 374, 375, 376, -1, -1, -1, 380, -1, 382, - -1, -1, -1, -1, -1, 388, 389, -1, -1, -1, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + -1, -1, -1, -1, 370, -1, -1, -1, -1, -1, + 376, 377, 378, 379, -1, -1, -1, 383, -1, 385, + -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, - 413, 414, 415, 416, 285, -1, -1, 288, -1, -1, + 416, 417, 418, 419, 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, -1, -1, -1, -1, 370, + -1, -1, -1, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, + -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, 416, 417, 418, 419, 285, + -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 367, -1, -1, -1, - -1, -1, 373, 374, 375, 376, -1, -1, -1, 380, - -1, 382, -1, -1, -1, -1, -1, 388, 389, -1, - -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, - -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, - 279, -1, 413, 414, 415, 416, 285, -1, -1, 288, - -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, - -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, - 319, -1, -1, 322, -1, -1, 325, -1, 327, -1, - 329, 330, 331, 332, -1, 334, -1, -1, -1, -1, - -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 367, -1, - -1, -1, -1, -1, 373, 374, 375, 376, -1, -1, - -1, 380, -1, 382, -1, -1, -1, -1, -1, 388, - 389, -1, -1, -1, -1, -1, -1, 264, 265, -1, - 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, - 277, -1, 279, -1, 413, 414, 415, 416, 285, -1, - 261, 288, -1, -1, -1, -1, -1, -1, 295, -1, - -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, - -1, -1, -1, 284, -1, -1, -1, -1, -1, 316, - -1, 318, 319, -1, -1, 322, 297, -1, 325, -1, - 327, 302, 329, 330, 331, 332, 307, 334, 309, 310, - 311, 312, -1, -1, 315, -1, 317, -1, -1, -1, - 321, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 333, -1, -1, 336, -1, 338, -1, -1, - 367, -1, -1, -1, -1, -1, 373, 374, 375, 376, - -1, -1, -1, 380, -1, 382, -1, -1, 359, -1, - -1, 388, 389, 364, 365, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + -1, -1, -1, -1, 370, -1, -1, -1, -1, -1, + 376, 377, 378, 379, -1, -1, -1, 383, -1, 385, + -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 416, 417, 418, 419, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, + 361, 362, -1, -1, -1, -1, -1, -1, -1, 370, + -1, -1, -1, -1, -1, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, -1, -1, -1, -1, + 391, 392, -1, -1, -1, -1, -1, -1, 264, 265, + -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, + 276, 277, -1, 279, -1, 416, 417, 418, 419, 285, + -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, + -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 263, -1, 265, -1, 267, 413, 414, 270, 416, - 272, 273, -1, 275, -1, 277, -1, 279, -1, 281, - 282, 283, -1, -1, -1, 287, 288, -1, -1, -1, - -1, 293, -1, 295, 296, -1, -1, -1, 300, -1, - -1, -1, 304, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, 316, -1, 318, -1, -1, -1, - 322, 323, -1, -1, -1, -1, -1, -1, 330, 331, - 264, 265, 334, 267, -1, 337, 270, 271, -1, -1, - 342, 275, 276, 277, -1, 279, -1, -1, -1, -1, - -1, 285, -1, -1, 288, -1, -1, -1, 360, 361, - -1, 295, -1, -1, -1, -1, 300, -1, 302, 303, - 304, 373, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 316, -1, 318, 319, -1, -1, 322, -1, - -1, 325, -1, 327, -1, 329, 330, 331, 332, 265, - 334, 267, -1, 337, 270, -1, 272, 273, -1, 275, - -1, 277, 414, 279, -1, 281, 282, 283, -1, -1, - -1, 287, 288, -1, -1, -1, -1, 293, -1, 295, - 296, -1, -1, 367, 300, -1, -1, -1, 304, -1, + 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, + -1, 327, -1, 329, 330, 331, 332, -1, 334, -1, + -1, -1, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 316, -1, 318, -1, -1, -1, 322, 323, -1, -1, - -1, -1, -1, -1, 330, 331, -1, -1, 334, -1, - -1, 337, -1, -1, -1, -1, 342, -1, -1, 413, - 414, 265, -1, 267, -1, -1, 270, -1, 272, 273, - -1, 275, -1, 277, -1, 279, -1, 281, 282, 283, - -1, -1, -1, 287, 288, -1, -1, 373, -1, 293, - -1, 295, 296, -1, -1, -1, 300, -1, -1, -1, - 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 316, -1, 318, -1, -1, -1, 322, 323, - -1, -1, -1, -1, -1, -1, 330, 331, 414, 265, - 334, 267, -1, 337, 270, -1, -1, 273, 342, 275, - -1, 277, -1, 279, -1, 281, 282, 283, -1, -1, - -1, 287, 288, -1, -1, -1, -1, 293, -1, 295, - -1, 265, -1, 267, 300, -1, 270, -1, 304, 273, - -1, 275, -1, 277, -1, 279, -1, 281, 282, 283, - 316, -1, 318, 287, 288, -1, 322, -1, -1, 293, - -1, 295, -1, -1, 330, 331, 300, -1, 334, -1, - 304, 337, -1, -1, -1, -1, 342, -1, -1, -1, - 414, 265, 316, 267, 318, -1, 270, -1, 322, -1, - -1, 275, -1, -1, -1, 279, 330, 331, -1, -1, - 334, -1, -1, 337, 288, -1, -1, 373, 342, -1, - -1, 295, -1, -1, -1, -1, 300, -1, -1, -1, - 304, 265, 306, 267, 308, -1, 270, -1, -1, 313, - -1, 275, 316, -1, 318, 279, -1, -1, 322, -1, - -1, 325, -1, -1, 288, -1, 330, 331, 414, -1, - 334, 295, -1, 337, -1, -1, 300, -1, -1, -1, - 304, -1, 306, -1, 308, -1, -1, -1, -1, 313, + -1, -1, -1, -1, 360, 361, 362, -1, -1, -1, + -1, -1, -1, -1, 370, -1, -1, -1, -1, -1, + 376, 377, 378, 379, -1, -1, -1, 383, -1, 385, + -1, -1, -1, -1, -1, 391, 392, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 416, 417, 418, 419, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, 265, -1, 267, -1, -1, + 270, -1, -1, -1, -1, 275, -1, -1, -1, 279, + -1, -1, -1, -1, -1, -1, -1, -1, 288, 360, + 361, 362, -1, -1, -1, 295, -1, -1, -1, 370, + 300, -1, -1, -1, 304, 376, 377, 378, 379, -1, + -1, -1, 383, -1, 385, -1, 316, -1, 318, -1, + 391, 392, 322, -1, -1, -1, -1, -1, -1, -1, + 330, 331, -1, -1, 334, -1, -1, 337, -1, -1, + 263, -1, 265, -1, 267, 416, 417, 270, 419, 272, + 273, -1, 275, -1, 277, -1, 279, -1, 281, 282, + 283, -1, -1, -1, 287, 288, -1, -1, -1, -1, + 293, -1, 295, 296, -1, -1, -1, 300, -1, -1, + -1, 304, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 315, 316, -1, 318, -1, -1, -1, 322, + 323, -1, -1, -1, -1, -1, -1, 330, 331, -1, + -1, 334, -1, -1, 337, -1, -1, 417, -1, 342, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 363, 364, -1, -1, 285, -1, -1, 288, -1, -1, + -1, -1, -1, 376, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, 417, 265, 337, 267, -1, -1, + 270, -1, 272, 273, -1, 275, -1, 277, -1, 279, + -1, 281, 282, 283, -1, -1, -1, 287, 288, 360, + 361, 362, -1, 293, -1, 295, 296, -1, -1, 370, + 300, -1, -1, -1, 304, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 316, -1, 318, -1, + -1, -1, 322, 323, -1, -1, -1, -1, -1, -1, + 330, 331, -1, -1, 334, -1, -1, 337, -1, -1, + -1, -1, 342, -1, -1, 416, 417, 265, -1, 267, + -1, -1, 270, -1, 272, 273, -1, 275, -1, 277, + -1, 279, -1, 281, 282, 283, -1, -1, -1, 287, + 288, -1, -1, -1, -1, 293, 376, 295, 296, 265, + -1, 267, 300, -1, 270, -1, 304, 273, -1, 275, + -1, 277, -1, 279, -1, 281, 282, 283, 316, -1, + 318, 287, 288, -1, 322, 323, -1, 293, -1, 295, + -1, -1, 330, 331, 300, -1, 334, 417, 304, 337, + -1, -1, -1, -1, 342, -1, -1, -1, -1, -1, + 316, -1, 318, -1, -1, -1, 322, -1, -1, -1, + -1, -1, -1, -1, 330, 331, -1, 265, 334, 267, + -1, 337, 270, -1, -1, 273, 342, 275, -1, 277, + -1, 279, -1, 281, 282, 283, -1, -1, -1, 287, + 288, -1, -1, -1, -1, 293, -1, 295, -1, 265, + -1, 267, 300, -1, 270, -1, 304, -1, -1, 275, + 376, -1, -1, 279, -1, -1, -1, -1, 316, 417, + 318, -1, 288, -1, 322, -1, -1, -1, -1, 295, + -1, -1, 330, 331, 300, -1, 334, -1, 304, 337, + 306, -1, 308, 265, 342, 267, -1, 313, 270, -1, + 316, 417, 318, 275, -1, -1, 322, 279, -1, 325, + -1, -1, -1, -1, 330, 331, 288, -1, 334, -1, + -1, 337, -1, 295, -1, -1, -1, -1, 300, -1, + -1, -1, 304, 265, 306, 267, 308, -1, 270, -1, + -1, 313, -1, 275, 316, -1, 318, 279, -1, -1, + 322, -1, -1, 325, -1, 371, 288, -1, 330, 331, + -1, -1, 334, 295, -1, 337, -1, -1, 300, 417, + -1, -1, 304, -1, 306, -1, 308, 265, -1, 267, + -1, 313, 270, -1, 316, -1, 318, 275, -1, -1, + 322, 279, -1, 325, -1, -1, -1, 369, 330, 331, + 288, 417, 334, -1, -1, 337, -1, 295, -1, 265, + -1, 267, 300, -1, 270, -1, 304, -1, 306, 275, + -1, -1, -1, 279, -1, 313, -1, -1, 316, -1, + 318, -1, 288, -1, 322, -1, -1, 325, -1, 295, + -1, -1, 330, 331, 300, 417, 334, -1, 304, 337, + -1, -1, -1, 265, -1, 267, -1, -1, 270, -1, + 316, -1, 318, 275, -1, -1, 322, 279, -1, -1, + -1, -1, -1, -1, 330, 331, 288, 265, 334, 267, + -1, 337, 270, 295, -1, 417, -1, 275, 300, -1, + -1, 279, 304, -1, -1, -1, -1, -1, -1, -1, + 288, -1, -1, -1, 316, -1, 318, 295, -1, -1, + 322, -1, 300, -1, -1, -1, 304, -1, 330, 331, + -1, 265, 334, 267, -1, 337, 270, -1, 316, 417, + 318, 275, -1, -1, 322, 279, -1, -1, -1, -1, + -1, -1, 330, 331, 288, 265, 334, 267, -1, 337, + 270, 295, -1, -1, -1, 275, 300, -1, -1, 279, + 304, 417, -1, -1, -1, -1, -1, -1, 288, -1, + -1, -1, 316, -1, 318, 295, -1, -1, 322, -1, + 300, -1, -1, -1, 304, -1, 330, 331, -1, 265, + 334, 267, -1, 337, 270, -1, 316, -1, 318, 275, + -1, -1, 322, 279, -1, 417, -1, -1, -1, -1, + 330, 331, 288, 265, 334, 267, -1, 337, 270, 295, + -1, -1, -1, 275, 300, -1, -1, 279, 304, 417, + -1, -1, -1, -1, -1, -1, 288, -1, -1, -1, + 316, -1, 318, 295, -1, -1, 322, -1, 300, -1, + -1, -1, 304, -1, 330, 331, -1, 265, 334, 267, + -1, 337, 270, -1, 316, -1, 318, 275, -1, -1, + 322, 279, -1, 417, -1, -1, -1, -1, 330, 331, + 288, 265, 334, 267, -1, 337, 270, 295, -1, -1, + -1, 275, 300, -1, -1, 279, 304, 417, -1, -1, + -1, -1, -1, -1, 288, -1, -1, -1, 316, -1, + 318, 295, -1, -1, 322, -1, 300, -1, -1, -1, + 304, -1, 330, 331, -1, -1, 334, -1, -1, 337, -1, -1, 316, -1, 318, -1, -1, -1, 322, -1, - 414, 325, -1, -1, 368, -1, 330, 331, -1, -1, - 334, -1, -1, 337, 265, -1, 267, -1, -1, 270, - -1, -1, -1, -1, 275, -1, -1, -1, 279, -1, - -1, -1, -1, -1, -1, -1, -1, 288, -1, -1, - -1, -1, 366, -1, 295, -1, 265, -1, 267, 300, - 414, 270, -1, 304, -1, 306, 275, 308, -1, -1, - 279, -1, 313, -1, -1, 316, -1, 318, -1, 288, - -1, 322, -1, -1, 325, -1, 295, -1, -1, 330, - 331, 300, -1, 334, -1, 304, 337, 306, -1, -1, - 414, -1, -1, -1, 313, -1, -1, 316, -1, 318, - 265, -1, 267, 322, -1, 270, 325, 272, -1, -1, - 275, 330, 331, -1, 279, 334, -1, 265, 337, 267, - -1, -1, 270, 288, -1, -1, -1, 275, -1, -1, - 295, 279, -1, -1, -1, 300, -1, 302, -1, 304, - 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, - -1, 316, 300, 318, -1, -1, 304, 322, 323, -1, - -1, -1, -1, 414, -1, 330, 331, -1, 316, 334, - 318, 265, 337, 267, 322, -1, 270, -1, -1, -1, - -1, 275, 330, 331, -1, 279, 334, -1, 265, 337, - 267, -1, -1, 270, 288, 414, -1, -1, 275, -1, - -1, 295, 279, -1, -1, -1, 300, -1, -1, -1, - 304, 288, -1, -1, -1, -1, -1, -1, 295, -1, - -1, -1, 316, 300, 318, -1, -1, 304, 322, -1, - -1, -1, -1, -1, -1, -1, 330, 331, -1, 316, - 334, 318, 265, 337, 267, 322, -1, 270, -1, 414, - -1, -1, 275, 330, 331, -1, 279, 334, -1, 265, - 337, 267, -1, -1, 270, 288, 414, -1, -1, 275, - -1, -1, 295, 279, -1, -1, -1, 300, -1, -1, - -1, 304, 288, -1, -1, -1, -1, -1, -1, 295, - -1, -1, -1, 316, 300, 318, -1, -1, 304, 322, - -1, -1, -1, -1, -1, -1, -1, 330, 331, -1, - 316, 334, 318, 265, 337, 267, 322, -1, 270, -1, - 414, -1, -1, 275, 330, 331, -1, 279, 334, -1, - 265, 337, 267, -1, -1, 270, 288, 414, -1, -1, - 275, -1, -1, 295, 279, -1, -1, -1, 300, -1, - -1, -1, 304, 288, -1, -1, -1, -1, -1, -1, - 295, -1, -1, -1, 316, 300, 318, -1, -1, 304, - 322, -1, -1, -1, -1, -1, -1, -1, 330, 331, - -1, 316, 334, 318, 265, 337, 267, 322, -1, 270, - -1, 414, -1, -1, 275, 330, 331, -1, 279, 334, - -1, 265, 337, 267, -1, -1, 270, 288, 414, -1, - -1, 275, -1, -1, 295, 279, -1, -1, -1, 300, - -1, -1, -1, 304, 288, -1, -1, -1, -1, -1, - -1, 295, -1, -1, -1, 316, 300, 318, -1, -1, - 304, 322, -1, 256, -1, -1, -1, -1, 261, 330, - 331, -1, 316, 334, 318, -1, 337, -1, 322, 272, - -1, -1, 414, -1, 277, -1, 330, 331, 281, -1, - 334, 284, -1, 337, -1, -1, -1, -1, -1, 414, - -1, -1, -1, 296, 297, -1, -1, -1, 301, 302, - -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, -1, 317, -1, -1, -1, 321, -1, - 323, -1, -1, -1, 256, -1, -1, -1, -1, 261, - 333, -1, 335, 336, -1, 338, -1, -1, -1, 342, - 272, -1, -1, 414, -1, 277, -1, -1, -1, 281, - -1, -1, 284, -1, -1, -1, 359, -1, -1, -1, - 414, 364, 365, -1, 296, 297, -1, -1, -1, 301, - 302, -1, -1, -1, -1, 307, -1, 309, 310, 311, - 312, -1, -1, -1, -1, 317, -1, -1, -1, 321, - -1, 323, -1, -1, -1, 256, -1, -1, -1, -1, - 261, 333, -1, 335, 336, -1, 338, -1, -1, -1, - 342, 272, -1, -1, -1, -1, 277, -1, -1, -1, - 281, -1, -1, 284, -1, -1, -1, 359, -1, -1, - -1, -1, 364, 365, -1, 296, 297, -1, -1, -1, + 261, 417, -1, -1, -1, -1, 330, 331, -1, -1, + 334, 272, -1, 337, -1, -1, 277, -1, -1, -1, + 281, -1, -1, 284, -1, 417, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 296, 297, -1, -1, -1, 301, 302, -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, - 321, -1, 323, -1, -1, -1, 256, -1, -1, -1, - -1, 261, 333, -1, -1, 336, -1, 338, -1, -1, - -1, 342, 272, -1, -1, -1, -1, 277, -1, -1, - -1, 281, -1, -1, 284, -1, -1, -1, 359, -1, - -1, -1, -1, 364, 365, -1, 296, 297, -1, -1, - -1, 301, 302, -1, -1, -1, -1, 307, -1, 309, - 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, - -1, 321, -1, 323, -1, -1, -1, -1, -1, -1, - -1, -1, 261, 333, -1, -1, 336, -1, 338, -1, - -1, -1, 342, 272, -1, -1, -1, -1, 277, -1, - -1, -1, 281, -1, -1, 284, -1, -1, -1, 359, - -1, -1, -1, -1, 364, 365, -1, 296, 297, -1, - -1, -1, 301, 302, -1, -1, -1, -1, 307, -1, - 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, - -1, -1, 321, -1, 323, -1, -1, -1, -1, -1, - -1, 261, -1, -1, 333, -1, -1, 336, -1, 338, - -1, -1, 272, 342, -1, -1, -1, 277, -1, -1, - -1, 281, -1, -1, 284, -1, -1, -1, -1, -1, - 359, -1, -1, -1, -1, 364, 296, 297, -1, -1, - -1, 301, 302, -1, -1, -1, -1, 307, -1, 309, - 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, - 261, 321, -1, 323, -1, -1, -1, -1, -1, -1, + 321, -1, 323, -1, -1, -1, -1, -1, 261, 417, + -1, -1, 333, -1, 335, 336, -1, 338, -1, 272, + -1, 342, -1, -1, 277, -1, -1, -1, 281, -1, + -1, 284, -1, 417, -1, -1, -1, -1, 359, -1, + -1, -1, -1, 296, 297, -1, 367, 368, 301, 302, + -1, 261, -1, -1, 307, -1, 309, 310, 311, 312, + -1, -1, -1, -1, 317, -1, -1, -1, 321, -1, + 323, -1, -1, -1, 284, -1, -1, -1, -1, -1, + 333, -1, -1, 336, -1, 338, -1, 297, -1, 342, + -1, -1, 302, -1, 261, -1, 263, 307, -1, 309, + 310, 311, 312, -1, -1, 315, 359, 317, -1, -1, + -1, 321, -1, -1, 367, 368, -1, 284, -1, -1, -1, -1, -1, 333, -1, -1, 336, -1, 338, -1, - -1, -1, 342, 284, -1, -1, -1, -1, -1, -1, - 261, -1, 263, -1, -1, -1, 297, -1, -1, 359, - -1, 302, -1, -1, 364, -1, 307, -1, 309, 310, - 311, 312, -1, 284, 315, -1, 317, -1, -1, -1, - 321, -1, -1, -1, -1, -1, 297, -1, -1, -1, - 261, 302, 333, -1, -1, 336, 307, 338, 309, 310, - 311, 312, -1, -1, 315, -1, 317, -1, -1, -1, - 321, -1, -1, 284, -1, -1, -1, -1, 359, -1, - -1, -1, 333, 364, -1, 336, 297, 338, -1, -1, - 301, 302, -1, -1, -1, -1, 307, -1, 309, 310, - 311, 312, -1, -1, -1, -1, 317, -1, 359, -1, - 321, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 297, -1, -1, -1, -1, 302, -1, -1, -1, -1, + 307, -1, 309, 310, 311, 312, -1, -1, -1, 359, + 317, -1, -1, -1, 321, -1, -1, 367, 368, -1, + -1, -1, 261, -1, -1, -1, 333, -1, -1, 336, + -1, 338, -1, 272, -1, -1, -1, -1, 277, -1, + -1, -1, 281, -1, -1, 284, -1, -1, -1, -1, + -1, -1, 359, -1, -1, -1, -1, 296, 297, -1, + 367, 368, 301, 302, -1, 261, -1, -1, 307, -1, + 309, 310, 311, 312, -1, -1, 272, -1, 317, -1, + -1, 277, 321, -1, 323, 281, -1, -1, 284, -1, + -1, -1, -1, -1, 333, -1, -1, 336, -1, 338, + 296, 297, -1, 342, -1, 301, 302, -1, 261, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + 359, 317, -1, -1, -1, 321, -1, 323, 367, -1, + -1, 284, -1, -1, -1, -1, -1, 333, -1, -1, + 336, -1, 338, 261, 297, -1, 342, -1, -1, 302, + -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, + -1, -1, -1, 359, 317, -1, 284, -1, 321, -1, + -1, 367, -1, -1, -1, -1, -1, -1, -1, 297, + 333, -1, -1, 336, 302, 338, -1, -1, -1, 307, + -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, + -1, -1, 261, 321, -1, -1, 359, -1, -1, -1, + 363, 364, -1, -1, 367, 333, -1, -1, 336, -1, + 338, -1, -1, -1, -1, 284, -1, -1, -1, -1, + -1, -1, 261, -1, 263, -1, -1, -1, 297, -1, + -1, 359, -1, 302, -1, 363, 364, -1, 307, 367, + 309, 310, 311, 312, -1, 284, 315, -1, 317, -1, + -1, -1, 321, -1, -1, -1, -1, -1, 297, -1, + -1, -1, -1, 302, 333, 261, -1, 336, 307, 338, + 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, + -1, -1, 321, -1, -1, -1, -1, -1, 284, -1, + 359, -1, -1, -1, 333, -1, -1, 336, 367, 338, + 261, 297, -1, -1, -1, -1, 302, -1, -1, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + 359, 317, -1, 284, -1, 321, -1, -1, 367, -1, + -1, -1, -1, -1, -1, -1, 297, 333, -1, -1, + 336, 302, 338, -1, -1, -1, 307, -1, 309, 310, + 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, + 321, -1, -1, 359, -1, -1, -1, 363, 364, -1, -1, -1, 333, -1, -1, 336, -1, 338, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 359, }; -#line 6031 "cs-parser.jay" +#line 6029 "cs-parser.jay" // // A class used to hold info about an operator declarator @@ -11489,8 +11602,10 @@ void Error_NamedArgumentExpected (NamedArgument a) void push_current_class (TypeContainer tc, object partial_token) { - if (RootContext.EvalMode){ - tc.ModFlags = (tc.ModFlags & ~(Modifiers.PRIVATE|Modifiers.INTERNAL)) | Modifiers.PUBLIC; + if (module.Evaluator != null){ + tc.Definition.Modifiers = tc.ModFlags = (tc.ModFlags & ~Modifiers.AccessibilityMask) | Modifiers.PUBLIC; + if (undo == null) + undo = new Undo (); undo.AddTypeContainer (current_container, tc); } @@ -11524,7 +11639,7 @@ MakeName (MemberName class_name) { Namespace ns = current_namespace.NS; - if (current_container == RootContext.ToplevelTypes) { + if (current_container == module) { if (ns.Name.Length != 0) return new MemberName (ns.MemberName, class_name); else @@ -11600,15 +11715,16 @@ static CSharpParser () oob_stack = new Stack (); } -public CSharpParser (SeekableStreamReader reader, CompilationUnit file, ModuleContainer module) +public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file) { - if (RootContext.EvalMode) - undo = new Undo (); - this.file = file; - this.module = module; + current_namespace = file.NamespaceContainer; + + this.module = current_namespace.Module; this.compiler = module.Compiler; - current_namespace = new NamespaceEntry (module, null, file, null); + this.settings = compiler.Settings; + lang_version = settings.Version; + doc_support = settings.DocumentationFile != null; current_class = current_namespace.SlaveDeclSpace; current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes oob_stack.Clear (); @@ -11647,9 +11763,6 @@ public void parse () Report.Error (589, lexer.Location, "Internal compiler error during parsing"); } } - - if (RootContext.ToplevelTypes.NamespaceEntry != null) - throw new InternalErrorException ("who set it?"); } void CheckToken (int error, int yyToken, string msg, Location loc) @@ -11668,6 +11781,11 @@ string ConsumeStoredComment () return s; } +void FeatureIsNotAvailable (Location loc, string feature) +{ + compiler.Report.FeatureIsNotAvailable (compiler, loc, feature); +} + Location GetLocation (object obj) { var lt = obj as Tokenizer.LocatedToken; @@ -11731,8 +11849,8 @@ end_block (Location loc) void start_anonymous (bool lambda, ParametersCompiled parameters, Location loc) { - if (RootContext.Version == LanguageVersion.ISO_1){ - Report.FeatureIsNotAvailable (loc, "anonymous methods"); + if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (loc, "anonymous methods"); } oob_stack.Push (current_anonymous_method); @@ -12013,6 +12131,7 @@ static string GetTokenName (int token) case Token.EXPLICIT: return "explicit"; case Token.EXTERN: + case Token.EXTERN_ALIAS: return "extern"; case Token.FALSE: return "false"; @@ -12106,6 +12225,12 @@ static string GetTokenName (int token) return "while"; case Token.ARGLIST: return "__arglist"; + case Token.REFVALUE: + return "__refvalue"; + case Token.REFTYPE: + return "__reftype"; + case Token.MAKEREF: + return "__makeref"; case Token.PARTIAL: return "partial"; case Token.ARROW: @@ -12441,72 +12566,75 @@ namespace yydebug { public const int INTERR_NULLABLE = 357; public const int EXTERN_ALIAS = 358; public const int ASYNC = 359; - public const int GET = 360; - public const int SET = 361; - public const int LAST_KEYWORD = 362; - public const int OPEN_BRACE = 363; - public const int CLOSE_BRACE = 364; - public const int OPEN_BRACKET = 365; - public const int CLOSE_BRACKET = 366; - public const int OPEN_PARENS = 367; - public const int CLOSE_PARENS = 368; - public const int DOT = 369; - public const int COMMA = 370; - public const int COLON = 371; - public const int SEMICOLON = 372; - public const int TILDE = 373; - public const int PLUS = 374; - public const int MINUS = 375; - public const int BANG = 376; - public const int ASSIGN = 377; - public const int OP_LT = 378; - public const int OP_GT = 379; - public const int BITWISE_AND = 380; - public const int BITWISE_OR = 381; - public const int STAR = 382; - public const int PERCENT = 383; - public const int DIV = 384; - public const int CARRET = 385; - public const int INTERR = 386; - public const int DOUBLE_COLON = 387; - public const int OP_INC = 388; - public const int OP_DEC = 389; - public const int OP_SHIFT_LEFT = 390; - public const int OP_SHIFT_RIGHT = 391; - public const int OP_LE = 392; - public const int OP_GE = 393; - public const int OP_EQ = 394; - public const int OP_NE = 395; - public const int OP_AND = 396; - public const int OP_OR = 397; - public const int OP_MULT_ASSIGN = 398; - public const int OP_DIV_ASSIGN = 399; - public const int OP_MOD_ASSIGN = 400; - public const int OP_ADD_ASSIGN = 401; - public const int OP_SUB_ASSIGN = 402; - public const int OP_SHIFT_LEFT_ASSIGN = 403; - public const int OP_SHIFT_RIGHT_ASSIGN = 404; - public const int OP_AND_ASSIGN = 405; - public const int OP_XOR_ASSIGN = 406; - public const int OP_OR_ASSIGN = 407; - public const int OP_PTR = 408; - public const int OP_COALESCING = 409; - public const int OP_GENERICS_LT = 410; - public const int OP_GENERICS_LT_DECL = 411; - public const int OP_GENERICS_GT = 412; - public const int LITERAL = 413; - public const int IDENTIFIER = 414; - public const int OPEN_PARENS_LAMBDA = 415; - public const int OPEN_PARENS_CAST = 416; - public const int GENERIC_DIMENSION = 417; - public const int DEFAULT_COLON = 418; - public const int OPEN_BRACKET_EXPR = 419; - public const int EVAL_STATEMENT_PARSER = 420; - public const int EVAL_COMPILATION_UNIT_PARSER = 421; - public const int EVAL_USING_DECLARATIONS_UNIT_PARSER = 422; - public const int GENERATE_COMPLETION = 423; - public const int COMPLETE_COMPLETION = 424; - public const int UMINUS = 425; + public const int REFVALUE = 360; + public const int REFTYPE = 361; + public const int MAKEREF = 362; + public const int GET = 363; + public const int SET = 364; + public const int LAST_KEYWORD = 365; + public const int OPEN_BRACE = 366; + public const int CLOSE_BRACE = 367; + public const int OPEN_BRACKET = 368; + public const int CLOSE_BRACKET = 369; + public const int OPEN_PARENS = 370; + public const int CLOSE_PARENS = 371; + public const int DOT = 372; + public const int COMMA = 373; + public const int COLON = 374; + public const int SEMICOLON = 375; + public const int TILDE = 376; + public const int PLUS = 377; + public const int MINUS = 378; + public const int BANG = 379; + public const int ASSIGN = 380; + public const int OP_LT = 381; + public const int OP_GT = 382; + public const int BITWISE_AND = 383; + public const int BITWISE_OR = 384; + public const int STAR = 385; + public const int PERCENT = 386; + public const int DIV = 387; + public const int CARRET = 388; + public const int INTERR = 389; + public const int DOUBLE_COLON = 390; + public const int OP_INC = 391; + public const int OP_DEC = 392; + public const int OP_SHIFT_LEFT = 393; + public const int OP_SHIFT_RIGHT = 394; + public const int OP_LE = 395; + public const int OP_GE = 396; + public const int OP_EQ = 397; + public const int OP_NE = 398; + public const int OP_AND = 399; + public const int OP_OR = 400; + public const int OP_MULT_ASSIGN = 401; + public const int OP_DIV_ASSIGN = 402; + public const int OP_MOD_ASSIGN = 403; + public const int OP_ADD_ASSIGN = 404; + public const int OP_SUB_ASSIGN = 405; + public const int OP_SHIFT_LEFT_ASSIGN = 406; + public const int OP_SHIFT_RIGHT_ASSIGN = 407; + public const int OP_AND_ASSIGN = 408; + public const int OP_XOR_ASSIGN = 409; + public const int OP_OR_ASSIGN = 410; + public const int OP_PTR = 411; + public const int OP_COALESCING = 412; + public const int OP_GENERICS_LT = 413; + public const int OP_GENERICS_LT_DECL = 414; + public const int OP_GENERICS_GT = 415; + public const int LITERAL = 416; + public const int IDENTIFIER = 417; + public const int OPEN_PARENS_LAMBDA = 418; + public const int OPEN_PARENS_CAST = 419; + public const int GENERIC_DIMENSION = 420; + public const int DEFAULT_COLON = 421; + public const int OPEN_BRACKET_EXPR = 422; + public const int EVAL_STATEMENT_PARSER = 423; + public const int EVAL_COMPILATION_UNIT_PARSER = 424; + public const int EVAL_USING_DECLARATIONS_UNIT_PARSER = 425; + public const int GENERATE_COMPLETION = 426; + public const int COMPLETE_COMPLETION = 427; + public const int UMINUS = 428; public const int yyErrorCode = 256; } namespace yyParser { diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay index bc8fb3fcc..46c39443c 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay @@ -94,7 +94,7 @@ namespace Mono.CSharp /// /// The current file. /// - CompilationUnit file; + readonly CompilationSourceFile file; /// /// Temporary Xml documentation cache. @@ -106,16 +106,13 @@ namespace Mono.CSharp /// Current attribute target string current_attr_target; - /// assembly and module attribute definitions are enabled - bool global_attrs_enabled = true; - ParameterModifierType valid_param_mod; bool default_parameter_used; /// When using the interactive parser, this holds the /// resulting expression - public object InteractiveResult; + public Class InteractiveResult; // // Keeps track of global data changes to undo on parser error @@ -124,12 +121,12 @@ namespace Mono.CSharp Stack linq_clause_blocks; - // A counter to create new class names in interactive mode - static int class_count; - ModuleContainer module; - CompilerContext compiler; + readonly CompilerContext compiler; + readonly LanguageVersion lang_version; + readonly bool doc_support; + readonly CompilerSettings settings; // // Instead of allocating carrier array everytime we @@ -144,7 +141,7 @@ namespace Mono.CSharp LocationsBag lbag; UsingsBag ubag; List> mod_locations; - Location parameterModifierLocation; + Location parameterModifierLocation, savedLocation; %} %token EOF @@ -255,6 +252,9 @@ namespace Mono.CSharp %token INTERR_NULLABLE %token EXTERN_ALIAS %token ASYNC +%token REFVALUE +%token REFTYPE +%token MAKEREF /* C# keywords which are not really keywords */ %token GET @@ -370,33 +370,39 @@ namespace Mono.CSharp %% compilation_unit - : outer_declarations opt_EOF - | outer_declarations global_attributes opt_EOF - | global_attributes opt_EOF - | opt_EOF /* allow empty files */ + : outer_declaration opt_EOF + { + Lexer.check_incorrect_doc_comment (); + } | interactive_parsing { Lexer.CompleteOnEOF = false; } opt_EOF ; - -opt_EOF - : /* empty */ + +outer_declaration + : opt_extern_alias_directives opt_using_directives + | opt_extern_alias_directives opt_using_directives namespace_or_type_declarations opt_attributes { - Lexer.check_incorrect_doc_comment (); + if ($4 != null) { + Attributes attrs = (Attributes) $4; + Report.Error (1730, attrs.Attrs [0].Location, + "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); + } } - | EOF + | opt_extern_alias_directives opt_using_directives attribute_sections { - Lexer.check_incorrect_doc_comment (); + module.AddAttributes ((Attributes) $3, current_namespace); + } + | error + { + if (yyToken == Token.EXTERN_ALIAS) + Report.Error (439, lexer.Location, "An extern alias declaration must precede all other elements"); + else + Error_SyntaxError (yyToken); } ; - -outer_declarations - : outer_declaration - | outer_declarations outer_declaration - ; - -outer_declaration - : extern_alias_directive - | using_directive - | namespace_member_declaration + +opt_EOF + : /* empty */ + | EOF ; extern_alias_directives @@ -411,11 +417,12 @@ extern_alias_directive string s = lt.Value; if (s != "alias"){ syntax_error (lt.Location, "`alias' expected"); - } else if (RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (lt.Location, "external alias"); + } else if (lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (lt.Location, "external alias"); } else { lt = (Tokenizer.LocatedToken) $3; current_namespace.AddUsingExternalAlias (lt.Value, lt.Location, Report); + ubag.AddExternAlias (GetLocation ($1), GetLocation ($2), lt, GetLocation ($4)); } } | EXTERN_ALIAS error @@ -432,12 +439,12 @@ using_directives using_directive : using_alias_directive { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } | using_namespace_directive { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } ; @@ -446,9 +453,14 @@ using_alias_directive : USING IDENTIFIER ASSIGN namespace_or_type_name SEMICOLON { var lt = (Tokenizer.LocatedToken) $2; + if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") { + Report.Warning (440, 2, lt.Location, + "An alias named `global' will not be used when resolving `global::'. The global namespace will be used instead"); + } + current_namespace.AddUsingAlias (lt.Value, (MemberName) $4, GetLocation ($1)); ubag.AddUsingAlias (GetLocation ($1), lt, GetLocation ($3), (MemberName) $4, GetLocation ($5)); - } + } | USING error { Error_SyntaxError (yyToken); @@ -472,24 +484,52 @@ using_namespace_directive namespace_declaration : opt_attributes NAMESPACE qualified_identifier { + Attributes attrs = (Attributes) $1; MemberName name = (MemberName) $3; - - if ($1 != null) { - Report.Error(1671, name.Location, "A namespace declaration cannot have modifiers or attributes"); + if (attrs != null) { + bool valid_global_attrs = true; + if ((current_namespace.DeclarationFound || current_namespace != file.NamespaceContainer)) { + valid_global_attrs = false; + } else { + foreach (var a in attrs.Attrs) { + if (a.ExplicitTarget == "assembly" || a.ExplicitTarget == "module") + continue; + + valid_global_attrs = false; + break; + } + } + + if (!valid_global_attrs) + Report.Error (1671, name.Location, "A namespace declaration cannot have modifiers or attributes"); } - - current_namespace = new NamespaceEntry (module, - current_namespace, file, name.GetName ()); + + current_namespace = new NamespaceEntry (module, current_namespace, file, name.GetName ()); current_class = current_namespace.SlaveDeclSpace; current_container = current_class.PartialContainer; + + module.AddAttributes (attrs, current_namespace); + ubag.DeclareNamespace (GetLocation ($2), name); - } - namespace_body opt_semicolon - { + } + OPEN_BRACE + { + if (doc_support) + Lexer.doc_state = XmlCommentState.Allowed; + ubag.OpenNamespace (GetLocation ($5)); + } + opt_extern_alias_directives opt_using_directives opt_namespace_or_type_declarations CLOSE_BRACE opt_semicolon + { + if ($11 != null) + lbag.AddLocation (current_namespace, GetLocation ($2), GetLocation ($5), GetLocation ($10), GetLocation ($11)); + else + lbag.AddLocation (current_namespace, GetLocation ($2), GetLocation ($5), GetLocation ($10)); + current_namespace = current_namespace.Parent; current_class = current_namespace.SlaveDeclSpace; current_container = current_class.PartialContainer; - ubag.EndNamespace (GetLocation ($6)); + ubag.CloseNamespace (GetLocation ($10)); + ubag.EndNamespace (GetLocation ($10)); } ; @@ -533,22 +573,6 @@ namespace_name } ; -namespace_body - : OPEN_BRACE - { - if (RootContext.Documentation != null) - Lexer.doc_state = XmlCommentState.Allowed; - ubag.OpenNamespace (GetLocation ($1)); - - } - opt_extern_alias_directives - opt_using_directives - opt_namespace_member_declarations - CLOSE_BRACE { - ubag.CloseNamespace (GetLocation ($6)); - } - ; - opt_using_directives : /* empty */ | using_directives @@ -559,25 +583,33 @@ opt_extern_alias_directives | extern_alias_directives ; -opt_namespace_member_declarations +opt_namespace_or_type_declarations : /* empty */ - | namespace_member_declarations + | namespace_or_type_declarations ; -namespace_member_declarations - : namespace_member_declaration - | namespace_member_declarations namespace_member_declaration +namespace_or_type_declarations + : namespace_or_type_declaration + | namespace_or_type_declarations namespace_or_type_declaration ; -namespace_member_declaration +namespace_or_type_declaration : type_declaration { if ($1 != null) { - DeclSpace ds = (DeclSpace)$1; - if ((ds.ModFlags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){ + TypeContainer ds = (TypeContainer)$1; + + if ((ds.ModFlags & (Modifiers.PRIVATE | Modifiers.PROTECTED)) != 0){ Report.Error (1527, ds.Location, "Namespace elements cannot be explicitly declared as private, protected or protected internal"); } + + // Here is a trick, for explicit attributes we don't know where they belong to until + // we parse succeeding declaration hence we parse them as normal and re-attach them + // when we know whether they are global (assembly:, module:) or local (type:). + if (ds.OptAttributes != null) { + ds.OptAttributes.ConvertGlobalAttributes (ds, current_namespace, !current_namespace.DeclarationFound && current_namespace == file.NamespaceContainer); + } } current_namespace.DeclarationFound = true; } @@ -585,10 +617,6 @@ namespace_member_declaration { current_namespace.DeclarationFound = true; } - | error - { - Error_SyntaxError (yyToken); - } ; type_declaration @@ -607,116 +635,68 @@ type_declaration ; // -// Attributes 17.2 +// Attributes // -global_attributes - : attribute_sections - { - if ($1 != null) { - Attributes attrs = (Attributes)$1; - if (global_attrs_enabled) { - module.AddAttributes (attrs.Attrs, current_namespace); - } else { - foreach (Attribute a in attrs.Attrs) { - Report.Error (1730, a.Location, "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); - } - } - } - $$ = $1; - } - ; - opt_attributes : /* empty */ - { - global_attrs_enabled = false; - $$ = null; - } | attribute_sections - { - global_attrs_enabled = false; - $$ = $1; - } ; - attribute_sections : attribute_section { - if (current_attr_target != String.Empty) { - var sect = (List) $1; - - if (global_attrs_enabled) { - if (!string.IsNullOrEmpty (current_attr_target)) { - module.AddAttributes (sect, current_namespace); - $$ = null; - } else { - $$ = new Attributes (sect); - } - if ($$ == null) { - if (RootContext.Documentation != null) { - Lexer.check_incorrect_doc_comment (); - Lexer.doc_state = - XmlCommentState.Allowed; - } - } - } else { - $$ = new Attributes (sect); - } - } - else - $$ = null; - current_attr_target = null; + var sect = (List) $1; + $$ = new Attributes (sect); } | attribute_sections attribute_section { - if (current_attr_target != String.Empty) { - Attributes attrs = $1 as Attributes; - var sect = (List) $2; - - if (global_attrs_enabled) { - if (!string.IsNullOrEmpty (current_attr_target)) { - module.AddAttributes (sect); - $$ = null; - } else { - if (attrs == null) - attrs = new Attributes (sect); - else - attrs.AddAttributes (sect); - } - } else { - if (attrs == null) - attrs = new Attributes (sect); - else - attrs.AddAttributes (sect); - } - $$ = attrs; - } + Attributes attrs = $1 as Attributes; + var sect = (List) $2; + if (attrs == null) + attrs = new Attributes (sect); else - $$ = null; - current_attr_target = null; + attrs.AddAttributes (sect); + $$ = attrs; } ; - + attribute_section - : OPEN_BRACKET attribute_target_specifier attribute_list opt_comma CLOSE_BRACKET + : OPEN_BRACKET { - $$ = $3; - } - | OPEN_BRACKET attribute_list opt_comma CLOSE_BRACKET + lexer.parsing_attribute_section = true; + } + attribute_section_cont { - $$ = $2; + lexer.parsing_attribute_section = false; + $$ = $3; } - ; - -attribute_target_specifier + ; + +attribute_section_cont : attribute_target COLON { - current_attr_target = (string)$1; + current_attr_target = (string) $1; + if (current_attr_target == "assembly" || current_attr_target == "module") { + Lexer.check_incorrect_doc_comment (); + } + } + attribute_list opt_comma CLOSE_BRACKET + { + // when attribute target is invalid + if (current_attr_target == string.Empty) + $$ = new List (0); + else + $$ = $4; + + current_attr_target = null; + lexer.parsing_attribute_section = false; + } + | attribute_list opt_comma CLOSE_BRACKET + { $$ = $1; } - ; + ; attribute_target : IDENTIFIER @@ -728,8 +708,13 @@ attribute_target | RETURN { $$ = "return"; } | error { - string name = GetTokenName (yyToken); - $$ = CheckAttributeTarget (name, GetLocation ($1)); + if (yyToken == Token.IDENTIFIER) { + Error_SyntaxError (yyToken); + $$ = null; + } else { + string name = GetTokenName (yyToken); + $$ = CheckAttributeTarget (name, GetLocation ($1)); + } } ; @@ -763,20 +748,12 @@ attribute Arguments [] arguments = (Arguments []) $3; ATypeNameExpression expr = mname.GetTypeExpression (); - - if (current_attr_target == String.Empty) - $$ = null; - else if (global_attrs_enabled && (current_attr_target == "assembly" || current_attr_target == "module")) - // FIXME: supply "nameEscaped" parameter here. - $$ = new GlobalAttribute (current_namespace, current_attr_target, - expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); - else - $$ = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); + $$ = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); } ; attribute_name - : namespace_or_type_name { /* reserved attribute name or identifier: 17.4 */ } + : namespace_or_type_name ; opt_attribute_arguments @@ -853,8 +830,8 @@ named_attribute_argument named_argument : IDENTIFIER COLON opt_named_modifier expression { - if (RootContext.Version <= LanguageVersion.V_3) - Report.FeatureIsNotAvailable (GetLocation ($1), "named argument"); + if (lang_version <= LanguageVersion.V_3) + FeatureIsNotAvailable (GetLocation ($1), "named argument"); // Avoid boxing in common case (no modifier) var arg_mod = $3 == null ? Argument.AType.None : (Argument.AType) $3; @@ -886,17 +863,17 @@ class_member_declarations | class_member_declarations class_member_declaration ; - + class_member_declaration - : constant_declaration // done - | field_declaration // done - | method_declaration // done - | property_declaration // done - | event_declaration // done - | indexer_declaration // done - | operator_declaration // done - | constructor_declaration // done - | destructor_declaration // done + : constant_declaration + | field_declaration + | method_declaration + | property_declaration + | event_declaration + | indexer_declaration + | operator_declaration + | constructor_declaration + | destructor_declaration | type_declaration | error { @@ -927,7 +904,7 @@ struct_declaration current_class.SetParameterInfo ((List) $9); - if (RootContext.Documentation != null) + if (doc_support) current_container.DocComment = Lexer.consume_doc_comment (); lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4)); @@ -935,7 +912,7 @@ struct_declaration struct_body { --lexer.parsing_declaration; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } opt_semicolon @@ -952,7 +929,7 @@ struct_declaration struct_body : OPEN_BRACE { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } opt_struct_member_declarations CLOSE_BRACE @@ -1007,7 +984,7 @@ constant_declaration } constant_initializer opt_constant_declarators SEMICOLON { - if (RootContext.Documentation != null) { + if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -1052,6 +1029,7 @@ constant_initializer { --lexer.parsing_block; $$ = new ConstInitializer (current_field, (Expression) $3, GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($1)); } | error { @@ -1073,7 +1051,7 @@ field_declaration lexer.parsing_generic_declaration = false; FullNamedExpression type = (FullNamedExpression) $3; - if (type.Type == TypeManager.void_type) + if (type.Type != null && type.Type.Kind == MemberKind.Void) Report.Error (670, GetLocation ($3), "Fields cannot have void type"); var lt = (Tokenizer.LocatedToken) $4; @@ -1085,7 +1063,7 @@ field_declaration opt_field_declarators SEMICOLON { - if (RootContext.Documentation != null) { + if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -1098,8 +1076,8 @@ field_declaration opt_modifiers FIXED simple_type IDENTIFIER { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($3), "fixed size buffers"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($3), "fixed size buffers"); var lt = (Tokenizer.LocatedToken) $5; current_field = new FixedField (current_class, (FullNamedExpression) $4, (Modifiers) $2, @@ -1109,13 +1087,13 @@ field_declaration } fixed_field_size opt_fixed_field_declarators SEMICOLON { - if (RootContext.Documentation != null) { + if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } current_field.Initializer = (ConstInitializer) $7; - lbag.AddMember (current_field, GetModifierLocations (), GetLocation ($9), GetLocation ($3)); + lbag.AddMember (current_field, GetModifierLocations (), GetLocation ($3), GetLocation ($9)); $$ = current_field; current_field = null; } @@ -1239,7 +1217,7 @@ variable_initializer method_declaration : method_header { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; // Add it early in the case of body being eof for full aot @@ -1256,7 +1234,7 @@ method_declaration current_local_parameters = null; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } ; @@ -1300,7 +1278,7 @@ method_header method.GetSignatureForError ()); } - if (RootContext.Documentation != null) + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); lbag.AddMember (method, GetModifierLocations (), GetLocation ($5), GetLocation ($8)); @@ -1334,7 +1312,7 @@ method_header GenericMethod generic = null; if (name.TypeArguments != null) { generic = new GenericMethod (current_namespace, current_class, name, - new TypeExpression (TypeManager.void_type, GetLocation ($4)), + new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)), current_local_parameters); generic.SetParameterInfo ((List) $11); @@ -1359,10 +1337,10 @@ method_header modifiers |= Modifiers.PARTIAL | Modifiers.PRIVATE; - method = new Method (current_class, generic, new TypeExpression (TypeManager.void_type, GetLocation ($4)), + method = new Method (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)), modifiers, name, current_local_parameters, (Attributes) $1); - if (RootContext.Documentation != null) + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); // TODO: lbag, push void @@ -1384,7 +1362,7 @@ method_header current_local_parameters = (ParametersCompiled) $7; - if (RootContext.Documentation != null) + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); $$ = method; @@ -1539,8 +1517,8 @@ fixed_parameter constant_expression { --lexer.parsing_block; - if (RootContext.Version <= LanguageVersion.V_3) { - Report.FeatureIsNotAvailable (GetLocation ($5), "optional parameter"); + if (lang_version <= LanguageVersion.V_3) { + FeatureIsNotAvailable (GetLocation ($5), "optional parameter"); } Parameter.Modifier mod = (Parameter.Modifier) $2; @@ -1629,8 +1607,8 @@ parameter_modifier if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation ($1)); - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "extension methods"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "extension methods"); $$ = Parameter.Modifier.This; } @@ -1691,15 +1669,16 @@ property_declaration member_type member_declaration_name { - if (RootContext.Documentation != null) + if (doc_support) tmpComment = Lexer.consume_doc_comment (); } OPEN_BRACE { - current_property = new Property (current_class, (FullNamedExpression) $3, (Modifiers) $2, + var type = (FullNamedExpression) $3; + current_property = new Property (current_class, type, (Modifiers) $2, (MemberName) $4, (Attributes) $1); - if (current_property.TypeExpression.Type == TypeManager.void_type) + if (type.Type != null && type.Type.Kind == MemberKind.Void) Report.Error (547, GetLocation ($3), "`{0}': property or indexer cannot have void type", current_property.GetSignatureForError ()); current_container.AddProperty ((Property)current_property); @@ -1711,7 +1690,7 @@ property_declaration { lexer.PropertyParsing = false; - if (RootContext.Documentation != null) + if (doc_support) current_property.DocComment = ConsumeStoredComment (); } CLOSE_BRACE @@ -1731,8 +1710,8 @@ indexer_declaration opt_formal_parameter_list CLOSE_BRACKET OPEN_BRACE { valid_param_mod = 0; - - Indexer indexer = new Indexer (current_class, (FullNamedExpression) $3, + var type = (FullNamedExpression) $3; + Indexer indexer = new Indexer (current_class, type, (MemberName)$4, (Modifiers) $2, (ParametersCompiled) $7, (Attributes) $1); current_property = indexer; @@ -1740,14 +1719,14 @@ indexer_declaration current_container.AddIndexer (indexer); lbag.AddMember (current_property, GetModifierLocations (), GetLocation ($5), GetLocation ($8), GetLocation ($9)); - if (indexer.TypeExpression.Type == TypeManager.void_type) + if (type.Type != null && type.Type.Kind == MemberKind.Void) Report.Error (620, GetLocation ($3), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError ()); if (indexer.Parameters.IsEmpty) { Report.Error (1551, GetLocation ($5), "Indexers must have at least one parameter"); } - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -1760,7 +1739,7 @@ indexer_declaration } CLOSE_BRACE { - if (RootContext.Documentation != null) + if (doc_support) current_property.DocComment = ConsumeStoredComment (); lbag.AppendToMember (current_property, GetLocation ($12)); @@ -1790,8 +1769,8 @@ accessor_declarations get_accessor_declaration : opt_attributes opt_modifiers GET { - if ($2 != ModifierNone && RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (GetLocation ($2), "access modifiers on properties"); + if ($2 != ModifierNone && lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (GetLocation ($2), "access modifiers on properties"); } if (current_property.Get != null) { @@ -1824,7 +1803,7 @@ get_accessor_declaration current_local_parameters = null; lexer.PropertyParsing = true; - if (RootContext.Documentation != null) + if (doc_support) if (Lexer.doc_state == XmlCommentState.Error) Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -1833,8 +1812,8 @@ get_accessor_declaration set_accessor_declaration : opt_attributes opt_modifiers SET { - if ($2 != ModifierNone && RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (GetLocation ($2), "access modifiers on properties"); + if ($2 != ModifierNone && lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (GetLocation ($2), "access modifiers on properties"); } if (current_property.Set != null) { @@ -1872,7 +1851,7 @@ set_accessor_declaration current_local_parameters = null; lexer.PropertyParsing = true; - if (RootContext.Documentation != null + if (doc_support && Lexer.doc_state == XmlCommentState.Error) Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -1913,7 +1892,7 @@ interface_declaration current_class.SetParameterInfo ((List) $9); - if (RootContext.Documentation != null) { + if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -1921,7 +1900,7 @@ interface_declaration OPEN_BRACE opt_interface_member_declarations CLOSE_BRACE { --lexer.parsing_declaration; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } opt_semicolon @@ -1985,7 +1964,7 @@ operator_declaration current_local_parameters, (ToplevelBlock) $5, (Attributes) $1, decl.location); - if (RootContext.Documentation != null) { + if (doc_support) { op.DocComment = tmpComment; Lexer.doc_state = XmlCommentState.Allowed; } @@ -2010,7 +1989,7 @@ operator_type | VOID { Report.Error (590, GetLocation ($1), "User-defined operators cannot return void"); - $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1)); + $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)); } ; @@ -2051,7 +2030,7 @@ operator_declarator } } - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -2102,7 +2081,7 @@ conversion_operator_declarator Location loc = GetLocation ($2); current_local_parameters = (ParametersCompiled)$6; - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -2121,7 +2100,7 @@ conversion_operator_declarator Location loc = GetLocation ($2); current_local_parameters = (ParametersCompiled)$6; - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -2150,13 +2129,13 @@ constructor_declaration Constructor c = (Constructor) $1; c.Block = (ToplevelBlock) $2; - if (RootContext.Documentation != null) + if (doc_support) c.DocComment = ConsumeStoredComment (); current_container.AddConstructor (c); current_local_parameters = null; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } ; @@ -2166,7 +2145,7 @@ constructor_declarator opt_modifiers IDENTIFIER { - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -2255,7 +2234,7 @@ constructor_initializer destructor_declaration : opt_attributes opt_modifiers TILDE { - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -2273,7 +2252,7 @@ destructor_declaration Destructor d = new Destructor (current_class, (Modifiers) $2, ParametersCompiled.EmptyReadOnlyParameters, (Attributes) $1, lt.Location); - if (RootContext.Documentation != null) + if (doc_support) d.DocComment = ConsumeStoredComment (); d.Block = (ToplevelBlock) $8; @@ -2303,7 +2282,7 @@ event_declaration opt_event_declarators SEMICOLON { - if (RootContext.Documentation != null) { + if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -2331,7 +2310,7 @@ event_declaration } CLOSE_BRACE { - if (RootContext.Documentation != null) { + if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -2500,12 +2479,12 @@ enum_declaration ENUM type_declaration_name opt_enum_base { - if (RootContext.Documentation != null) + if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } OPEN_BRACE { - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; MemberName name = (MemberName) $4; @@ -2518,17 +2497,17 @@ enum_declaration opt_enum_member_declarations { // here will be evaluated after CLOSE_BLACE is consumed. - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } CLOSE_BRACE opt_semicolon { - if (RootContext.Documentation != null) + if (doc_support) current_class.DocComment = enumTypeComment; --lexer.parsing_declaration; -// if (RootContext.Documentation != null) +// if (doc_support) // em.DocComment = ev.DocComment; lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($3), GetLocation ($7), GetLocation ($11)); @@ -2541,11 +2520,7 @@ opt_enum_base | COLON type { var te = $2 as TypeExpression; - if (te == null || - (te.Type != TypeManager.int32_type && te.Type != TypeManager.uint32_type && - te.Type != TypeManager.int64_type && te.Type != TypeManager.uint64_type && - te.Type != TypeManager.short_type && te.Type != TypeManager.ushort_type && - te.Type != TypeManager.byte_type && te.Type != TypeManager.sbyte_type)) { + if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { Enum.Error_1008 (GetLocation ($2), Report); $$ = null; } else { @@ -2584,7 +2559,7 @@ enum_member_declaration var em = new EnumMember ((Enum) current_class, new MemberName (lt.Value, lt.Location), (Attributes) $1); ((Enum) current_class).AddEnumMember (em); - if (RootContext.Documentation != null) { + if (doc_support) { em.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -2594,7 +2569,7 @@ enum_member_declaration | opt_attributes IDENTIFIER { ++lexer.parsing_block; - if (RootContext.Documentation != null) { + if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } @@ -2608,7 +2583,7 @@ enum_member_declaration em.Initializer = new ConstInitializer (em, (Expression) $5, GetLocation ($4)); ((Enum) current_class).AddEnumMember (em); - if (RootContext.Documentation != null) + if (doc_support) em.DocComment = ConsumeStoredComment (); $$ = em; @@ -2634,14 +2609,8 @@ delegate_declaration Delegate del = new Delegate (current_namespace, current_class, (FullNamedExpression) $4, (Modifiers) $2, name, p, (Attributes) $1); - if (RootContext.Documentation != null) { - del.DocComment = Lexer.consume_doc_comment (); - Lexer.doc_state = XmlCommentState.Allowed; - } - ubag.PushTypeDeclaration (del); ubag.PopTypeDeclaration (); - current_container.AddDelegate (del); current_delegate = del; lexer.ConstraintsParsing = true; @@ -2652,6 +2621,11 @@ delegate_declaration } SEMICOLON { + if (doc_support) { + current_delegate.DocComment = Lexer.consume_doc_comment (); + Lexer.doc_state = XmlCommentState.Allowed; + } + current_delegate.SetParameterInfo ((List) $11); lbag.AddMember (current_delegate, GetModifierLocations (), GetLocation ($3), GetLocation ($6), GetLocation ($9), GetLocation ($13)); @@ -2665,8 +2639,8 @@ opt_nullable : /* empty */ | INTERR_NULLABLE { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "nullable types"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "nullable types"); $$ = ComposedTypeSpecifier.CreateNullable (GetLocation ($1)); } @@ -2708,8 +2682,8 @@ opt_type_argument_list : /* empty */ | OP_GENERICS_LT type_arguments OP_GENERICS_GT { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "generics"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "generics"); $$ = $2; } @@ -2811,8 +2785,8 @@ opt_type_parameter_list : /* empty */ | OP_GENERICS_LT_DECL type_parameters OP_GENERICS_GT { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "generics"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "generics"); $$ = $2; lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3)); @@ -2859,7 +2833,7 @@ type_and_void : type_expression_or_array | VOID { - $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1)); + $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)); } ; @@ -2878,7 +2852,7 @@ type | VOID { Expression.Error_VoidInvalidInTheContext (GetLocation ($1), Report); - $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1)); + $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)); } ; @@ -2887,7 +2861,7 @@ simple_type | VOID { Expression.Error_VoidInvalidInTheContext (GetLocation ($1), Report); - $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1)); + $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)); } ; @@ -2896,7 +2870,7 @@ parameter_type | VOID { Report.Error (1536, GetLocation ($1), "Invalid parameter type `void'"); - $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1)); + $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)); } ; @@ -2937,7 +2911,7 @@ type_expression } | VOID pointer_stars { - $$ = new ComposedCast (new TypeExpression (TypeManager.void_type, GetLocation ($1)), (ComposedTypeSpecifier) $2); + $$ = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)), (ComposedTypeSpecifier) $2); } ; @@ -2976,25 +2950,25 @@ base_type_name * simple types, but we need this to reuse it easily in variable_type */ builtin_types - : OBJECT { $$ = new TypeExpression (TypeManager.object_type, GetLocation ($1)); } - | STRING { $$ = new TypeExpression (TypeManager.string_type, GetLocation ($1)); } - | BOOL { $$ = new TypeExpression (TypeManager.bool_type, GetLocation ($1)); } - | DECIMAL { $$ = new TypeExpression (TypeManager.decimal_type, GetLocation ($1)); } - | FLOAT { $$ = new TypeExpression (TypeManager.float_type, GetLocation ($1)); } - | DOUBLE { $$ = new TypeExpression (TypeManager.double_type, GetLocation ($1)); } + : OBJECT { $$ = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation ($1)); } + | STRING { $$ = new TypeExpression (compiler.BuiltinTypes.String, GetLocation ($1)); } + | BOOL { $$ = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation ($1)); } + | DECIMAL { $$ = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation ($1)); } + | FLOAT { $$ = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation ($1)); } + | DOUBLE { $$ = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation ($1)); } | integral_type ; integral_type - : SBYTE { $$ = new TypeExpression (TypeManager.sbyte_type, GetLocation ($1)); } - | BYTE { $$ = new TypeExpression (TypeManager.byte_type, GetLocation ($1)); } - | SHORT { $$ = new TypeExpression (TypeManager.short_type, GetLocation ($1)); } - | USHORT { $$ = new TypeExpression (TypeManager.ushort_type, GetLocation ($1)); } - | INT { $$ = new TypeExpression (TypeManager.int32_type, GetLocation ($1)); } - | UINT { $$ = new TypeExpression (TypeManager.uint32_type, GetLocation ($1)); } - | LONG { $$ = new TypeExpression (TypeManager.int64_type, GetLocation ($1)); } - | ULONG { $$ = new TypeExpression (TypeManager.uint64_type, GetLocation ($1)); } - | CHAR { $$ = new TypeExpression (TypeManager.char_type, GetLocation ($1)); } + : SBYTE { $$ = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation ($1)); } + | BYTE { $$ = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation ($1)); } + | SHORT { $$ = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation ($1)); } + | USHORT { $$ = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation ($1)); } + | INT { $$ = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation ($1)); } + | UINT { $$ = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation ($1)); } + | LONG { $$ = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation ($1)); } + | ULONG { $$ = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation ($1)); } + | CHAR { $$ = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation ($1)); } ; // @@ -3022,6 +2996,7 @@ primary_expression | unchecked_expression | pointer_member_access | anonymous_method_expression + | undocumented_expressions ; primary_expression_or_type @@ -3044,8 +3019,8 @@ literal ; boolean_literal - : TRUE { $$ = new BoolLiteral (true, GetLocation ($1)); } - | FALSE { $$ = new BoolLiteral (false, GetLocation ($1)); } + : TRUE { $$ = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation ($1)); } + | FALSE { $$ = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation ($1)); } ; @@ -3401,8 +3376,8 @@ object_or_delegate_creation_expression : NEW new_expr_type open_parens_any opt_argument_list CLOSE_PARENS opt_object_or_collection_initializer { if ($6 != null) { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "object initializers"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "object initializers"); $$ = new NewInitialize ((FullNamedExpression) $2, (Arguments) $4, (CollectionOrObjectInitializers) $6, GetLocation ($1)); } else { @@ -3413,8 +3388,8 @@ object_or_delegate_creation_expression } | NEW new_expr_type object_or_collection_initializer { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "collection initializers"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "collection initializers"); $$ = new NewInitialize ((FullNamedExpression) $2, null, (CollectionOrObjectInitializers) $3, GetLocation ($1)); } @@ -3440,8 +3415,8 @@ array_creation_expression } | NEW rank_specifier array_initializer { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "implicitly typed arrays"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "implicitly typed arrays"); $$ = new ImplicitlyTypedArrayCreation ((ComposedTypeSpecifier) $2, (ArrayInitializer) $3, GetLocation ($1)); } @@ -3471,8 +3446,8 @@ new_expr_type anonymous_type_expression : NEW OPEN_BRACE anonymous_type_parameters_opt_comma CLOSE_BRACE { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "anonymous types"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "anonymous types"); $$ = new NewAnonymousType ((List) $3, current_container, GetLocation ($1)); @@ -3681,8 +3656,8 @@ unbound_type_name generic_dimension : GENERIC_DIMENSION { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "generics"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "generics"); $$ = $1; } @@ -3692,8 +3667,8 @@ qualified_alias_member : IDENTIFIER DOUBLE_COLON { var lt = (Tokenizer.LocatedToken) $1; - if (RootContext.Version == LanguageVersion.ISO_1) - Report.FeatureIsNotAvailable (lt.Location, "namespace alias qualifier"); + if (lang_version == LanguageVersion.ISO_1) + FeatureIsNotAvailable (lt.Location, "namespace alias qualifier"); $$ = lt; } @@ -3765,8 +3740,8 @@ anonymous_method_signature default_value_expression : DEFAULT open_parens_any type CLOSE_PARENS { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "default value expression"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "default value expression"); $$ = new DefaultValueExpression ((Expression) $3, GetLocation ($1)); lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); @@ -3972,8 +3947,8 @@ null_coalescing_expression : conditional_or_expression | conditional_or_expression OP_COALESCING null_coalescing_expression { - if (RootContext.Version < LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($2), "null coalescing operator"); + if (lang_version < LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($2), "null coalescing operator"); $$ = new Nullable.NullCoalescingOperator ((Expression) $1, (Expression) $3, GetLocation ($2)); } @@ -4106,6 +4081,7 @@ lambda_expression_body_simple expression_or_error // Have to close block when error occurs { Block b = end_block (lexer.Location); + b.IsCompilerGenerated = true; b.AddStatement (new ContextualReturn ((Expression) $2)); $$ = b; } @@ -4134,8 +4110,8 @@ lambda_expression } | OPEN_PARENS_LAMBDA { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (GetLocation ($1), "lambda expressions"); + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (GetLocation ($1), "lambda expressions"); valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -4163,7 +4139,25 @@ non_assignment_expression | ARGLIST { $$ = new ArglistAccess (GetLocation ($1)); - } + } + ; + +undocumented_expressions + : REFVALUE OPEN_PARENS non_assignment_expression COMMA type CLOSE_PARENS + { + $$ = new RefValueExpr ((Expression) $3, (FullNamedExpression) $5, GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4), GetLocation ($6)); + } + | REFTYPE open_parens_any expression CLOSE_PARENS + { + $$ = new RefTypeExpr ((Expression) $3, GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); + } + | MAKEREF open_parens_any expression CLOSE_PARENS + { + $$ = new MakeRefExpr ((Expression) $3, GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); + } ; constant_expression @@ -4191,7 +4185,12 @@ class_declaration type_declaration_name { MemberName name = MakeName ((MemberName) $6); - push_current_class (new Class (current_namespace, current_class, name, (Modifiers) $2, (Attributes) $1), $3); + Class c = new Class (current_namespace, current_class, name, (Modifiers) $2, (Attributes) $1); + if (((c.ModFlags & Modifiers.STATIC) != 0) && lang_version == LanguageVersion.ISO_1) { + FeatureIsNotAvailable (c.Location, "static classes"); + } + + push_current_class (c, $3); } opt_class_base opt_type_parameter_constraints_clauses @@ -4201,7 +4200,7 @@ class_declaration current_class.SetParameterInfo ((List) $9); lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4)); - if (RootContext.Documentation != null) { + if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } @@ -4209,7 +4208,7 @@ class_declaration OPEN_BRACE opt_class_member_declarations CLOSE_BRACE { --lexer.parsing_declaration; - if (RootContext.Documentation != null) + if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } opt_semicolon @@ -4261,7 +4260,7 @@ modifier $$ = Modifiers.NEW; StoreModifierLocation ($$, GetLocation ($1)); - if (current_container == RootContext.ToplevelTypes) + if (current_container == module) Report.Error (1530, GetLocation ($1), "Keyword `new' is not allowed on namespace elements"); } | PUBLIC @@ -4328,7 +4327,7 @@ modifier { $$ = Modifiers.UNSAFE; StoreModifierLocation ($$, GetLocation ($1)); - if (!RootContext.Unsafe) + if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation ($1)); } | ASYNC @@ -4454,8 +4453,8 @@ opt_type_parameter_variance } | type_parameter_variance { - if (RootContext.Version <= LanguageVersion.V_3) - Report.FeatureIsNotAvailable (lexer.Location, "generic type variance"); + if (lang_version <= LanguageVersion.V_3) + FeatureIsNotAvailable (lexer.Location, "generic type variance"); $$ = $1; } @@ -4717,12 +4716,12 @@ variable_type_simple } | VOID pointer_stars { - $$ = new ComposedCast (new TypeExpression (TypeManager.void_type, GetLocation ($1)), (ComposedTypeSpecifier) $2); + $$ = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)), (ComposedTypeSpecifier) $2); } | VOID { Expression.Error_VoidInvalidInTheContext (GetLocation ($1), Report); - $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1)); + $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)); } ; @@ -4765,9 +4764,13 @@ block_variable_declaration } const_variable_initializer opt_const_declarators SEMICOLON { - $$ = current_variable; + if (current_variable.Initializer != null) { + lbag.AddLocation (current_variable, GetLocation ($1), savedLocation, GetLocation ($7)); + } else { + lbag.AddLocation (current_variable, GetLocation ($1), GetLocation ($7)); + } + $$ = current_variable;; current_variable = null; - lbag.AddLocation ($$, GetLocation ($1), GetLocation ($7)); } ; @@ -4827,6 +4830,7 @@ const_variable_initializer } | ASSIGN constant_initializer_expr { + savedLocation = GetLocation ($1); current_variable.Initializer = (Expression) $2; } ; @@ -5000,7 +5004,7 @@ switch_section switch_labels : switch_label { - var labels = new List (4); + var labels = new List (2); labels.Add ((SwitchLabel) $1); $$ = labels; @@ -5238,8 +5242,8 @@ yield_statement Report.Error (1003, lt.Location, "; expected"); } else if ($3 == null) { Report.Error (1627, GetLocation ($4), "Expression expected after yield return"); - } else if (RootContext.Version == LanguageVersion.ISO_1){ - Report.FeatureIsNotAvailable (lt.Location, "iterators"); + } else if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (lt.Location, "iterators"); } current_block.ParametersBlock.TopBlock.IsIterator = true; @@ -5252,8 +5256,8 @@ yield_statement string s = lt.Value; if (s != "yield"){ Report.Error (1003, lt.Location, "; expected"); - } else if (RootContext.Version == LanguageVersion.ISO_1){ - Report.FeatureIsNotAvailable (lt.Location, "iterators"); + } else if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (lt.Location, "iterators"); } current_block.ParametersBlock.TopBlock.IsIterator = true; @@ -5374,7 +5378,7 @@ unchecked_statement unsafe_statement : UNSAFE { - if (!RootContext.Unsafe) + if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation ($1)); } block { $$ = new Unsafe ((Block) $3, GetLocation ($1)); @@ -5514,7 +5518,7 @@ query_expression first_from_clause : FROM_FIRST IDENTIFIER IN expression { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) $2; var rv = new Linq.RangeVariable (lt.Value, lt.Location); @@ -5522,7 +5526,7 @@ first_from_clause } | FROM_FIRST type IDENTIFIER IN expression { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) $3; var rv = new Linq.RangeVariable (lt.Value, lt.Location); @@ -5537,7 +5541,7 @@ first_from_clause nested_from_clause : FROM IDENTIFIER IN expression { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) $2; var rv = new Linq.RangeVariable (lt.Value, lt.Location); @@ -5545,7 +5549,7 @@ nested_from_clause } | FROM type IDENTIFIER IN expression { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) $3; var rv = new Linq.RangeVariable (lt.Value, lt.Location); @@ -5560,7 +5564,7 @@ nested_from_clause from_clause : FROM IDENTIFIER IN { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } expression { @@ -5575,7 +5579,7 @@ from_clause } | FROM type IDENTIFIER IN { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } expression { @@ -5620,7 +5624,7 @@ query_body select_or_group_clause : SELECT { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } expression { @@ -5634,7 +5638,7 @@ select_or_group_clause if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock)current_block); } expression @@ -5642,7 +5646,7 @@ select_or_group_clause current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } BY expression { @@ -5678,7 +5682,7 @@ query_body_clause let_clause : LET IDENTIFIER ASSIGN { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } expression { @@ -5696,11 +5700,11 @@ let_clause where_clause : WHERE { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } - boolean_expression + expression { - $$ = new Linq.Where ((Linq.QueryBlock)current_block, (BooleanExpression)$3, GetLocation ($1)); + $$ = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)$3, GetLocation ($1)); current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -5713,7 +5717,7 @@ join_clause if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } expression ON @@ -5721,7 +5725,7 @@ join_clause current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } expression EQUALS @@ -5730,7 +5734,7 @@ join_clause current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } expression opt_join_into { @@ -5773,7 +5777,7 @@ join_clause if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } expression ON @@ -5781,7 +5785,7 @@ join_clause current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } expression EQUALS @@ -5790,7 +5794,7 @@ join_clause current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } expression opt_join_into { @@ -5845,7 +5849,7 @@ opt_join_into orderby_clause : ORDERBY { - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } orderings { @@ -5863,7 +5867,7 @@ orderings current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } orderings_then_by { @@ -5879,7 +5883,7 @@ orderings_then_by current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, (Linq.QueryBlock) current_block, lexer.Location); + current_block = new Linq.QueryBlock ((Linq.QueryBlock) current_block, lexer.Location); } then_by { @@ -5930,7 +5934,7 @@ opt_query_continuation current_block.SetEndLocation (GetLocation ($1)); current_block = current_block.Parent; - current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -5964,33 +5968,34 @@ opt_query_continuation interactive_parsing : EVAL_STATEMENT_PARSER EOF | EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives opt_COMPLETE_COMPLETION - | EVAL_STATEMENT_PARSER { - Evaluator.LoadAliases (current_namespace); - - push_current_class (new Class (current_namespace, current_class, new MemberName ("Class" + class_count++), - Modifiers.PUBLIC, null), null); - - var baseclass_list = new List (); - baseclass_list.Add (new TypeExpression (Evaluator.InteractiveBaseClass, lexer.Location)); - current_container.AddBasesForPart (current_class, baseclass_list); + | EVAL_STATEMENT_PARSER + { + current_container = new Class (current_namespace, current_class, new MemberName (""), Modifiers.PUBLIC, null); + current_class = current_container; // (ref object retval) Parameter [] mpar = new Parameter [1]; - mpar [0] = new Parameter (new TypeExpression (TypeManager.object_type, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null); + mpar [0] = new Parameter (new TypeExpression (compiler.BuiltinTypes.Object, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null); ParametersCompiled pars = new ParametersCompiled (mpar); + var mods = Modifiers.PUBLIC | Modifiers.STATIC; + if (settings.Unsafe) + mods |= Modifiers.UNSAFE; + current_local_parameters = pars; Method method = new Method ( current_class, null, // generic - new TypeExpression (TypeManager.void_type, Location.Null), - Modifiers.PUBLIC | Modifiers.STATIC, + new TypeExpression (compiler.BuiltinTypes.Void, Location.Null), + mods, new MemberName ("Host"), pars, null /* attributes */); + + current_container.AddMethod (method); oob_stack.Push (method); - ++lexer.parsing_block; + ++lexer.parsing_block; start_block (lexer.Location); } interactive_statement_list opt_COMPLETE_COMPLETION @@ -5999,23 +6004,16 @@ interactive_parsing Method method = (Method) oob_stack.Pop (); method.Block = (ToplevelBlock) end_block(lexer.Location); - current_container.AddMethod (method); - --lexer.parsing_declaration; - InteractiveResult = pop_current_class (); + InteractiveResult = (Class) pop_current_class (); current_local_parameters = null; } - | EVAL_COMPILATION_UNIT_PARSER { - Evaluator.LoadAliases (current_namespace); - } - interactive_compilation_unit + | EVAL_COMPILATION_UNIT_PARSER interactive_compilation_unit ; interactive_compilation_unit - : outer_declarations - | outer_declarations global_attributes - | global_attributes - | /* nothing */ + : opt_extern_alias_directives opt_using_directives + | opt_extern_alias_directives opt_using_directives namespace_or_type_declarations ; opt_COMPLETE_COMPLETION @@ -6088,8 +6086,10 @@ void Error_NamedArgumentExpected (NamedArgument a) void push_current_class (TypeContainer tc, object partial_token) { - if (RootContext.EvalMode){ - tc.ModFlags = (tc.ModFlags & ~(Modifiers.PRIVATE|Modifiers.INTERNAL)) | Modifiers.PUBLIC; + if (module.Evaluator != null){ + tc.Definition.Modifiers = tc.ModFlags = (tc.ModFlags & ~Modifiers.AccessibilityMask) | Modifiers.PUBLIC; + if (undo == null) + undo = new Undo (); undo.AddTypeContainer (current_container, tc); } @@ -6123,7 +6123,7 @@ MakeName (MemberName class_name) { Namespace ns = current_namespace.NS; - if (current_container == RootContext.ToplevelTypes) { + if (current_container == module) { if (ns.Name.Length != 0) return new MemberName (ns.MemberName, class_name); else @@ -6199,15 +6199,16 @@ static CSharpParser () oob_stack = new Stack (); } -public CSharpParser (SeekableStreamReader reader, CompilationUnit file, ModuleContainer module) +public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file) { - if (RootContext.EvalMode) - undo = new Undo (); - this.file = file; - this.module = module; + current_namespace = file.NamespaceContainer; + + this.module = current_namespace.Module; this.compiler = module.Compiler; - current_namespace = new NamespaceEntry (module, null, file, null); + this.settings = compiler.Settings; + lang_version = settings.Version; + doc_support = settings.DocumentationFile != null; current_class = current_namespace.SlaveDeclSpace; current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes oob_stack.Clear (); @@ -6246,9 +6247,6 @@ public void parse () Report.Error (589, lexer.Location, "Internal compiler error during parsing"); } } - - if (RootContext.ToplevelTypes.NamespaceEntry != null) - throw new InternalErrorException ("who set it?"); } void CheckToken (int error, int yyToken, string msg, Location loc) @@ -6267,6 +6265,11 @@ string ConsumeStoredComment () return s; } +void FeatureIsNotAvailable (Location loc, string feature) +{ + compiler.Report.FeatureIsNotAvailable (compiler, loc, feature); +} + Location GetLocation (object obj) { var lt = obj as Tokenizer.LocatedToken; @@ -6330,8 +6333,8 @@ end_block (Location loc) void start_anonymous (bool lambda, ParametersCompiled parameters, Location loc) { - if (RootContext.Version == LanguageVersion.ISO_1){ - Report.FeatureIsNotAvailable (loc, "anonymous methods"); + if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (loc, "anonymous methods"); } oob_stack.Push (current_anonymous_method); @@ -6612,6 +6615,7 @@ static string GetTokenName (int token) case Token.EXPLICIT: return "explicit"; case Token.EXTERN: + case Token.EXTERN_ALIAS: return "extern"; case Token.FALSE: return "false"; @@ -6705,6 +6709,12 @@ static string GetTokenName (int token) return "while"; case Token.ARGLIST: return "__arglist"; + case Token.REFVALUE: + return "__refvalue"; + case Token.REFTYPE: + return "__reftype"; + case Token.MAKEREF: + return "__makeref"; case Token.PARTIAL: return "partial"; case Token.ARROW: diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs index 71e6fec5b..da7328bc6 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs @@ -11,7 +11,6 @@ // Copyright 2004-2008 Novell, Inc // // - using System; using System.Text; using System.Collections.Generic; @@ -23,7 +22,6 @@ namespace Mono.CSharp /// /// Tokenizer for C# source code. /// - public class Tokenizer : yyParser.yyInput { class KeywordEntry @@ -32,7 +30,7 @@ namespace Mono.CSharp public KeywordEntry Next; public readonly char[] Value; - public KeywordEntry (string value, T token) + public KeywordEntry (string value,T token) { this.Value = value.ToCharArray (); this.Token = token; @@ -75,7 +73,6 @@ namespace Mono.CSharp { int row, column; string value; - static LocatedToken[] buffer; static int pos; @@ -87,7 +84,7 @@ namespace Mono.CSharp { return Create (null, row, column); } - + public static LocatedToken Create (string value, int row, int column) { // @@ -124,7 +121,7 @@ namespace Mono.CSharp { token = Create (row, col); } - + public static void Initialize () { if (buffer == null) @@ -164,7 +161,7 @@ namespace Mono.CSharp SeekableStreamReader reader; SourceFile ref_name; - CompilationUnit file_name; + CompilationSourceFile file_name; CompilerContext context; bool hidden = false; int ref_line = 1; @@ -178,9 +175,9 @@ namespace Mono.CSharp bool handle_where = false; bool handle_typeof = false; bool lambda_arguments_parsing; - Location current_comment_location = Location.Null; List escaped_identifiers; int parsing_generic_less_than; + readonly bool doc_processing; // // Used mainly for parser optimizations. Some expressions for instance @@ -205,6 +202,7 @@ namespace Mono.CSharp // namespace yet // public int parsing_declaration; + public bool parsing_attribute_section; // // The special character to inject on streams to trigger the EXPRESSION_PARSE @@ -249,13 +247,26 @@ namespace Mono.CSharp // This is needed because `define' is not allowed to be used // after a token has been seen. // - bool any_token_seen = false; + bool any_token_seen; + // + // Class variables + // + static readonly KeywordEntry[][] keywords; + static readonly KeywordEntry[][] keywords_preprocessor; + static readonly Dictionary keyword_strings; // TODO: HashSet + static readonly NumberStyles styles; + static readonly NumberFormatInfo csharp_format_info; + + // Pragma arguments + static readonly char[] pragma_warning = "warning".ToCharArray (); + static readonly char[] pragma_warning_disable = "disable".ToCharArray (); + static readonly char[] pragma_warning_restore = "restore".ToCharArray (); + static readonly char[] pragma_checksum = "checksum".ToCharArray (); static readonly char[] simple_whitespaces = new char[] { ' ', '\t' }; - bool startsLine = true; internal SpecialsBag sbag; - + public bool PropertyParsing { get { return handle_get_set; } set { handle_get_set = value; } @@ -280,7 +291,7 @@ namespace Mono.CSharp get { return tab_size; } set { tab_size = value; } } - + public XmlCommentState doc_state { get { return xml_doc_state; } set { @@ -295,7 +306,7 @@ namespace Mono.CSharp // // This is used to trigger completion generation on the parser public bool CompleteOnEOF; - + void AddEscapedIdentifier (Location loc) { if (escaped_identifiers == null) @@ -309,21 +320,6 @@ namespace Mono.CSharp return escaped_identifiers != null && escaped_identifiers.Contains (name.Location); } - // - // Class variables - // - static KeywordEntry[][] keywords; - static KeywordEntry[][] keywords_preprocessor; - static Dictionary keyword_strings; // TODO: HashSet - static NumberStyles styles; - static NumberFormatInfo csharp_format_info; - - // Pragma arguments - static readonly char[] pragma_warning = "warning".ToCharArray (); - static readonly char[] pragma_warning_disable = "disable".ToCharArray (); - static readonly char[] pragma_warning_restore = "restore".ToCharArray (); - static readonly char[] pragma_checksum = "checksum".ToCharArray (); - // // Values for the associated token returned // @@ -334,9 +330,9 @@ namespace Mono.CSharp // Pre-processor // const int TAKING = 1; - const int ELSE_SEEN = 4; + const int ELSE_SEEN = 4; const int PARENT_TAKING = 8; - const int REGION = 16; + const int REGION = 16; // // pre-processor if stack state: @@ -344,18 +340,14 @@ namespace Mono.CSharp Stack ifstack; static System.Text.StringBuilder string_builder; - const int max_id_size = 512; - static char [] id_builder = new char [max_id_size]; - + static readonly char[] id_builder = new char [max_id_size]; public static Dictionary[] identifiers = new Dictionary[max_id_size + 1]; - const int max_number_size = 512; - static char [] number_builder = new char [max_number_size]; + static char[] number_builder = new char [max_number_size]; static int number_pos; + static char[] value_builder = new char[256]; - static StringBuilder static_cmd_arg = new System.Text.StringBuilder (); - public int Line { get { return ref_line; @@ -370,7 +362,8 @@ namespace Mono.CSharp // Stack position_stack = new Stack (2); - class Position { + class Position + { public int position; public int line; public int ref_line; @@ -404,6 +397,30 @@ namespace Mono.CSharp val = t.val; } } + + public Tokenizer (SeekableStreamReader input, CompilationSourceFile file, CompilerContext ctx) + { + this.ref_name = file; + this.file_name = file; + this.context = ctx; + reader = input; + + putback_char = -1; + + xml_comment_buffer = new StringBuilder (); + doc_processing = ctx.Settings.DocumentationFile != null; + + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + tab_size = 4; + else + tab_size = 8; + + // + // FIXME: This could be `Location.Push' but we have to + // find out why the MS compiler allows this + // + Mono.CSharp.Location.Push (file, file); + } public void PushPosition () { @@ -431,14 +448,14 @@ namespace Mono.CSharp public void DiscardPosition () { position_stack.Pop (); - } + } static void AddKeyword (string kw, int token) { keyword_strings.Add (kw, null); AddKeyword (keywords, kw, token); - } +} static void AddPreprocessorKeyword (string kw, PreprocessorDirective directive) { @@ -466,14 +483,20 @@ namespace Mono.CSharp kwe.Next = new KeywordEntry (kw, token); } - static void InitTokens () + // + // Class initializer + // + static Tokenizer () { keyword_strings = new Dictionary (); // 11 is the length of the longest keyword for now - keywords = new KeywordEntry [11] []; + keywords = new KeywordEntry[11][]; AddKeyword ("__arglist", Token.ARGLIST); + AddKeyword ("__makeref", Token.MAKEREF); + AddKeyword ("__reftype", Token.REFTYPE); + AddKeyword ("__refvalue", Token.REFVALUE); AddKeyword ("abstract", Token.ABSTRACT); AddKeyword ("as", Token.AS); AddKeyword ("add", Token.ADD); @@ -587,14 +610,7 @@ namespace Mono.CSharp AddPreprocessorKeyword ("warning", PreprocessorDirective.Warning); AddPreprocessorKeyword ("pragma", PreprocessorDirective.Pragma); AddPreprocessorKeyword ("line", PreprocessorDirective.Line); - } - // - // Class initializer - // - static Tokenizer () - { - InitTokens (); csharp_format_info = NumberFormatInfo.InvariantInfo; styles = NumberStyles.Float; @@ -693,8 +709,8 @@ namespace Mono.CSharp res = Token.FROM_FIRST; query_parsing = true; - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (Location, "query expressions"); + if (context.Settings.Version <= LanguageVersion.ISO_2) + Report.FeatureIsNotAvailable (context, Location, "query expressions"); break; case Token.VOID: Expression.Error_VoidInvalidInTheContext (Location, Report); @@ -749,11 +765,10 @@ namespace Mono.CSharp if (ok) { if (next_token == Token.VOID) { - if (RootContext.Version == LanguageVersion.ISO_1 || - RootContext.Version == LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (Location, "partial methods"); - } else if (RootContext.Version == LanguageVersion.ISO_1) - Report.FeatureIsNotAvailable (Location, "partial types"); + if (context.Settings.Version <= LanguageVersion.ISO_2) + Report.FeatureIsNotAvailable (context, Location, "partial methods"); + } else if (context.Settings.Version == LanguageVersion.ISO_1) + Report.FeatureIsNotAvailable (context, Location, "partial types"); return res; } @@ -768,7 +783,7 @@ namespace Mono.CSharp break; case Token.ASYNC: - if (parsing_block > 0 || RootContext.Version != LanguageVersion.Future) { + if (parsing_block > 0 || context.Settings.Version != LanguageVersion.Future) { res = -1; break; } @@ -816,29 +831,6 @@ namespace Mono.CSharp } } - public Tokenizer (SeekableStreamReader input, CompilationUnit file, CompilerContext ctx) - { - this.ref_name = file; - this.file_name = file; - this.context = ctx; - reader = input; - - putback_char = -1; - - xml_comment_buffer = new StringBuilder (); - - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - tab_size = 4; - else - tab_size = 8; - - // - // FIXME: This could be `Location.Push' but we have to - // find out why the MS compiler allows this - // - Mono.CSharp.Location.Push (file, file); - } - static bool is_identifier_start_character (int c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || Char.IsLetter ((char)c); @@ -1330,7 +1322,7 @@ namespace Mono.CSharp } if (is_long && is_unsigned){ - val = new ULongLiteral (ul, Location); + val = new ULongLiteral (context.BuiltinTypes, ul, Location); return Token.LITERAL; } @@ -1338,29 +1330,29 @@ namespace Mono.CSharp // uint if possible, or ulong else. if ((ul & 0xffffffff00000000) == 0) - val = new UIntLiteral ((uint) ul, Location); + val = new UIntLiteral (context.BuiltinTypes, (uint) ul, Location); else - val = new ULongLiteral (ul, Location); + val = new ULongLiteral (context.BuiltinTypes, ul, Location); } else if (is_long){ // long if possible, ulong otherwise if ((ul & 0x8000000000000000) != 0) - val = new ULongLiteral (ul, Location); + val = new ULongLiteral (context.BuiltinTypes, ul, Location); else - val = new LongLiteral ((long) ul, Location); + val = new LongLiteral (context.BuiltinTypes, (long) ul, Location); } else { // int, uint, long or ulong in that order if ((ul & 0xffffffff00000000) == 0){ uint ui = (uint) ul; if ((ui & 0x80000000) != 0) - val = new UIntLiteral (ui, Location); + val = new UIntLiteral (context.BuiltinTypes, ui, Location); else - val = new IntLiteral ((int) ui, Location); + val = new IntLiteral (context.BuiltinTypes, (int) ui, Location); } else { if ((ul & 0x8000000000000000) != 0) - val = new ULongLiteral (ul, Location); + val = new ULongLiteral (context.BuiltinTypes, ul, Location); else - val = new LongLiteral ((long) ul, Location); + val = new LongLiteral (context.BuiltinTypes, (long) ul, Location); } } return Token.LITERAL; @@ -1391,12 +1383,12 @@ namespace Mono.CSharp } } catch (OverflowException) { Error_NumericConstantTooLong (); - val = new IntLiteral (0, Location); + val = new IntLiteral (context.BuiltinTypes, 0, Location); return Token.LITERAL; } catch (FormatException) { Report.Error (1013, Location, "Invalid number"); - val = new IntLiteral (0, Location); + val = new IntLiteral (context.BuiltinTypes, 0, Location); return Token.LITERAL; } } @@ -1409,25 +1401,25 @@ namespace Mono.CSharp switch (t){ case TypeCode.Decimal: try { - val = new DecimalLiteral (decimal.Parse (s, styles, csharp_format_info), Location); + val = new DecimalLiteral (context.BuiltinTypes, decimal.Parse (s, styles, csharp_format_info), Location); } catch (OverflowException) { - val = new DecimalLiteral (0, Location); + val = new DecimalLiteral (context.BuiltinTypes, 0, Location); Report.Error (594, Location, error_details, "decimal"); } break; case TypeCode.Single: try { - val = new FloatLiteral (float.Parse (s, styles, csharp_format_info), Location); + val = new FloatLiteral (context.BuiltinTypes, float.Parse (s, styles, csharp_format_info), Location); } catch (OverflowException) { - val = new FloatLiteral (0, Location); + val = new FloatLiteral (context.BuiltinTypes, 0, Location); Report.Error (594, Location, error_details, "float"); } break; default: try { - val = new DoubleLiteral (double.Parse (s, styles, csharp_format_info), Location); + val = new DoubleLiteral (context.BuiltinTypes, double.Parse (s, styles, csharp_format_info), Location); } catch (OverflowException) { - val = new DoubleLiteral (0, Location); + val = new DoubleLiteral (context.BuiltinTypes, 0, Location); Report.Error (594, Location, error_details, "double"); } break; @@ -1458,12 +1450,12 @@ namespace Mono.CSharp ul = System.UInt64.Parse (s, NumberStyles.HexNumber); } catch (OverflowException){ Error_NumericConstantTooLong (); - val = new IntLiteral (0, Location); + val = new IntLiteral (context.BuiltinTypes, 0, Location); return Token.LITERAL; } catch (FormatException) { Report.Error (1013, Location, "Invalid number"); - val = new IntLiteral (0, Location); + val = new IntLiteral (context.BuiltinTypes, 0, Location); return Token.LITERAL; } @@ -1677,9 +1669,18 @@ namespace Mono.CSharp if (putback_char != -1) { x = putback_char; putback_char = -1; - } else + } else { x = reader.Read (); - if (x == '\n') { + } + + if (x == '\r') { + if (peek_char () == '\n') { + putback_char = -1; + } + + x = '\n'; + advance_line (); + } else if (x == '\n') { advance_line (); } else { col++; @@ -1763,7 +1764,7 @@ namespace Mono.CSharp // skip over white space do { c = get_char (); - } while (c == '\r' || c == ' ' || c == '\t'); + } while (c == ' ' || c == '\t'); endLine = line; endCol = col; @@ -1808,11 +1809,13 @@ namespace Mono.CSharp // skip over white space - while (c == '\r' || c == ' ' || c == '\t') + while (c == ' ' || c == '\t') c = get_char (); - static_cmd_arg.Length = 0; int has_identifier_argument = (int)(cmd & PreprocessorDirective.RequiresArgument); + + int pos = 0; + while (c != -1 && c != '\n' && c != '\r') { if (c == '\\' && has_identifier_argument >= 0) { if (has_identifier_argument != 0) { @@ -1823,29 +1826,47 @@ namespace Mono.CSharp int surrogate; c = EscapeUnicode (c, out surrogate); if (surrogate != 0) { - if (is_identifier_part_character ((char) c)) - static_cmd_arg.Append ((char) c); + if (is_identifier_part_character ((char)c)) { + if (pos == value_builder.Length) + Array.Resize (ref value_builder, pos * 2); + + value_builder [pos++] = (char)c; + } c = surrogate; } } } else { has_identifier_argument = -1; } + } else if (c == '/' && peek_char () == '/') { + // + // Eat single-line comments + // + get_char (); + do { + c = get_char (); + } while (c != -1 && c != '\n'); + + break; } - static_cmd_arg.Append ((char) c); + endLine = line; endCol = col; + + if (pos == value_builder.Length) + Array.Resize (ref value_builder, pos * 2); + + value_builder[pos++] = (char) c; c = get_char (); } - if (static_cmd_arg.Length != 0) { - arg = static_cmd_arg.ToString (); - - // Eat any trailing whitespaces and single-line comments - if (arg.IndexOf ("//") != -1) { - arg = arg.Substring (0, arg.IndexOf ("//")); - } + if (pos != 0) { + if (pos > max_id_size) + arg = new string (value_builder, 0, pos); + else + arg = InternIdentifier (value_builder, pos); + // Eat any trailing whitespaces arg = arg.Trim (simple_whitespaces); } sbag.AddPreProcessorDirective (startLine, startCol, endLine, endCol, cmd, arg); @@ -1882,8 +1903,8 @@ namespace Mono.CSharp char [] quotes = { '\"' }; string name = arg.Substring (pos). Trim (quotes); - ref_name = Location.LookupFile (file_name, name); - file_name.AddFile (ref_name); + ref_name = context.LookupFile (file_name, name); + file_name.AddIncludeFile (ref_name); hidden = false; Location.Push (file_name, ref_name); } else { @@ -1929,7 +1950,7 @@ namespace Mono.CSharp // // #define ident // - if (RootContext.IsConditionalDefined (ident)) + if (context.Settings.IsConditionalSymbolDefined (ident)) return; file_name.AddDefine (ident); @@ -2007,7 +2028,7 @@ namespace Mono.CSharp if (c != ' ') return false; - SourceFile file = Location.LookupFile (file_name, string_builder.ToString ()); + SourceFile file = context.LookupFile (file_name, string_builder.ToString ()); if (get_char () != '"' || get_char () != '{') return false; @@ -2113,7 +2134,7 @@ namespace Mono.CSharp c = get_char (); // skip over white space - while (c == '\r' || c == ' ' || c == '\t') + while (c == ' ' || c == '\t') c = get_char (); if (c == ',') { @@ -2121,7 +2142,7 @@ namespace Mono.CSharp } // skip over white space - while (c == '\r' || c == ' ' || c == '\t') + while (c == ' ' || c == '\t') c = get_char (); } else { number = -1; @@ -2175,7 +2196,7 @@ namespace Mono.CSharp bool disable = IsTokenIdentifierEqual (pragma_warning_disable); if (disable || IsTokenIdentifierEqual (pragma_warning_restore)) { // skip over white space - while (c == '\r' || c == ' ' || c == '\t') + while (c == ' ' || c == '\t') c = get_char (); var loc = Location; @@ -2239,7 +2260,7 @@ namespace Mono.CSharp if (s == "false") return false; - return file_name.IsConditionalDefined (s); + return file_name.IsConditionalDefined (context, s); } bool pp_primary (ref string s) @@ -2425,6 +2446,18 @@ namespace Mono.CSharp { Report.Error (1025, Location, "Single-line comment or end-of-line expected"); } + + // + // Raises a warning when tokenizer found documentation comment + // on unexpected place + // + void WarningMisplacedComment (Location loc) + { + if (doc_state != XmlCommentState.Error) { + doc_state = XmlCommentState.Error; + Report.Warning (1587, 2, loc, "XML comment is not placed on a valid language element"); + } + } // // if true, then the code continues processing the code @@ -2608,8 +2641,8 @@ namespace Mono.CSharp return true; case PreprocessorDirective.Pragma: - if (RootContext.Version == LanguageVersion.ISO_1) { - Report.FeatureIsNotAvailable (Location, "#pragma"); + if (context.Settings.Version == LanguageVersion.ISO_1) { + Report.FeatureIsNotAvailable (context, Location, "#pragma"); } ParsePragmaDirective (arg); @@ -2629,18 +2662,29 @@ namespace Mono.CSharp private int consume_string (bool quoted) { int c; - string_builder.Length = 0; - + int pos = 0; + Location start_location = Location; while (true){ c = get_char (); if (c == '"') { if (quoted && peek_char () == '"') { - string_builder.Append ((char) c); + if (pos == value_builder.Length) + Array.Resize (ref value_builder, pos * 2); + + value_builder[pos++] = (char) c; get_char (); continue; } - val = new StringLiteral (string_builder.ToString (), Location); + string s; + if (pos == 0) + s = string.Empty; + else if (pos <= 4) + s = InternIdentifier (value_builder, pos); + else + s = new string (value_builder, 0, pos); + + val = new StringLiteral (context.BuiltinTypes, s, start_location); return Token.LITERAL; } @@ -2653,7 +2697,10 @@ namespace Mono.CSharp if (c == -1) return Token.ERROR; if (surrogate != 0) { - string_builder.Append ((char) c); + if (pos == value_builder.Length) + Array.Resize (ref value_builder, pos * 2); + + value_builder[pos++] = (char) c; c = surrogate; } } else if (c == -1) { @@ -2661,7 +2708,10 @@ namespace Mono.CSharp return Token.EOF; } - string_builder.Append ((char) c); + if (pos == value_builder.Length) + Array.Resize (ref value_builder, pos * 2); + + value_builder[pos++] = (char) c; } } @@ -2745,47 +2795,49 @@ namespace Mono.CSharp } } + string s = InternIdentifier (id_builder, pos); +#if FULL_AST + if (quoted) { + val = LocatedToken.Create ("@" + s, ref_line, column - 1); + } else { + val = LocatedToken.Create (s, ref_line, column); + } +#else + val = LocatedToken.Create (s, ref_line, column); +#endif + if (quoted && parsing_attribute_section) + AddEscapedIdentifier (((LocatedToken) val).Location); + + return Token.IDENTIFIER; + } + + static string InternIdentifier (char[] charBuffer, int length) + { // // Keep identifiers in an array of hashtables to avoid needless // allocations // - var identifiers_group = identifiers [pos]; + var identifiers_group = identifiers [length]; string s; if (identifiers_group != null) { - if (identifiers_group.TryGetValue (id_builder, out s)) { - val = LocatedToken.Create (s, ref_line, column); - if (quoted) - AddEscapedIdentifier (((LocatedToken) val).Location); - return Token.IDENTIFIER; + if (identifiers_group.TryGetValue (charBuffer, out s)) { + return s; } } else { // TODO: this should be number of files dependant // corlib compilation peaks at 1000 and System.Core at 150 - int capacity = pos > 20 ? 10 : 100; - identifiers_group = new Dictionary (capacity, new IdentifiersComparer (pos)); - identifiers [pos] = identifiers_group; + int capacity = length > 20 ? 10 : 100; + identifiers_group = new Dictionary (capacity, new IdentifiersComparer (length)); + identifiers [length] = identifiers_group; } - char [] chars = new char [pos]; - Array.Copy (id_builder, chars, pos); + char[] chars = new char[length]; + Array.Copy (charBuffer, chars, length); - s = new string (id_builder, 0, pos); + s = new string (charBuffer, 0, length); identifiers_group.Add (chars, s); -#if FULL_AST - // Special handling of quoted identifier since md needs them in it's AST - if (quoted) { - val = LocatedToken.Create ("@" + s, ref_line, column - 1); - AddEscapedIdentifier (((LocatedToken) val).Location); - } else { - val = LocatedToken.Create (s, ref_line, column); - } -#else - val = LocatedToken.Create (s, ref_line, column); - if (quoted) - AddEscapedIdentifier (((LocatedToken) val).Location); -#endif - return Token.IDENTIFIER; + return s; } public int xtoken () @@ -2819,17 +2871,6 @@ namespace Mono.CSharp } break; */ - case '\r': - if (peek_char () != '\n') - advance_line (); - else - get_char (); - - any_token_seen |= tokens_seen; - tokens_seen = false; - comments_seen = false; - continue; - case '\\': tokens_seen = true; return consume_identifier (c); @@ -2944,7 +2985,7 @@ namespace Mono.CSharp val = LocatedToken.Create (ref_line, col); d = peek_char (); - if (d == '='){ + if (d == '=') { get_char (); return Token.OP_GE; } @@ -2997,7 +3038,7 @@ namespace Mono.CSharp case '!': val = LocatedToken.Create (ref_line, col); - if (peek_char () == '='){ + if (peek_char () == '=') { get_char (); return Token.OP_NE; } @@ -3006,11 +3047,11 @@ namespace Mono.CSharp case '=': val = LocatedToken.Create (ref_line, col); d = peek_char (); - if (d == '='){ + if (d == '=') { get_char (); return Token.OP_EQ; } - if (d == '>'){ + if (d == '>') { get_char (); return Token.ARROW; } @@ -3020,11 +3061,11 @@ namespace Mono.CSharp case '&': val = LocatedToken.Create (ref_line, col); d = peek_char (); - if (d == '&'){ + if (d == '&') { get_char (); return Token.OP_AND; } - if (d == '='){ + if (d == '=') { get_char (); return Token.OP_AND_ASSIGN; } @@ -3033,11 +3074,11 @@ namespace Mono.CSharp case '|': val = LocatedToken.Create (ref_line, col); d = peek_char (); - if (d == '|'){ + if (d == '|') { get_char (); return Token.OP_OR; } - if (d == '='){ + if (d == '=') { get_char (); return Token.OP_OR_ASSIGN; } @@ -3045,7 +3086,7 @@ namespace Mono.CSharp case '*': val = LocatedToken.Create (ref_line, col); - if (peek_char () == '='){ + if (peek_char () == '=') { get_char (); return Token.OP_MULT_ASSIGN; } @@ -3053,26 +3094,29 @@ namespace Mono.CSharp case '/': d = peek_char (); - if (d == '='){ + if (d == '=') { val = LocatedToken.Create (ref_line, col); get_char (); return Token.OP_DIV_ASSIGN; } // Handle double-slash comments. - if (d == '/'){ + if (d == '/') { get_char (); - if (RootContext.Documentation != null && peek_char () == '/') { - sbag.StartComment (SpecialsBag.CommentType.Documentation, startsLine, line, col - 1); - get_char (); - // Don't allow ////. - if ((d = peek_char ()) != '/') { - sbag.PushCommentChar (d); - update_comment_location (); - if (doc_state == XmlCommentState.Allowed) - handle_one_line_xml_comment (); - else if (doc_state == XmlCommentState.NotAllowed) - warn_incorrect_doc_comment (); + if (doc_processing) { + if (peek_char () == '/') { + sbag.StartComment (SpecialsBag.CommentType.Documentation, startsLine, line, col - 1); + get_char (); + // Don't allow ////. + if ((d = peek_char ()) != '/') { + sbag.PushCommentChar (d); + if (doc_state == XmlCommentState.Allowed) + handle_one_line_xml_comment (); + else if (doc_state == XmlCommentState.NotAllowed) + WarningMisplacedComment (Location - 3); + } + } else { + check_incorrect_doc_comment (); } } else { bool isDoc = peek_char () == '/'; @@ -3092,6 +3136,7 @@ namespace Mono.CSharp sbag.EndComment (line, col + 1); } } + any_token_seen |= tokens_seen; tokens_seen = false; comments_seen = false; @@ -3100,10 +3145,9 @@ namespace Mono.CSharp sbag.StartComment (SpecialsBag.CommentType.Multi, startsLine, line, col); get_char (); bool docAppend = false; - if (RootContext.Documentation != null && peek_char () == '*') { + if (doc_processing && peek_char () == '*') { int ch = get_char (); sbag.PushCommentChar (ch); - update_comment_location (); // But when it is /**/, just do nothing. if (peek_char () == '/') { ch = get_char (); @@ -3113,8 +3157,9 @@ namespace Mono.CSharp } if (doc_state == XmlCommentState.Allowed) docAppend = true; - else if (doc_state == XmlCommentState.NotAllowed) - warn_incorrect_doc_comment (); + else if (doc_state == XmlCommentState.NotAllowed) { + WarningMisplacedComment (Location - 2); + } } int current_comment_start = 0; @@ -3222,7 +3267,7 @@ namespace Mono.CSharp continue; } - if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f' || c == '\v' ) + if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\v' ) continue; if (c == '#') { @@ -3272,6 +3317,9 @@ namespace Mono.CSharp return consume_identifier (c); } + if (char.IsWhiteSpace ((char) c)) + continue; + Report.Error (1056, Location, "Unexpected character `{0}'", ((char) c).ToString ()); } @@ -3292,12 +3340,12 @@ namespace Mono.CSharp int c = get_char (); tokens_seen = true; if (c == '\'') { - val = new CharLiteral ((char) c, Location); + val = new CharLiteral (context.BuiltinTypes, (char) c, Location); Report.Error (1011, Location, "Empty character literal"); return Token.LITERAL; } - if (c == '\r' || c == '\n') { + if (c == '\n') { Report.Error (1010, Location, "Newline in constant"); return Token.ERROR; } @@ -3309,7 +3357,7 @@ namespace Mono.CSharp if (d != 0) throw new NotImplementedException (); - val = new CharLiteral ((char) c, Location); + val = new CharLiteral (context.BuiltinTypes, (char) c, Location); c = get_char (); if (c != '\'') { @@ -3421,18 +3469,6 @@ namespace Mono.CSharp xml_comment_buffer.Insert (current_comment_start, String.Join (Environment.NewLine, lines)); } - // - // Updates current comment location. - // - private void update_comment_location () - { - if (current_comment_location.IsNull) { - // "-2" is for heading "//" or "/*" - current_comment_location = - new Location (ref_line, hidden ? -1 : col - 2); - } - } - // // Checks if there was incorrect doc comments and raise // warnings. @@ -3440,22 +3476,7 @@ namespace Mono.CSharp public void check_incorrect_doc_comment () { if (xml_comment_buffer.Length > 0) - warn_incorrect_doc_comment (); - } - - // - // Raises a warning when tokenizer found incorrect doccomment - // markup. - // - private void warn_incorrect_doc_comment () - { - if (doc_state != XmlCommentState.Error) { - doc_state = XmlCommentState.Error; - // in csc, it is 'XML comment is not placed on - // a valid language element'. But that does not - // make sense. - Report.Warning (1587, 2, Location, "XML comment is not placed on a valid language element"); - } + WarningMisplacedComment (Location); } // @@ -3479,7 +3500,6 @@ namespace Mono.CSharp void reset_doc_comment () { xml_comment_buffer.Length = 0; - current_comment_location = Location.Null; } public void cleanup () diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs index 15ab646b5..ff0363b41 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs @@ -45,7 +45,7 @@ namespace Mono.CSharp { bool is_double_colon; public bool IsDoubleColon { get { return is_double_colon; } } - + private MemberName (MemberName left, string name, bool is_double_colon, Location loc) { @@ -392,7 +392,7 @@ namespace Mono.CSharp { } } else { if ((ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN | Modifiers.PARTIAL)) == 0 && !(Parent is Delegate)) { - if (RootContext.Version >= LanguageVersion.V_3) { + if (Compiler.Settings.Version >= LanguageVersion.V_3) { Property.PropertyMethod pm = this as Property.PropertyMethod; if (pm is Indexer.GetIndexerMethod || pm is Indexer.SetIndexerMethod) pm = null; @@ -466,7 +466,7 @@ namespace Mono.CSharp { /// public virtual void Emit () { - if (!RootContext.VerifyClsCompliance) + if (!Compiler.Settings.VerifyClsCompliance) return; VerifyClsCompliance (); @@ -826,22 +826,30 @@ namespace Mono.CSharp { // Returns a string that represents the signature for this // member which should be used in XML documentation. // - public virtual string GetDocCommentName (DeclSpace ds) + public virtual string GetDocCommentName () { - if (ds == null || this is DeclSpace) - return DocCommentHeader + Name; - else - return String.Concat (DocCommentHeader, ds.Name, ".", Name); + return DocCommentHeader + Parent.Name + "." + Name; } // // Generates xml doc comments (if any), and if required, // handle warning report. // - internal virtual void GenerateDocComment (DeclSpace ds) + internal virtual void GenerateDocComment (DocumentationBuilder builder) { + if (DocComment == null) { + if (IsExposedFromAssembly ()) { + Constructor c = this as Constructor; + if (c == null || !c.IsDefault ()) + Report.Warning (1591, 4, Location, + "Missing XML comment for publicly visible type or member `{0}'", GetSignatureForError ()); + } + + return; + } + try { - DocUtil.GenerateDocComment (this, ds, Report); + builder.GenerateDocumentationForMember (this); } catch (Exception e) { throw new InternalErrorException (this, e); } @@ -922,6 +930,10 @@ namespace Mono.CSharp { PendingBaseTypeInflate = 1 << 15, InterfacesExpanded = 1 << 16, IsNotRealProperty = 1 << 17, + SpecialRuntimeType = 1 << 18, + InflatedExpressionType = 1 << 19, + InflatedNullableType = 1 << 20, + GenericIterateInterface = 1 << 21, } protected Modifiers modifiers; @@ -1097,32 +1109,32 @@ namespace Mono.CSharp { } // - // Is this member accessible from invocationType + // Is this member accessible from invocation context // - public bool IsAccessible (TypeSpec invocationType) + public bool IsAccessible (IMemberContext ctx) { var ma = Modifiers & Modifiers.AccessibilityMask; if (ma == Modifiers.PUBLIC) return true; var parentType = /* this as TypeSpec ?? */ DeclaringType; + var ctype = ctx.CurrentType; - // It's null for module context - if (invocationType == null) - invocationType = InternalType.FakeInternalType; - - // - // If only accessible to the current class or children - // - if (ma == Modifiers.PRIVATE) - return invocationType.MemberDefinition == parentType.MemberDefinition || - TypeManager.IsNestedChildOf (invocationType, parentType.MemberDefinition); + if (ma == Modifiers.PRIVATE) { + if (ctype == null) + return false; + // + // It's only accessible to the current class or children + // + if (parentType.MemberDefinition == ctype.MemberDefinition) + return true; + + return TypeManager.IsNestedChildOf (ctype, parentType.MemberDefinition); + } if ((ma & Modifiers.INTERNAL) != 0) { bool b; - var assembly = invocationType == InternalType.FakeInternalType ? - RootContext.ToplevelTypes.DeclaringAssembly : - invocationType.MemberDefinition.DeclaringAssembly; + var assembly = ctype == null ? ctx.Module.DeclaringAssembly : ctype.MemberDefinition.DeclaringAssembly; if (parentType == null) { b = ((ITypeDefinition) MemberDefinition).IsInternalAsPublic (assembly); @@ -1134,11 +1146,18 @@ namespace Mono.CSharp { return b; } - // PROTECTED - if (!TypeManager.IsNestedFamilyAccessible (invocationType, parentType)) - return false; + // + // Checks whether `ctype' is a subclass or nested child of `parentType'. + // + while (ctype != null) { + if (TypeManager.IsFamilyAccessible (ctype, parentType)) + return true; - return true; + // Handle nested types. + ctype = ctype.DeclaringType; // TODO: Untested ??? + } + + return false; } // @@ -1168,7 +1187,7 @@ namespace Mono.CSharp { return (state & StateFlags.CLSCompliant) != 0; } - public bool IsConditionallyExcluded (Location loc) + public bool IsConditionallyExcluded (CompilerContext ctx, Location loc) { if ((Kind & (MemberKind.Class | MemberKind.Method)) == 0) return false; @@ -1178,7 +1197,7 @@ namespace Mono.CSharp { return false; foreach (var condition in conditions) { - if (loc.CompilationUnit.IsConditionalDefined (condition)) + if (loc.CompilationUnit.IsConditionalDefined (ctx, condition)) return false; } @@ -1260,7 +1279,7 @@ namespace Mono.CSharp { } } - static string[] attribute_targets = new string [] { "type" }; + static readonly string[] attribute_targets = new string [] { "type" }; public DeclSpace (NamespaceEntry ns, DeclSpace parent, MemberName name, Attributes attrs) @@ -1366,6 +1385,11 @@ namespace Mono.CSharp { type.GetSignatureForError ()); } + public override string GetDocCommentName () + { + return DocCommentHeader + Name; + } + public override string GetSignatureForError () { return MemberName.GetSignatureForError (); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/delegate.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/delegate.cs index 39dbee419..e79894dd7 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/delegate.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/delegate.cs @@ -82,6 +82,11 @@ namespace Mono.CSharp { } #endregion + public override void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); + } + public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.ReturnValue) { @@ -103,14 +108,16 @@ namespace Mono.CSharp { protected override bool DoDefineMembers () { + var builtin_types = Compiler.BuiltinTypes; + var ctor_parameters = ParametersCompiled.CreateFullyResolved ( new [] { - new Parameter (new TypeExpression (TypeManager.object_type, Location), "object", Parameter.Modifier.NONE, null, Location), - new Parameter (new TypeExpression (TypeManager.intptr_type, Location), "method", Parameter.Modifier.NONE, null, Location) + new Parameter (new TypeExpression (builtin_types.Object, Location), "object", Parameter.Modifier.NONE, null, Location), + new Parameter (new TypeExpression (builtin_types.IntPtr, Location), "method", Parameter.Modifier.NONE, null, Location) }, new [] { - TypeManager.object_type, - TypeManager.intptr_type + builtin_types.Object, + builtin_types.IntPtr } ); @@ -164,7 +171,7 @@ namespace Mono.CSharp { CheckProtectedModifier (); - if (RootContext.StdLib && TypeManager.IsSpecialType (ret_type)) { + if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType) { Method.Error1599 (Location, ret_type, Report); return false; } @@ -217,11 +224,11 @@ namespace Mono.CSharp { async_parameters = ParametersCompiled.MergeGenerated (Compiler, async_parameters, false, new Parameter[] { new Parameter (new TypeExpression (async_callback.TypeSpec, Location), "callback", Parameter.Modifier.NONE, null, Location), - new Parameter (new TypeExpression (TypeManager.object_type, Location), "object", Parameter.Modifier.NONE, null, Location) + new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, Location), "object", Parameter.Modifier.NONE, null, Location) }, new [] { async_callback.TypeSpec, - TypeManager.object_type + Compiler.BuiltinTypes.Object } ); @@ -289,7 +296,7 @@ namespace Mono.CSharp { public override void EmitType () { if (ReturnType.Type != null) { - if (ReturnType.Type == InternalType.Dynamic) { + if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location); Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder); } else if (ReturnType.Type.HasDynamicElement) { @@ -321,7 +328,7 @@ namespace Mono.CSharp { protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class) { - base_type = TypeManager.multicast_delegate_type; + base_type = Compiler.BuiltinTypes.MulticastDelegate; base_class = null; return null; } @@ -357,7 +364,7 @@ namespace Mono.CSharp { } - public static MethodSpec GetConstructor (CompilerContext ctx, TypeSpec container_type, TypeSpec delType) + public static MethodSpec GetConstructor (TypeSpec delType) { var ctor = MemberCache.FindMember (delType, MemberFilter.Constructor (null), BindingRestriction.DeclaredOnly); return (MethodSpec) ctor; @@ -366,7 +373,7 @@ namespace Mono.CSharp { // // Returns the "Invoke" from a delegate type // - public static MethodSpec GetInvokeMethod (CompilerContext ctx, TypeSpec delType) + public static MethodSpec GetInvokeMethod (TypeSpec delType) { var invoke = MemberCache.FindMember (delType, MemberFilter.Method (InvokeMethodName, 0, null, null), @@ -375,26 +382,26 @@ namespace Mono.CSharp { return (MethodSpec) invoke; } - public static AParametersCollection GetParameters (CompilerContext ctx, TypeSpec delType) + public static AParametersCollection GetParameters (TypeSpec delType) { - var invoke_mb = GetInvokeMethod (ctx, delType); + var invoke_mb = GetInvokeMethod (delType); return invoke_mb.Parameters; } // // 15.2 Delegate compatibility // - public static bool IsTypeCovariant (Expression a, TypeSpec b) + public static bool IsTypeCovariant (ResolveContext rc, TypeSpec a, TypeSpec b) { // // For each value parameter (a parameter with no ref or out modifier), an // identity conversion or implicit reference conversion exists from the // parameter type in D to the corresponding parameter type in M // - if (a.Type == b) + if (a == b) return true; - if (RootContext.Version == LanguageVersion.ISO_1) + if (rc.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) return false; return Convert.ImplicitReferenceConversionExists (a, b); @@ -413,11 +420,6 @@ namespace Mono.CSharp { instance_expr = value; } } - - public override void Accept (StructuralVisitor visitor) - { - visitor.Visit (this); - } } // @@ -477,9 +479,9 @@ namespace Mono.CSharp { protected override Expression DoResolve (ResolveContext ec) { - constructor_method = Delegate.GetConstructor (ec.Compiler, ec.CurrentType, type); + constructor_method = Delegate.GetConstructor (type); - var invoke_method = Delegate.GetInvokeMethod (ec.Compiler, type); + var invoke_method = Delegate.GetInvokeMethod (type); Arguments arguments = CreateDelegateMethodArguments (invoke_method.Parameters, invoke_method.Parameters.Types, loc); method_group = method_group.OverloadResolve (ec, ref arguments, this, OverloadResolver.Restrictions.CovariantDelegate); @@ -488,7 +490,7 @@ namespace Mono.CSharp { var delegate_method = method_group.BestCandidate; - if (TypeManager.IsNullableType (delegate_method.DeclaringType)) { + if (delegate_method.DeclaringType.IsNullableType) { ec.Report.Error (1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable type", delegate_method.GetSignatureForError ()); return null; @@ -507,12 +509,12 @@ namespace Mono.CSharp { } TypeSpec rt = delegate_method.ReturnType; - Expression ret_expr = new TypeExpression (rt, loc); - if (!Delegate.IsTypeCovariant (ret_expr, invoke_method.ReturnType)) { + if (!Delegate.IsTypeCovariant (ec, rt, invoke_method.ReturnType)) { + Expression ret_expr = new TypeExpression (rt, loc); Error_ConversionFailed (ec, delegate_method, ret_expr); } - if (delegate_method.IsConditionallyExcluded (loc)) { + if (delegate_method.IsConditionallyExcluded (ec.Module.Compiler, loc)) { ec.Report.SymbolRelatedToPreviousError (delegate_method); MethodOrOperator m = delegate_method.MemberDefinition as MethodOrOperator; if (m != null && m.IsPartialDefinition) { @@ -526,7 +528,7 @@ namespace Mono.CSharp { var expr = method_group.InstanceExpression; if (expr != null && (expr.Type.IsGenericParameter || !TypeManager.IsReferenceType (expr.Type))) - method_group.InstanceExpression = new BoxedCast (expr, TypeManager.object_type); + method_group.InstanceExpression = new BoxedCast (expr, ec.BuiltinTypes.Object); eclass = ExprClass.Value; return this; @@ -554,14 +556,14 @@ namespace Mono.CSharp { void Error_ConversionFailed (ResolveContext ec, MethodSpec method, Expression return_type) { - var invoke_method = Delegate.GetInvokeMethod (ec.Compiler, type); + var invoke_method = Delegate.GetInvokeMethod (type); string member_name = method_group.InstanceExpression != null ? Delegate.FullDelegateDesc (method) : TypeManager.GetFullNameSignature (method); ec.Report.SymbolRelatedToPreviousError (type); ec.Report.SymbolRelatedToPreviousError (method); - if (RootContext.Version == LanguageVersion.ISO_1) { + if (ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) { ec.Report.Error (410, loc, "A method or delegate `{0} {1}' parameters and return type must be same as delegate `{2} {3}' parameters and return type", TypeManager.CSharpName (method.ReturnType), member_name, TypeManager.CSharpName (invoke_method.ReturnType), Delegate.FullDelegateDesc (invoke_method)); @@ -581,10 +583,10 @@ namespace Mono.CSharp { public static bool ImplicitStandardConversionExists (ResolveContext ec, MethodGroupExpr mg, TypeSpec target_type) { - if (target_type == TypeManager.delegate_type || target_type == TypeManager.multicast_delegate_type) - return false; +// if (target_type == TypeManager.delegate_type || target_type == TypeManager.multicast_delegate_type) +// return false; - var invoke = Delegate.GetInvokeMethod (ec.Compiler, target_type); + var invoke = Delegate.GetInvokeMethod (target_type); Arguments arguments = CreateDelegateMethodArguments (invoke.Parameters, invoke.Parameters.Types, mg.Location); return mg.OverloadResolve (ec, ref arguments, null, OverloadResolver.Restrictions.CovariantDelegate | OverloadResolver.Restrictions.ProbingOnly) != null; @@ -668,7 +670,7 @@ namespace Mono.CSharp { Expression e = a.Expr; AnonymousMethodExpression ame = e as AnonymousMethodExpression; - if (ame != null && RootContext.Version != LanguageVersion.ISO_1) { + if (ame != null && ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1) { e = ame.Compatible (ec, type); if (e == null) return null; @@ -678,7 +680,7 @@ namespace Mono.CSharp { method_group = e as MethodGroupExpr; if (method_group == null) { - if (e.Type == InternalType.Dynamic) { + if (e.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { e = Convert.ImplicitConversionRequired (ec, e, type, loc); } else if (!e.Type.IsDelegate) { e.Error_UnexpectedKind (ec, ResolveFlags.MethodGroup | ResolveFlags.Type, loc); @@ -688,7 +690,7 @@ namespace Mono.CSharp { // // An argument is not a method but another delegate // - method_group = new MethodGroupExpr (Delegate.GetInvokeMethod (ec.Compiler, e.Type), e.Type, loc); + method_group = new MethodGroupExpr (Delegate.GetInvokeMethod (e.Type), e.Type, loc); method_group.InstanceExpression = e; } @@ -730,7 +732,7 @@ namespace Mono.CSharp { // Do only core overload resolution the rest of the checks has been // done on primary expression // - method = Delegate.GetInvokeMethod (ec.Compiler, del_type); + method = Delegate.GetInvokeMethod (del_type); var res = new OverloadResolver (new MemberSpec[] { method }, OverloadResolver.Restrictions.DelegateInvoke, loc); var valid = res.ResolveMember (ec, ref arguments); if (valid == null && !res.BestCandidateIsDynamic) @@ -756,7 +758,7 @@ namespace Mono.CSharp { // // Pop the return value if there is one // - if (type != TypeManager.void_type) + if (type.Kind != MemberKind.Void) ec.Emit (OpCodes.Pop); } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs index aff97d8ad..41dc98467 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs @@ -18,75 +18,53 @@ using System.Xml; using System.Linq; -namespace Mono.CSharp { - +namespace Mono.CSharp +{ // - // Support class for XML documentation. + // Implements XML documentation generation. // - static class DocUtil + class DocumentationBuilder { - // TypeContainer - // - // Generates xml doc comments (if any), and if required, - // handle warning report. + // Used to create element which helps well-formedness checking. // - internal static void GenerateTypeDocComment (TypeContainer t, - DeclSpace ds, Report Report) - { - GenerateDocComment (t, ds, Report); - - if (t.DefaultStaticConstructor != null) - t.DefaultStaticConstructor.GenerateDocComment (t); + readonly XmlDocument XmlDocumentation; - if (t.InstanceConstructors != null) - foreach (Constructor c in t.InstanceConstructors) - c.GenerateDocComment (t); + readonly ModuleContainer module; - if (t.Types != null) - foreach (TypeContainer tc in t.Types) - tc.GenerateDocComment (t); - - if (t.Constants != null) - foreach (Const c in t.Constants) - c.GenerateDocComment (t); - - if (t.Fields != null) - foreach (FieldBase f in t.Fields) - f.GenerateDocComment (t); - - if (t.Events != null) - foreach (Event e in t.Events) - e.GenerateDocComment (t); - - if (t.Indexers != null) - foreach (Indexer ix in t.Indexers) - ix.GenerateDocComment (t); + // + // The output for XML documentation. + // + public XmlWriter XmlCommentOutput; - if (t.Properties != null) - foreach (Property p in t.Properties) - p.GenerateDocComment (t); + static readonly string line_head = Environment.NewLine + " "; + static readonly char[] wsChars = new char[] { ' ', '\t', '\n', '\r' }; - if (t.Methods != null) - foreach (MethodOrOperator m in t.Methods) - m.GenerateDocComment (t); + // + // Stores XmlDocuments that are included in XML documentation. + // Keys are included filenames, values are XmlDocuments. + // + Dictionary StoredDocuments = new Dictionary (); - if (t.Operators != null) - foreach (Operator o in t.Operators) - o.GenerateDocComment (t); + public DocumentationBuilder (ModuleContainer module) + { + this.module = module; + XmlDocumentation = new XmlDocument (); + XmlDocumentation.PreserveWhitespace = false; } - // MemberCore - private static readonly string line_head = - Environment.NewLine + " "; + Report Report { + get { + return module.Compiler.Report; + } + } - private static XmlNode GetDocCommentNode (MemberCore mc, - string name, Report Report) + XmlNode GetDocCommentNode (MemberCore mc, string name) { // FIXME: It could be even optimizable as not // to use XmlDocument. But anyways the nodes // are not kept in memory. - XmlDocument doc = RootContext.Documentation.XmlDocumentation; + XmlDocument doc = XmlDocumentation; try { XmlElement el = doc.CreateElement ("member"); el.SetAttribute ("name", name); @@ -110,9 +88,10 @@ namespace Mono.CSharp { line_head, split, 0, j); return el; } catch (Exception ex) { - Report.Warning (1570, 1, mc.Location, "XML comment on `{0}' has non-well-formed XML ({1})", name, ex.Message); - XmlComment com = doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name)); - return com; + Report.Warning (1570, 1, mc.Location, "XML documentation comment on `{0}' is not well-formed XML markup ({1})", + mc.GetSignatureForError (), ex.Message); + + return doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name)); } } @@ -120,58 +99,49 @@ namespace Mono.CSharp { // Generates xml doc comments (if any), and if required, // handle warning report. // - internal static void GenerateDocComment (MemberCore mc, - DeclSpace ds, Report Report) + internal void GenerateDocumentationForMember (MemberCore mc) { - if (mc.DocComment != null) { - string name = mc.GetDocCommentName (ds); - - XmlNode n = GetDocCommentNode (mc, name, Report); - - XmlElement el = n as XmlElement; - if (el != null) { - mc.OnGenerateDocComment (el); - - // FIXME: it could be done with XmlReader - XmlNodeList nl = n.SelectNodes (".//include"); - if (nl.Count > 0) { - // It could result in current node removal, so prepare another list to iterate. - var al = new List (nl.Count); - foreach (XmlNode inc in nl) - al.Add (inc); - foreach (XmlElement inc in al) - if (!HandleInclude (mc, inc, Report)) - inc.ParentNode.RemoveChild (inc); - } - - // FIXME: it could be done with XmlReader - DeclSpace ds_target = mc as DeclSpace; - if (ds_target == null) - ds_target = ds; - - foreach (XmlElement see in n.SelectNodes (".//see")) - HandleSee (mc, ds_target, see, Report); - foreach (XmlElement seealso in n.SelectNodes (".//seealso")) - HandleSeeAlso (mc, ds_target, seealso ,Report); - foreach (XmlElement see in n.SelectNodes (".//exception")) - HandleException (mc, ds_target, see, Report); + string name = mc.GetDocCommentName (); + + XmlNode n = GetDocCommentNode (mc, name); + + XmlElement el = n as XmlElement; + if (el != null) { + mc.OnGenerateDocComment (el); + + // FIXME: it could be done with XmlReader + XmlNodeList nl = n.SelectNodes (".//include"); + if (nl.Count > 0) { + // It could result in current node removal, so prepare another list to iterate. + var al = new List (nl.Count); + foreach (XmlNode inc in nl) + al.Add (inc); + foreach (XmlElement inc in al) + if (!HandleInclude (mc, inc)) + inc.ParentNode.RemoveChild (inc); } - n.WriteTo (RootContext.Documentation.XmlCommentOutput); - } - else if (mc.IsExposedFromAssembly ()) { - Constructor c = mc as Constructor; - if (c == null || !c.IsDefault ()) - Report.Warning (1591, 4, mc.Location, - "Missing XML comment for publicly visible type or member `{0}'", mc.GetSignatureForError ()); + // FIXME: it could be done with XmlReader + DeclSpace ds_target = mc as DeclSpace; + if (ds_target == null) + ds_target = mc.Parent; + + foreach (XmlElement see in n.SelectNodes (".//see")) + HandleSee (mc, ds_target, see); + foreach (XmlElement seealso in n.SelectNodes (".//seealso")) + HandleSeeAlso (mc, ds_target, seealso); + foreach (XmlElement see in n.SelectNodes (".//exception")) + HandleException (mc, ds_target, see); } + + n.WriteTo (XmlCommentOutput); } // // Processes "include" element. Check included file and // embed the document content inside this documentation node. // - private static bool HandleInclude (MemberCore mc, XmlElement el, Report Report) + bool HandleInclude (MemberCore mc, XmlElement el) { bool keep_include_node = false; string file = el.GetAttribute ("file"); @@ -188,11 +158,11 @@ namespace Mono.CSharp { } else { XmlDocument doc; - if (!RootContext.Documentation.StoredDocuments.TryGetValue (file, out doc)) { + if (!StoredDocuments.TryGetValue (file, out doc)) { try { doc = new XmlDocument (); doc.Load (file); - RootContext.Documentation.StoredDocuments.Add (file, doc); + StoredDocuments.Add (file, doc); } catch (Exception) { el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (String.Format (" Badly formed XML in at comment file `{0}': cannot be included ", file)), el); Report.Warning (1592, 1, mc.Location, "Badly formed XML in included comments file -- `{0}'", file); @@ -220,38 +190,32 @@ namespace Mono.CSharp { // // Handles elements. // - private static void HandleSee (MemberCore mc, - DeclSpace ds, XmlElement see, Report r) + void HandleSee (MemberCore mc, DeclSpace ds, XmlElement see) { - HandleXrefCommon (mc, ds, see, r); + HandleXrefCommon (mc, ds, see); } // // Handles elements. // - private static void HandleSeeAlso (MemberCore mc, - DeclSpace ds, XmlElement seealso, Report r) + void HandleSeeAlso (MemberCore mc, DeclSpace ds, XmlElement seealso) { - HandleXrefCommon (mc, ds, seealso, r); + HandleXrefCommon (mc, ds, seealso); } // // Handles elements. // - private static void HandleException (MemberCore mc, - DeclSpace ds, XmlElement seealso, Report r) + void HandleException (MemberCore mc, DeclSpace ds, XmlElement seealso) { - HandleXrefCommon (mc, ds, seealso, r); + HandleXrefCommon (mc, ds, seealso); } - static readonly char [] wsChars = - new char [] {' ', '\t', '\n', '\r'}; - // // returns a full runtime type name from a name which might // be C# specific type name. // - private static TypeSpec FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref, Report r) + TypeSpec FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref) { bool is_array = false; string identifier = name; @@ -262,48 +226,48 @@ namespace Mono.CSharp { is_array = true; } } - TypeSpec t = FindDocumentedTypeNonArray (mc, identifier, ds, cref, r); + TypeSpec t = FindDocumentedTypeNonArray (mc, identifier, ds, cref); if (t != null && is_array) - t = ArrayContainer.MakeType (t); + t = ArrayContainer.MakeType (mc.Module, t); return t; } - private static TypeSpec FindDocumentedTypeNonArray (MemberCore mc, - string identifier, DeclSpace ds, string cref, Report r) + TypeSpec FindDocumentedTypeNonArray (MemberCore mc, string identifier, DeclSpace ds, string cref) { + var types = module.Compiler.BuiltinTypes; switch (identifier) { case "int": - return TypeManager.int32_type; + return types.Int; case "uint": - return TypeManager.uint32_type; + return types.UInt; case "short": - return TypeManager.short_type;; + return types.Short; case "ushort": - return TypeManager.ushort_type; + return types.UShort; case "long": - return TypeManager.int64_type; + return types.Long; case "ulong": - return TypeManager.uint64_type;; + return types.ULong; case "float": - return TypeManager.float_type;; + return types.Float; case "double": - return TypeManager.double_type; + return types.Double; case "char": - return TypeManager.char_type;; + return types.Char; case "decimal": - return TypeManager.decimal_type;; + return types.Decimal; case "byte": - return TypeManager.byte_type;; + return types.Byte; case "sbyte": - return TypeManager.sbyte_type;; + return types.SByte; case "object": - return TypeManager.object_type;; + return types.Object; case "bool": - return TypeManager.bool_type;; + return types.Bool; case "string": - return TypeManager.string_type;; + return types.String; case "void": - return TypeManager.void_type;; + return types.Void; } FullNamedExpression e = ds.LookupNamespaceOrType (identifier, 0, mc.Location, false); if (e != null) { @@ -320,19 +284,19 @@ namespace Mono.CSharp { Namespace ns = ds.NamespaceEntry.NS.GetNamespace (nsName, false); ns = ns ?? mc.Module.GlobalRootNamespace.GetNamespace(nsName, false); if (ns != null) { - var te = ns.LookupType(mc.Compiler, typeName, 0, true, mc.Location); + var te = ns.LookupType(mc, typeName, 0, true, mc.Location); if(te != null) return te.Type; } int warn; - TypeSpec parent = FindDocumentedType (mc, identifier.Substring (0, index), ds, cref, r); + TypeSpec parent = FindDocumentedType (mc, identifier.Substring (0, index), ds, cref); if (parent == null) return null; // no need to detect warning 419 here var ts = FindDocumentedMember (mc, parent, identifier.Substring (index + 1), - null, ds, out warn, cref, false, null, r) as TypeSpec; + null, ds, out warn, cref, false, null) as TypeSpec; if (ts != null) return ts; return null; @@ -342,16 +306,16 @@ namespace Mono.CSharp { // Returns a MemberInfo that is referenced in XML documentation // (by "see" or "seealso" elements). // - private static MemberSpec FindDocumentedMember (MemberCore mc, + MemberSpec FindDocumentedMember (MemberCore mc, TypeSpec type, string member_name, AParametersCollection param_list, DeclSpace ds, out int warning_type, string cref, - bool warn419, string name_for_error, Report r) + bool warn419, string name_for_error) { // for (; type != null; type = type.DeclaringType) { var mi = FindDocumentedMemberNoNest ( mc, type, member_name, param_list, ds, out warning_type, cref, warn419, - name_for_error, r); + name_for_error); if (mi != null) return mi; // new FoundMember (type, mi); // } @@ -359,10 +323,10 @@ namespace Mono.CSharp { return null; } - private static MemberSpec FindDocumentedMemberNoNest ( + MemberSpec FindDocumentedMemberNoNest ( MemberCore mc, TypeSpec type, string member_name, AParametersCollection param_list, DeclSpace ds, out int warning_type, - string cref, bool warn419, string name_for_error, Report Report) + string cref, bool warn419, string name_for_error) { warning_type = 0; // var filter = new MemberFilter (member_name, 0, MemberKind.All, param_list, null); @@ -376,7 +340,7 @@ namespace Mono.CSharp { return null; if (warn419 && found.Count > 1) { - Report419 (mc, name_for_error, found.ToArray (), Report); + Report419 (mc, name_for_error, found.ToArray ()); } return found [0]; @@ -476,8 +440,7 @@ namespace Mono.CSharp { // Processes "see" or "seealso" elements. // Checks cref attribute. // - private static void HandleXrefCommon (MemberCore mc, - DeclSpace ds, XmlElement xref, Report Report) + void HandleXrefCommon (MemberCore mc, DeclSpace ds, XmlElement xref) { string cref = xref.GetAttribute ("cref").Trim (wsChars); // when, XmlReader, "if (cref == null)" @@ -520,7 +483,7 @@ namespace Mono.CSharp { name = signature; parameters = null; } - Normalize (mc, ref name, Report); + Normalize (mc, ref name); string identifier = GetBodyIdentifierFromName (name); @@ -531,7 +494,7 @@ namespace Mono.CSharp { for (int i = 0; i < name_elems.Length; i++) { string nameElem = GetBodyIdentifierFromName (name_elems [i]); if (i > 0) - Normalize (mc, ref nameElem, Report); + Normalize (mc, ref nameElem); if (!Tokenizer.IsValidIdentifier (nameElem) && nameElem.IndexOf ("operator") < 0) { Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'", @@ -552,8 +515,8 @@ namespace Mono.CSharp { var plist = new List (); for (int i = 0; i < param_list.Length; i++) { string param_type_name = param_list [i].Trim (wsChars); - Normalize (mc, ref param_type_name, Report); - TypeSpec param_type = FindDocumentedType (mc, param_type_name, ds, cref, Report); + Normalize (mc, ref param_type_name); + TypeSpec param_type = FindDocumentedType (mc, param_type_name, ds, cref); if (param_type == null) { Report.Warning (1580, 1, mc.Location, "Invalid type for parameter `{0}' in XML comment cref attribute `{1}'", (i + 1).ToString (), cref); @@ -565,7 +528,7 @@ namespace Mono.CSharp { parameter_types = ParametersCompiled.CreateFullyResolved (plist.ToArray ()); } - TypeSpec type = FindDocumentedType (mc, name, ds, cref, Report); + TypeSpec type = FindDocumentedType (mc, name, ds, cref); if (type != null // delegate must not be referenced with args && (!type.IsDelegate @@ -581,12 +544,12 @@ namespace Mono.CSharp { string typeName = name.Substring (0, period); string member_name = name.Substring (period + 1); string lookup_name = member_name == "this" ? MemberCache.IndexerNameAlias : member_name; - Normalize (mc, ref lookup_name, Report); - Normalize (mc, ref member_name, Report); - type = FindDocumentedType (mc, typeName, ds, cref, Report); + Normalize (mc, ref lookup_name); + Normalize (mc, ref member_name); + type = FindDocumentedType (mc, typeName, ds, cref); int warn_result; if (type != null) { - var mi = FindDocumentedMember (mc, type, lookup_name, parameter_types, ds, out warn_result, cref, true, name, Report); + var mi = FindDocumentedMember (mc, type, lookup_name, parameter_types, ds, out warn_result, cref, true, name); if (warn_result > 0) return; if (mi != null) { @@ -600,7 +563,7 @@ namespace Mono.CSharp { } } else { int warn_result; - var mi = FindDocumentedMember (mc, ds.PartialContainer.Definition, name, parameter_types, ds, out warn_result, cref, true, name, Report); + var mi = FindDocumentedMember (mc, ds.PartialContainer.Definition, name, parameter_types, ds, out warn_result, cref, true, name); if (warn_result > 0) return; @@ -670,7 +633,7 @@ namespace Mono.CSharp { return identifier; } - static void Report419 (MemberCore mc, string member_name, MemberSpec [] mis, Report Report) + void Report419 (MemberCore mc, string member_name, MemberSpec [] mis) { Report.Warning (419, 3, mc.Location, "Ambiguous reference in cref attribute `{0}'. Assuming `{1}' but other overloads including `{2}' have also matched", @@ -705,7 +668,7 @@ namespace Mono.CSharp { // Returns a string that represents the signature for this // member which should be used in XML documentation. // - public static string GetMethodDocCommentName (MemberCore mc, ParametersCompiled parameters, DeclSpace ds) + public static string GetMethodDocCommentName (MemberCore mc, ParametersCompiled parameters) { IParameterData [] plist = parameters.FixedParameters; string paramSpec = String.Empty; @@ -746,7 +709,7 @@ namespace Mono.CSharp { break; } } - return String.Concat (mc.DocCommentHeader, ds.Name, ".", name, paramSpec, suffix); + return String.Concat (mc.DocCommentHeader, mc.Parent.Name, ".", name, paramSpec, suffix); } static string GetSignatureForDoc (TypeSpec type) @@ -820,7 +783,7 @@ namespace Mono.CSharp { } } - private static void Normalize (MemberCore mc, ref string name, Report Report) + void Normalize (MemberCore mc, ref string name) { if (name.Length > 0 && name [0] == '@') name = name.Substring (1); @@ -853,82 +816,39 @@ namespace Mono.CSharp { } return false; } - } - - // - // Implements XML documentation generation. - // - public class Documentation - { - public Documentation (string xml_output_filename) - { - docfilename = xml_output_filename; - XmlDocumentation = new XmlDocument (); - XmlDocumentation.PreserveWhitespace = false; - } - - private string docfilename; - - // - // Used to create element which helps well-formedness checking. - // - public XmlDocument XmlDocumentation; - - // - // The output for XML documentation. - // - public XmlWriter XmlCommentOutput; - - // - // Stores XmlDocuments that are included in XML documentation. - // Keys are included filenames, values are XmlDocuments. - // - public Dictionary StoredDocuments = new Dictionary (); // // Outputs XML documentation comment from tokenized comments. // - public bool OutputDocComment (string asmfilename, Report Report) + public bool OutputDocComment (string asmfilename, string xmlFileName) { XmlTextWriter w = null; try { - w = new XmlTextWriter (docfilename, null); + w = new XmlTextWriter (xmlFileName, null); w.Indentation = 4; w.Formatting = Formatting.Indented; w.WriteStartDocument (); w.WriteStartElement ("doc"); w.WriteStartElement ("assembly"); w.WriteStartElement ("name"); - w.WriteString (Path.ChangeExtension (asmfilename, null)); + w.WriteString (Path.GetFileNameWithoutExtension (asmfilename)); w.WriteEndElement (); // name w.WriteEndElement (); // assembly w.WriteStartElement ("members"); XmlCommentOutput = w; - GenerateDocComment (Report); + module.GenerateDocComment (this); w.WriteFullEndElement (); // members w.WriteEndElement (); w.WriteWhitespace (Environment.NewLine); w.WriteEndDocument (); return true; } catch (Exception ex) { - Report.Error (1569, "Error generating XML documentation file `{0}' (`{1}')", docfilename, ex.Message); + module.Compiler.Report.Error (1569, "Error generating XML documentation file `{0}' (`{1}')", xmlFileName, ex.Message); return false; } finally { if (w != null) w.Close (); } } - - // - // Fixes full type name of each documented types/members up. - // - public void GenerateDocComment (Report r) - { - TypeContainer root = RootContext.ToplevelTypes; - - if (root.Types != null) - foreach (TypeContainer tc in root.Types) - DocUtil.GenerateTypeDocComment (tc, null, r); - } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs index d05ffc219..87378eaab 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs @@ -27,34 +27,20 @@ namespace Mono.CSharp /// class Driver { - string first_source; + readonly CompilerContext ctx; - internal int fatal_errors; - - internal readonly CompilerContext ctx; - - static readonly char[] argument_value_separator = new char [] { ';', ',' }; - - private Driver (CompilerContext ctx) + public Driver (CompilerContext ctx) { this.ctx = ctx; } - public static Driver Create (string[] args, bool require_files, Func unknown_option_parser, ReportPrinter printer) - { - Driver d = new Driver (new CompilerContext (new Report (printer))); - - if (!d.ParseArguments (args, require_files, unknown_option_parser)) - return null; - - return d; - } - Report Report { - get { return ctx.Report; } + get { + return ctx.Report; + } } - - void tokenize_file (CompilationUnit file, CompilerContext ctx) + + void tokenize_file (CompilationSourceFile file) { Stream input; @@ -66,7 +52,7 @@ namespace Mono.CSharp } using (input){ - SeekableStreamReader reader = new SeekableStreamReader (input, RootContext.Encoding); + SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding); Tokenizer lexer = new Tokenizer (reader, file, ctx); int token, tokens = 0, errors = 0; @@ -81,7 +67,22 @@ namespace Mono.CSharp return; } - void Parse (CompilationUnit file, ModuleContainer module) + void Parse (ModuleContainer module) + { + Location.Initialize (module.Compiler.SourceFiles); + + bool tokenize_only = module.Compiler.Settings.TokenizeOnly; + var sources = module.Compiler.SourceFiles; + for (int i = 0; i < sources.Count; ++i) { + if (tokenize_only) { + tokenize_file (sources[i]); + } else { + Parse (sources[i], module); + } + } + } + + void Parse (CompilationSourceFile file, ModuleContainer module) { Stream input; @@ -100,112 +101,35 @@ namespace Mono.CSharp } input.Position = 0; - SeekableStreamReader reader = new SeekableStreamReader (input, RootContext.Encoding); + SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding); Parse (reader, file, module); reader.Dispose (); input.Close (); } - void Parse (SeekableStreamReader reader, CompilationUnit file, ModuleContainer module) + public void Parse (SeekableStreamReader reader, CompilationSourceFile file, ModuleContainer module) { - CSharpParser parser = new CSharpParser (reader, file, module); - parser.parse (); - } + file.NamespaceContainer = new NamespaceEntry (module, null, file, null); - static void OtherFlags () - { - Console.WriteLine ( - "Other flags in the compiler\n" + - " --fatal[=COUNT] Makes errors after COUNT fatal\n" + - " --lint Enhanced warnings\n" + - " --parse Only parses the source file\n" + - " --runtime:VERSION Sets mscorlib.dll metadata version: v1, v2, v4\n" + - " --stacktrace Shows stack trace at error location\n" + - " --timestamp Displays time stamps of various compiler events\n" + - " -v Verbose parsing (for debugging the parser)\n" + - " --mcs-debug X Sets MCS debugging level to X\n"); - } - - static void Usage () - { - Console.WriteLine ( - "Mono C# compiler, Copyright 2001 - 2011 Novell, Inc.\n" + - "mcs [options] source-files\n" + - " --about About the Mono C# compiler\n" + - " -addmodule:M1[,Mn] Adds the module to the generated assembly\n" + - " -checked[+|-] Sets default aritmetic overflow context\n" + - " -clscheck[+|-] Disables CLS Compliance verifications\n" + - " -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n" + - " -define:S1[;S2] Defines one or more conditional symbols (short: -d)\n" + - " -debug[+|-], -g Generate debugging information\n" + - " -delaysign[+|-] Only insert the public key into the assembly (no signing)\n" + - " -doc:FILE Process documentation comments to XML file\n" + - " -fullpaths Any issued error or warning uses absolute file path\n" + - " -help Lists all compiler options (short: -?)\n" + - " -keycontainer:NAME The key pair container used to sign the output assembly\n" + - " -keyfile:FILE The key file used to strongname the ouput assembly\n" + - " -langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, Default, or Future\n" + - " -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n" + - " -main:CLASS Specifies the class with the Main method (short: -m)\n" + - " -noconfig Disables implicitly referenced assemblies\n" + - " -nostdlib[+|-] Does not reference mscorlib.dll library\n" + - " -nowarn:W1[,Wn] Suppress one or more compiler warnings\n" + - " -optimize[+|-] Enables advanced compiler optimizations (short: -o)\n" + - " -out:FILE Specifies output assembly name\n" + - " -pkg:P1[,Pn] References packages P1..Pn\n" + - " -platform:ARCH Specifies the target platform of the output assembly\n" + - " ARCH can be one of: anycpu, x86, x64 or itanium\n" + - " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" + - " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + - " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + - " -sdk:VERSION Specifies SDK version of referenced assemlies\n" + - " VERSION can be one of: 2 (default), 4\n" + - " -target:KIND Specifies the format of the output assembly (short: -t)\n" + - " KIND can be one of: exe, winexe, library, module\n" + - " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" + - " -warnaserror[+|-] Treats all warnings as errors\n" + - " -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors\n" + - " -warn:0-4 Sets warning level, the default is 4 (short -w:)\n" + - " -helpinternal Shows internal and advanced compiler options\n" + - "\n" + - "Resources:\n" + - " -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)\n" + - " -resource:FILE[,ID] Embed FILE as a resource (short: -res)\n" + - " -win32res:FILE Specifies Win32 resource file (.res)\n" + - " -win32icon:FILE Use this icon for the output\n" + - " @file Read response file for more options\n\n" + - "Options can be of the form -option or /option"); - } - - void TargetUsage () - { - Report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'"); + CSharpParser parser = new CSharpParser (reader, file); + parser.parse (); } - static void About () - { - Console.WriteLine ( - "The Mono C# compiler is Copyright 2001-2011, Novell, Inc.\n\n" + - "The compiler source code is released under the terms of the \n"+ - "MIT X11 or GNU GPL licenses\n\n" + - - "For more information on Mono, visit the project Web site\n" + - " http://www.mono-project.com\n\n" + - - "The compiler was written by Miguel de Icaza, Ravi Pratap, Martin Baulig, Marek Safar, Raja R Harinath, Atushi Enomoto"); - Environment.Exit (0); - } - public static int Main (string[] args) { Location.InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t"; - var crp = new ConsoleReportPrinter (); - Driver d = Driver.Create (args, true, null, crp); - if (d == null) + + var r = new Report (new ConsoleReportPrinter ()); + CommandLineParser cmd = new CommandLineParser (r); + var settings = cmd.ParseArguments (args); + if (settings == null || r.Errors > 0) return 1; - crp.Fatal = d.fatal_errors; + if (cmd.HasBeenStopped) + return 0; + + Driver d = new Driver (new CompilerContext (settings, r)); if (d.Compile () && d.Report.Errors == 0) { if (d.Report.Warnings > 0) { @@ -222,544 +146,7 @@ namespace Mono.CSharp return 1; } - static string [] LoadArgs (string file) - { - StreamReader f; - var args = new List (); - string line; - try { - f = new StreamReader (file); - } catch { - return null; - } - - StringBuilder sb = new StringBuilder (); - - while ((line = f.ReadLine ()) != null){ - int t = line.Length; - - for (int i = 0; i < t; i++){ - char c = line [i]; - - if (c == '"' || c == '\''){ - char end = c; - - for (i++; i < t; i++){ - c = line [i]; - - if (c == end) - break; - sb.Append (c); - } - } else if (c == ' '){ - if (sb.Length > 0){ - args.Add (sb.ToString ()); - sb.Length = 0; - } - } else - sb.Append (c); - } - if (sb.Length > 0){ - args.Add (sb.ToString ()); - sb.Length = 0; - } - } - - return args.ToArray (); - } - - // - // Given a path specification, splits the path from the file/pattern - // - static void SplitPathAndPattern (string spec, out string path, out string pattern) - { - int p = spec.LastIndexOf ('/'); - if (p != -1){ - // - // Windows does not like /file.cs, switch that to: - // "\", "file.cs" - // - if (p == 0){ - path = "\\"; - pattern = spec.Substring (1); - } else { - path = spec.Substring (0, p); - pattern = spec.Substring (p + 1); - } - return; - } - - p = spec.LastIndexOf ('\\'); - if (p != -1){ - path = spec.Substring (0, p); - pattern = spec.Substring (p + 1); - return; - } - - path = "."; - pattern = spec; - } - - void AddSourceFile (string f) - { - if (first_source == null) - first_source = f; - - Location.AddFile (Report, f); - } - - bool ParseArguments (string[] args, bool require_files, Func unknown_option_parser) - { - List response_file_list = null; - bool parsing_options = true; - - for (int i = 0; i < args.Length; i++) { - string arg = args [i]; - if (arg.Length == 0) - continue; - - if (arg [0] == '@') { - string [] extra_args; - string response_file = arg.Substring (1); - - if (response_file_list == null) - response_file_list = new List (); - - if (response_file_list.Contains (response_file)) { - Report.Error ( - 1515, "Response file `" + response_file + - "' specified multiple times"); - return false; - } - - response_file_list.Add (response_file); - - extra_args = LoadArgs (response_file); - if (extra_args == null) { - Report.Error (2011, "Unable to open response file: " + - response_file); - return false; - } - - args = AddArgs (args, extra_args); - continue; - } - - if (parsing_options) { - if (arg == "--") { - parsing_options = false; - continue; - } - - if (arg [0] == '-') { - if (UnixParseOption (arg, ref args, ref i)) - continue; - - // Try a -CSCOPTION - string csc_opt = "/" + arg.Substring (1); - if (CSCParseOption (csc_opt, ref args)) - continue; - - if (unknown_option_parser != null){ - var ret = unknown_option_parser (args, i); - if (ret != -1){ - i = ret; - return true; - } - } - - Error_WrongOption (arg); - return false; - } - if (arg [0] == '/') { - if (CSCParseOption (arg, ref args)) - continue; - - // Need to skip `/home/test.cs' however /test.cs is considered as error - if (arg.Length < 2 || arg.IndexOf ('/', 2) == -1) { - Error_WrongOption (arg); - return false; - } - } - } - - ProcessSourceFiles (arg, false); - } - - if (require_files == false) - return true; - - // - // If we are an exe, require a source file for the entry point - // - if (RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe || RootContext.Target == Target.Module) { - if (first_source == null) { - Report.Error (2008, "No files to compile were specified"); - return false; - } - - } - - // - // If there is nothing to put in the assembly, and we are not a library - // - if (first_source == null && RootContext.Resources == null) { - Report.Error (2008, "No files to compile were specified"); - return false; - } - - return true; - } - - public void Parse (ModuleContainer module) - { - Location.Initialize (); - - var cu = Location.SourceFiles; - for (int i = 0; i < cu.Count; ++i) { - if (RootContext.TokenizeOnly) { - tokenize_file (cu [i], ctx); - } else { - Parse (cu [i], module); - } - } - } - - void ProcessSourceFiles (string spec, bool recurse) - { - string path, pattern; - - SplitPathAndPattern (spec, out path, out pattern); - if (pattern.IndexOf ('*') == -1){ - AddSourceFile (spec); - return; - } - - string [] files = null; - try { - files = Directory.GetFiles (path, pattern); - } catch (System.IO.DirectoryNotFoundException) { - Report.Error (2001, "Source file `" + spec + "' could not be found"); - return; - } catch (System.IO.IOException){ - Report.Error (2001, "Source file `" + spec + "' could not be found"); - return; - } - foreach (string f in files) { - AddSourceFile (f); - } - - if (!recurse) - return; - - string [] dirs = null; - - try { - dirs = Directory.GetDirectories (path); - } catch { - } - - foreach (string d in dirs) { - - // Don't include path in this string, as each - // directory entry already does - ProcessSourceFiles (d + "/" + pattern, true); - } - } - - void SetWarningLevel (string s) - { - int level = -1; - - try { - level = Int32.Parse (s); - } catch { - } - if (level < 0 || level > 4){ - Report.Error (1900, "Warning level must be in the range 0-4"); - return; - } - Report.WarningLevel = level; - } - - static void Version () - { - string version = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString (); - Console.WriteLine ("Mono C# compiler version {0}", version); - Environment.Exit (0); - } - - // - // Currently handles the Unix-like command line options, but will be - // deprecated in favor of the CSCParseOption, which will also handle the - // options that start with a dash in the future. - // - bool UnixParseOption (string arg, ref string [] args, ref int i) - { - switch (arg){ - case "-v": - CSharpParser.yacc_verbose_flag++; - return true; - - case "--version": - Version (); - return true; - - case "--parse": - RootContext.ParseOnly = true; - return true; - - case "--main": case "-m": - Report.Warning (-29, 1, "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS"); - if ((i + 1) >= args.Length){ - Usage (); - Environment.Exit (1); - } - RootContext.MainClass = args [++i]; - return true; - - case "--unsafe": - Report.Warning (-29, 1, "Compatibility: Use -unsafe instead of --unsafe"); - RootContext.Unsafe = true; - return true; - - case "/?": case "/h": case "/help": - case "--help": - Usage (); - Environment.Exit (0); - return true; - - case "--define": - Report.Warning (-29, 1, "Compatibility: Use -d:SYMBOL instead of --define SYMBOL"); - if ((i + 1) >= args.Length){ - Usage (); - Environment.Exit (1); - } - RootContext.AddConditional (args [++i]); - return true; - - case "--tokenize": - RootContext.TokenizeOnly = true; - return true; - - case "-o": - case "--output": - Report.Warning (-29, 1, "Compatibility: Use -out:FILE instead of --output FILE or -o FILE"); - if ((i + 1) >= args.Length){ - Usage (); - Environment.Exit (1); - } - RootContext.OutputFile = args [++i]; - return true; - - case "--checked": - Report.Warning (-29, 1, "Compatibility: Use -checked instead of --checked"); - RootContext.Checked = true; - return true; - - case "--stacktrace": - Report.Printer.Stacktrace = true; - return true; - - case "--linkresource": - case "--linkres": - Report.Warning (-29, 1, "Compatibility: Use -linkres:VALUE instead of --linkres VALUE"); - if ((i + 1) >= args.Length){ - Usage (); - Report.Error (5, "Missing argument to --linkres"); - Environment.Exit (1); - } - - AddResource (new AssemblyResource (args[++i], args[i])); - return true; - - case "--resource": - case "--res": - Report.Warning (-29, 1, "Compatibility: Use -res:VALUE instead of --res VALUE"); - if ((i + 1) >= args.Length){ - Usage (); - Report.Error (5, "Missing argument to --resource"); - Environment.Exit (1); - } - - AddResource (new AssemblyResource (args[++i], args[i], true)); - return true; - - case "--target": - Report.Warning (-29, 1, "Compatibility: Use -target:KIND instead of --target KIND"); - if ((i + 1) >= args.Length){ - Environment.Exit (1); - return true; - } - - string type = args [++i]; - switch (type){ - case "library": - RootContext.Target = Target.Library; - RootContext.TargetExt = ".dll"; - break; - - case "exe": - RootContext.Target = Target.Exe; - break; - - case "winexe": - RootContext.Target = Target.WinExe; - break; - - case "module": - RootContext.Target = Target.Module; - RootContext.TargetExt = ".dll"; - break; - default: - TargetUsage (); - break; - } - return true; - - case "-r": - Report.Warning (-29, 1, "Compatibility: Use -r:LIBRARY instead of -r library"); - if ((i + 1) >= args.Length){ - Usage (); - Environment.Exit (1); - } - - string val = args [++i]; - int idx = val.IndexOf ('='); - if (idx > -1) { - string alias = val.Substring (0, idx); - string assembly = val.Substring (idx + 1); - AddAssemblyReference (alias, assembly); - return true; - } - - AddAssemblyReference (val); - return true; - - case "-L": - Report.Warning (-29, 1, "Compatibility: Use -lib:ARG instead of --L arg"); - if ((i + 1) >= args.Length){ - Usage (); - Environment.Exit (1); - } - RootContext.ReferencesLookupPaths.Add (args [++i]); - return true; - - case "--lint": - RootContext.EnhancedWarnings = true; - return true; - - case "--nostdlib": - Report.Warning (-29, 1, "Compatibility: Use -nostdlib instead of --nostdlib"); - RootContext.StdLib = false; - return true; - - case "--nowarn": - Report.Warning (-29, 1, "Compatibility: Use -nowarn instead of --nowarn"); - if ((i + 1) >= args.Length){ - Usage (); - Environment.Exit (1); - } - int warn = 0; - - try { - warn = Int32.Parse (args [++i]); - } catch { - Usage (); - Environment.Exit (1); - } - Report.SetIgnoreWarning (warn); - return true; - - case "--wlevel": - Report.Warning (-29, 1, "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL"); - if ((i + 1) >= args.Length){ - Report.Error ( - 1900, - "--wlevel requires a value from 0 to 4"); - Environment.Exit (1); - } - - SetWarningLevel (args [++i]); - return true; - - case "--mcs-debug": - if ((i + 1) >= args.Length){ - Report.Error (5, "--mcs-debug requires an argument"); - Environment.Exit (1); - } - - try { - Report.DebugFlags = Int32.Parse (args [++i]); - } catch { - Report.Error (5, "Invalid argument to --mcs-debug"); - Environment.Exit (1); - } - return true; - - case "--about": - About (); - return true; - - case "--recurse": - Report.Warning (-29, 1, "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN"); - if ((i + 1) >= args.Length){ - Report.Error (5, "--recurse requires an argument"); - Environment.Exit (1); - } - ProcessSourceFiles (args [++i], true); - return true; - - case "--timestamp": - RootContext.Timestamps = true; - return true; - - case "--debug": case "-g": - Report.Warning (-29, 1, "Compatibility: Use -debug option instead of -g or --debug"); - RootContext.GenerateDebugInfo = true; - return true; - - case "--noconfig": - Report.Warning (-29, 1, "Compatibility: Use -noconfig option instead of --noconfig"); - RootContext.LoadDefaultReferences = false; - return true; - - default: - if (arg.StartsWith ("--fatal")){ - if (arg.StartsWith ("--fatal=")){ - if (!Int32.TryParse (arg.Substring (8), out fatal_errors)) - fatal_errors = 1; - } else - fatal_errors = 1; - return true; - } - if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) { - string version = arg.Substring (10); - - switch (version) { - case "v1": - case "V1": - RootContext.StdLibRuntimeVersion = RuntimeVersion.v1; - break; - case "v2": - case "V2": - RootContext.StdLibRuntimeVersion = RuntimeVersion.v2; - return true; - case "v4": - case "V4": - RootContext.StdLibRuntimeVersion = RuntimeVersion.v4; - return true; - } - return true; - } - - break; - } - - return false; - } - - public static string GetPackageFlags (string packages, bool fatal, Report report) + public static string GetPackageFlags (string packages, Report report) { ProcessStartInfo pi = new ProcessStartInfo (); pi.FileName = "pkg-config"; @@ -770,653 +157,56 @@ namespace Mono.CSharp try { p = Process.Start (pi); } catch (Exception e) { + if (report == null) + throw; + report.Error (-27, "Couldn't run pkg-config: " + e.Message); - if (fatal) - Environment.Exit (1); - p.Close (); return null; } - if (p.StandardOutput == null){ + if (p.StandardOutput == null) { + if (report == null) + throw new ApplicationException ("Specified package did not return any information"); + report.Warning (-27, 1, "Specified package did not return any information"); p.Close (); return null; } + string pkgout = p.StandardOutput.ReadToEnd (); p.WaitForExit (); if (p.ExitCode != 0) { + if (report == null) + throw new ApplicationException (pkgout); + report.Error (-27, "Error running pkg-config. Check the above output."); - if (fatal) - Environment.Exit (1); p.Close (); return null; } - p.Close (); + p.Close (); return pkgout; } // - // This parses the -arg and /arg options to the compiler, even if the strings - // in the following text use "/arg" on the strings. + // Main compilation method // - bool CSCParseOption (string option, ref string [] args) - { - int idx = option.IndexOf (':'); - string arg, value; - - if (idx == -1){ - arg = option; - value = ""; - } else { - arg = option.Substring (0, idx); - - value = option.Substring (idx + 1); - } - - switch (arg.ToLowerInvariant ()){ - case "/nologo": - return true; - - case "/t": - case "/target": - switch (value){ - case "exe": - RootContext.Target = Target.Exe; - break; - - case "winexe": - RootContext.Target = Target.WinExe; - break; - - case "library": - RootContext.Target = Target.Library; - RootContext.TargetExt = ".dll"; - break; - - case "module": - RootContext.Target = Target.Module; - RootContext.TargetExt = ".netmodule"; - break; - - default: - TargetUsage (); - break; - } - return true; - - case "/out": - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - RootContext.OutputFile = value; - return true; - - case "/o": - case "/o+": - case "/optimize": - case "/optimize+": - RootContext.Optimize = true; - return true; - - case "/o-": - case "/optimize-": - RootContext.Optimize = false; - return true; - - // TODO: Not supported by csc 3.5+ - case "/incremental": - case "/incremental+": - case "/incremental-": - // nothing. - return true; - - case "/d": - case "/define": { - if (value.Length == 0){ - Usage (); - Environment.Exit (1); - } - - foreach (string d in value.Split (argument_value_separator)) { - string conditional = d.Trim (); - if (!Tokenizer.IsValidIdentifier (conditional)) { - Report.Warning (2029, 1, "Invalid conditional define symbol `{0}'", conditional); - continue; - } - RootContext.AddConditional (conditional); - } - return true; - } - - case "/bugreport": - // - // We should collect data, runtime, etc and store in the file specified - // - Console.WriteLine ("To file bug reports, please visit: http://www.mono-project.com/Bugs"); - return true; - - case "/pkg": { - string packages; - - if (value.Length == 0){ - Usage (); - Environment.Exit (1); - } - packages = String.Join (" ", value.Split (new Char [] { ';', ',', '\n', '\r'})); - string pkgout = GetPackageFlags (packages, true, Report); - - if (pkgout != null){ - string [] xargs = pkgout.Trim (new Char [] {' ', '\n', '\r', '\t'}). - Split (new Char [] { ' ', '\t'}); - args = AddArgs (args, xargs); - } - - return true; - } - - case "/linkres": - case "/linkresource": - case "/res": - case "/resource": - AssemblyResource res = null; - string[] s = value.Split (argument_value_separator, StringSplitOptions.RemoveEmptyEntries); - switch (s.Length) { - case 1: - if (s[0].Length == 0) - goto default; - res = new AssemblyResource (s [0], Path.GetFileName (s[0])); - break; - case 2: - res = new AssemblyResource (s [0], s [1]); - break; - case 3: - if (s [2] != "public" && s [2] != "private") { - Report.Error (1906, "Invalid resource visibility option `{0}'. Use either `public' or `private' instead", s [2]); - return true; - } - res = new AssemblyResource (s[0], s[1], s[2] == "private"); - break; - default: - Report.Error (-2005, "Wrong number of arguments for option `{0}'", option); - break; - } - - if (res != null) { - res.IsEmbeded = arg [1] == 'r' || arg [1] == 'R'; - AddResource (res); - } - - return true; - - case "/recurse": - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - ProcessSourceFiles (value, true); - return true; - - case "/r": - case "/reference": { - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - string[] refs = value.Split (argument_value_separator); - foreach (string r in refs){ - if (r.Length == 0) - continue; - - string val = r; - int index = val.IndexOf ('='); - if (index > -1) { - string alias = r.Substring (0, index); - string assembly = r.Substring (index + 1); - AddAssemblyReference (alias, assembly); - if (refs.Length != 1) { - Report.Error (2034, "Cannot specify multiple aliases using single /reference option"); - break; - } - } else { - AddAssemblyReference (val); - } - } - return true; - } - case "/addmodule": { - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - string[] refs = value.Split (argument_value_separator); - foreach (string r in refs){ - RootContext.Modules.Add (r); - } - return true; - } - case "/win32res": { - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - if (RootContext.Win32IconFile != null) - Report.Error (1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time"); - - RootContext.Win32ResourceFile = value; - return true; - } - case "/win32icon": { - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - if (RootContext.Win32ResourceFile != null) - Report.Error (1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time"); - - RootContext.Win32IconFile = value; - return true; - } - case "/doc": { - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - RootContext.Documentation = new Documentation (value); - return true; - } - case "/lib": { - string [] libdirs; - - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - libdirs = value.Split (argument_value_separator); - foreach (string dir in libdirs) - RootContext.ReferencesLookupPaths.Add (dir); - return true; - } - - case "/debug-": - RootContext.GenerateDebugInfo = false; - return true; - - case "/debug": - if (value == "full" || value == "") - RootContext.GenerateDebugInfo = true; - - return true; - - case "/debug+": - RootContext.GenerateDebugInfo = true; - return true; - - case "/checked": - case "/checked+": - RootContext.Checked = true; - return true; - - case "/checked-": - RootContext.Checked = false; - return true; - - case "/clscheck": - case "/clscheck+": - RootContext.VerifyClsCompliance = true; - return true; - - case "/clscheck-": - RootContext.VerifyClsCompliance = false; - return true; - - case "/unsafe": - case "/unsafe+": - RootContext.Unsafe = true; - return true; - - case "/unsafe-": - RootContext.Unsafe = false; - return true; - - case "/warnaserror": - case "/warnaserror+": - if (value.Length == 0) { - Report.WarningsAreErrors = true; - } else { - foreach (string wid in value.Split (argument_value_separator)) - Report.AddWarningAsError (wid); - } - return true; - - case "/warnaserror-": - if (value.Length == 0) { - Report.WarningsAreErrors = false; - } else { - foreach (string wid in value.Split (argument_value_separator)) - Report.RemoveWarningAsError (wid); - } - return true; - - case "/warn": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - SetWarningLevel (value); - return true; - - case "/nowarn": { - if (value.Length == 0){ - Error_RequiresArgument (option); - break; - } - - var warns = value.Split (argument_value_separator); - foreach (string wc in warns){ - try { - if (wc.Trim ().Length == 0) - continue; - - int warn = Int32.Parse (wc); - if (warn < 1) { - throw new ArgumentOutOfRangeException("warn"); - } - Report.SetIgnoreWarning (warn); - } catch { - Report.Error (1904, "`{0}' is not a valid warning number", wc); - } - } - return true; - } - - case "/noconfig": - RootContext.LoadDefaultReferences = false; - return true; - - case "/platform": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - switch (value.ToLower (CultureInfo.InvariantCulture)) { - case "anycpu": - RootContext.Platform = Platform.AnyCPU; - break; - case "x86": - RootContext.Platform = Platform.X86; - break; - case "x64": - RootContext.Platform = Platform.X64; - break; - case "itanium": - RootContext.Platform = Platform.IA64; - break; - default: - Report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'"); - break; - } - - return true; - - case "/sdk": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - switch (value.ToLowerInvariant ()) { - case "2": - RootContext.SdkVersion = SdkVersion.v2; - break; - case "4": - RootContext.SdkVersion = SdkVersion.v4; - break; - default: - Report.Error (-26, "Invalid sdk version name"); - break; - } - - return true; - - // We just ignore this. - case "/errorreport": - case "/filealign": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - return true; - - case "/helpinternal": - OtherFlags (); - Environment.Exit(0); - return true; - - case "/help": - case "/?": - Usage (); - Environment.Exit (0); - return true; - - case "/main": - case "/m": - if (value.Length == 0){ - Error_RequiresArgument (option); - break; - } - RootContext.MainClass = value; - return true; - - case "/nostdlib": - case "/nostdlib+": - RootContext.StdLib = false; - return true; - - case "/nostdlib-": - RootContext.StdLib = true; - return true; - - case "/fullpaths": - RootContext.ShowFullPaths = true; - return true; - - case "/keyfile": - if (value.Length == 0) { - Error_RequiresFileName (option); - break; - } - - RootContext.StrongNameKeyFile = value; - return true; - - case "/keycontainer": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - RootContext.StrongNameKeyContainer = value; - return true; - case "/delaysign+": - case "/delaysign": - RootContext.StrongNameDelaySign = true; - return true; - case "/delaysign-": - RootContext.StrongNameDelaySign = false; - return true; - - case "/langversion": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - switch (value.ToLowerInvariant ()) { - case "iso-1": - RootContext.Version = LanguageVersion.ISO_1; - return true; - case "default": - RootContext.Version = LanguageVersion.Default; - RootContext.AddConditional ("__V2__"); - return true; - case "iso-2": - RootContext.Version = LanguageVersion.ISO_2; - return true; - case "3": - RootContext.Version = LanguageVersion.V_3; - return true; - case "future": - RootContext.Version = LanguageVersion.Future; - return true; - } - - Report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or `Default'", value); - return true; - - case "/codepage": - if (value.Length == 0) { - Error_RequiresArgument (option); - break; - } - - switch (value) { - case "utf8": - RootContext.Encoding = new UTF8Encoding(); - break; - case "reset": - RootContext.Encoding = Encoding.Default; - break; - default: - try { - RootContext.Encoding = Encoding.GetEncoding (Int32.Parse (value)); - } catch { - Report.Error (2016, "Code page `{0}' is invalid or not installed", value); - } - break; - } - return true; - - default: - return false; - } - - return true; - } - - void Error_WrongOption (string option) - { - Report.Error (2007, "Unrecognized command-line option: `{0}'", option); - } - - void Error_RequiresFileName (string option) - { - Report.Error (2005, "Missing file specification for `{0}' option", option); - } - - void Error_RequiresArgument (string option) - { - Report.Error (2006, "Missing argument for `{0}' option", option); - } - - static string [] AddArgs (string [] args, string [] extra_args) - { - string [] new_args; - new_args = new string [extra_args.Length + args.Length]; - - // if args contains '--' we have to take that into account - // split args into first half and second half based on '--' - // and add the extra_args before -- - int split_position = Array.IndexOf (args, "--"); - if (split_position != -1) - { - Array.Copy (args, new_args, split_position); - extra_args.CopyTo (new_args, split_position); - Array.Copy (args, split_position, new_args, split_position + extra_args.Length, args.Length - split_position); - } - else - { - args.CopyTo (new_args, 0); - extra_args.CopyTo (new_args, args.Length); - } - - return new_args; - } - - void AddAssemblyReference (string assembly) - { - RootContext.AssemblyReferences.Add (assembly); - } - - void AddAssemblyReference (string alias, string assembly) - { - if (assembly.Length == 0) { - Report.Error (1680, "Invalid reference alias `{0}='. Missing filename", alias); - return; - } - - if (!IsExternAliasValid (alias)) { - Report.Error (1679, "Invalid extern alias for -reference. Alias `{0}' is not a valid identifier", alias); - return; - } - - RootContext.AssemblyReferencesAliases.Add (Tuple.Create (alias, assembly)); - } - - void AddResource (AssemblyResource res) + public bool Compile () { - if (RootContext.Resources == null) { - RootContext.Resources = new List (); - RootContext.Resources.Add (res); - return; - } + var settings = ctx.Settings; - if (RootContext.Resources.Contains (res)) { - ctx.Report.Error (1508, "The resource identifier `{0}' has already been used in this assembly", res.Name); - return; - } - - RootContext.Resources.Add (res); - } - - static bool IsExternAliasValid (string identifier) - { - if (identifier.Length == 0) - return false; - if (identifier [0] != '_' && !Char.IsLetter (identifier [0])) + // + // If we are an exe, require a source file for the entry point or + // if there is nothing to put in the assembly, and we are not a library + // + if (settings.FirstSourceFile == null && + ((settings.Target == Target.Exe || settings.Target == Target.WinExe || settings.Target == Target.Module) || + settings.Resources == null)) { + Report.Error (2008, "No files to compile were specified"); return false; - - for (int i = 1; i < identifier.Length; i++) { - char c = identifier [i]; - if (Char.IsLetter (c) || Char.IsDigit (c)) - continue; - - UnicodeCategory category = Char.GetUnicodeCategory (c); - if (category != UnicodeCategory.Format || category != UnicodeCategory.NonSpacingMark || - category != UnicodeCategory.SpacingCombiningMark || - category != UnicodeCategory.ConnectorPunctuation) - return false; } - - return true; - } - // - // Main compilation method - // - public bool Compile () - { - TimeReporter tr = new TimeReporter (RootContext.Timestamps); + TimeReporter tr = new TimeReporter (settings.Timestamps); ctx.TimeReporter = tr; tr.StartTotal (); @@ -1430,37 +220,36 @@ namespace Mono.CSharp if (Report.Errors > 0) return false; - if (RootContext.TokenizeOnly || RootContext.ParseOnly) + if (settings.TokenizeOnly || settings.ParseOnly) { + tr.StopTotal (); + tr.ShowStats (); return true; + } - if (RootContext.ToplevelTypes.NamespaceEntry != null) - throw new InternalErrorException ("who set it?"); - - // - // Quick hack - // - var output_file = RootContext.OutputFile; + var output_file = settings.OutputFile; string output_file_name; if (output_file == null) { - if (first_source == null) { + var source_file = settings.FirstSourceFile; + + if (source_file == null) { Report.Error (1562, "If no source files are specified you must specify the output file with -out:"); return false; } - int pos = first_source.LastIndexOf ('.'); + output_file_name = source_file.Name; + int pos = output_file_name.LastIndexOf ('.'); if (pos > 0) - output_file = first_source.Substring (0, pos) + RootContext.TargetExt; - else - output_file = first_source + RootContext.TargetExt; - - output_file_name = output_file; + output_file_name = output_file_name.Substring (0, pos); + + output_file_name += settings.TargetExt; + output_file = output_file_name; } else { output_file_name = Path.GetFileName (output_file); } #if STATIC - var importer = new StaticImporter (); + var importer = new StaticImporter (module); var references_loader = new StaticLoader (importer, ctx); tr.Start (TimeReporter.TimerType.AssemblyBuilderSetup); @@ -1480,7 +269,7 @@ namespace Mono.CSharp references_loader.LoadReferences (module); tr.Start (TimeReporter.TimerType.PredefinedTypesInit); - if (!ctx.BuildinTypes.CheckDefinitions (module)) + if (!ctx.BuiltinTypes.CheckDefinitions (module)) return false; tr.Stop (TimeReporter.TimerType.PredefinedTypesInit); @@ -1490,13 +279,13 @@ namespace Mono.CSharp var assembly = new AssemblyDefinitionDynamic (module, output_file_name, output_file); module.SetDeclaringAssembly (assembly); - var importer = new ReflectionImporter (ctx.BuildinTypes); + var importer = new ReflectionImporter (module, ctx.BuiltinTypes); assembly.Importer = importer; var loader = new DynamicLoader (importer, ctx); loader.LoadReferences (module); - if (!ctx.BuildinTypes.CheckDefinitions (module)) + if (!ctx.BuiltinTypes.CheckDefinitions (module)) return false; if (!assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Save)) @@ -1506,6 +295,14 @@ namespace Mono.CSharp loader.LoadModules (assembly, module.GlobalRootNamespace); #endif + module.InitializePredefinedTypes (); + + tr.Start (TimeReporter.TimerType.UsingResolve); + foreach (var source_file in ctx.SourceFiles) { + source_file.NamespaceContainer.Resolve (); + } + tr.Stop (TimeReporter.TimerType.UsingResolve); + tr.Start (TimeReporter.TimerType.ModuleDefinitionTotal); module.Define (); tr.Stop (TimeReporter.TimerType.ModuleDefinitionTotal); @@ -1513,20 +310,9 @@ namespace Mono.CSharp if (Report.Errors > 0) return false; - if (RootContext.Documentation != null && - !RootContext.Documentation.OutputDocComment ( - output_file, Report)) - return false; - - // - // Verify using aliases now - // - tr.Start (TimeReporter.TimerType.UsingVerification); - NamespaceEntry.VerifyAllUsing (); - tr.Stop (TimeReporter.TimerType.UsingVerification); - - if (Report.Errors > 0){ - return false; + if (settings.DocumentationFile != null) { + var doc = new DocumentationBuilder (module); + doc.OutputDocComment (output_file, settings.DocumentationFile); } assembly.Resolve (); @@ -1562,7 +348,7 @@ namespace Mono.CSharp tr.StopTotal (); tr.ShowStats (); - return (Report.Errors == 0); + return Report.Errors == 0; } } @@ -1581,12 +367,14 @@ namespace Mono.CSharp public static bool InvokeCompiler (string [] args, TextWriter error) { try { - StreamReportPrinter srp = new StreamReportPrinter (error); - Driver d = Driver.Create (args, true, delegate (string[] a, int i) { System.Console.WriteLine ("Unknown option:" + a[i]); return 0; }, srp); - if (d == null) + var r = new Report (new StreamReportPrinter (error)); + CommandLineParser cmd = new CommandLineParser (r, error); + var setting = cmd.ParseArguments (args); + if (setting == null || r.Errors > 0) return false; - return d.Compile () && srp.ErrorsCount == 0; + var d = new Driver (new CompilerContext (setting, r)); + return d.Compile (); } finally { Reset (); } @@ -1616,29 +404,12 @@ namespace Mono.CSharp if (!full_flag) return; - RootContext.Reset (full_flag); - TypeManager.Reset (); - ArrayContainer.Reset (); - ReferenceContainer.Reset (); - PointerContainer.Reset (); - Parameter.Reset (); - - Unary.Reset (); - UnaryMutator.Reset (); - Binary.Reset (); - ConstantFold.Reset (); - CastFromDecimal.Reset (); - StringConcat.Reset (); - - NamespaceEntry.Reset (); - Attribute.Reset (); AnonymousTypeClass.Reset (); AnonymousMethodBody.Reset (); AnonymousMethodStorey.Reset (); SymbolWriter.Reset (); Switch.Reset (); Linq.QueryBlock.TransparentParameter.Reset (); - Convert.Reset (); TypeInfo.Reset (); } @@ -1648,37 +419,42 @@ namespace Mono.CSharp } internal static object parseLock = new object (); + public static CompilerCompilationUnit ParseFile (string[] args, Stream input, string inputFile, ReportPrinter reportPrinter) { lock (parseLock) { try { - Driver d = Driver.Create (args, false, null, reportPrinter); - if (d == null) + // Driver d = Driver.Create (args, false, null, reportPrinter); + // if (d == null) + // return null; + + var r = new Report (reportPrinter); + CommandLineParser cmd = new CommandLineParser (r, Console.Out); + var setting = cmd.ParseArguments (args); + if (setting == null || r.Errors > 0) return null; - - Location.AddFile (null, inputFile); - Location.Initialize (); - + + CompilerContext ctx = new CompilerContext (setting, r); + + var files = new List (); + var unit = new CompilationSourceFile (inputFile, inputFile, 0); + var module = new ModuleContainer (ctx); + unit.NamespaceContainer = new NamespaceEntry (module, null, unit, null); + files.Add (unit); + Location.Initialize (files); + // TODO: encoding from driver SeekableStreamReader reader = new SeekableStreamReader (input, Encoding.Default); - - CompilerContext ctx = new CompilerContext (new Report (reportPrinter)); + + RootContext.ToplevelTypes = module; - RootContext.ToplevelTypes = new ModuleContainer (ctx); - CompilationUnit unit = null; - try { - unit = (CompilationUnit) Location.SourceFiles [0]; - } catch (Exception) { - string path = Path.GetFullPath (inputFile); - unit = new CompilationUnit (inputFile, path, 0); - } - CSharpParser parser = new CSharpParser (reader, unit, RootContext.ToplevelTypes); + CSharpParser parser = new CSharpParser (reader, unit); parser.Lexer.TabSize = 1; parser.Lexer.sbag = new SpecialsBag (); parser.LocationsBag = new LocationsBag (); parser.UsingsBag = new UsingsBag (); parser.parse (); - + return new CompilerCompilationUnit () { ModuleCompiled = RootContext.ToplevelTypes, LocationsBag = parser.LocationsBag, UsingsBag = parser.UsingsBag, SpecialsBag = parser.Lexer.sbag }; } finally { Reset (); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/dynamic.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/dynamic.cs index 646fbd590..8cf647fc3 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/dynamic.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/dynamic.cs @@ -45,13 +45,11 @@ namespace Mono.CSharp public DynamicTypeExpr (Location loc) { this.loc = loc; - - type = InternalType.Dynamic; - eclass = ExprClass.Type; } protected override TypeExpr DoResolveAsTypeStep (IMemberContext ec) { + type = ec.Module.Compiler.BuiltinTypes.Dynamic; return this; } } @@ -227,11 +225,12 @@ namespace Mono.CSharp { this.flags = flags; this.statement = statement; + eclass = 0; } protected override Expression DoResolve (ResolveContext ec) { - Child = new IntConstant ((int) (flags | statement.flags), statement.loc).Resolve (ec); + Child = new IntConstant (ec.BuiltinTypes, (int) (flags | statement.flags), statement.loc); type = ec.Module.PredefinedTypes.BinderFlags.Resolve (loc); eclass = Child.eclass; @@ -247,6 +246,7 @@ namespace Mono.CSharp protected CSharpBinderFlags flags; TypeSpec binder_type; + TypeParameter[] context_mvars; public DynamicExpressionStatement (IDynamicBinder binder, Arguments args, Location loc) { @@ -261,28 +261,25 @@ namespace Mono.CSharp } } - FieldSpec CreateSiteField (EmitContext ec, FullNamedExpression type) - { - var site_container = ec.CreateDynamicSite (); - return site_container.CreateCallSiteField (type, loc); - } - public override Expression CreateExpressionTree (ResolveContext ec) { ec.Report.Error (1963, loc, "An expression tree cannot contain a dynamic operation"); return null; } - protected override Expression DoResolve (ResolveContext ec) + protected override Expression DoResolve (ResolveContext rc) { - if (DoResolveCore (ec)) - binder_expr = binder.CreateCallSiteBinder (ec, arguments); + if (DoResolveCore (rc)) + binder_expr = binder.CreateCallSiteBinder (rc, arguments); return this; } protected bool DoResolveCore (ResolveContext rc) { + if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter) + context_mvars = rc.CurrentTypeParameters; + int errors = rc.Report.Errors; var pt = rc.Module.PredefinedTypes; @@ -293,7 +290,7 @@ namespace Mono.CSharp eclass = ExprClass.Value; if (type == null) - type = InternalType.Dynamic; + type = rc.BuiltinTypes.Dynamic; if (rc.Report.Errors == errors) return true; @@ -315,68 +312,50 @@ namespace Mono.CSharp protected void EmitCall (EmitContext ec, Expression binder, Arguments arguments, bool isStatement) { + // + // This method generates all internal infrastructure for a dynamic call. The + // reason why it's quite complicated is the mixture of dynamic and anonymous + // methods. Dynamic itself requires a temporary class (ContainerX) and anonymous + // methods can generate temporary storey as well (AnonStorey). Handling MVAR + // type parameters rewrite is non-trivial in such case as there are various + // combinations possible therefore the mutator is not straightforward. Secondly + // we need to keep both MVAR(possibly VAR for anon storey) and type VAR to emit + // correct Site field type and its access from EmitContext. + // + int dyn_args_count = arguments == null ? 0 : arguments.Count; - TypeExpr site_type = CreateSiteType (ec, arguments, dyn_args_count, isStatement); - var field = CreateSiteField (ec, site_type); - if (field == null) - return; + int default_args = isStatement ? 1 : 2; + var module = ec.Module; - FieldExpr site_field_expr = new FieldExpr (field, loc); + bool has_ref_out_argument = false; + var targs = new TypeExpression[dyn_args_count + default_args]; + targs[0] = new TypeExpression (module.PredefinedTypes.CallSite.TypeSpec, loc); - SymbolWriter.OpenCompilerGeneratedBlock (ec); + TypeExpression[] targs_for_instance = null; + TypeParameterMutator mutator; - Arguments args = new Arguments (1); - args.Add (new Argument (binder)); - StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (site_type, "Create"), args))); - - BlockContext bc = new BlockContext (ec.MemberContext, null, TypeManager.void_type); - if (s.Resolve (bc)) { - Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc); - init.Emit (ec); - } + var site_container = ec.CreateDynamicSite (); - args = new Arguments (1 + dyn_args_count); - args.Add (new Argument (site_field_expr)); - if (arguments != null) { - foreach (Argument a in arguments) { - if (a is NamedArgument) { - // Name is not valid in this context - args.Add (new Argument (a.Expr, a.ArgType)); - continue; - } + if (context_mvars != null) { + TypeParameter[] tparam; + TypeContainer sc = site_container; + do { + tparam = sc.CurrentTypeParameters; + sc = sc.Parent; + } while (tparam == null); - args.Add (a); + mutator = new TypeParameterMutator (context_mvars, tparam); + + if (!ec.IsAnonymousStoreyMutateRequired) { + targs_for_instance = new TypeExpression[targs.Length]; + targs_for_instance[0] = targs[0]; } + } else { + mutator = null; } - Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc); - if (target != null) - target.Emit (ec); - - SymbolWriter.CloseCompilerGeneratedBlock (ec); - } - - public static MemberAccess GetBinderNamespace (Location loc) - { - return new MemberAccess (new MemberAccess ( - new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "Microsoft", loc), "CSharp", loc), "RuntimeBinder", loc); - } - - protected MemberAccess GetBinder (string name, Location loc) - { - return new MemberAccess (new TypeExpression (binder_type, loc), name, loc); - } - - TypeExpr CreateSiteType (EmitContext ec, Arguments arguments, int dyn_args_count, bool is_statement) - { - int default_args = is_statement ? 1 : 2; - var module = ec.MemberContext.Module; - - bool has_ref_out_argument = false; - var targs = new TypeExpression[dyn_args_count + default_args]; - targs [0] = new TypeExpression (module.PredefinedTypes.CallSite.TypeSpec, loc); for (int i = 0; i < dyn_args_count; ++i) { - Argument a = arguments [i]; + Argument a = arguments[i]; if (a.ArgType == Argument.AType.Out || a.ArgType == Argument.AType.Ref) has_ref_out_argument = true; @@ -384,52 +363,71 @@ namespace Mono.CSharp // Convert any internal type like dynamic or null to object if (t.Kind == MemberKind.InternalCompilerType) - t = TypeManager.object_type; + t = ec.BuiltinTypes.Object; + + if (targs_for_instance != null) + targs_for_instance[i + 1] = new TypeExpression (t, loc); - targs [i + 1] = new TypeExpression (t, loc); + if (mutator != null) + t = t.Mutate (mutator); + + targs[i + 1] = new TypeExpression (t, loc); } TypeExpr del_type = null; + TypeExpr del_type_instance_access = null; if (!has_ref_out_argument) { - string d_name = is_statement ? "Action" : "Func"; + string d_name = isStatement ? "Action" : "Func"; TypeExpr te = null; Namespace type_ns = module.GlobalRootNamespace.GetNamespace ("System", true); if (type_ns != null) { - te = type_ns.LookupType (module.Compiler, d_name, dyn_args_count + default_args, true, Location.Null); + te = type_ns.LookupType (module, d_name, dyn_args_count + default_args, true, Location.Null); } - + if (te != null) { - if (!is_statement) - targs [targs.Length - 1] = new TypeExpression (type, loc); + if (!isStatement) { + var t = type; + if (t.Kind == MemberKind.InternalCompilerType) + t = ec.BuiltinTypes.Object; + + if (targs_for_instance != null) + targs_for_instance[targs_for_instance.Length - 1] = new TypeExpression (t, loc); + + if (mutator != null) + t = t.Mutate (mutator); + + targs[targs.Length - 1] = new TypeExpression (t, loc); + } del_type = new GenericTypeExpr (te.Type, new TypeArguments (targs), loc); + if (targs_for_instance != null) + del_type_instance_access = new GenericTypeExpr (te.Type, new TypeArguments (targs_for_instance), loc); + else + del_type_instance_access = del_type; } } // - // Create custom delegate when no appropriate predefined one is found + // Create custom delegate when no appropriate predefined delegate has been found // + Delegate d; if (del_type == null) { - TypeSpec rt = is_statement ? TypeManager.void_type : type; - Parameter[] p = new Parameter [dyn_args_count + 1]; - p[0] = new Parameter (targs [0], "p0", Parameter.Modifier.NONE, null, loc); + TypeSpec rt = isStatement ? ec.BuiltinTypes.Void : type; + Parameter[] p = new Parameter[dyn_args_count + 1]; + p[0] = new Parameter (targs[0], "p0", Parameter.Modifier.NONE, null, loc); var site = ec.CreateDynamicSite (); int index = site.Types == null ? 0 : site.Types.Count; - if (site.Mutator != null) - rt = site.Mutator.Mutate (rt); + if (mutator != null) + rt = mutator.Mutate (rt); for (int i = 1; i < dyn_args_count + 1; ++i) { - var t = targs[i]; - if (site.Mutator != null) - t.Type = site.Mutator.Mutate (t.Type); - - p[i] = new Parameter (t, "p" + i.ToString ("X"), arguments[i - 1].Modifier, null, loc); + p[i] = new Parameter (targs[i], "p" + i.ToString ("X"), arguments[i - 1].Modifier, null, loc); } - Delegate d = new Delegate (site.NamespaceEntry, site, new TypeExpression (rt, loc), + d = new Delegate (site.NamespaceEntry, site, new TypeExpression (rt, loc), Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED, new MemberName ("Container" + index.ToString ("X")), new ParametersCompiled (p), null); @@ -439,12 +437,101 @@ namespace Mono.CSharp d.Define (); d.Emit (); - var inflated = site.AddDelegate (d); - del_type = new TypeExpression (inflated, loc); + site.AddDelegate (d); + del_type = new TypeExpression (d.CurrentType, loc); + if (targs_for_instance != null) { + del_type_instance_access = null; + } else { + del_type_instance_access = del_type; + } + } else { + d = null; + } + + var site_type_decl = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc); + var field = site_container.CreateCallSiteField (site_type_decl, loc); + if (field == null) + return; + + if (del_type_instance_access == null) { + var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Select (l => l.Type).ToArray ()); + del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc); } - TypeExpr site_type = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc); - return site_type; + FullNamedExpression instanceAccessExprType = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, + new TypeArguments (del_type_instance_access), loc); + + BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void); + + instanceAccessExprType = instanceAccessExprType.ResolveAsTypeStep (bc, false); + if (instanceAccessExprType == null) + return; + + bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired; + + TypeSpec gt; + if (inflate_using_mvar || context_mvars == null) { + gt = site_container.CurrentType; + } else { + gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Select (l => l.Type).ToArray ()); + } + + // When site container already exists the inflated version has to be + // updated manually to contain newly created field + if (gt is InflatedTypeSpec && site_container.Fields.Count > 1) { + var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes; + var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments); + gt.MemberCache.AddMember (field.InflateMember (inflator)); + } + + FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc); + + SymbolWriter.OpenCompilerGeneratedBlock (ec); + + Arguments args = new Arguments (1); + args.Add (new Argument (binder)); + StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args))); + + if (s.Resolve (bc)) { + Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc); + init.Emit (ec); + } + + args = new Arguments (1 + dyn_args_count); + args.Add (new Argument (site_field_expr)); + if (arguments != null) { + int arg_pos = 1; + foreach (Argument a in arguments) { + if (a is NamedArgument) { + // Name is not valid in this context + args.Add (new Argument (a.Expr, a.ArgType)); + } else { + args.Add (a); + } + + if (inflate_using_mvar && a.Type != targs[arg_pos].Type) + a.Expr.Type = targs[arg_pos].Type; + + ++arg_pos; + } + } + + Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc); + if (target != null) + target.Emit (ec); + + SymbolWriter.CloseCompilerGeneratedBlock (ec); + } + + public static MemberAccess GetBinderNamespace (Location loc) + { + return new MemberAccess (new MemberAccess ( + new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "Microsoft", loc), "CSharp", loc), "RuntimeBinder", loc); + } + + protected MemberAccess GetBinder (string name, Location loc) + { + return new MemberAccess (new TypeExpression (binder_type, loc), name, loc); } } @@ -466,12 +553,12 @@ namespace Mono.CSharp public Expression CreateCallSiteBinder (ResolveContext ec, Arguments args) { - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; Arguments binder_args = new Arguments (3); binder_args.Add (new Argument (new BinderFlags (0, this))); - binder_args.Add (new Argument (new StringLiteral (name, loc))); + binder_args.Add (new Argument (new StringLiteral (ec.BuiltinTypes, name, loc))); binder_args.Add (new Argument (new TypeOf (new TypeExpression (ec.CurrentType, loc), loc))); return new Invocation (GetBinder ("IsEvent", loc), binder_args); @@ -496,7 +583,7 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext rc) { - type = InternalType.Dynamic; + type = rc.BuiltinTypes.Dynamic; eclass = ExprClass.Value; condition = condition.Resolve (rc); return this; @@ -669,7 +756,7 @@ namespace Mono.CSharp binder_args.Add (new Argument (new BinderFlags (call_flags, this))); if (is_member_access) - binder_args.Add (new Argument (new StringLiteral (member.Name, member.Location))); + binder_args.Add (new Argument (new StringLiteral (ec.BuiltinTypes, member.Name, member.Location))); if (member != null && member.HasTypeArguments) { TypeArguments ta = member.TypeArguments; @@ -729,7 +816,7 @@ namespace Mono.CSharp Arguments binder_args = new Arguments (4); binder_args.Add (new Argument (new BinderFlags (flags, this))); - binder_args.Add (new Argument (new StringLiteral (name, loc))); + binder_args.Add (new Argument (new StringLiteral (ec.BuiltinTypes, name, loc))); binder_args.Add (new Argument (new TypeOf (new TypeExpression (ec.CurrentType, loc), loc))); binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation (args.CreateDynamicBinderArguments (ec), loc))); @@ -772,7 +859,7 @@ namespace Mono.CSharp public override Expression DoResolveLValue (ResolveContext rc, Expression right_side) { - if (right_side == EmptyExpression.OutAccess.Instance) { + if (right_side == EmptyExpression.OutAccess) { right_side.DoResolveLValue (rc, this); return null; } @@ -830,14 +917,14 @@ namespace Mono.CSharp base.binder = this; } - public static DynamicUnaryConversion CreateIsTrue (Arguments args, Location loc) + public static DynamicUnaryConversion CreateIsTrue (ResolveContext rc, Arguments args, Location loc) { - return new DynamicUnaryConversion ("IsTrue", args, loc) { type = TypeManager.bool_type }; + return new DynamicUnaryConversion ("IsTrue", args, loc) { type = rc.BuiltinTypes.Bool }; } - public static DynamicUnaryConversion CreateIsFalse (Arguments args, Location loc) + public static DynamicUnaryConversion CreateIsFalse (ResolveContext rc, Arguments args, Location loc) { - return new DynamicUnaryConversion ("IsFalse", args, loc) { type = TypeManager.bool_type }; + return new DynamicUnaryConversion ("IsFalse", args, loc) { type = rc.BuiltinTypes.Bool }; } public Expression CreateCallSiteBinder (ResolveContext ec, Arguments args) @@ -858,45 +945,14 @@ namespace Mono.CSharp } } - public class DynamicSiteClass : HoistedStoreyClass + sealed class DynamicSiteClass : HoistedStoreyClass { - // - // Holds the type to access the site. It gets inflated - // by MVARs for generic call sites - // - TypeSpec instance_type; - public DynamicSiteClass (TypeContainer parent, MemberBase host, TypeParameter[] tparams) : base (parent, MakeMemberName (host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC) { - if (tparams != null) { - mutator = new TypeParameterMutator (tparams, CurrentTypeParameters); - } - parent.DynamicSitesCounter++; } - public override TypeSpec AddDelegate (Delegate d) - { - TypeSpec inflated; - - base.AddDelegate (d); - - // Inflated type instance has to be updated manually - if (instance_type is InflatedTypeSpec) { - var inflator = new TypeParameterInflator (instance_type, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); - inflated = (TypeSpec) d.CurrentType.InflateMember (inflator); - instance_type.MemberCache.AddMember (inflated); - - //inflator = new TypeParameterInflator (d.Parent.CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); - //d.Parent.CurrentType.MemberCache.AddMember (d.CurrentType.InflateMember (inflator)); - } else { - inflated = d.CurrentType; - } - - return inflated; - } - public FieldSpec CreateCallSiteField (FullNamedExpression type, Location loc) { int index = fields == null ? 0 : fields.Count; @@ -904,26 +960,7 @@ namespace Mono.CSharp f.Define (); AddField (f); - - var fs = f.Spec; - if (mutator != null) { - // - // Inflate the field, no need to keep it in MemberCache as it's accessed only once - // - var inflator = new TypeParameterInflator (instance_type, spec.MemberDefinition.TypeParameters, instance_type.TypeArguments); - fs = (FieldSpec) fs.InflateMember (inflator); - } - - return fs; - } - - protected override bool DoResolveTypeParameters () - { - instance_type = spec; - if (mutator != null) - instance_type = instance_type.MakeGenericType (mutator.MethodTypeParameters.Select (l => l.Type).ToArray ()); - - return true; + return f.Spec; } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs index 436f16de6..75c9a1fd2 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs @@ -205,7 +205,8 @@ namespace Mono.CSharp { // public virtual TypeExpr ResolveAsTypeTerminal (IMemberContext ec , bool silent) { - int errors = ec.Compiler.Report.Errors; + // FIXME: THIS IS TOO SLOW and it should not be needed either + int errors = ec.Module.Compiler.Report.Errors; FullNamedExpression fne = ResolveAsTypeStep (ec, silent); @@ -214,13 +215,13 @@ namespace Mono.CSharp { TypeExpr te = fne as TypeExpr; if (te == null) { - if (!silent && errors == ec.Compiler.Report.Errors) - fne.Error_UnexpectedKind (ec.Compiler.Report, null, "type", loc); + if (!silent && errors == ec.Module.Compiler.Report.Errors) + fne.Error_UnexpectedKind (ec.Module.Compiler.Report, null, "type", loc); return null; } - if (!te.type.IsAccessible (ec.CurrentType)) { - ec.Compiler.Report.SymbolRelatedToPreviousError (te.Type); + if (!te.type.IsAccessible (ec)) { + ec.Module.Compiler.Report.SymbolRelatedToPreviousError (te.Type); ErrorIsInaccesible (ec, te.Type.GetSignatureForError (), loc); } @@ -238,7 +239,7 @@ namespace Mono.CSharp { if (!silent && !(ec is TypeContainer.BaseContext)) { ObsoleteAttribute obsolete_attr = te.Type.GetAttributeObsolete (); if (obsolete_attr != null && !ec.IsObsolete) { - AttributeTester.Report_ObsoleteMessage (obsolete_attr, te.GetSignatureForError (), Location, ec.Compiler.Report); + AttributeTester.Report_ObsoleteMessage (obsolete_attr, te.GetSignatureForError (), Location, ec.Module.Compiler.Report); } } @@ -247,7 +248,7 @@ namespace Mono.CSharp { public static void ErrorIsInaccesible (IMemberContext rc, string member, Location loc) { - rc.Compiler.Report.Error (122, loc, "`{0}' is inaccessible due to its protection level", member); + rc.Module.Compiler.Report.Error (122, loc, "`{0}' is inaccessible due to its protection level", member); } public void Error_ExpressionMustBeConstant (ResolveContext rc, Location loc, string e_name) @@ -291,8 +292,8 @@ namespace Mono.CSharp { string from_type = type.GetSignatureForError (); string to_type = target.GetSignatureForError (); if (from_type == to_type) { - from_type = string.Format ("{0} [{1}]", from_type, type.MemberDefinition.DeclaringAssembly.FullName); - to_type = string.Format ("{0} [{1}]", to_type, target.MemberDefinition.DeclaringAssembly.FullName); + from_type = type.GetSignatureForErrorIncludingAssemblyName (); + to_type = target.GetSignatureForErrorIncludingAssemblyName (); } if (expl) { @@ -422,7 +423,7 @@ namespace Mono.CSharp { return e; } catch (Exception ex) { - if (loc.IsNull || Report.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled) + if (loc.IsNull || ec.Module.Compiler.Settings.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled) throw; ec.Report.Error (584, loc, "Internal compiler error: {0}", ex.Message); @@ -449,7 +450,7 @@ namespace Mono.CSharp { public Expression ResolveLValue (ResolveContext ec, Expression right_side) { int errors = ec.Report.Errors; - bool out_access = right_side == EmptyExpression.OutAccess.Instance; + bool out_access = right_side == EmptyExpression.OutAccess; Expression e = DoResolveLValue (ec, right_side); @@ -483,7 +484,7 @@ namespace Mono.CSharp { public virtual void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) { - rc.Compiler.Report.Error (182, loc, + rc.Module.Compiler.Report.Error (182, loc, "An attribute argument must be a constant expression, typeof expression or array creation expression"); } @@ -579,7 +580,7 @@ namespace Mono.CSharp { // Lookup type `queried_type' for code in class `container_type' with a qualifier of // `qualifier_type' or null to lookup members in the current class. // - public static Expression MemberLookup (ResolveContext rc, TypeSpec currentType, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc) + public static Expression MemberLookup (IMemberContext rc, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc) { var members = MemberCache.FindMembers (queried_type, name, false); if (members == null) @@ -587,7 +588,6 @@ namespace Mono.CSharp { MemberSpec non_method = null; MemberSpec ambig_non_method = null; - currentType = currentType ?? InternalType.FakeInternalType; do { for (int i = 0; i < members.Count; ++i) { var member = members[i]; @@ -599,8 +599,8 @@ namespace Mono.CSharp { if ((arity > 0 || (restrictions & MemberLookupRestrictions.ExactArity) != 0) && member.Arity != arity) continue; - if (rc != null) { - if (!member.IsAccessible (currentType)) + if (!errorMode) { + if (!member.IsAccessible (rc)) continue; // @@ -617,7 +617,7 @@ namespace Mono.CSharp { // } // } // - if (rc.Compiler.IsRuntimeBinder && !member.DeclaringType.IsAccessible (currentType)) + if (rc.Module.Compiler.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc)) continue; } @@ -631,16 +631,17 @@ namespace Mono.CSharp { if (non_method == null || member is MethodSpec) { non_method = member; - } else if (currentType != null) { + } else if (!errorMode) { ambig_non_method = member; } } if (non_method != null) { if (ambig_non_method != null && rc != null) { - rc.Report.SymbolRelatedToPreviousError (non_method); - rc.Report.SymbolRelatedToPreviousError (ambig_non_method); - rc.Report.Error (229, loc, "Ambiguity between `{0}' and `{1}'", + var report = rc.Module.Compiler.Report; + report.SymbolRelatedToPreviousError (non_method); + report.SymbolRelatedToPreviousError (ambig_non_method); + report.Error (229, loc, "Ambiguity between `{0}' and `{1}'", non_method.GetSignatureForError (), ambig_non_method.GetSignatureForError ()); } @@ -801,34 +802,6 @@ namespace Mono.CSharp { Report.Error (214, loc, "Pointers and fixed size buffers may only be used in an unsafe context"); } - - // - // Returns the size of type `t' if known, otherwise, 0 - // - public static int GetTypeSize (TypeSpec t) - { - if (t == TypeManager.int32_type || - t == TypeManager.uint32_type || - t == TypeManager.float_type) - return 4; - else if (t == TypeManager.int64_type || - t == TypeManager.uint64_type || - t == TypeManager.double_type) - return 8; - else if (t == TypeManager.byte_type || - t == TypeManager.sbyte_type || - t == TypeManager.bool_type) - return 1; - else if (t == TypeManager.short_type || - t == TypeManager.char_type || - t == TypeManager.ushort_type) - return 2; - else if (t == TypeManager.decimal_type) - return 16; - else - return 0; - } - protected void Error_CannotModifyIntermediateExpressionValue (ResolveContext ec) { ec.Report.SymbolRelatedToPreviousError (type); @@ -846,25 +819,27 @@ namespace Mono.CSharp { // protected Expression ConvertExpressionToArrayIndex (ResolveContext ec, Expression source) { - if (source.type == InternalType.Dynamic) { + var btypes = ec.BuiltinTypes; + + if (source.type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments args = new Arguments (1); args.Add (new Argument (source)); - return new DynamicConversion (TypeManager.int32_type, CSharpBinderFlags.ConvertArrayIndex, args, loc).Resolve (ec); + return new DynamicConversion (btypes.Int, CSharpBinderFlags.ConvertArrayIndex, args, loc).Resolve (ec); } Expression converted; using (ec.Set (ResolveContext.Options.CheckedScope)) { - converted = Convert.ImplicitConversion (ec, source, TypeManager.int32_type, source.loc); + converted = Convert.ImplicitConversion (ec, source, btypes.Int, source.loc); if (converted == null) - converted = Convert.ImplicitConversion (ec, source, TypeManager.uint32_type, source.loc); + converted = Convert.ImplicitConversion (ec, source, btypes.UInt, source.loc); if (converted == null) - converted = Convert.ImplicitConversion (ec, source, TypeManager.int64_type, source.loc); + converted = Convert.ImplicitConversion (ec, source, btypes.Long, source.loc); if (converted == null) - converted = Convert.ImplicitConversion (ec, source, TypeManager.uint64_type, source.loc); + converted = Convert.ImplicitConversion (ec, source, btypes.ULong, source.loc); if (converted == null) { - source.Error_ValueCannotBeConverted (ec, source.loc, TypeManager.int32_type, false); + source.Error_ValueCannotBeConverted (ec, source.loc, btypes.Int, false); return null; } } @@ -877,10 +852,10 @@ namespace Mono.CSharp { Error_NegativeArrayIndex (ec, source.loc); // No conversion needed to array index - if (converted.Type == TypeManager.int32_type) + if (converted.Type.BuiltinType == BuiltinTypeSpec.Type.Int) return converted; - return new ArrayIndexCast (converted).Resolve (ec); + return new ArrayIndexCast (converted, btypes.Int).Resolve (ec); } // @@ -1104,113 +1079,50 @@ namespace Mono.CSharp { } // - // Used for predefined class library user casts (no obsolete check, etc.) + // Used for predefined type user operator (no obsolete check, etc.) // - public class OperatorCast : TypeCast { - MethodSpec conversion_operator; - - public OperatorCast (Expression child, TypeSpec target_type) - : this (child, target_type, false) - { - } - - public OperatorCast (Expression child, TypeSpec target_type, bool find_explicit) - : base (child, target_type) - { - conversion_operator = GetConversionOperator (find_explicit); - if (conversion_operator == null) - throw new InternalErrorException ("Outer conversion routine is out of sync"); - } - - // Returns the implicit operator that converts from - // 'child.Type' to our target type (type) - MethodSpec GetConversionOperator (bool find_explicit) - { - var op = find_explicit ? Operator.OpType.Explicit : Operator.OpType.Implicit; - - var mi = MemberCache.GetUserOperator (child.Type, op, true); - if (mi == null){ - mi = MemberCache.GetUserOperator (type, op, true); - } - - foreach (MethodSpec oper in mi) { - if (oper.ReturnType != type) - continue; - - if (oper.Parameters.Types [0] == child.Type) - return oper; - } - - return null; - } + public class OperatorCast : TypeCast + { + readonly MethodSpec conversion_operator; - public override void Emit (EmitContext ec) - { - child.Emit (ec); - ec.Emit (OpCodes.Call, conversion_operator); - } - } - - /// - /// This is a numeric cast to a Decimal - /// - public class CastToDecimal : OperatorCast { - public CastToDecimal (Expression child) - : this (child, false) + public OperatorCast (Expression expr, TypeSpec target_type) + : this (expr, target_type, target_type, false) { } - - public CastToDecimal (Expression child, bool find_explicit) - : base (child, TypeManager.decimal_type, find_explicit) + + public OperatorCast (Expression expr, TypeSpec target_type, bool find_explicit) + : this (expr, target_type, target_type, find_explicit) { } - } - - /// - /// This is an explicit numeric cast from a Decimal - /// - public class CastFromDecimal : TypeCast - { - static Dictionary operators; - - public CastFromDecimal (Expression child, TypeSpec return_type) - : base (child, return_type) + + public OperatorCast (Expression expr, TypeSpec declaringType, TypeSpec returnType, bool isExplicit) + : base (expr, returnType) { - if (child.Type != TypeManager.decimal_type) - throw new ArgumentException ("Expected decimal child " + child.Type.GetSignatureForError ()); - } + var op = isExplicit ? Operator.OpType.Explicit : Operator.OpType.Implicit; + var mi = MemberCache.GetUserOperator (declaringType, op, true); - // Returns the explicit operator that converts from an - // express of type System.Decimal to 'type'. - public Expression Resolve () - { - if (operators == null) { - var all_oper = MemberCache.GetUserOperator (TypeManager.decimal_type, Operator.OpType.Explicit, true); + if (mi != null) { + foreach (MethodSpec oper in mi) { + if (oper.ReturnType != returnType) + continue; - operators = new Dictionary (); - foreach (MethodSpec oper in all_oper) { - AParametersCollection pd = oper.Parameters; - if (pd.Types [0] == TypeManager.decimal_type) - operators.Add (oper.ReturnType, oper); + if (oper.Parameters.Types[0] == expr.Type) { + conversion_operator = oper; + return; + } } } - return operators.ContainsKey (type) ? this : null; + throw new InternalErrorException ("Missing predefined user operator between `{0}' and `{1}'", + returnType.GetSignatureForError (), expr.Type.GetSignatureForError ()); } public override void Emit (EmitContext ec) { child.Emit (ec); - - ec.Emit (OpCodes.Call, operators [type]); - } - - public static void Reset () - { - operators = null; + ec.Emit (OpCodes.Call, conversion_operator); } } - // // Constant specialization of EmptyCast. @@ -1219,7 +1131,7 @@ namespace Mono.CSharp { // public class EmptyConstantCast : Constant { - public Constant child; + public readonly Constant child; public EmptyConstantCast (Constant child, TypeSpec type) : base (child.Location) @@ -1273,11 +1185,6 @@ namespace Mono.CSharp { get { return child.IsZeroInteger; } } - protected override Expression DoResolve (ResolveContext rc) - { - return this; - } - public override void Emit (EmitContext ec) { child.Emit (ec); @@ -1307,12 +1214,21 @@ namespace Mono.CSharp { return child.GetValueAsLiteral (); } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec target_type) + public override long GetValueAsLong () { + return child.GetValueAsLong (); + } + + public override Constant ConvertImplicitly (TypeSpec target_type) + { + if (type == target_type) + return this; + // FIXME: Do we need to check user conversions? if (!Convert.ImplicitStandardConversionExists (this, target_type)) return null; - return child.ConvertImplicitly (rc, target_type); + + return child.ConvertImplicitly (target_type); } } @@ -1327,6 +1243,8 @@ namespace Mono.CSharp { : base (child.Location) { this.Child = child; + + this.eclass = ExprClass.Value; this.type = enum_type; } @@ -1335,13 +1253,6 @@ namespace Mono.CSharp { { } - protected override Expression DoResolve (ResolveContext rc) - { - Child = Child.Resolve (rc); - this.eclass = ExprClass.Value; - return this; - } - public override void Emit (EmitContext ec) { Child.Emit (ec); @@ -1391,6 +1302,11 @@ namespace Mono.CSharp { return Child.GetValueAsLiteral (); } + public override long GetValueAsLong () + { + return Child.GetValueAsLong (); + } + public EnumConstant Increment() { return new EnumConstant (((IntegralConstant) Child).Increment (), type); @@ -1420,7 +1336,7 @@ namespace Mono.CSharp { return Child.ConvertExplicitly (in_checked_context, target_type); } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec type) + public override Constant ConvertImplicitly (TypeSpec type) { if (this.type == type) { return this; @@ -1430,7 +1346,7 @@ namespace Mono.CSharp { return null; } - return Child.ConvertImplicitly (rc, type); + return Child.ConvertImplicitly (type); } } @@ -1459,7 +1375,7 @@ namespace Mono.CSharp { public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) { // Only boxing to object type is supported - if (targetType != TypeManager.object_type) { + if (targetType.BuiltinType != BuiltinTypeSpec.Type.Object) { base.EncodeAttributeValue (rc, enc, targetType); return; } @@ -1479,8 +1395,8 @@ namespace Mono.CSharp { { // boxing is side-effectful, since it involves runtime checks, except when boxing to Object or ValueType // so, we need to emit the box+pop instructions in most cases - if (TypeManager.IsStruct (child.Type) && - (type == TypeManager.object_type || type == TypeManager.value_type)) + if (child.Type.IsStruct && + (type.BuiltinType == BuiltinTypeSpec.Type.Object || type.BuiltinType == BuiltinTypeSpec.Type.ValueType)) child.EmitSideEffect (ec); else base.EmitSideEffect (ec); @@ -1835,9 +1751,9 @@ namespace Mono.CSharp { this.orig_expr = orig_expr; } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec target_type) + public override Constant ConvertImplicitly (TypeSpec target_type) { - Constant c = base.ConvertImplicitly (rc, target_type); + Constant c = base.ConvertImplicitly (target_type); if (c != null) c = new ReducedConstantExpression (c, orig_expr); @@ -1867,6 +1783,9 @@ namespace Mono.CSharp { { this.orig_expr = orig; this.stm = stm; + this.eclass = stm.eclass; + this.type = stm.Type; + this.loc = orig.Location; } @@ -1877,8 +1796,6 @@ namespace Mono.CSharp { protected override Expression DoResolve (ResolveContext ec) { - eclass = stm.eclass; - type = stm.Type; return this; } @@ -2195,7 +2112,7 @@ namespace Mono.CSharp { if (ec.CurrentMemberDefinition != null) { MemberCore mc = ec.CurrentMemberDefinition.Parent.GetDefinition (Name); if (mc != null) { - Error_UnexpectedKind (ec.Compiler.Report, mc, "type", GetMemberType (mc), loc); + Error_UnexpectedKind (ec.Module.Compiler.Report, mc, "type", GetMemberType (mc), loc); return; } } @@ -2226,7 +2143,7 @@ namespace Mono.CSharp { FullNamedExpression retval = ec.LookupNamespaceOrType (Name, -System.Math.Max (1, Arity), loc, true); if (retval != null) { - Error_TypeArgumentsCannotBeUsed (ec.Compiler.Report, loc, retval.Type, Arity); + Error_TypeArgumentsCannotBeUsed (ec.Module.Compiler.Report, loc, retval.Type, Arity); /* var te = retval as TypeExpr; if (HasTypeArguments && te != null && !te.Type.IsGeneric) @@ -2237,7 +2154,7 @@ namespace Mono.CSharp { return; } - NamespaceEntry.Error_NamespaceNotFound (loc, Name, ec.Compiler.Report); + NamespaceEntry.Error_NamespaceNotFound (loc, Name, ec.Module.Compiler.Report); } protected override Expression DoResolve (ResolveContext ec) @@ -2252,7 +2169,7 @@ namespace Mono.CSharp { public override FullNamedExpression ResolveAsTypeStep (IMemberContext ec, bool silent) { - int errors = ec.Compiler.Report.Errors; + int errors = ec.Module.Compiler.Report.Errors; FullNamedExpression fne = ec.LookupNamespaceOrType (Name, Arity, loc, /*ignore_cs0104=*/ false); if (fne != null) { @@ -2272,20 +2189,20 @@ namespace Mono.CSharp { return fne; } - if (Arity == 0 && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) { + if (Arity == 0 && Name == "dynamic" && ec.Module.Compiler.Settings.Version > LanguageVersion.V_3) { if (!ec.Module.PredefinedAttributes.Dynamic.IsDefined) { - ec.Compiler.Report.Error (1980, Location, + ec.Module.Compiler.Report.Error (1980, Location, "Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?", ec.Module.PredefinedAttributes.Dynamic.GetSignatureForError ()); } - return new DynamicTypeExpr (loc); + return new DynamicTypeExpr (loc).ResolveAsTypeStep (ec, silent); } if (fne != null) return fne; - if (silent || errors != ec.Compiler.Report.Errors) + if (silent || errors != ec.Module.Compiler.Report.Errors) return null; Error_TypeOrNamespaceNotFound (ec); @@ -2330,9 +2247,8 @@ namespace Mono.CSharp { // Stage 2: Lookup members if we are inside a type up to top level type for nested types // TypeSpec member_type = rc.CurrentType; - TypeSpec current_type = member_type; for (; member_type != null; member_type = member_type.DeclaringType) { - e = MemberLookup (errorMode ? null : rc, current_type, member_type, Name, lookup_arity, restrictions, loc); + e = MemberLookup (rc, errorMode, member_type, Name, lookup_arity, restrictions, loc); if (e == null) continue; @@ -2375,12 +2291,12 @@ namespace Mono.CSharp { // Break as there is no other overload available anyway if ((restrictions & MemberLookupRestrictions.ReadAccess) != 0) { - if (!pe.PropertyInfo.HasGet || !pe.PropertyInfo.Get.IsAccessible (current_type)) + if (!pe.PropertyInfo.HasGet || !pe.PropertyInfo.Get.IsAccessible (rc)) break; pe.Getter = pe.PropertyInfo.Get; } else { - if (!pe.PropertyInfo.HasSet || !pe.PropertyInfo.Set.IsAccessible (current_type)) + if (!pe.PropertyInfo.HasSet || !pe.PropertyInfo.Set.IsAccessible (rc)) break; pe.Setter = pe.PropertyInfo.Set; @@ -2425,8 +2341,8 @@ namespace Mono.CSharp { return null; } - if (RootContext.EvalMode) { - var fi = Evaluator.LookupField (Name); + if (rc.Module.Evaluator != null) { + var fi = rc.Module.Evaluator.LookupField (Name); if (fi != null) return new FieldExpr (fi.Item1, loc); } @@ -2653,7 +2569,7 @@ namespace Mono.CSharp { } if (targs != null) - method = method.MakeGenericMethod (targs); + method = method.MakeGenericMethod (rc, targs); } // @@ -2671,17 +2587,21 @@ namespace Mono.CSharp { if (InstanceExpression == null) return; - if ((member.Modifiers & Modifiers.AccessibilityMask) == Modifiers.PROTECTED && !(InstanceExpression is This)) { + if ((member.Modifiers & Modifiers.PROTECTED) != 0 && !(InstanceExpression is This)) { var ct = rc.CurrentType; var expr_type = InstanceExpression.Type; - if (ct != expr_type) { - expr_type = expr_type.GetDefinition (); - if (ct != expr_type && !IsSameOrBaseQualifier (ct, expr_type)) { - rc.Report.SymbolRelatedToPreviousError (member); - rc.Report.Error (1540, loc, - "Cannot access protected member `{0}' via a qualifier of type `{1}'. The qualifier must be of type `{2}' or derived from it", - member.GetSignatureForError (), expr_type.GetSignatureForError (), ct.GetSignatureForError ()); - } + if (ct == expr_type) + return; + + if ((member.Modifiers & Modifiers.INTERNAL) != 0 && member.DeclaringType.MemberDefinition.IsInternalAsPublic (ct.MemberDefinition.DeclaringAssembly)) + return; + + expr_type = expr_type.GetDefinition (); + if (ct != expr_type && !IsSameOrBaseQualifier (ct, expr_type)) { + rc.Report.SymbolRelatedToPreviousError (member); + rc.Report.Error (1540, loc, + "Cannot access protected member `{0}' via a qualifier of type `{1}'. The qualifier must be of type `{2}' or derived from it", + member.GetSignatureForError (), expr_type.GetSignatureForError (), ct.GetSignatureForError ()); } } } @@ -2820,7 +2740,7 @@ namespace Mono.CSharp { me.ResolveInstanceExpression (rc, rhs); var fe = me as FieldExpr; - if (fe != null && fe.IsMarshalByRefAccess ()) { + if (fe != null && fe.IsMarshalByRefAccess (rc)) { rc.Report.SymbolRelatedToPreviousError (me.DeclaringType); rc.Report.Warning (1690, 1, loc, "Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class", @@ -3101,7 +3021,7 @@ namespace Mono.CSharp { return null; } - if (best_candidate.IsConditionallyExcluded (loc)) + if (best_candidate.IsConditionallyExcluded (ec.Module.Compiler, loc)) ec.Report.Error (765, loc, "Partial methods with only a defining declaration or removed conditional methods cannot be used in an expression tree"); @@ -3437,11 +3357,11 @@ namespace Mono.CSharp { // // If argument is an anonymous function // - if (argument_type == InternalType.AnonymousMethod && RootContext.Version > LanguageVersion.ISO_2) { + if (argument_type == InternalType.AnonymousMethod && ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2) { // // p and q are delegate types or expression tree types // - if (p.GetDefinition () == TypeManager.expression_type || q.GetDefinition () == TypeManager.expression_type) { + if (p.IsExpressionTreeType || q.IsExpressionTreeType) { if (q.MemberDefinition != p.MemberDefinition) { return 0; } @@ -3453,8 +3373,8 @@ namespace Mono.CSharp { p = TypeManager.GetTypeArguments (p)[0]; } - var p_m = Delegate.GetInvokeMethod (ec.Compiler, p); - var q_m = Delegate.GetInvokeMethod (ec.Compiler, q); + var p_m = Delegate.GetInvokeMethod (p); + var q_m = Delegate.GetInvokeMethod (q); // // With identical parameter lists @@ -3468,15 +3388,15 @@ namespace Mono.CSharp { // // if p is void returning, and q has a return type Y, then C2 is the better conversion. // - if (p == TypeManager.void_type) { - return q != TypeManager.void_type ? 2 : 0; + if (p.Kind == MemberKind.Void) { + return q.Kind != MemberKind.Void ? 2 : 0; } // // if p has a return type Y, and q is void returning, then C1 is the better conversion. // - if (q == TypeManager.void_type) { - return p != TypeManager.void_type ? 1: 0; + if (q.Kind == MemberKind.Void) { + return p.Kind != MemberKind.Void ? 1: 0; } } else { if (argument_type == p) @@ -3497,40 +3417,64 @@ namespace Mono.CSharp { if (p == null || q == null) throw new InternalErrorException ("BetterTypeConversion got a null conversion"); - if (p == TypeManager.int32_type) { - if (q == TypeManager.uint32_type || q == TypeManager.uint64_type) + switch (p.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + if (q.BuiltinType == BuiltinTypeSpec.Type.UInt || q.BuiltinType == BuiltinTypeSpec.Type.ULong) return 1; - } else if (p == TypeManager.int64_type) { - if (q == TypeManager.uint64_type) + break; + case BuiltinTypeSpec.Type.Long: + if (q.BuiltinType == BuiltinTypeSpec.Type.ULong) return 1; - } else if (p == TypeManager.sbyte_type) { - if (q == TypeManager.byte_type || q == TypeManager.ushort_type || - q == TypeManager.uint32_type || q == TypeManager.uint64_type) + break; + case BuiltinTypeSpec.Type.SByte: + switch (q.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.ULong: return 1; - } else if (p == TypeManager.short_type) { - if (q == TypeManager.ushort_type || q == TypeManager.uint32_type || - q == TypeManager.uint64_type) + } + break; + case BuiltinTypeSpec.Type.Short: + switch (q.BuiltinType) { + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.ULong: return 1; - } else if (p == InternalType.Dynamic) { + } + break; + case BuiltinTypeSpec.Type.Dynamic: // Dynamic is never better return 2; } - if (q == TypeManager.int32_type) { - if (p == TypeManager.uint32_type || p == TypeManager.uint64_type) + switch (q.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + if (p.BuiltinType == BuiltinTypeSpec.Type.UInt || p.BuiltinType == BuiltinTypeSpec.Type.ULong) return 2; - } if (q == TypeManager.int64_type) { - if (p == TypeManager.uint64_type) + break; + case BuiltinTypeSpec.Type.Long: + if (p.BuiltinType == BuiltinTypeSpec.Type.ULong) return 2; - } else if (q == TypeManager.sbyte_type) { - if (p == TypeManager.byte_type || p == TypeManager.ushort_type || - p == TypeManager.uint32_type || p == TypeManager.uint64_type) + break; + case BuiltinTypeSpec.Type.SByte: + switch (p.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.ULong: return 2; - } if (q == TypeManager.short_type) { - if (p == TypeManager.ushort_type || p == TypeManager.uint32_type || - p == TypeManager.uint64_type) + } + break; + case BuiltinTypeSpec.Type.Short: + switch (p.BuiltinType) { + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.ULong: return 2; - } else if (q == InternalType.Dynamic) { + } + break; + case BuiltinTypeSpec.Type.Dynamic: // Dynamic is never better return 1; } @@ -3871,7 +3815,7 @@ namespace Mono.CSharp { if (g_args_count != type_arguments.Count) return int.MaxValue - 20000 + System.Math.Abs (type_arguments.Count - g_args_count); - ms = ms.MakeGenericMethod (type_arguments.Arguments); + ms = ms.MakeGenericMethod (ec, type_arguments.Arguments); } else { // TODO: It should not be here (we don't know yet whether any argument is lambda) but // for now it simplifies things. I should probably add a callback to ResolveContext @@ -3888,7 +3832,7 @@ namespace Mono.CSharp { return ti.InferenceScore - 20000; if (i_args.Length != 0) { - ms = ms.MakeGenericMethod (i_args); + ms = ms.MakeGenericMethod (ec, i_args); } cc.IgnoreInferredDynamic = true; @@ -3911,7 +3855,7 @@ namespace Mono.CSharp { // if (candidate != pm) { MethodSpec override_ms = (MethodSpec) pm; - var inflator = new TypeParameterInflator (ms.DeclaringType, override_ms.GenericDefinition.TypeParameters, ms.TypeArguments); + var inflator = new TypeParameterInflator (ec, ms.DeclaringType, override_ms.GenericDefinition.TypeParameters, ms.TypeArguments); returnType = inflator.Inflate (returnType); } else { returnType = ms.ReturnType; @@ -3949,7 +3893,7 @@ namespace Mono.CSharp { // // LAMESPEC: No idea what the exact rules are for System.Reflection.Missing.Value instead of null // - if (e == EmptyExpression.MissingValue && ptypes[i] == TypeManager.object_type || ptypes[i] == InternalType.Dynamic) { + if (e == EmptyExpression.MissingValue && ptypes[i].BuiltinType == BuiltinTypeSpec.Type.Object || ptypes[i].BuiltinType == BuiltinTypeSpec.Type.Dynamic) { e = new MemberAccess (new MemberAccess (new MemberAccess ( new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Reflection", loc), "Missing", loc), "Value", loc); } else { @@ -3981,8 +3925,8 @@ namespace Mono.CSharp { // var at = a.Type; if (at == pt || TypeSpecComparer.IsEqual (at, pt) || - Convert.ImplicitReferenceConversionExists (a.Expr, pt) || - Convert.ImplicitBoxingConversion (EmptyExpression.Null, at, pt) != null) { + Convert.ImplicitReferenceConversionExists (at, pt) || + Convert.ImplicitBoxingConversion (null, at, pt) != null) { score = 0; continue; } @@ -4057,7 +4001,7 @@ namespace Mono.CSharp { // // Using dynamic for ref/out parameter can still succeed at runtime // - if (argument.Type == InternalType.Dynamic && argument.Modifier == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) + if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && argument.Modifier == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; return 2; @@ -4068,14 +4012,14 @@ namespace Mono.CSharp { // // Using dynamic for ref/out parameter can still succeed at runtime // - if (argument.Type == InternalType.Dynamic && argument.Modifier == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) + if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && argument.Modifier == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; return 1; } } else { - if (argument.Type == InternalType.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0) + if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; // @@ -4160,7 +4104,6 @@ namespace Mono.CSharp { Arguments candidate_args = args; bool error_mode = false; - var current_type = rc.CurrentType; MemberSpec invocable_member = null; // Be careful, cannot return until error reporter is restored @@ -4183,10 +4126,10 @@ namespace Mono.CSharp { continue; if (!error_mode) { - if (!member.IsAccessible (current_type)) + if (!member.IsAccessible (rc)) continue; - if (rc.Compiler.IsRuntimeBinder && !member.DeclaringType.IsAccessible (current_type)) + if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc)) continue; } @@ -4454,9 +4397,8 @@ namespace Mono.CSharp { string p2 = TypeManager.CSharpName (paramType); if (p1 == p2) { - ec.Report.ExtraInformation (loc, "(equally named types possibly from different assemblies in previous "); - ec.Report.SymbolRelatedToPreviousError (a.Expr.Type); - ec.Report.SymbolRelatedToPreviousError (paramType); + p1 = a.Type.GetSignatureForErrorIncludingAssemblyName (); + p2 = paramType.GetSignatureForErrorIncludingAssemblyName (); } ec.Report.Error (1503, loc, @@ -4490,7 +4432,7 @@ namespace Mono.CSharp { int unexpanded_count = ((IParametersMember) best_candidate).Parameters.HasParams ? pm.Parameters.Count - 1 : pm.Parameters.Count; if (pm.Parameters.Count == arg_count || params_expanded || unexpanded_count == arg_count) { // Reject any inaccessible member - if (!best_candidate.IsAccessible (rc.CurrentType) || !best_candidate.DeclaringType.IsAccessible (rc.CurrentType)) { + if (!best_candidate.IsAccessible (rc) || !best_candidate.DeclaringType.IsAccessible (rc)) { rc.Report.SymbolRelatedToPreviousError (best_candidate); Expression.ErrorIsInaccesible (rc, best_candidate.GetSignatureForError (), loc); return; @@ -4610,10 +4552,10 @@ namespace Mono.CSharp { } } - if (a.Expr.Type == InternalType.Dynamic) + if (a.Expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) continue; - if ((restrictions & Restrictions.CovariantDelegate) != 0 && !Delegate.IsTypeCovariant (a.Expr, pt)) { + if ((restrictions & Restrictions.CovariantDelegate) != 0 && !Delegate.IsTypeCovariant (ec, a.Expr.Type, pt)) { custom_errors.NoArgumentMatch (ec, member); return false; } @@ -4687,7 +4629,7 @@ namespace Mono.CSharp { if (type_arguments == null && member.IsGeneric) { var ms = (MethodSpec) member; foreach (var ta in ms.TypeArguments) { - if (!ta.IsAccessible (ec.CurrentType)) { + if (!ta.IsAccessible (ec)) { ec.Report.SymbolRelatedToPreviousError (ta); Expression.ErrorIsInaccesible (ec, member.GetSignatureForError (), loc); break; @@ -4738,7 +4680,7 @@ namespace Mono.CSharp { var c = constant.GetConstant (rc); // Creates reference expression to the constant value - return Constant.CreateConstant (rc, constant.MemberType, c.GetValue (), loc); + return Constant.CreateConstant (constant.MemberType, c.GetValue (), loc); } public override void Emit (EmitContext ec) @@ -4837,12 +4779,12 @@ namespace Mono.CSharp { return TypeManager.GetFullNameSignature (spec); } - public bool IsMarshalByRefAccess () + public bool IsMarshalByRefAccess (ResolveContext rc) { // Checks possible ldflda of field access expression - return !spec.IsStatic && TypeManager.IsValueType (spec.MemberType) && - TypeSpec.IsBaseClass (spec.DeclaringType, TypeManager.mbr_type, false) && - !(InstanceExpression is This); + return !spec.IsStatic && TypeManager.IsValueType (spec.MemberType) && !(InstanceExpression is This) && + rc.Module.PredefinedTypes.MarshalByRefObject.Define () && + TypeSpec.IsBaseClass (spec.DeclaringType, rc.Module.PredefinedTypes.MarshalByRefObject.TypeSpec, false); } public void SetHasAddressTaken () @@ -4889,7 +4831,7 @@ namespace Mono.CSharp { if (lvalue_instance) { using (ec.With (ResolveContext.Options.DoFlowAnalysis, false)) { - bool out_access = rhs == EmptyExpression.OutAccess.Instance || rhs == EmptyExpression.LValueMemberOutAccess; + bool out_access = rhs == EmptyExpression.OutAccess || rhs == EmptyExpression.LValueMemberOutAccess; Expression right_side = out_access ? EmptyExpression.LValueMemberOutAccess : EmptyExpression.LValueMemberAccess; @@ -4972,7 +4914,7 @@ namespace Mono.CSharp { Expression Report_AssignToReadonly (ResolveContext ec, Expression right_side) { int i = 0; - if (right_side == EmptyExpression.OutAccess.Instance || right_side == EmptyExpression.LValueMemberOutAccess) + if (right_side == EmptyExpression.OutAccess || right_side == EmptyExpression.LValueMemberOutAccess) i += 1; if (IsStatic) i += 2; @@ -4992,7 +4934,7 @@ namespace Mono.CSharp { spec.MemberDefinition.SetIsAssigned (); - if ((right_side == EmptyExpression.UnaryAddress || right_side == EmptyExpression.OutAccess.Instance) && + if ((right_side == EmptyExpression.UnaryAddress || right_side == EmptyExpression.OutAccess) && (spec.Modifiers & Modifiers.VOLATILE) != 0) { ec.Report.Warning (420, 1, loc, "`{0}': A volatile field references will not be treated as volatile", @@ -5018,8 +4960,7 @@ namespace Mono.CSharp { } } - if (right_side == EmptyExpression.OutAccess.Instance && - !IsStatic && !(InstanceExpression is This) && TypeManager.mbr_type != null && TypeSpec.IsBaseClass (spec.DeclaringType, TypeManager.mbr_type, false)) { + if (right_side == EmptyExpression.OutAccess && IsMarshalByRefAccess (ec)) { ec.Report.SymbolRelatedToPreviousError (spec.DeclaringType); ec.Report.Warning (197, 1, loc, "Passing `{0}' as ref or out or taking its address may cause a runtime exception because it is a field of a marshal-by-reference class", @@ -5083,7 +5024,7 @@ namespace Mono.CSharp { EmitInstance (ec, false); // Optimization for build-in types - if (TypeManager.IsStruct (type) && type == ec.MemberContext.CurrentType && InstanceExpression.Type == type) { + if (type.IsStruct && type == ec.CurrentType && InstanceExpression.Type == type) { ec.EmitLoadFromPtr (type); } else { var ff = spec as FixedFieldSpec; @@ -5324,7 +5265,7 @@ namespace Mono.CSharp { bool IsSingleDimensionalArrayLength () { - if (best_candidate.DeclaringType != TypeManager.array_type || !best_candidate.HasGet || Name != "Length") + if (best_candidate.DeclaringType.BuiltinType != BuiltinTypeSpec.Type.Array || !best_candidate.HasGet || Name != "Length") return false; ArrayContainer ac = InstanceExpression.Type as ArrayContainer; @@ -5475,7 +5416,7 @@ namespace Mono.CSharp { public override Expression DoResolveLValue (ResolveContext ec, Expression right_side) { - if (right_side == EmptyExpression.OutAccess.Instance) { + if (right_side == EmptyExpression.OutAccess) { // TODO: best_candidate can be null at this point INamedBlockVariable variable = null; if (best_candidate != null && ec.CurrentBlock.ParametersBlock.TopBlock.GetLocalName (best_candidate.Name, ec.CurrentBlock, ref variable) && variable is Linq.RangeVariable) { @@ -5531,7 +5472,7 @@ namespace Mono.CSharp { best_candidate.GetSignatureForError ()); return false; } - } else if (!best_candidate.Get.IsAccessible (rc.CurrentType)) { + } else if (!best_candidate.Get.IsAccessible (rc)) { if (best_candidate.HasDifferentAccessibility) { rc.Report.SymbolRelatedToPreviousError (best_candidate.Get); rc.Report.Error (271, loc, "The property or indexer `{0}' cannot be used in this context because the get accessor is inaccessible", @@ -5558,7 +5499,7 @@ namespace Mono.CSharp { return false; } - if (!best_candidate.Set.IsAccessible (rc.CurrentType)) { + if (!best_candidate.Set.IsAccessible (rc)) { if (best_candidate.HasDifferentAccessibility) { rc.Report.SymbolRelatedToPreviousError (best_candidate.Set); rc.Report.Error (272, loc, "The property or indexer `{0}' cannot be used in this context because the set accessor is inaccessible", @@ -5888,7 +5829,7 @@ namespace Mono.CSharp { throw new InternalErrorException ("An implicitly typed local variable could not be redefined"); type = right_side.Type; - if (type == InternalType.Null || type == TypeManager.void_type || type == InternalType.AnonymousMethod || type == InternalType.MethodGroup) { + if (type == InternalType.NullLiteral || type.Kind == MemberKind.Void || type == InternalType.AnonymousMethod || type == InternalType.MethodGroup) { ec.Report.Error (815, loc, "An implicitly typed local variable declaration cannot be initialized with `{0}'", type.GetSignatureForError ()); @@ -5901,10 +5842,10 @@ namespace Mono.CSharp { protected override void Error_TypeOrNamespaceNotFound (IMemberContext ec) { - if (RootContext.Version < LanguageVersion.V_3) + if (ec.Module.Compiler.Settings.Version < LanguageVersion.V_3) base.Error_TypeOrNamespaceNotFound (ec); else - ec.Compiler.Report.Error (825, loc, "The contextual keyword `var' may only appear within a local variable declaration"); + ec.Module.Compiler.Report.Error (825, loc, "The contextual keyword `var' may only appear within a local variable declaration"); } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/enum.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/enum.cs index c1a8aa031..ea6f2a226 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/enum.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/enum.cs @@ -46,10 +46,20 @@ namespace Mono.CSharp { static bool IsValidEnumType (TypeSpec t) { - return (t == TypeManager.int32_type || t == TypeManager.uint32_type || t == TypeManager.int64_type || - t == TypeManager.byte_type || t == TypeManager.sbyte_type || t == TypeManager.short_type || - t == TypeManager.ushort_type || t == TypeManager.uint64_type || t == TypeManager.char_type || - TypeManager.IsEnumType (t)); + switch (t.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Char: + return true; + default: + return t.IsEnum; + } } public override Constant ConvertInitializer (ResolveContext rc, Constant expr) @@ -69,7 +79,7 @@ namespace Mono.CSharp { if (expr == null) expr = New.Constantify (underlying, Location); - return new EnumConstant (expr, MemberType).Resolve (rc); + return new EnumConstant (expr, MemberType); } public override bool Define () @@ -100,7 +110,7 @@ namespace Mono.CSharp { // // Implicit enum member initializer, used when no constant value is provided // - class ImplicitInitializer : Expression + sealed class ImplicitInitializer : Expression { readonly EnumMember prev; readonly EnumMember current; @@ -120,18 +130,18 @@ namespace Mono.CSharp { { // We are the first member if (prev == null) { - return New.Constantify (current.Parent.Definition, Location).Resolve (rc); + return New.Constantify (current.Parent.Definition, Location); } var c = ((ConstSpec) prev.Spec).GetConstant (rc) as EnumConstant; try { - return c.Increment ().Resolve (rc); + return c.Increment (); } catch (OverflowException) { rc.Report.Error (543, current.Location, "The enumerator value `{0}' is outside the range of enumerator underlying type `{1}'", current.GetSignatureForError (), ((Enum) current.Parent).UnderlyingType.GetSignatureForError ()); - return New.Constantify (current.Parent.Definition, current.Location).Resolve (rc); + return New.Constantify (current.Parent.Definition, current.Location); } } @@ -189,6 +199,11 @@ namespace Mono.CSharp { #endregion + public override void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); + } + public void AddEnumMember (EnumMember em) { if (em.Name == UnderlyingValueField) { @@ -208,7 +223,7 @@ namespace Mono.CSharp { protected override bool DefineNestedTypes () { - ((EnumSpec) spec).UnderlyingType = base_type_expr == null ? TypeManager.int32_type : base_type_expr.Type; + ((EnumSpec) spec).UnderlyingType = base_type_expr == null ? Compiler.BuiltinTypes.Int : base_type_expr.Type; TypeBuilder.DefineField (UnderlyingValueField, UnderlyingType.GetMetaInfo (), FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); @@ -239,7 +254,7 @@ namespace Mono.CSharp { protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class) { - base_type = TypeManager.enum_type; + base_type = Compiler.BuiltinTypes.Enum; base_class = base_type_expr; return null; } @@ -249,19 +264,17 @@ namespace Mono.CSharp { if (!base.VerifyClsCompliance ()) return false; - if (UnderlyingType == TypeManager.uint32_type || - UnderlyingType == TypeManager.uint64_type || - UnderlyingType == TypeManager.ushort_type) { - Report.Warning (3009, 1, Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (UnderlyingType)); + switch (UnderlyingType.BuiltinType) { + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.UShort: + Report.Warning (3009, 1, Location, "`{0}': base type `{1}' is not CLS-compliant", + GetSignatureForError (), TypeManager.CSharpName (UnderlyingType)); + break; } return true; } - - public override void Accept (StructuralVisitor visitor) - { - visitor.Visit (this); - } } class EnumSpec : TypeSpec @@ -290,5 +303,22 @@ namespace Mono.CSharp { { return ((EnumSpec) t.GetDefinition ()).UnderlyingType; } + + public static bool IsValidUnderlyingType (TypeSpec type) + { + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.ULong: + return true; + } + + return false; + } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs index 301b48b8e..d09dfa289 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs @@ -3,11 +3,12 @@ // // Authors: // Miguel de Icaza (miguel@gnome.org) +// Marek Safar (marek.safar@gmail.com) // // Dual licensed under the terms of the MIT X11 or GNU GPL // // Copyright 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com) -// Copyright 2004, 2005, 2006, 2007, 2008 Novell, Inc +// Copyright 2004-2011 Novell, Inc // using System; @@ -17,6 +18,7 @@ using System.Reflection; using System.Reflection.Emit; using System.IO; using System.Text; +using System.Linq; namespace Mono.CSharp { @@ -51,128 +53,73 @@ namespace Mono.CSharp } static object evaluator_lock = new object (); + static volatile bool invoking; - static string current_debug_name; static int count; static Thread invoke_thread; - static List using_alias_list = new List (); - internal static List using_list = new List (); - static Dictionary> fields = new Dictionary> (); + readonly Dictionary> fields; - static TypeSpec interactive_base_class; - static Driver driver; - static bool inited; + Type base_class; + bool inited; - static CompilerContext ctx; - static DynamicLoader loader; + readonly CompilerContext ctx; + readonly ModuleContainer module; + readonly ReflectionImporter importer; + readonly CompilationSourceFile source_file; - public static TextWriter MessageOutput = Console.Out; - - /// - /// Optional initialization for the Evaluator. - /// - /// - /// Initializes the Evaluator with the command line options - /// that would be processed by the command line compiler. Only - /// the first call to Init will work, any future invocations are - /// ignored. - /// - /// You can safely avoid calling this method if your application - /// does not need any of the features exposed by the command line - /// interface. - /// - public static void Init (string [] args) + public Evaluator (CompilerSettings settings, Report report) { - InitAndGetStartupFiles (args); - } + ctx = new CompilerContext (settings, report); - internal static ReportPrinter SetPrinter (ReportPrinter report_printer) - { - return ctx.Report.SetPrinter (report_printer); - } + module = new ModuleContainer (ctx); + module.Evaluator = this; - public static string [] InitAndGetStartupFiles (string [] args) - { - return InitAndGetStartupFiles (args, null); - } + source_file = new CompilationSourceFile ("{interactive}", "", 1); + source_file.NamespaceContainer = new NamespaceEntry (module, null, source_file, null); - /// - /// Optional initialization for the Evaluator. - /// - /// - /// Initializes the Evaluator with the command line - /// options that would be processed by the command - /// line compiler. Only the first call to - /// InitAndGetStartupFiles or Init will work, any future - /// invocations are ignored. - /// - /// You can safely avoid calling this method if your application - /// does not need any of the features exposed by the command line - /// interface. - /// - /// This method return an array of strings that contains any - /// files that were specified in `args'. - /// - /// If the unknownOptionParser is not null, this function is invoked - /// with the current args array and the index of the option that is not - /// known. A value of true means that the value was processed, otherwise - /// it will be reported as an error - /// - public static string [] InitAndGetStartupFiles (string [] args, Func unknownOptionParser) - { - lock (evaluator_lock){ - if (inited) - return new string [0]; - - CompilerCallableEntryPoint.Reset (); - var crp = new ConsoleReportPrinter (); - driver = Driver.Create (args, false, unknownOptionParser, crp); - if (driver == null) - throw new Exception ("Failed to create compiler driver with the given arguments"); + ctx.SourceFiles.Add (source_file); - crp.Fatal = driver.fatal_errors; - ctx = driver.ctx; + // FIXME: Importer needs this assembly for internalsvisibleto + module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator")); + importer = new ReflectionImporter (module, ctx.BuiltinTypes); - RootContext.ToplevelTypes = new ModuleContainer (ctx); - - var startup_files = new List (); - foreach (CompilationUnit file in Location.SourceFiles) - startup_files.Add (file.Path); - - CompilerCallableEntryPoint.PartialReset (); + InteractiveBaseClass = typeof (InteractiveBase); + fields = new Dictionary> (); + } - var importer = new ReflectionImporter (ctx.BuildinTypes); - loader = new DynamicLoader (importer, ctx); + void Init () + { + var loader = new DynamicLoader (importer, ctx); - RootContext.ToplevelTypes.SetDeclaringAssembly (new AssemblyDefinitionDynamic (RootContext.ToplevelTypes, "temp")); + CompilerCallableEntryPoint.Reset (); + RootContext.ToplevelTypes = module; - loader.LoadReferences (RootContext.ToplevelTypes); - ctx.BuildinTypes.CheckDefinitions (RootContext.ToplevelTypes); - RootContext.ToplevelTypes.InitializePredefinedTypes (); + //var startup_files = new List (); + //foreach (CompilationUnit file in Location.SourceFiles) + // startup_files.Add (file.Path); - RootContext.EvalMode = true; - inited = true; + loader.LoadReferences (module); + ctx.BuiltinTypes.CheckDefinitions (module); + module.InitializePredefinedTypes (); - return startup_files.ToArray (); - } + inited = true; } - static void Init () - { - Init (new string [0]); - } - - static void Reset () + void Reset () { CompilerCallableEntryPoint.PartialReset (); - Location.AddFile (null, "{interactive}"); - Location.Initialize (); - - current_debug_name = "interactive" + (count++) + ".dll"; + Location.Reset (); + Location.Initialize (ctx.SourceFiles); } + /// + /// If true, turns type expressions into valid expressions + /// and calls the describe method on it + /// + public bool DescribeTypeExpressions; + /// /// The base class for the classes that host the user generated code /// @@ -187,25 +134,16 @@ namespace Mono.CSharp /// base class and the static members that are /// available to your evaluated code. /// - static public TypeSpec InteractiveBaseClass { + public Type InteractiveBaseClass { get { - if (interactive_base_class != null) - return interactive_base_class; - - return loader.Importer.ImportType (typeof (InteractiveBase)); + return base_class; } - } + set { + base_class = value; - public static void SetInteractiveBaseClass (Type type) - { - if (type == null) - throw new ArgumentNullException (); - - if (!inited) - throw new Exception ("Evaluator has to be initiated before seting custom InteractiveBase class"); - - lock (evaluator_lock) - interactive_base_class = loader.Importer.ImportType (type); + if (value != null && typeof (InteractiveBase).IsAssignableFrom (value)) + InteractiveBase.Evaluator = this; + } } /// @@ -214,7 +152,7 @@ namespace Mono.CSharp /// /// Use this method to interrupt long-running invocations. /// - public static void Interrupt () + public void Interrupt () { if (!inited || !invoking) return; @@ -248,8 +186,8 @@ namespace Mono.CSharp /// compiled parameter will be set to the delegate /// that can be invoked to execute the code. /// - /// - static public string Compile (string input, out CompiledMethod compiled) + /// + public string Compile (string input, out CompiledMethod compiled) { if (input == null || input.Length == 0){ compiled = null; @@ -262,8 +200,6 @@ namespace Mono.CSharp else ctx.Report.Printer.Reset (); - // RootContext.ToplevelTypes = new ModuleContainer (ctx); - bool partial_input; CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input); if (parser == null){ @@ -275,24 +211,9 @@ namespace Mono.CSharp return null; } - object parser_result = parser.InteractiveResult; - - if (!(parser_result is Class)){ - int errors = ctx.Report.Errors; - - NamespaceEntry.VerifyAllUsing (); - if (errors == ctx.Report.Errors) - parser.CurrentNamespace.Extract (using_alias_list, using_list); - else - NamespaceEntry.Reset (); - } - -#if STATIC - throw new NotSupportedException (); -#else - compiled = CompileBlock (parser_result as Class, parser.undo, ctx.Report); + Class parser_result = parser.InteractiveResult; + compiled = CompileBlock (parser_result, parser.undo, ctx.Report); return null; -#endif } } @@ -314,8 +235,8 @@ namespace Mono.CSharp /// On success, a delegate is returned that can be used /// to invoke the method. /// - /// - static public CompiledMethod Compile (string input) + /// + public CompiledMethod Compile (string input) { CompiledMethod compiled; @@ -329,11 +250,6 @@ namespace Mono.CSharp return compiled; } - // - // Todo: Should we handle errors, or expect the calling code to setup - // the recording themselves? - // - /// /// Evaluates and expression or statement and returns any result values. /// @@ -356,7 +272,7 @@ namespace Mono.CSharp /// that the input is partial and that the user /// should provide an updated string. /// - public static string Evaluate (string input, out object result, out bool result_set) + public string Evaluate (string input, out object result, out bool result_set) { CompiledMethod compiled; @@ -373,7 +289,7 @@ namespace Mono.CSharp // // The code execution does not need to keep the compiler lock // - object retval = typeof (NoValueSet); + object retval = typeof (QuitValue); try { invoke_thread = System.Threading.Thread.CurrentThread; @@ -390,7 +306,7 @@ namespace Mono.CSharp // We use a reference to a compiler type, in this case // Driver as a flag to indicate that this was a statement // - if (retval != typeof (NoValueSet)){ + if (!ReferenceEquals (retval, typeof (QuitValue))) { result_set = true; result = retval; } @@ -398,7 +314,7 @@ namespace Mono.CSharp return null; } - public static string [] GetCompletions (string input, out string prefix) + public string [] GetCompletions (string input, out string prefix) { prefix = ""; if (input == null || input.Length == 0) @@ -416,46 +332,29 @@ namespace Mono.CSharp return null; } - Class parser_result = parser.InteractiveResult as Class; - - if (parser_result == null){ - if (CSharpParser.yacc_verbose_flag != 0) - Console.WriteLine ("Do not know how to cope with !Class yet"); - return null; - } + Class parser_result = parser.InteractiveResult; - try { - var a = new AssemblyDefinitionDynamic (RootContext.ToplevelTypes, "temp"); - a.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Run); - RootContext.ToplevelTypes.SetDeclaringAssembly (a); - RootContext.ToplevelTypes.CreateType (); - RootContext.ToplevelTypes.Define (); - if (ctx.Report.Errors != 0) - return null; - - MethodOrOperator method = null; - foreach (MemberCore member in parser_result.Methods){ - if (member.Name != "Host") - continue; - - method = (MethodOrOperator) member; - break; - } - if (method == null) - throw new InternalErrorException ("did not find the the Host method"); +#if NET_4_0 + var access = AssemblyBuilderAccess.RunAndCollect; +#else + var access = AssemblyBuilderAccess.Run; +#endif + var a = new AssemblyDefinitionDynamic (module, "completions"); + a.Create (AppDomain.CurrentDomain, access); + module.SetDeclaringAssembly (a); - BlockContext bc = new BlockContext (method, method.Block, method.ReturnType); + // Need to setup MemberCache + parser_result.CreateType (); - try { - method.Block.Resolve (null, bc, method); - } catch (CompletionResult cr){ - prefix = cr.BaseText; - return cr.Result; - } - } finally { - parser.undo.ExecuteUndo (); - } - + var method = parser_result.Methods[0] as Method; + BlockContext bc = new BlockContext (method, method.Block, ctx.BuiltinTypes.Void); + + try { + method.Block.Resolve (null, bc, method); + } catch (CompletionResult cr) { + prefix = cr.BaseText; + return cr.Result; + } } return null; } @@ -468,17 +367,12 @@ namespace Mono.CSharp /// on success, false on parsing errors. Exceptions /// might be thrown by the called code. /// - public static bool Run (string statement) + public bool Run (string statement) { - if (!inited) - Init (); - object result; bool result_set; - bool ok = Evaluate (statement, out result, out result_set) == null; - - return ok; + return Evaluate (statement, out result, out result_set) == null; } /// @@ -491,7 +385,7 @@ namespace Mono.CSharp /// This method will throw an exception if there is a syntax error, /// of if the provided input is not an expression but a statement. /// - public static object Evaluate (string input) + public object Evaluate (string input) { object result; bool result_set; @@ -524,9 +418,9 @@ namespace Mono.CSharp // without more than one lookahead token. There are very // few ambiguities. // - static InputKind ToplevelOrStatement (SeekableStreamReader seekable) + InputKind ToplevelOrStatement (SeekableStreamReader seekable) { - Tokenizer tokenizer = new Tokenizer (seekable, (CompilationUnit) Location.SourceFiles [0], ctx); + Tokenizer tokenizer = new Tokenizer (seekable, source_file, ctx); int t = tokenizer.token (); switch (t){ @@ -628,11 +522,10 @@ namespace Mono.CSharp // @partial_input: if @silent is true, then it returns whether the // parsed expression was partial, and more data is needed // - static CSharpParser ParseString (ParseMode mode, string input, out bool partial_input) + CSharpParser ParseString (ParseMode mode, string input, out bool partial_input) { partial_input = false; Reset (); - queued_fields.Clear (); Tokenizer.LocatedToken.Initialize (); Stream s = new MemoryStream (Encoding.Default.GetBytes (input)); @@ -655,20 +548,15 @@ namespace Mono.CSharp } seekable.Position = 0; - CSharpParser parser = new CSharpParser (seekable, Location.SourceFiles [0], RootContext.ToplevelTypes); + source_file.NamespaceContainer.DeclarationFound = false; + CSharpParser parser = new CSharpParser (seekable, source_file); if (kind == InputKind.StatementOrExpression){ parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter; - RootContext.StatementMode = true; + ctx.Settings.StatementMode = true; } else { - // - // Do not activate EvalCompilationUnitParserCharacter until - // I have figured out all the limitations to invoke methods - // in the generated classes. See repl.txt - // - parser.Lexer.putback_char = Tokenizer.EvalUsingDeclarationsParserCharacter; - //parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter; - RootContext.StatementMode = false; + parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter; + ctx.Settings.StatementMode = false; } if (mode == ParseMode.GetCompletions) @@ -676,7 +564,7 @@ namespace Mono.CSharp ReportPrinter old_printer = null; if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions) && CSharpParser.yacc_verbose_flag == 0) - old_printer = SetPrinter (new StreamReportPrinter (TextWriter.Null)); + old_printer = ctx.Report.SetPrinter (new StreamReportPrinter (TextWriter.Null)); try { parser.parse (); @@ -685,75 +573,87 @@ namespace Mono.CSharp if (mode != ParseMode.ReportErrors && parser.UnexpectedEOF) partial_input = true; - parser.undo.ExecuteUndo (); + if (parser.undo != null) + parser.undo.ExecuteUndo (); + parser = null; } if (old_printer != null) - SetPrinter (old_printer); + ctx.Report.SetPrinter (old_printer); } return parser; } - // - // Queue all the fields that we use, as we need to then go from FieldBuilder to FieldInfo - // or reflection gets confused (it basically gets confused, and variables override each - // other). - // - static List queued_fields = new List (); - - //static ArrayList types = new ArrayList (); - - static volatile bool invoking; -#if !STATIC - static CompiledMethod CompileBlock (Class host, Undo undo, Report Report) + CompiledMethod CompileBlock (Class host, Undo undo, Report Report) { + string current_debug_name = "eval-" + count + ".dll"; + ++count; +#if STATIC + throw new NotSupportedException (); +#else AssemblyDefinitionDynamic assembly; + AssemblyBuilderAccess access; if (Environment.GetEnvironmentVariable ("SAVE") != null) { - assembly = new AssemblyDefinitionDynamic (RootContext.ToplevelTypes, current_debug_name, current_debug_name); - assembly.Importer = loader.Importer; + access = AssemblyBuilderAccess.RunAndSave; + assembly = new AssemblyDefinitionDynamic (module, current_debug_name, current_debug_name); + assembly.Importer = importer; } else { - assembly = new AssemblyDefinitionDynamic (RootContext.ToplevelTypes, current_debug_name); +#if NET_4_0 + access = AssemblyBuilderAccess.RunAndCollect; +#else + access = AssemblyBuilderAccess.Run; +#endif + assembly = new AssemblyDefinitionDynamic (module, current_debug_name); } - assembly.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.RunAndSave); - RootContext.ToplevelTypes.CreateType (); - RootContext.ToplevelTypes.Define (); + assembly.Create (AppDomain.CurrentDomain, access); + + Method expression_method; + if (host != null) { + var base_class_imported = importer.ImportType (base_class); + var baseclass_list = new List (1) { + new TypeExpression (base_class_imported, host.Location) + }; + + host.AddBasesForPart (host, baseclass_list); + + host.CreateType (); + host.DefineType (); + host.Define (); + + expression_method = (Method) host.Methods[0]; + } else { + expression_method = null; + } + + module.CreateType (); + module.Define (); if (Report.Errors != 0){ - undo.ExecuteUndo (); + if (undo != null) + undo.ExecuteUndo (); + return null; } - TypeBuilder tb = null; - MethodBuilder mb = null; - if (host != null){ - tb = host.TypeBuilder; - mb = null; - foreach (MemberCore member in host.Methods){ - if (member.Name != "Host") - continue; - - MethodOrOperator method = (MethodOrOperator) member; - mb = method.MethodBuilder; - break; - } - - if (mb == null) - throw new Exception ("Internal error: did not find the method builder for the generated method"); + host.EmitType (); } - RootContext.ToplevelTypes.Emit (); + module.Emit (); if (Report.Errors != 0){ - undo.ExecuteUndo (); + if (undo != null) + undo.ExecuteUndo (); return null; } - RootContext.ToplevelTypes.CloseType (); + module.CloseType (); + if (host != null) + host.CloseType (); - if (Environment.GetEnvironmentVariable ("SAVE") != null) + if (access == AssemblyBuilderAccess.RunAndSave) assembly.Save (); if (host == null) @@ -763,78 +663,58 @@ namespace Mono.CSharp // Unlike Mono, .NET requires that the MethodInfo is fetched, it cant // work from MethodBuilders. Retarded, I know. // - var tt = assembly.Builder.GetType (tb.Name); - MethodInfo mi = tt.GetMethod (mb.Name); - - // Pull the FieldInfos from the type, and keep track of them - foreach (Field field in queued_fields){ - FieldInfo fi = tt.GetField (field.Name); + var tt = assembly.Builder.GetType (host.TypeBuilder.Name); + var mi = tt.GetMethod (expression_method.Name); - Tuple old; - - // If a previous value was set, nullify it, so that we do - // not leak memory - if (fields.TryGetValue (field.Name, out old)) { - if (old.Item1.MemberType.IsStruct) { - // - // TODO: Clear fields for structs - // - } else { - try { - old.Item2.SetValue (null, null); - } catch { + if (host.Fields != null) { + // + // We need to then go from FieldBuilder to FieldInfo + // or reflection gets confused (it basically gets confused, and variables override each + // other). + // + foreach (Field field in host.Fields) { + var fi = tt.GetField (field.Name); + + Tuple old; + + // If a previous value was set, nullify it, so that we do + // not leak memory + if (fields.TryGetValue (field.Name, out old)) { + if (old.Item1.MemberType.IsStruct) { + // + // TODO: Clear fields for structs + // + } else { + try { + old.Item2.SetValue (null, null); + } catch { + } } } - fields [field.Name] = Tuple.Create (field.Spec, fi); - } else { - fields.Add (field.Name, Tuple.Create (field.Spec, fi)); + fields[field.Name] = Tuple.Create (field.Spec, fi); } } - //types.Add (tb); - - queued_fields.Clear (); return (CompiledMethod) System.Delegate.CreateDelegate (typeof (CompiledMethod), mi); - } #endif - static internal void LoadAliases (NamespaceEntry ns) - { - ns.Populate (using_alias_list, using_list); } - + /// /// A sentinel value used to indicate that no value was /// was set by the compiled function. This is used to /// differentiate between a function not returning a /// value and null. /// - public class NoValueSet { - } + internal static class QuitValue { } - static internal Tuple LookupField (string name) + internal Tuple LookupField (string name) { Tuple fi; fields.TryGetValue (name, out fi); return fi; } - // - // Puts the FieldBuilder into a queue of names that will be - // registered. We can not register FieldBuilders directly - // we need to fetch the FieldInfo after Reflection cooks the - // types, or bad things happen (bad means: FieldBuilders behave - // incorrectly across multiple assemblies, causing assignments to - // invalid areas - // - // This also serves for the parser to register Field classes - // that should be exposed as global variables - // - static internal void QueueField (Field f) - { - queued_fields.Add (f); - } - static string Quote (string s) { if (s.IndexOf ('"') != -1) @@ -843,37 +723,38 @@ namespace Mono.CSharp return "\"" + s + "\""; } - static public string GetUsing () + public string GetUsing () { - lock (evaluator_lock){ - StringBuilder sb = new StringBuilder (); - - foreach (object x in using_alias_list) - sb.Append (String.Format ("using {0};\n", x)); - - foreach (object x in using_list) - sb.Append (String.Format ("using {0};\n", x)); - - return sb.ToString (); + StringBuilder sb = new StringBuilder (); + // TODO: + //foreach (object x in ns.using_alias_list) + // sb.AppendFormat ("using {0};\n", x); + + foreach (var ue in source_file.NamespaceContainer.Usings) { + sb.AppendFormat ("using {0};", ue.ToString ()); + sb.Append (Environment.NewLine); } + + return sb.ToString (); } - static internal ICollection GetUsingList () + internal ICollection GetUsingList () { - var res = new List (using_list.Count); - foreach (object ue in using_list) + var res = new List (); + + foreach (var ue in source_file.NamespaceContainer.Usings) res.Add (ue.ToString ()); return res; } - static internal string [] GetVarNames () + internal string [] GetVarNames () { lock (evaluator_lock){ return new List (fields.Keys).ToArray (); } } - static public string GetVars () + public string GetVars () { lock (evaluator_lock){ StringBuilder sb = new StringBuilder (); @@ -900,30 +781,27 @@ namespace Mono.CSharp /// /// Loads the given assembly and exposes the API to the user. /// - static public void LoadAssembly (string file) + public void LoadAssembly (string file) { + var loader = new DynamicLoader (importer, ctx); + var assembly = loader.LoadAssemblyFile (file); + if (assembly == null) + return; + lock (evaluator_lock){ - var a = loader.LoadAssemblyFile (file); - if (a != null) - loader.Importer.ImportAssembly (a, RootContext.ToplevelTypes.GlobalRootNamespace); + importer.ImportAssembly (assembly, module.GlobalRootNamespace); } } /// /// Exposes the API of the given assembly to the Evaluator /// - static public void ReferenceAssembly (Assembly a) + public void ReferenceAssembly (Assembly a) { lock (evaluator_lock){ - loader.Importer.ImportAssembly (a, RootContext.ToplevelTypes.GlobalRootNamespace); + importer.ImportAssembly (a, module.GlobalRootNamespace); } } - - /// - /// If true, turns type expressions into valid expressions - /// and calls the describe method on it - /// - public static bool DescribeTypeExpressions; } @@ -976,6 +854,8 @@ namespace Mono.CSharp /// Used to signal that the user has invoked the `quit' statement. /// public static bool QuitRequested; + + public static Evaluator Evaluator; /// /// Shows all the variables defined so far. @@ -994,20 +874,17 @@ namespace Mono.CSharp Output.Write (Evaluator.GetUsing ()); Output.Flush (); } - - public delegate void Simple (); - + /// /// Times the execution of the given delegate /// - static public TimeSpan Time (Simple a) + static public TimeSpan Time (Action a) { DateTime start = DateTime.Now; a (); return DateTime.Now - start; } -#if !STATIC /// /// Loads the assemblies from a package /// @@ -1023,9 +900,7 @@ namespace Mono.CSharp return; } - string pkgout = Driver.GetPackageFlags (pkg, false, RootContext.ToplevelTypes.Compiler.Report); - if (pkgout == null) - return; + string pkgout = Driver.GetPackageFlags (pkg, null); string [] xargs = pkgout.Trim (new Char [] {' ', '\n', '\r', '\t'}). Split (new Char [] { ' ', '\t'}); @@ -1039,9 +914,7 @@ namespace Mono.CSharp } } } -#endif -#if !STATIC /// /// Loads the assembly /// @@ -1056,7 +929,7 @@ namespace Mono.CSharp Evaluator.LoadAssembly (assembly); } - static public void print (string obj) + static public void print (object obj) { Output.WriteLine (obj); } @@ -1065,7 +938,6 @@ namespace Mono.CSharp { Output.WriteLine (fmt, args); } -#endif /// /// Returns a list of available static methods. @@ -1095,7 +967,7 @@ namespace Mono.CSharp QuitRequested = true; // To avoid print null at the exit - return typeof (Evaluator.NoValueSet); + return typeof (Evaluator.QuitValue); } } @@ -1155,52 +1027,52 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext ec) { - CloneContext cc = new CloneContext (); - Expression clone = source.Clone (cc); + Expression clone = source.Clone (new CloneContext ()); + + clone = clone.Resolve (ec); + if (clone == null) + return null; // // A useful feature for the REPL: if we can resolve the expression // as a type, Describe the type; // - if (Evaluator.DescribeTypeExpressions){ - var old_printer = Evaluator.SetPrinter (new StreamReportPrinter (TextWriter.Null)); - clone = clone.Resolve (ec); - if (clone == null){ - clone = source.Clone (cc); - clone = clone.Resolve (ec, ResolveFlags.Type); - if (clone == null){ - Evaluator.SetPrinter (old_printer); - clone = source.Clone (cc); - clone = clone.Resolve (ec); - return null; - } - + if (ec.Module.Evaluator.DescribeTypeExpressions){ + var old_printer = ec.Report.SetPrinter (new SessionReportPrinter ()); + Expression tclone; + try { + // Note: clone context cannot be shared otherwise block mapping would leak + tclone = source.Clone (new CloneContext ()); + tclone = tclone.Resolve (ec, ResolveFlags.Type); + if (ec.Report.Errors > 0) + tclone = null; + } finally { + ec.Report.SetPrinter (old_printer); + } + + if (tclone != null) { Arguments args = new Arguments (1); args.Add (new Argument (new TypeOf ((TypeExpr) clone, Location))); - source = new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec); + return new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec); } - Evaluator.SetPrinter (old_printer); - } else { - clone = clone.Resolve (ec); - if (clone == null) - return null; } - + // This means its really a statement. - if (clone.Type == TypeManager.void_type || clone is DynamicInvocation || clone is Assign) { + if (clone.Type.Kind == MemberKind.Void || clone is DynamicInvocation || clone is Assign) { return clone; } + source = clone; return base.DoResolve (ec); } } - public class Undo { - List> undo_types; + public class Undo + { + List undo_actions; public Undo () { - undo_types = new List> (); } public void AddTypeContainer (TypeContainer current_container, TypeContainer tc) @@ -1210,23 +1082,29 @@ namespace Mono.CSharp return; } - if (undo_types == null) - undo_types = new List> (); + if (undo_actions == null) + undo_actions = new List (); - undo_types.Add (new KeyValuePair (current_container, tc)); + var existing = current_container.Types.FirstOrDefault (l => l.MemberName.Basename == tc.MemberName.Basename); + if (existing != null) { + current_container.RemoveTypeContainer (existing); + existing.NamespaceEntry.SlaveDeclSpace.RemoveTypeContainer (existing); + undo_actions.Add (() => current_container.AddTypeContainer (existing)); + } + + undo_actions.Add (() => current_container.RemoveTypeContainer (tc)); } public void ExecuteUndo () { - if (undo_types == null) + if (undo_actions == null) return; - foreach (var p in undo_types){ - TypeContainer current_container = p.Key; - - current_container.RemoveTypeContainer (p.Value); + foreach (var p in undo_actions){ + p (); } - undo_types = null; + + undo_actions = null; } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs index c27050544..7c923a627 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs @@ -120,8 +120,6 @@ namespace Mono.CSharp AddressOf, TOP } - static TypeSpec[][] predefined_operators; - public readonly Operator Oper; public Expression Expr; Expression enum_conversion; @@ -152,22 +150,26 @@ namespace Mono.CSharp switch (Oper){ case Operator.UnaryPlus: // Unary numeric promotions - if (expr_type == TypeManager.byte_type) - return new IntConstant (((ByteConstant)e).Value, e.Location); - if (expr_type == TypeManager.sbyte_type) - return new IntConstant (((SByteConstant)e).Value, e.Location); - if (expr_type == TypeManager.short_type) - return new IntConstant (((ShortConstant)e).Value, e.Location); - if (expr_type == TypeManager.ushort_type) - return new IntConstant (((UShortConstant)e).Value, e.Location); - if (expr_type == TypeManager.char_type) - return new IntConstant (((CharConstant)e).Value, e.Location); + switch (expr_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + return new IntConstant (ec.BuiltinTypes, ((ByteConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.SByte: + return new IntConstant (ec.BuiltinTypes, ((SByteConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Short: + return new IntConstant (ec.BuiltinTypes, ((ShortConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.UShort: + return new IntConstant (ec.BuiltinTypes, ((UShortConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Char: + return new IntConstant (ec.BuiltinTypes, ((CharConstant) e).Value, e.Location); // Predefined operators - if (expr_type == TypeManager.int32_type || expr_type == TypeManager.uint32_type || - expr_type == TypeManager.int64_type || expr_type == TypeManager.uint64_type || - expr_type == TypeManager.float_type || expr_type == TypeManager.double_type || - expr_type == TypeManager.decimal_type) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.Double: + case BuiltinTypeSpec.Type.Decimal: return e; } @@ -175,108 +177,109 @@ namespace Mono.CSharp case Operator.UnaryNegation: // Unary numeric promotions - if (expr_type == TypeManager.byte_type) - return new IntConstant (-((ByteConstant)e).Value, e.Location); - if (expr_type == TypeManager.sbyte_type) - return new IntConstant (-((SByteConstant)e).Value, e.Location); - if (expr_type == TypeManager.short_type) - return new IntConstant (-((ShortConstant)e).Value, e.Location); - if (expr_type == TypeManager.ushort_type) - return new IntConstant (-((UShortConstant)e).Value, e.Location); - if (expr_type == TypeManager.char_type) - return new IntConstant (-((CharConstant)e).Value, e.Location); - + switch (expr_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + return new IntConstant (ec.BuiltinTypes, -((ByteConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.SByte: + return new IntConstant (ec.BuiltinTypes, -((SByteConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Short: + return new IntConstant (ec.BuiltinTypes, -((ShortConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.UShort: + return new IntConstant (ec.BuiltinTypes, -((UShortConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Char: + return new IntConstant (ec.BuiltinTypes, -((CharConstant) e).Value, e.Location); + // Predefined operators - if (expr_type == TypeManager.int32_type) { - int value = ((IntConstant)e).Value; - if (value == int.MinValue) { + case BuiltinTypeSpec.Type.Int: + int ivalue = ((IntConstant) e).Value; + if (ivalue == int.MinValue) { if (ec.ConstantCheckState) { ConstantFold.Error_CompileTimeOverflow (ec, loc); return null; } return e; } - return new IntConstant (-value, e.Location); - } - if (expr_type == TypeManager.int64_type) { - long value = ((LongConstant)e).Value; - if (value == long.MinValue) { + return new IntConstant (ec.BuiltinTypes, -ivalue, e.Location); + + case BuiltinTypeSpec.Type.Long: + long lvalue = ((LongConstant) e).Value; + if (lvalue == long.MinValue) { if (ec.ConstantCheckState) { ConstantFold.Error_CompileTimeOverflow (ec, loc); return null; } return e; } - return new LongConstant (-value, e.Location); - } - - if (expr_type == TypeManager.uint32_type) { + return new LongConstant (ec.BuiltinTypes, -lvalue, e.Location); + + case BuiltinTypeSpec.Type.UInt: UIntLiteral uil = e as UIntLiteral; if (uil != null) { if (uil.Value == int.MaxValue + (uint) 1) - return new IntLiteral (int.MinValue, e.Location); - return new LongLiteral (-uil.Value, e.Location); + return new IntLiteral (ec.BuiltinTypes, int.MinValue, e.Location); + return new LongLiteral (ec.BuiltinTypes, -uil.Value, e.Location); } - return new LongConstant (-((UIntConstant)e).Value, e.Location); - } - - if (expr_type == TypeManager.uint64_type) { + return new LongConstant (ec.BuiltinTypes, -((UIntConstant) e).Value, e.Location); + + + case BuiltinTypeSpec.Type.ULong: ULongLiteral ull = e as ULongLiteral; if (ull != null && ull.Value == 9223372036854775808) - return new LongLiteral (long.MinValue, e.Location); + return new LongLiteral (ec.BuiltinTypes, long.MinValue, e.Location); return null; - } - - if (expr_type == TypeManager.float_type) { + + case BuiltinTypeSpec.Type.Float: FloatLiteral fl = e as FloatLiteral; // For better error reporting if (fl != null) - return new FloatLiteral (-fl.Value, e.Location); + return new FloatLiteral (ec.BuiltinTypes, -fl.Value, e.Location); - return new FloatConstant (-((FloatConstant)e).Value, e.Location); - } - if (expr_type == TypeManager.double_type) { + return new FloatConstant (ec.BuiltinTypes, -((FloatConstant) e).Value, e.Location); + + case BuiltinTypeSpec.Type.Double: DoubleLiteral dl = e as DoubleLiteral; // For better error reporting if (dl != null) - return new DoubleLiteral (-dl.Value, e.Location); + return new DoubleLiteral (ec.BuiltinTypes, -dl.Value, e.Location); + + return new DoubleConstant (ec.BuiltinTypes, -((DoubleConstant) e).Value, e.Location); - return new DoubleConstant (-((DoubleConstant)e).Value, e.Location); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (ec.BuiltinTypes, -((DecimalConstant) e).Value, e.Location); } - if (expr_type == TypeManager.decimal_type) - return new DecimalConstant (-((DecimalConstant)e).Value, e.Location); - + return null; case Operator.LogicalNot: - if (expr_type != TypeManager.bool_type) + if (expr_type.BuiltinType != BuiltinTypeSpec.Type.Bool) return null; bool b = (bool)e.GetValue (); - return new BoolConstant (!b, e.Location); + return new BoolConstant (ec.BuiltinTypes, !b, e.Location); case Operator.OnesComplement: // Unary numeric promotions - if (expr_type == TypeManager.byte_type) - return new IntConstant (~((ByteConstant)e).Value, e.Location); - if (expr_type == TypeManager.sbyte_type) - return new IntConstant (~((SByteConstant)e).Value, e.Location); - if (expr_type == TypeManager.short_type) - return new IntConstant (~((ShortConstant)e).Value, e.Location); - if (expr_type == TypeManager.ushort_type) - return new IntConstant (~((UShortConstant)e).Value, e.Location); - if (expr_type == TypeManager.char_type) - return new IntConstant (~((CharConstant)e).Value, e.Location); + switch (expr_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + return new IntConstant (ec.BuiltinTypes, ~((ByteConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.SByte: + return new IntConstant (ec.BuiltinTypes, ~((SByteConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Short: + return new IntConstant (ec.BuiltinTypes, ~((ShortConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.UShort: + return new IntConstant (ec.BuiltinTypes, ~((UShortConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Char: + return new IntConstant (ec.BuiltinTypes, ~((CharConstant) e).Value, e.Location); // Predefined operators - if (expr_type == TypeManager.int32_type) - return new IntConstant (~((IntConstant)e).Value, e.Location); - if (expr_type == TypeManager.uint32_type) - return new UIntConstant (~((UIntConstant)e).Value, e.Location); - if (expr_type == TypeManager.int64_type) - return new LongConstant (~((LongConstant)e).Value, e.Location); - if (expr_type == TypeManager.uint64_type){ - return new ULongConstant (~((ULongConstant)e).Value, e.Location); + case BuiltinTypeSpec.Type.Int: + return new IntConstant (ec.BuiltinTypes, ~((IntConstant)e).Value, e.Location); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (ec.BuiltinTypes, ~((UIntConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (ec.BuiltinTypes, ~((LongConstant) e).Value, e.Location); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (ec.BuiltinTypes, ~((ULongConstant) e).Value, e.Location); } if (e is EnumConstant) { e = TryReduceConstant (ec, ((EnumConstant)e).Child); @@ -293,17 +296,16 @@ namespace Mono.CSharp { eclass = ExprClass.Value; - if (predefined_operators == null) - CreatePredefinedOperatorsTable (); - TypeSpec expr_type = expr.Type; Expression best_expr; + TypeSpec[] predefined = ec.BuiltinTypes.OperatorsUnary [(int) Oper]; + // // Primitive types first // - if (TypeManager.IsPrimitiveType (expr_type)) { - best_expr = ResolvePrimitivePredefinedType (expr); + if (BuiltinTypeSpec.IsPrimitiveType (expr_type)) { + best_expr = ResolvePrimitivePredefinedType (ec, expr, predefined); if (best_expr == null) return null; @@ -316,20 +318,20 @@ namespace Mono.CSharp // E operator ~(E x); // if (Oper == Operator.OnesComplement && TypeManager.IsEnumType (expr_type)) - return ResolveEnumOperator (ec, expr); + return ResolveEnumOperator (ec, expr, predefined); - return ResolveUserType (ec, expr); + return ResolveUserType (ec, expr, predefined); } - protected virtual Expression ResolveEnumOperator (ResolveContext ec, Expression expr) + protected virtual Expression ResolveEnumOperator (ResolveContext ec, Expression expr, TypeSpec[] predefined) { TypeSpec underlying_type = EnumSpec.GetUnderlyingType (expr.Type); - Expression best_expr = ResolvePrimitivePredefinedType (EmptyCast.Create (expr, underlying_type)); + Expression best_expr = ResolvePrimitivePredefinedType (ec, EmptyCast.Create (expr, underlying_type), predefined); if (best_expr == null) return null; Expr = best_expr; - enum_conversion = Convert.ExplicitNumericConversion (new EmptyExpression (best_expr.Type), underlying_type); + enum_conversion = Convert.ExplicitNumericConversion (ec, new EmptyExpression (best_expr.Type), underlying_type); type = expr.Type; return EmptyCast.Create (this, type); } @@ -371,60 +373,66 @@ namespace Mono.CSharp return CreateExpressionFactoryCall (ec, method_name, args); } - static void CreatePredefinedOperatorsTable () + public static TypeSpec[][] CreatePredefinedOperatorsTable (BuiltinTypes types) { - predefined_operators = new TypeSpec [(int) Operator.TOP] []; + var predefined_operators = new TypeSpec[(int) Operator.TOP][]; // // 7.6.1 Unary plus operator // predefined_operators [(int) Operator.UnaryPlus] = new TypeSpec [] { - TypeManager.int32_type, TypeManager.uint32_type, - TypeManager.int64_type, TypeManager.uint64_type, - TypeManager.float_type, TypeManager.double_type, - TypeManager.decimal_type + types.Int, types.UInt, + types.Long, types.ULong, + types.Float, types.Double, + types.Decimal }; // // 7.6.2 Unary minus operator // predefined_operators [(int) Operator.UnaryNegation] = new TypeSpec [] { - TypeManager.int32_type, - TypeManager.int64_type, - TypeManager.float_type, TypeManager.double_type, - TypeManager.decimal_type + types.Int, types.Long, + types.Float, types.Double, + types.Decimal }; // // 7.6.3 Logical negation operator // predefined_operators [(int) Operator.LogicalNot] = new TypeSpec [] { - TypeManager.bool_type + types.Bool }; // // 7.6.4 Bitwise complement operator // predefined_operators [(int) Operator.OnesComplement] = new TypeSpec [] { - TypeManager.int32_type, TypeManager.uint32_type, - TypeManager.int64_type, TypeManager.uint64_type + types.Int, types.UInt, + types.Long, types.ULong }; + + return predefined_operators; } // // Unary numeric promotions // - static Expression DoNumericPromotion (Operator op, Expression expr) + static Expression DoNumericPromotion (ResolveContext rc, Operator op, Expression expr) { TypeSpec expr_type = expr.Type; - if ((op == Operator.UnaryPlus || op == Operator.UnaryNegation || op == Operator.OnesComplement) && - expr_type == TypeManager.byte_type || expr_type == TypeManager.sbyte_type || - expr_type == TypeManager.short_type || expr_type == TypeManager.ushort_type || - expr_type == TypeManager.char_type) - return Convert.ImplicitNumericConversion (expr, TypeManager.int32_type); + if (op == Operator.UnaryPlus || op == Operator.UnaryNegation || op == Operator.OnesComplement) { + switch (expr_type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Char: + return Convert.ImplicitNumericConversion (expr, rc.BuiltinTypes.Int); + } + } - if (op == Operator.UnaryNegation && expr_type == TypeManager.uint32_type) - return Convert.ImplicitNumericConversion (expr, TypeManager.int64_type); + if (op == Operator.UnaryNegation && expr_type.BuiltinType == BuiltinTypeSpec.Type.UInt) + return Convert.ImplicitNumericConversion (expr, rc.BuiltinTypes.Long); return expr; } @@ -439,13 +447,13 @@ namespace Mono.CSharp if (Expr == null) return null; - if (Expr.Type == InternalType.Dynamic) { + if (Expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments args = new Arguments (1); args.Add (new Argument (Expr)); return new DynamicUnaryConversion (GetOperatorExpressionTypeName (), args, loc).Resolve (ec); } - if (TypeManager.IsNullableType (Expr.Type)) + if (Expr.Type.IsNullableType) return new Nullable.LiftedUnaryOperator (Oper, Expr, loc).Resolve (ec); // @@ -455,7 +463,7 @@ namespace Mono.CSharp if (cexpr != null) { cexpr = TryReduceConstant (ec, cexpr); if (cexpr != null) - return cexpr.Resolve (ec); + return cexpr; } Expression expr = ResolveOperator (ec, Expr); @@ -491,7 +499,7 @@ namespace Mono.CSharp case Operator.UnaryNegation: if (ec.HasSet (EmitContext.Options.CheckedScope) && !IsFloat (type)) { ec.Emit (OpCodes.Ldc_I4_0); - if (type == TypeManager.int64_type) + if (type.BuiltinType == BuiltinTypeSpec.Type.Long) ec.Emit (OpCodes.Conv_U8); Expr.Emit (ec); ec.Emit (OpCodes.Sub_Ovf); @@ -569,7 +577,7 @@ namespace Mono.CSharp static bool IsFloat (TypeSpec t) { - return t == TypeManager.float_type || t == TypeManager.double_type; + return t.BuiltinType == BuiltinTypeSpec.Type.Double || t.BuiltinType == BuiltinTypeSpec.Type.Float; } // @@ -612,11 +620,6 @@ namespace Mono.CSharp } } - public static void Reset () - { - predefined_operators = null; - } - Expression ResolveAddressOf (ResolveContext ec) { if (!ec.IsUnsafe) @@ -628,7 +631,7 @@ namespace Mono.CSharp return null; } - if (!TypeManager.VerifyUnmanaged (ec.Compiler, Expr.Type, loc)) { + if (!TypeManager.VerifyUnmanaged (ec.Module, Expr.Type, loc)) { return null; } @@ -661,16 +664,15 @@ namespace Mono.CSharp ec.Report.Error (212, loc, "You can only take the address of unfixed expression inside of a fixed statement initializer"); } - type = PointerContainer.MakeType (Expr.Type); + type = PointerContainer.MakeType (ec.Module, Expr.Type); eclass = ExprClass.Value; return this; } - Expression ResolvePrimitivePredefinedType (Expression expr) + Expression ResolvePrimitivePredefinedType (ResolveContext rc, Expression expr, TypeSpec[] predefined) { - expr = DoNumericPromotion (Oper, expr); + expr = DoNumericPromotion (rc, Oper, expr); TypeSpec expr_type = expr.Type; - TypeSpec[] predefined = predefined_operators [(int) Oper]; foreach (TypeSpec t in predefined) { if (t == expr_type) return expr; @@ -717,13 +719,12 @@ namespace Mono.CSharp // // Unary user type overload resolution // - Expression ResolveUserType (ResolveContext ec, Expression expr) + Expression ResolveUserType (ResolveContext ec, Expression expr, TypeSpec[] predefined) { Expression best_expr = ResolveUserOperator (ec, expr); if (best_expr != null) return best_expr; - TypeSpec[] predefined = predefined_operators [(int) Oper]; foreach (TypeSpec t in predefined) { Expression oper_expr = Convert.ImplicitUserConversion (ec, expr, t, expr.Location); if (oper_expr == null) @@ -732,10 +733,10 @@ namespace Mono.CSharp // // decimal type is predefined but has user-operators // - if (oper_expr.Type == TypeManager.decimal_type) - oper_expr = ResolveUserType (ec, oper_expr); + if (oper_expr.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) + oper_expr = ResolveUserType (ec, oper_expr, predefined); else - oper_expr = ResolvePrimitivePredefinedType (oper_expr); + oper_expr = ResolvePrimitivePredefinedType (ec, oper_expr, predefined); if (oper_expr == null) continue; @@ -762,8 +763,8 @@ namespace Mono.CSharp // // HACK: Decimal user-operator is included in standard operators // - if (best_expr.Type == TypeManager.decimal_type) - return best_expr; + if (best_expr.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) + return best_expr; Expr = best_expr; type = best_expr.Type; @@ -848,7 +849,7 @@ namespace Mono.CSharp source.Emit (ec); if (leave_copy) { ec.Emit (OpCodes.Dup); - temporary = new LocalTemporary (expr.Type); + temporary = new LocalTemporary (source.Type); temporary.Store (ec); } @@ -888,7 +889,7 @@ namespace Mono.CSharp type = pc.Element; - if (type.BuildinType == BuildinTypeSpec.Type.Void) { + if (type.Kind == MemberKind.Void) { Error_VoidPointerOperation (ec); return null; } @@ -1022,8 +1023,6 @@ namespace Mono.CSharp } } - static TypeSpec[] predefined; - public UnaryMutator (Mode m, Expression e, Location loc) { mode = m; @@ -1036,26 +1035,25 @@ namespace Mono.CSharp return new SimpleAssign (this, this).CreateExpressionTree (ec); } - void CreatePredefinedOperators () + public static TypeSpec[] CreatePredefinedOperatorsTable (BuiltinTypes types) { // // Predefined ++ and -- operators exist for the following types: // sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal // - predefined = new TypeSpec[] { - TypeManager.int32_type, - - TypeManager.sbyte_type, - TypeManager.byte_type, - TypeManager.short_type, - TypeManager.ushort_type, - TypeManager.uint32_type, - TypeManager.int64_type, - TypeManager.uint64_type, - TypeManager.char_type, - TypeManager.float_type, - TypeManager.double_type, - TypeManager.decimal_type + return new TypeSpec[] { + types.Int, + types.Long, + + types.SByte, + types.Byte, + types.Short, + types.UInt, + types.ULong, + types.Char, + types.Float, + types.Double, + types.Decimal }; } @@ -1066,7 +1064,7 @@ namespace Mono.CSharp if (expr == null) return null; - if (expr.Type == InternalType.Dynamic) { + if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { // // Handle postfix unary operators using local // temporary variable @@ -1079,7 +1077,7 @@ namespace Mono.CSharp return new SimpleAssign (expr, new DynamicUnaryConversion (GetOperatorExpressionTypeName (), args, loc)).Resolve (ec); } - if (TypeManager.IsNullableType (expr.Type)) + if (expr.Type.IsNullableType) return new Nullable.LiftedUnaryMutator (mode, expr, loc).Resolve (ec); eclass = ExprClass.Value; @@ -1128,50 +1126,67 @@ namespace Mono.CSharp // // Step 2: Try predefined types // - if (predefined == null) - CreatePredefinedOperators (); - // Predefined without user conversion first for speed-up Expression source = null; - bool primitive_type = false; - foreach (var t in predefined) { - if (t == type) { - source = operation; - primitive_type = true; - break; - } - } - - // ++/-- on pointer variables of all types except void* - if (source == null && type.IsPointer) { - if (((PointerContainer) type).Element.BuildinType == BuildinTypeSpec.Type.Void) { - Error_VoidPointerOperation (ec); - return null; - } + bool primitive_type; + // + // Predefined without user conversion first for speed-up + // + // Predefined ++ and -- operators exist for the following types: + // sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal + // + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.Double: + case BuiltinTypeSpec.Type.Decimal: source = operation; - } + primitive_type = true; + break; + default: + primitive_type = false; - if (source == null) { - // LAMESPEC: It should error on ambiguous operators but that would make us incompatible - foreach (var t in predefined) { - source = Convert.ImplicitUserConversion (ec, operation, t, loc); - if (source != null) { - break; + // ++/-- on pointer variables of all types except void* + if (type.IsPointer) { + if (((PointerContainer) type).Element.Kind == MemberKind.Void) { + Error_VoidPointerOperation (ec); + return null; + } + + source = operation; + } else { + foreach (var t in ec.BuiltinTypes.OperatorsUnaryMutator) { + source = Convert.ImplicitUserConversion (ec, operation, t, loc); + + // LAMESPEC: It should error on ambiguous operators but that would make us incompatible + if (source != null) { + break; + } } } - } - // ++/-- on enum types - if (source == null && type.IsEnum) - source = operation; + // ++/-- on enum types + if (source == null && type.IsEnum) + source = operation; - if (source == null) { - Unary.Error_OperatorCannotBeApplied (ec, loc, Operator.GetName (user_op), type); - return null; + if (source == null) { + Unary.Error_OperatorCannotBeApplied (ec, loc, Operator.GetName (user_op), type); + return null; + } + + break; } - var one = new IntConstant (1, loc); + var one = new IntConstant (ec.BuiltinTypes, 1, loc); var op = IsDecrement ? Binary.Operator.Subtraction : Binary.Operator.Addition; operation = new Binary (op, source, one, loc); operation = operation.Resolve (ec); @@ -1180,7 +1195,7 @@ namespace Mono.CSharp if (operation.Type != type) { if (primitive_type) - operation = Convert.ExplicitNumericConversion (operation, type); + operation = Convert.ExplicitNumericConversion (ec, operation, type); else operation = Convert.ImplicitConversionRequired (ec, operation, type, loc); } @@ -1241,11 +1256,6 @@ namespace Mono.CSharp } #endif - public static void Reset () - { - predefined = null; - } - protected override void CloneTo (CloneContext clonectx, Expression t) { UnaryMutator target = (UnaryMutator) t; @@ -1380,7 +1390,7 @@ namespace Mono.CSharp ec.Report.Warning (184, 1, loc, "The given expression is never of the provided (`{0}') type", TypeManager.CSharpName (probe_type_expr.Type)); - return ReducedExpression.Create (new BoolConstant (result, loc).Resolve (ec), this); + return ReducedExpression.Create (new BoolConstant (ec.BuiltinTypes, result, loc), this); } protected override Expression DoResolve (ResolveContext ec) @@ -1398,7 +1408,7 @@ namespace Mono.CSharp if (expr.IsNull || expr.eclass == ExprClass.MethodGroup) return CreateConstantResult (ec, false); - if (TypeManager.IsNullableType (d)) { + if (d.IsNullableType) { var ut = Nullable.NullableInfo.GetUnderlyingType (d); if (!ut.IsGenericParameter) { d = ut; @@ -1406,11 +1416,11 @@ namespace Mono.CSharp } } - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; eclass = ExprClass.Value; TypeSpec t = probe_type_expr.Type; bool t_is_nullable = false; - if (TypeManager.IsNullableType (t)) { + if (t.IsNullableType) { var ut = Nullable.NullableInfo.GetUnderlyingType (t); if (!ut.IsGenericParameter) { t = ut; @@ -1418,7 +1428,7 @@ namespace Mono.CSharp } } - if (TypeManager.IsStruct (t)) { + if (t.IsStruct) { if (d == t) { // // D and T are the same value types but D can be null @@ -1447,13 +1457,13 @@ namespace Mono.CSharp if (TypeManager.IsGenericParameter (t)) return ResolveGenericParameter (ec, d, (TypeParameterSpec) t); - if (t == InternalType.Dynamic) { + if (t.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { ec.Report.Warning (1981, 3, loc, "Using `{0}' to test compatibility with `{1}' is identical to testing compatibility with `object'", OperatorName, t.GetSignatureForError ()); } - if (TypeManager.IsStruct (d) && d != TypeManager.void_type) { + if (d.IsStruct) { if (Convert.ImplicitBoxingConversion (null, d, t) != null) return CreateConstantResult (ec, true); } else { @@ -1463,7 +1473,7 @@ namespace Mono.CSharp if (InflatedTypeSpec.ContainsTypeParameter (d)) return this; - if (Convert.ImplicitReferenceConversionExists (expr, t) || + if (Convert.ImplicitReferenceConversionExists (d, t) || Convert.ExplicitReferenceConversionExists (d, t)) { return this; } @@ -1476,7 +1486,7 @@ namespace Mono.CSharp Expression ResolveGenericParameter (ResolveContext ec, TypeSpec d, TypeParameterSpec t) { if (t.IsReferenceType) { - if (TypeManager.IsStruct (d)) + if (d.IsStruct) return CreateConstantResult (ec, false); } @@ -1526,7 +1536,7 @@ namespace Mono.CSharp ec.Emit (OpCodes.Isinst, type); - if (TypeManager.IsGenericParameter (type) || TypeManager.IsNullableType (type)) + if (TypeManager.IsGenericParameter (type) || type.IsNullableType) ec.Emit (OpCodes.Unbox_Any, type); } @@ -1543,7 +1553,7 @@ namespace Mono.CSharp eclass = ExprClass.Value; TypeSpec etype = expr.Type; - if (!TypeManager.IsReferenceType (type) && !TypeManager.IsNullableType (type)) { + if (!TypeManager.IsReferenceType (type) && !type.IsNullableType) { if (TypeManager.IsGenericParameter (type)) { ec.Report.Error (413, loc, "The `as' operator cannot be used with a non-reference type parameter `{0}'. Consider adding `class' or a reference type constraint", @@ -1556,12 +1566,12 @@ namespace Mono.CSharp return null; } - if (expr.IsNull && TypeManager.IsNullableType (type)) { + if (expr.IsNull && type.IsNullableType) { return Nullable.LiftedNull.CreateFromExpression (ec, this); } // If the compile-time type of E is dynamic, unlike the cast operator the as operator is not dynamically bound - if (etype == InternalType.Dynamic) { + if (etype.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return this; } @@ -1735,14 +1745,14 @@ namespace Mono.CSharp } if (type.IsPointer) - return new NullLiteral (Location).ConvertImplicitly (ec, type); + return new NullLiteral (Location).ConvertImplicitly (type); if (TypeManager.IsReferenceType (type)) return new NullConstant (type, loc); Constant c = New.Constantify (type, expr.Location); if (c != null) - return c.Resolve (ec); + return c; eclass = ExprClass.Variable; return this; @@ -1782,7 +1792,8 @@ namespace Mono.CSharp /// public class Binary : Expression, IDynamicBinder { - protected class PredefinedOperator { + public class PredefinedOperator + { protected readonly TypeSpec left; protected readonly TypeSpec right; public readonly Operator OperatorsMask; @@ -1826,7 +1837,7 @@ namespace Mono.CSharp // is considered to be predefined type therefore we apply predefined operators rules // and then look for decimal user-operator implementation // - if (left == TypeManager.decimal_type) + if (left.BuiltinType == BuiltinTypeSpec.Type.Decimal) return b.ResolveUserOperator (ec, b.left, b.right); var c = b.right as Constant; @@ -1840,7 +1851,7 @@ namespace Mono.CSharp c = b.left as Constant; if (c != null) { - if (c.IsDefaultValue && (b.oper == Operator.Addition || b.oper == Operator.Subtraction || (b.oper == Operator.BitwiseOr && !(b is Nullable.LiftedBinaryOperator)))) + if (c.IsDefaultValue && (b.oper == Operator.Addition || (b.oper == Operator.BitwiseOr && !(b is Nullable.LiftedBinaryOperator)))) return ReducedExpression.Create (b.right, b).Resolve (ec); if (b.oper == Operator.Multiply && c.IsOneInteger) return ReducedExpression.Create (b.right, b).Resolve (ec); @@ -1889,17 +1900,16 @@ namespace Mono.CSharp } } - class PredefinedStringOperator : PredefinedOperator { - public PredefinedStringOperator (TypeSpec type, Operator op_mask) - : base (type, op_mask, type) + sealed class PredefinedStringOperator : PredefinedOperator + { + public PredefinedStringOperator (TypeSpec type, Operator op_mask, TypeSpec retType) + : base (type, type, op_mask, retType) { - ReturnType = TypeManager.string_type; } - public PredefinedStringOperator (TypeSpec ltype, TypeSpec rtype, Operator op_mask) - : base (ltype, rtype, op_mask) + public PredefinedStringOperator (TypeSpec ltype, TypeSpec rtype, Operator op_mask, TypeSpec retType) + : base (ltype, rtype, op_mask, retType) { - ReturnType = TypeManager.string_type; } public override Expression ConvertResult (ResolveContext ec, Binary b) @@ -1925,9 +1935,10 @@ namespace Mono.CSharp } } - class PredefinedShiftOperator : PredefinedOperator { - public PredefinedShiftOperator (TypeSpec ltype, Operator op_mask) : - base (ltype, TypeManager.int32_type, op_mask) + sealed class PredefinedShiftOperator : PredefinedOperator + { + public PredefinedShiftOperator (TypeSpec ltype, TypeSpec rtype, Operator op_mask) + : base (ltype, rtype, op_mask) { } @@ -1935,15 +1946,15 @@ namespace Mono.CSharp { b.left = Convert.ImplicitConversion (ec, b.left, left, b.left.Location); - Expression expr_tree_expr = Convert.ImplicitConversion (ec, b.right, TypeManager.int32_type, b.right.Location); + Expression expr_tree_expr = Convert.ImplicitConversion (ec, b.right, right, b.right.Location); - int right_mask = left == TypeManager.int32_type || left == TypeManager.uint32_type ? 0x1f : 0x3f; + int right_mask = left.BuiltinType == BuiltinTypeSpec.Type.Int || left.BuiltinType == BuiltinTypeSpec.Type.UInt ? 0x1f : 0x3f; // // b = b.left >> b.right & (0x1f|0x3f) // b.right = new Binary (Operator.BitwiseAnd, - b.right, new IntConstant (right_mask, b.right.Location), b.loc).Resolve (ec); + b.right, new IntConstant (ec.BuiltinTypes, right_mask, b.right.Location), b.loc).Resolve (ec); // // Expression tree representation does not use & mask @@ -1962,7 +1973,7 @@ namespace Mono.CSharp } } - class PredefinedEqualityOperator : PredefinedOperator + sealed class PredefinedEqualityOperator : PredefinedOperator { MethodSpec equal_method, inequal_method; @@ -1985,15 +1996,23 @@ namespace Mono.CSharp MethodSpec method; if (b.oper == Operator.Equality) { if (equal_method == null) { - equal_method = TypeManager.GetPredefinedMethod (left, - new MemberFilter (CSharp.Operator.GetMetadataName (CSharp.Operator.OpType.Equality), 0, MemberKind.Operator, null, ReturnType), b.loc); + if (left.BuiltinType == BuiltinTypeSpec.Type.String) + equal_method = ec.Module.PredefinedMembers.StringEqual.Resolve (b.loc); + else if (left.BuiltinType == BuiltinTypeSpec.Type.Delegate) + equal_method = ec.Module.PredefinedMembers.DelegateEqual.Resolve (b.loc); + else + throw new NotImplementedException (left.GetSignatureForError ()); } method = equal_method; } else { if (inequal_method == null) { - inequal_method = TypeManager.GetPredefinedMethod (left, - new MemberFilter (CSharp.Operator.GetMetadataName (CSharp.Operator.OpType.Inequality), 0, MemberKind.Operator, null, ReturnType), b.loc); + if (left.BuiltinType == BuiltinTypeSpec.Type.String) + inequal_method = ec.Module.PredefinedMembers.StringInequal.Resolve (b.loc); + else if (left.BuiltinType == BuiltinTypeSpec.Type.Delegate) + inequal_method = ec.Module.PredefinedMembers.DelegateInequal.Resolve (b.loc); + else + throw new NotImplementedException (left.GetSignatureForError ()); } method = inequal_method; @@ -2123,10 +2142,6 @@ namespace Mono.CSharp protected State state; Expression enum_conversion; - static PredefinedOperator[] standard_operators; - static PredefinedOperator[] equality_operators; - static PredefinedOperator[] pointer_operators; - public Binary (Operator oper, Expression left, Expression right, bool isCompound, Location loc) : this (oper, left, right, loc) { @@ -2354,7 +2369,7 @@ namespace Mono.CSharp switch (oper){ case Operator.Multiply: if (ec.HasSet (EmitContext.Options.CheckedScope)) { - if (l == TypeManager.int32_type || l == TypeManager.int64_type) + if (l.BuiltinType == BuiltinTypeSpec.Type.Int || l.BuiltinType == BuiltinTypeSpec.Type.Long) opcode = OpCodes.Mul_Ovf; else if (!IsFloat (l)) opcode = OpCodes.Mul_Ovf_Un; @@ -2381,7 +2396,7 @@ namespace Mono.CSharp case Operator.Addition: if (ec.HasSet (EmitContext.Options.CheckedScope)) { - if (l == TypeManager.int32_type || l == TypeManager.int64_type) + if (l.BuiltinType == BuiltinTypeSpec.Type.Int || l.BuiltinType == BuiltinTypeSpec.Type.Long) opcode = OpCodes.Add_Ovf; else if (!IsFloat (l)) opcode = OpCodes.Add_Ovf_Un; @@ -2393,7 +2408,7 @@ namespace Mono.CSharp case Operator.Subtraction: if (ec.HasSet (EmitContext.Options.CheckedScope)) { - if (l == TypeManager.int32_type || l == TypeManager.int64_type) + if (l.BuiltinType == BuiltinTypeSpec.Type.Int || l.BuiltinType == BuiltinTypeSpec.Type.Long) opcode = OpCodes.Sub_Ovf; else if (!IsFloat (l)) opcode = OpCodes.Sub_Ovf_Un; @@ -2481,21 +2496,21 @@ namespace Mono.CSharp static bool IsUnsigned (TypeSpec t) { - if (t.IsPointer) + switch (t.BuiltinType) { + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Byte: return true; + } - return (t == TypeManager.uint32_type || t == TypeManager.uint64_type || - t == TypeManager.ushort_type || t == TypeManager.byte_type); + return t.IsPointer; } static bool IsFloat (TypeSpec t) { - return t == TypeManager.float_type || t == TypeManager.double_type; - } - - public static void Reset () - { - equality_operators = pointer_operators = standard_operators = null; + return t.BuiltinType == BuiltinTypeSpec.Type.Float || t.BuiltinType == BuiltinTypeSpec.Type.Double; } Expression ResolveOperator (ResolveContext ec) @@ -2505,15 +2520,12 @@ namespace Mono.CSharp Expression expr; bool primitives_only = false; - if (standard_operators == null) - CreateStandardOperatorsTable (); - // // Handles predefined primitive types // - if (TypeManager.IsPrimitiveType (l) && TypeManager.IsPrimitiveType (r)) { + if (BuiltinTypeSpec.IsPrimitiveType (l) && BuiltinTypeSpec.IsPrimitiveType (r)) { if ((oper & Operator.ShiftMask) == 0) { - if (l != TypeManager.bool_type && !DoBinaryOperatorPromotion (ec)) + if (l.BuiltinType != BuiltinTypeSpec.Type.Bool && !DoBinaryOperatorPromotion (ec)) return null; primitives_only = true; @@ -2556,7 +2568,7 @@ namespace Mono.CSharp } } - return ResolveOperatorPredefined (ec, standard_operators, primitives_only, null); + return ResolveOperatorPredefined (ec, ec.BuiltinTypes.OperatorsBinaryStandard, primitives_only, null); } // at least one of 'left' or 'right' is an enumeration constant (EnumConstant or SideEffectConstant or ...) @@ -2625,84 +2637,82 @@ namespace Mono.CSharp TypeManager.CSharpName (lcast != null ? lcast.UnderlyingType : rcast.UnderlyingType)); } - static void CreatePointerOperatorsTable () + public static PredefinedOperator[] CreatePointerOperatorsTable (BuiltinTypes types) { - var temp = new List (); - - // - // Pointer arithmetic: - // - // T* operator + (T* x, int y); T* operator - (T* x, int y); - // T* operator + (T* x, uint y); T* operator - (T* x, uint y); - // T* operator + (T* x, long y); T* operator - (T* x, long y); - // T* operator + (T* x, ulong y); T* operator - (T* x, ulong y); - // - temp.Add (new PredefinedPointerOperator (null, TypeManager.int32_type, Operator.AdditionMask | Operator.SubtractionMask)); - temp.Add (new PredefinedPointerOperator (null, TypeManager.uint32_type, Operator.AdditionMask | Operator.SubtractionMask)); - temp.Add (new PredefinedPointerOperator (null, TypeManager.int64_type, Operator.AdditionMask | Operator.SubtractionMask)); - temp.Add (new PredefinedPointerOperator (null, TypeManager.uint64_type, Operator.AdditionMask | Operator.SubtractionMask)); + return new PredefinedOperator[] { + // + // Pointer arithmetic: + // + // T* operator + (T* x, int y); T* operator - (T* x, int y); + // T* operator + (T* x, uint y); T* operator - (T* x, uint y); + // T* operator + (T* x, long y); T* operator - (T* x, long y); + // T* operator + (T* x, ulong y); T* operator - (T* x, ulong y); + // + new PredefinedPointerOperator (null, types.Int, Operator.AdditionMask | Operator.SubtractionMask), + new PredefinedPointerOperator (null, types.UInt, Operator.AdditionMask | Operator.SubtractionMask), + new PredefinedPointerOperator (null, types.Long, Operator.AdditionMask | Operator.SubtractionMask), + new PredefinedPointerOperator (null, types.ULong, Operator.AdditionMask | Operator.SubtractionMask), - // - // T* operator + (int y, T* x); - // T* operator + (uint y, T *x); - // T* operator + (long y, T *x); - // T* operator + (ulong y, T *x); - // - temp.Add (new PredefinedPointerOperator (TypeManager.int32_type, null, Operator.AdditionMask, null)); - temp.Add (new PredefinedPointerOperator (TypeManager.uint32_type, null, Operator.AdditionMask, null)); - temp.Add (new PredefinedPointerOperator (TypeManager.int64_type, null, Operator.AdditionMask, null)); - temp.Add (new PredefinedPointerOperator (TypeManager.uint64_type, null, Operator.AdditionMask, null)); + // + // T* operator + (int y, T* x); + // T* operator + (uint y, T *x); + // T* operator + (long y, T *x); + // T* operator + (ulong y, T *x); + // + new PredefinedPointerOperator (types.Int, null, Operator.AdditionMask, null), + new PredefinedPointerOperator (types.UInt, null, Operator.AdditionMask, null), + new PredefinedPointerOperator (types.Long, null, Operator.AdditionMask, null), + new PredefinedPointerOperator (types.ULong, null, Operator.AdditionMask, null), - // - // long operator - (T* x, T *y) - // - temp.Add (new PredefinedPointerOperator (null, Operator.SubtractionMask, TypeManager.int64_type)); + // + // long operator - (T* x, T *y) + // + new PredefinedPointerOperator (null, Operator.SubtractionMask, types.Long) + }; + } - pointer_operators = temp.ToArray (); + public static PredefinedOperator[] CreateStandardOperatorsTable (BuiltinTypes types) + { + TypeSpec bool_type = types.Bool; + return new PredefinedOperator[] { + new PredefinedOperator (types.Int, Operator.ArithmeticMask | Operator.BitwiseMask), + new PredefinedOperator (types.UInt, Operator.ArithmeticMask | Operator.BitwiseMask), + new PredefinedOperator (types.Long, Operator.ArithmeticMask | Operator.BitwiseMask), + new PredefinedOperator (types.ULong, Operator.ArithmeticMask | Operator.BitwiseMask), + new PredefinedOperator (types.Float, Operator.ArithmeticMask), + new PredefinedOperator (types.Double, Operator.ArithmeticMask), + new PredefinedOperator (types.Decimal, Operator.ArithmeticMask), + + new PredefinedOperator (types.Int, Operator.ComparisonMask, bool_type), + new PredefinedOperator (types.UInt, Operator.ComparisonMask, bool_type), + new PredefinedOperator (types.Long, Operator.ComparisonMask, bool_type), + new PredefinedOperator (types.ULong, Operator.ComparisonMask, bool_type), + new PredefinedOperator (types.Float, Operator.ComparisonMask, bool_type), + new PredefinedOperator (types.Double, Operator.ComparisonMask, bool_type), + new PredefinedOperator (types.Decimal, Operator.ComparisonMask, bool_type), + + new PredefinedStringOperator (types.String, Operator.AdditionMask, types.String), + new PredefinedStringOperator (types.String, types.Object, Operator.AdditionMask, types.String), + new PredefinedStringOperator (types.Object, types.String, Operator.AdditionMask, types.String), + + new PredefinedOperator (bool_type, Operator.BitwiseMask | Operator.LogicalMask | Operator.EqualityMask, bool_type), + + new PredefinedShiftOperator (types.Int, types.Int, Operator.ShiftMask), + new PredefinedShiftOperator (types.UInt, types.Int, Operator.ShiftMask), + new PredefinedShiftOperator (types.Long, types.Int, Operator.ShiftMask), + new PredefinedShiftOperator (types.ULong, types.Int, Operator.ShiftMask) + }; } - static void CreateStandardOperatorsTable () + public static PredefinedOperator[] CreateEqualityOperatorsTable (BuiltinTypes types) { - var temp = new List (); - TypeSpec bool_type = TypeManager.bool_type; - - temp.Add (new PredefinedOperator (TypeManager.int32_type, Operator.ArithmeticMask | Operator.BitwiseMask)); - temp.Add (new PredefinedOperator (TypeManager.uint32_type, Operator.ArithmeticMask | Operator.BitwiseMask)); - temp.Add (new PredefinedOperator (TypeManager.int64_type, Operator.ArithmeticMask | Operator.BitwiseMask)); - temp.Add (new PredefinedOperator (TypeManager.uint64_type, Operator.ArithmeticMask | Operator.BitwiseMask)); - temp.Add (new PredefinedOperator (TypeManager.float_type, Operator.ArithmeticMask)); - temp.Add (new PredefinedOperator (TypeManager.double_type, Operator.ArithmeticMask)); - temp.Add (new PredefinedOperator (TypeManager.decimal_type, Operator.ArithmeticMask)); - - temp.Add (new PredefinedOperator (TypeManager.int32_type, Operator.ComparisonMask, bool_type)); - temp.Add (new PredefinedOperator (TypeManager.uint32_type, Operator.ComparisonMask, bool_type)); - temp.Add (new PredefinedOperator (TypeManager.int64_type, Operator.ComparisonMask, bool_type)); - temp.Add (new PredefinedOperator (TypeManager.uint64_type, Operator.ComparisonMask, bool_type)); - temp.Add (new PredefinedOperator (TypeManager.float_type, Operator.ComparisonMask, bool_type)); - temp.Add (new PredefinedOperator (TypeManager.double_type, Operator.ComparisonMask, bool_type)); - temp.Add (new PredefinedOperator (TypeManager.decimal_type, Operator.ComparisonMask, bool_type)); - - temp.Add (new PredefinedStringOperator (TypeManager.string_type, Operator.AdditionMask)); - temp.Add (new PredefinedStringOperator (TypeManager.string_type, TypeManager.object_type, Operator.AdditionMask)); - temp.Add (new PredefinedStringOperator (TypeManager.object_type, TypeManager.string_type, Operator.AdditionMask)); - - temp.Add (new PredefinedOperator (bool_type, - Operator.BitwiseMask | Operator.LogicalMask | Operator.EqualityMask, bool_type)); - - temp.Add (new PredefinedShiftOperator (TypeManager.int32_type, Operator.ShiftMask)); - temp.Add (new PredefinedShiftOperator (TypeManager.uint32_type, Operator.ShiftMask)); - temp.Add (new PredefinedShiftOperator (TypeManager.int64_type, Operator.ShiftMask)); - temp.Add (new PredefinedShiftOperator (TypeManager.uint64_type, Operator.ShiftMask)); - - standard_operators = temp.ToArray (); + TypeSpec bool_type = types.Bool; - var equality = new List () { - new PredefinedEqualityOperator (TypeManager.string_type, bool_type), - new PredefinedEqualityOperator (TypeManager.delegate_type, bool_type), + return new PredefinedOperator[] { + new PredefinedEqualityOperator (types.String, bool_type), + new PredefinedEqualityOperator (types.Delegate, bool_type), new PredefinedOperator (bool_type, Operator.EqualityMask, bool_type) }; - - equality_operators = equality.ToArray (); } // @@ -2711,40 +2721,47 @@ namespace Mono.CSharp static bool DoNumericPromotion (ResolveContext rc, ref Expression prim_expr, ref Expression second_expr, TypeSpec type) { Expression temp; - TypeSpec etype; Constant c = prim_expr as Constant; if (c != null) { - temp = c.ConvertImplicitly (rc, type); + temp = c.ConvertImplicitly (type); if (temp != null) { prim_expr = temp; return true; } } - if (type == TypeManager.uint32_type) { - etype = prim_expr.Type; - if (etype == TypeManager.int32_type || etype == TypeManager.short_type || etype == TypeManager.sbyte_type) { - type = TypeManager.int64_type; + if (type.BuiltinType == BuiltinTypeSpec.Type.UInt) { + switch (prim_expr.Type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Long: + type = rc.BuiltinTypes.Long; if (type != second_expr.Type) { c = second_expr as Constant; if (c != null) - temp = c.ConvertImplicitly (rc, type); + temp = c.ConvertImplicitly (type); else temp = Convert.ImplicitNumericConversion (second_expr, type); if (temp == null) return false; second_expr = temp; } + break; } - } else if (type == TypeManager.uint64_type) { + } else if (type.BuiltinType == BuiltinTypeSpec.Type.ULong) { // // A compile-time error occurs if the other operand is of type sbyte, short, int, or long // - if (type == TypeManager.int32_type || type == TypeManager.int64_type || - type == TypeManager.short_type || type == TypeManager.sbyte_type) + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.SByte: return false; + } } temp = Convert.ImplicitNumericConversion (prim_expr, type); @@ -2764,7 +2781,7 @@ namespace Mono.CSharp TypeSpec rtype = right.Type; Expression temp; - foreach (TypeSpec t in ConstantFold.BinaryPromotionsTypes) { + foreach (TypeSpec t in ec.BuiltinTypes.BinaryPromotionsTypes) { if (t == ltype) return t == rtype || DoNumericPromotion (ec, ref right, ref left, t); @@ -2772,11 +2789,11 @@ namespace Mono.CSharp return t == ltype || DoNumericPromotion (ec, ref left, ref right, t); } - TypeSpec int32 = TypeManager.int32_type; + TypeSpec int32 = ec.BuiltinTypes.Int; if (ltype != int32) { Constant c = left as Constant; if (c != null) - temp = c.ConvertImplicitly (ec, int32); + temp = c.ConvertImplicitly (int32); else temp = Convert.ImplicitNumericConversion (left, int32); @@ -2788,7 +2805,7 @@ namespace Mono.CSharp if (rtype != int32) { Constant c = right as Constant; if (c != null) - temp = c.ConvertImplicitly (ec, int32); + temp = c.ConvertImplicitly (int32); else temp = Convert.ImplicitNumericConversion (right, int32); @@ -2823,7 +2840,7 @@ namespace Mono.CSharp Constant lc = left as Constant; - if (lc != null && lc.Type == TypeManager.bool_type && + if (lc != null && lc.Type.BuiltinType == BuiltinTypeSpec.Type.Bool && ((oper == Operator.LogicalAnd && lc.IsDefaultValue) || (oper == Operator.LogicalOr && !lc.IsDefaultValue))) { @@ -2851,9 +2868,6 @@ namespace Mono.CSharp if (rc != null && lc != null) { int prev_e = ec.Report.Errors; Expression e = ConstantFold.BinaryFold (ec, oper, lc, rc, loc); - if (e != null) - e = e.Resolve (ec); - if (e != null || ec.Report.Errors != prev_e) return e; } @@ -2863,15 +2877,15 @@ namespace Mono.CSharp if (left.Equals (right)) { ec.Report.Warning (1718, 3, loc, "A comparison made to same variable. Did you mean to compare something else?"); } - CheckUselessComparison (ec, lc, right.Type); - CheckUselessComparison (ec, rc, left.Type); + CheckOutOfRangeComparison (ec, lc, right.Type); + CheckOutOfRangeComparison (ec, rc, left.Type); } - if (left.Type == InternalType.Dynamic || right.Type == InternalType.Dynamic) { + if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic || right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { var lt = left.Type; var rt = right.Type; - if (lt == TypeManager.void_type || lt == InternalType.MethodGroup || lt == InternalType.AnonymousMethod || - rt == TypeManager.void_type || rt == InternalType.MethodGroup || rt == InternalType.AnonymousMethod) { + if (lt.Kind == MemberKind.Void || lt == InternalType.MethodGroup || lt == InternalType.AnonymousMethod || + rt.Kind == MemberKind.Void || rt == InternalType.MethodGroup || rt == InternalType.AnonymousMethod) { Error_OperatorCannotBeApplied (ec, left, right); return null; } @@ -2887,7 +2901,7 @@ namespace Mono.CSharp args = new Arguments (2); - if (lt == InternalType.Dynamic) { + if (lt.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { LocalVariable temp = LocalVariable.CreateCompilerGenerated (lt, ec.CurrentBlock, loc); var cond_args = new Arguments (1); @@ -2899,10 +2913,10 @@ namespace Mono.CSharp // left = temp.CreateReferenceExpression (ec, loc); if (oper == Operator.LogicalAnd) { - expr = DynamicUnaryConversion.CreateIsFalse (cond_args, loc); + expr = DynamicUnaryConversion.CreateIsFalse (ec, cond_args, loc); cond_left = left; } else { - expr = DynamicUnaryConversion.CreateIsTrue (cond_args, loc); + expr = DynamicUnaryConversion.CreateIsTrue (ec, cond_args, loc); cond_left = left; } @@ -2910,7 +2924,7 @@ namespace Mono.CSharp args.Add (new Argument (right)); cond_right = new DynamicExpressionStatement (this, args, loc); } else { - LocalVariable temp = LocalVariable.CreateCompilerGenerated (TypeManager.bool_type, ec.CurrentBlock, loc); + LocalVariable temp = LocalVariable.CreateCompilerGenerated (ec.BuiltinTypes.Bool, ec.CurrentBlock, loc); args.Add (new Argument (temp.CreateReferenceExpression (ec, loc).Resolve (ec))); args.Add (new Argument (right)); @@ -2940,10 +2954,10 @@ namespace Mono.CSharp return new DynamicExpressionStatement (this, args, loc).Resolve (ec); } - if (RootContext.Version >= LanguageVersion.ISO_2 && - ((TypeManager.IsNullableType (left.Type) && (right is NullLiteral || TypeManager.IsNullableType (right.Type) || TypeManager.IsValueType (right.Type))) || + if (ec.Module.Compiler.Settings.Version >= LanguageVersion.ISO_2 && + ((left.Type.IsNullableType && (right is NullLiteral || right.Type.IsNullableType || TypeManager.IsValueType (right.Type))) || (TypeManager.IsValueType (left.Type) && right is NullLiteral) || - (TypeManager.IsNullableType (right.Type) && (left is NullLiteral || TypeManager.IsNullableType (left.Type) || TypeManager.IsValueType (left.Type))) || + (right.Type.IsNullableType && (left is NullLiteral || left.Type.IsNullableType || TypeManager.IsValueType (left.Type))) || (TypeManager.IsValueType (right.Type) && left is NullLiteral))) { var lifted = new Nullable.LiftedBinaryOperator (oper, left, right, loc); lifted.state = state; @@ -3024,13 +3038,13 @@ namespace Mono.CSharp { if (l != r && !TypeSpecComparer.Variant.IsEqual (r, l)) { Expression tmp; - if (right.eclass == ExprClass.MethodGroup || r == InternalType.AnonymousMethod || r == InternalType.Null) { + if (right.eclass == ExprClass.MethodGroup || r == InternalType.AnonymousMethod || r == InternalType.NullLiteral) { tmp = Convert.ImplicitConversionRequired (ec, right, l, loc); if (tmp == null) return null; right = tmp; r = right.Type; - } else if (left.eclass == ExprClass.MethodGroup || (l == InternalType.AnonymousMethod || l == InternalType.Null)) { + } else if (left.eclass == ExprClass.MethodGroup || (l == InternalType.AnonymousMethod || l == InternalType.NullLiteral)) { tmp = Convert.ImplicitConversionRequired (ec, left, r, loc); if (tmp == null) return null; @@ -3041,30 +3055,21 @@ namespace Mono.CSharp } } - MethodSpec method; + MethodSpec method = null; Arguments args = new Arguments (2); args.Add (new Argument (left)); args.Add (new Argument (right)); if (oper == Operator.Addition) { - if (TypeManager.delegate_combine_delegate_delegate == null) { - TypeManager.delegate_combine_delegate_delegate = TypeManager.GetPredefinedMethod ( - TypeManager.delegate_type, "Combine", loc, TypeManager.delegate_type, TypeManager.delegate_type); - } - - method = TypeManager.delegate_combine_delegate_delegate; + method = ec.Module.PredefinedMembers.DelegateCombine.Resolve (loc); } else if (oper == Operator.Subtraction) { - if (TypeManager.delegate_remove_delegate_delegate == null) { - TypeManager.delegate_remove_delegate_delegate = TypeManager.GetPredefinedMethod ( - TypeManager.delegate_type, "Remove", loc, TypeManager.delegate_type, TypeManager.delegate_type); - } - - method = TypeManager.delegate_remove_delegate_delegate; - } else { - return new EmptyExpression (TypeManager.decimal_type); + method = ec.Module.PredefinedMembers.DelegateRemove.Resolve (loc); } - MethodGroupExpr mg = MethodGroupExpr.CreatePredefined (method, TypeManager.delegate_type, loc); + if (method == null) + return new EmptyExpression (ec.BuiltinTypes.Decimal); + + MethodGroupExpr mg = MethodGroupExpr.CreatePredefined (method, ec.BuiltinTypes.Delegate, loc); Expression expr = new UserOperatorCall (mg.BestCandidate, args, CreateExpressionTree, loc); return new ClassCast (expr, l); } @@ -3205,14 +3210,14 @@ namespace Mono.CSharp // with constants and expressions if (left.Type != underlying_type) { if (left is Constant) - left = ((Constant) left).ConvertExplicitly (false, underlying_type).Resolve (ec); + left = ((Constant) left).ConvertExplicitly (false, underlying_type); else left = EmptyCast.Create (left, underlying_type); } if (right.Type != underlying_type) { if (right is Constant) - right = ((Constant) right).ConvertExplicitly (false, underlying_type).Resolve (ec); + right = ((Constant) right).ConvertExplicitly (false, underlying_type); else right = EmptyCast.Create (right, underlying_type); } @@ -3228,10 +3233,10 @@ namespace Mono.CSharp } if (underlying_type_result != null && left.Type != underlying_type_result) { - enum_conversion = Convert.ExplicitNumericConversion (new EmptyExpression (left.Type), underlying_type_result); + enum_conversion = Convert.ExplicitNumericConversion (ec, new EmptyExpression (left.Type), underlying_type_result); } - expr = ResolveOperatorPredefined (ec, standard_operators, true, res_type); + expr = ResolveOperatorPredefined (ec, ec.BuiltinTypes.OperatorsBinaryStandard, true, res_type); if (expr == null) return null; @@ -3270,7 +3275,7 @@ namespace Mono.CSharp Expression ResolveOperatorEquality (ResolveContext ec, TypeSpec l, TypeSpec r) { Expression result; - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; // // a, Both operands are reference-type values or the value null @@ -3285,7 +3290,7 @@ namespace Mono.CSharp var tparam_r = r as TypeParameterSpec; if (tparam_l != null) { if (right is NullLiteral && !tparam_l.HasSpecialStruct) { - left = new BoxedCast (left, TypeManager.object_type); + left = new BoxedCast (left, ec.BuiltinTypes.Object); return this; } @@ -3303,7 +3308,7 @@ namespace Mono.CSharp if (tparam_r != null) { if (left is NullLiteral && !tparam_r.HasSpecialStruct) { - right = new BoxedCast (right, TypeManager.object_type); + right = new BoxedCast (right, ec.BuiltinTypes.Object); return this; } @@ -3355,8 +3360,8 @@ namespace Mono.CSharp // LAMESPEC: Reference equality comparison can apply to value types when // they implement an implicit conversion to any of types above. // - if (r != TypeManager.object_type && l != TypeManager.object_type) { - result = ResolveOperatorPredefined (ec, equality_operators, false, null); + if (r.BuiltinType != BuiltinTypeSpec.Type.Object && l.BuiltinType != BuiltinTypeSpec.Type.Object) { + result = ResolveOperatorPredefined (ec, ec.BuiltinTypes.OperatorsBinaryEquality, false, null); if (result != null) return result; } @@ -3382,12 +3387,12 @@ namespace Mono.CSharp if (!TypeManager.IsReferenceType (l) || !TypeManager.IsReferenceType (r)) return null; - if (l == TypeManager.string_type || l == TypeManager.delegate_type || MemberCache.GetUserOperator (l, CSharp.Operator.OpType.Equality, false) != null) + if (l.BuiltinType == BuiltinTypeSpec.Type.String || l.BuiltinType == BuiltinTypeSpec.Type.Delegate || MemberCache.GetUserOperator (l, CSharp.Operator.OpType.Equality, false) != null) ec.Report.Warning (253, 2, loc, "Possible unintended reference comparison. Consider casting the right side expression to type `{0}' to get value comparison", l.GetSignatureForError ()); - if (r == TypeManager.string_type || r == TypeManager.delegate_type || MemberCache.GetUserOperator (r, CSharp.Operator.OpType.Equality, false) != null) + if (r.BuiltinType == BuiltinTypeSpec.Type.String || r.BuiltinType == BuiltinTypeSpec.Type.Delegate || MemberCache.GetUserOperator (r, CSharp.Operator.OpType.Equality, false) != null) ec.Report.Warning (252, 2, loc, "Possible unintended reference comparison. Consider casting the left side expression to type `{0}' to get value comparison", r.GetSignatureForError ()); @@ -3422,14 +3427,11 @@ namespace Mono.CSharp right = temp; } - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; return this; } - if (pointer_operators == null) - CreatePointerOperatorsTable (); - - return ResolveOperatorPredefined (ec, pointer_operators, false, null); + return ResolveOperatorPredefined (ec, ec.BuiltinTypes.OperatorsBinaryUnsafe, false, null); } // @@ -3492,7 +3494,7 @@ namespace Mono.CSharp new SideEffectConstant (lc, right, loc) : new SideEffectConstant (rc, left, loc); - return ReducedExpression.Create (side_effect.Resolve (ec), expr); + return ReducedExpression.Create (side_effect, expr); } } @@ -3513,10 +3515,10 @@ namespace Mono.CSharp { var op = ConvertBinaryToUserOperator (oper); var l = left.Type; - if (TypeManager.IsNullableType (l)) + if (l.IsNullableType) l = Nullable.NullableInfo.GetUnderlyingType (l); var r = right.Type; - if (TypeManager.IsNullableType (r)) + if (r.IsNullableType) r = Nullable.NullableInfo.GetUnderlyingType (r); IList left_operators = MemberCache.GetUserOperator (l, op, false); @@ -3619,97 +3621,17 @@ namespace Mono.CSharp return null; } - private void CheckUselessComparison (ResolveContext ec, Constant c, TypeSpec type) + void CheckOutOfRangeComparison (ResolveContext ec, Constant c, TypeSpec type) { - if (c == null || !IsTypeIntegral (type) - || c is StringConstant - || c is BoolConstant - || c is FloatConstant - || c is DoubleConstant - || c is DecimalConstant - ) - return; - - long value = 0; - - if (c is ULongConstant) { - ulong uvalue = ((ULongConstant) c).Value; - if (uvalue > long.MaxValue) { - if (type == TypeManager.byte_type || - type == TypeManager.sbyte_type || - type == TypeManager.short_type || - type == TypeManager.ushort_type || - type == TypeManager.int32_type || - type == TypeManager.uint32_type || - type == TypeManager.int64_type || - type == TypeManager.char_type) - WarnUselessComparison (ec, type); - return; + if (c is IntegralConstant || c is CharConstant) { + try { + c.ConvertExplicitly (true, type); + } catch (OverflowException) { + ec.Report.Warning (652, 2, loc, + "A comparison between a constant and a variable is useless. The constant is out of the range of the variable type `{0}'", + TypeManager.CSharpName (type)); } - value = (long) uvalue; - } - else if (c is ByteConstant) - value = ((ByteConstant) c).Value; - else if (c is SByteConstant) - value = ((SByteConstant) c).Value; - else if (c is ShortConstant) - value = ((ShortConstant) c).Value; - else if (c is UShortConstant) - value = ((UShortConstant) c).Value; - else if (c is IntConstant) - value = ((IntConstant) c).Value; - else if (c is UIntConstant) - value = ((UIntConstant) c).Value; - else if (c is LongConstant) - value = ((LongConstant) c).Value; - else if (c is CharConstant) - value = ((CharConstant)c).Value; - - if (value == 0) - return; - - if (IsValueOutOfRange (value, type)) - WarnUselessComparison (ec, type); - } - - static bool IsValueOutOfRange (long value, TypeSpec type) - { - if (IsTypeUnsigned (type) && value < 0) - return true; - return type == TypeManager.sbyte_type && (value >= 0x80 || value < -0x80) || - type == TypeManager.byte_type && value >= 0x100 || - type == TypeManager.short_type && (value >= 0x8000 || value < -0x8000) || - type == TypeManager.ushort_type && value >= 0x10000 || - type == TypeManager.int32_type && (value >= 0x80000000 || value < -0x80000000) || - type == TypeManager.uint32_type && value >= 0x100000000; - } - - private static bool IsTypeIntegral (TypeSpec type) - { - return type == TypeManager.uint64_type || - type == TypeManager.int64_type || - type == TypeManager.uint32_type || - type == TypeManager.int32_type || - type == TypeManager.ushort_type || - type == TypeManager.short_type || - type == TypeManager.sbyte_type || - type == TypeManager.byte_type || - type == TypeManager.char_type; - } - - private static bool IsTypeUnsigned (TypeSpec type) - { - return type == TypeManager.uint64_type || - type == TypeManager.uint32_type || - type == TypeManager.ushort_type || - type == TypeManager.byte_type || - type == TypeManager.char_type; - } - - private void WarnUselessComparison (ResolveContext ec, TypeSpec type) - { - ec.Report.Warning (652, 2, loc, "A comparison between a constant and a variable is useless. The constant is out of the range of the variable type `{0}'", - TypeManager.CSharpName (type)); + } } /// @@ -3743,11 +3665,11 @@ namespace Mono.CSharp // // brtrue/brfalse works with native int only // - if (((Constant) right).IsZeroInteger && right.Type != TypeManager.int64_type && right.Type != TypeManager.uint64_type) { + if (((Constant) right).IsZeroInteger && right.Type.BuiltinType != BuiltinTypeSpec.Type.Long && right.Type.BuiltinType != BuiltinTypeSpec.Type.ULong) { left.EmitBranchable (ec, target, my_on_true); return; } - if (right.Type == TypeManager.bool_type) { + if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Bool) { // right is a boolean, and it's not 'false' => it is 'true' left.EmitBranchable (ec, target, !my_on_true); return; @@ -3956,7 +3878,7 @@ namespace Mono.CSharp if ((oper & Operator.LogicalMask) != 0) flags |= CSharpBinderFlags.BinaryOperationLogical; - binder_args.Add (new Argument (new EnumConstant (new IntLiteral ((int) flags, loc), ec.Module.PredefinedTypes.BinderFlags.Resolve (loc)))); + binder_args.Add (new Argument (new EnumConstant (new IntLiteral (ec.BuiltinTypes, (int) flags, loc), ec.Module.PredefinedTypes.BinderFlags.Resolve (loc)))); binder_args.Add (new Argument (new MemberAccess (new MemberAccess (sle, "ExpressionType", loc), GetOperatorExpressionTypeName (), loc))); binder_args.Add (new Argument (new TypeOf (new TypeExpression (ec.CurrentType, loc), loc))); binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation (args.CreateDynamicBinderArguments (ec), loc))); @@ -4054,7 +3976,7 @@ namespace Mono.CSharp args.Add (new Argument (right.CreateExpressionTree (ec))); if (method != null) { if (lift_arg) - args.Add (new Argument (new BoolLiteral (false, loc))); + args.Add (new Argument (new BoolLiteral (ec.BuiltinTypes, false, loc))); args.Add (new Argument (method)); } @@ -4073,16 +3995,13 @@ namespace Mono.CSharp // Represents the operation a + b [+ c [+ d [+ ...]]], where a is a string // b, c, d... may be strings or objects. // - public class StringConcat : Expression { + public class StringConcat : Expression + { Arguments arguments; - static IList concat_members; - public StringConcat (Expression left, Expression right, Location loc) + StringConcat (Location loc) { this.loc = loc; - type = TypeManager.string_type; - eclass = ExprClass.Value; - arguments = new Arguments (2); } @@ -4091,7 +4010,10 @@ namespace Mono.CSharp if (left.eclass == ExprClass.Unresolved || right.eclass == ExprClass.Unresolved) throw new ArgumentException (); - var s = new StringConcat (left, right, loc); + var s = new StringConcat (loc); + s.type = rc.BuiltinTypes.String; + s.eclass = ExprClass.Value; + s.Append (rc, left); s.Append (rc, right); return s; @@ -4117,7 +4039,7 @@ namespace Mono.CSharp concat_args.Add (arguments [pos]); add_args.Add (new Argument (arguments [pos].CreateExpressionTree (ec))); - var methods = CreateConcatMethodCandidates (); + var methods = GetConcatMethodCandidates (); if (methods == null) return null; @@ -4152,8 +4074,7 @@ namespace Mono.CSharp Argument last_argument = arguments [arguments.Count - 1]; StringConstant last_expr_constant = last_argument.Expr as StringConstant; if (last_expr_constant != null) { - last_argument.Expr = new StringConstant ( - last_expr_constant.Value + sc.Value, sc.Location).Resolve (rc); + last_argument.Expr = new StringConstant (rc.BuiltinTypes, last_expr_constant.Value + sc.Value, sc.Location); return; } } @@ -4171,18 +4092,14 @@ namespace Mono.CSharp arguments.Add (new Argument (operand)); } - IList CreateConcatMethodCandidates () + IList GetConcatMethodCandidates () { - if (concat_members == null) { - concat_members = MemberCache.FindMembers (type, "Concat", true); - } - - return concat_members; + return MemberCache.FindMembers (type, "Concat", true); } public override void Emit (EmitContext ec) { - var members = CreateConcatMethodCandidates (); + var members = GetConcatMethodCandidates (); var res = new OverloadResolver (members, OverloadResolver.Restrictions.NoBaseMembers, loc); var method = res.ResolveMember (new ResolveContext (ec.MemberContext), ref arguments); if (method != null) @@ -4197,11 +4114,6 @@ namespace Mono.CSharp var concat = typeof (string).GetMethod ("Concat", new[] { typeof (object), typeof (object) }); return SLE.Expression.Add (arguments[0].Expr.MakeExpression (ctx), arguments[1].Expr.MakeExpression (ctx), concat); } - - public static void Reset () - { - concat_members = null; - } } // @@ -4287,7 +4199,7 @@ namespace Mono.CSharp eclass = ExprClass.Variable; var pc = left.Type as PointerContainer; - if (pc != null && pc.Element.BuildinType == BuildinTypeSpec.Type.Void) { + if (pc != null && pc.Element.Kind == MemberKind.Void) { Error_VoidPointerOperation (ec); return null; } @@ -4311,7 +4223,7 @@ namespace Mono.CSharp element = op_type; } - int size = GetTypeSize (element); + int size = BuiltinTypeSpec.GetSize(element); TypeSpec rtype = right.Type; if ((op & Binary.Operator.SubtractionMask) != 0 && rtype.IsPointer){ @@ -4357,7 +4269,7 @@ namespace Mono.CSharp return; if (size != 0) - right = new IntConstant (size, right.Location); + right = new IntConstant (ec.BuiltinTypes, size, right.Location); else right = new SizeOf (new TypeExpression (element, right.Location), right.Location); @@ -4369,11 +4281,16 @@ namespace Mono.CSharp } right.Emit (ec); - if (rtype == TypeManager.sbyte_type || rtype == TypeManager.byte_type || - rtype == TypeManager.short_type || rtype == TypeManager.ushort_type) { + switch (rtype.BuiltinType) { + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: ec.Emit (OpCodes.Conv_I); - } else if (rtype == TypeManager.uint32_type) { + break; + case BuiltinTypeSpec.Type.UInt: ec.Emit (OpCodes.Conv_U); + break; } if (right_const == null && size != 1){ @@ -4381,16 +4298,16 @@ namespace Mono.CSharp ec.Emit (OpCodes.Sizeof, element); else ec.EmitInt (size); - if (rtype == TypeManager.int64_type || rtype == TypeManager.uint64_type) + if (rtype.BuiltinType == BuiltinTypeSpec.Type.Long || rtype.BuiltinType == BuiltinTypeSpec.Type.ULong) ec.Emit (OpCodes.Conv_I8); Binary.EmitOperatorOpcode (ec, Binary.Operator.Multiply, rtype); } if (left_const == null) { - if (rtype == TypeManager.int64_type) + if (rtype.BuiltinType == BuiltinTypeSpec.Type.Long) ec.Emit (OpCodes.Conv_I); - else if (rtype == TypeManager.uint64_type) + else if (rtype.BuiltinType == BuiltinTypeSpec.Type.ULong) ec.Emit (OpCodes.Conv_U); Binary.EmitOperatorOpcode (ec, op, op_type); @@ -4434,16 +4351,16 @@ namespace Mono.CSharp "Assignment in conditional expression is always constant. Did you mean to use `==' instead ?"); } - if (expr.Type == TypeManager.bool_type) + if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Bool) return expr; - if (expr.Type == InternalType.Dynamic) { + if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments args = new Arguments (1); args.Add (new Argument (expr)); - return DynamicUnaryConversion.CreateIsTrue (args, loc).Resolve (ec); + return DynamicUnaryConversion.CreateIsTrue (ec, args, loc).Resolve (ec); } - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; Expression converted = Convert.ImplicitConversion (ec, expr, type, loc); if (converted != null) return converted; @@ -4540,13 +4457,13 @@ namespace Mono.CSharp // if (!TypeSpecComparer.IsEqual (true_type, false_type)) { Expression conv = Convert.ImplicitConversion (ec, true_expr, false_type, loc); - if (conv != null && true_type != InternalType.Dynamic) { + if (conv != null && true_type.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { // // Check if both can convert implicitly to each other's type // type = false_type; - if (false_type != InternalType.Dynamic && Convert.ImplicitConversion (ec, false_expr, true_type, loc) != null) { + if (false_type.BuiltinType != BuiltinTypeSpec.Type.Dynamic && Convert.ImplicitConversion (ec, false_expr, true_type, loc) != null) { ec.Report.Error (172, true_expr.Location, "Type of conditional expression cannot be determined as `{0}' and `{1}' convert implicitly to each other", true_type.GetSignatureForError (), false_type.GetSignatureForError ()); @@ -4687,8 +4604,6 @@ namespace Mono.CSharp public void Emit (EmitContext ec, bool leave_copy) { - Report.Debug (64, "VARIABLE EMIT", this, Variable, type, IsRef, loc); - HoistedVariable hv = GetHoistedVariable (ec); if (hv != null) { hv.Emit (ec, leave_copy); @@ -4888,13 +4803,13 @@ namespace Mono.CSharp public override Expression DoResolveLValue (ResolveContext ec, Expression right_side) { // is out param - if (right_side == EmptyExpression.OutAccess.Instance) + if (right_side == EmptyExpression.OutAccess) local_info.SetIsUsed (); if (local_info.IsReadonly && !ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.UsingInitializerScope)) { int code; string msg; - if (right_side == EmptyExpression.OutAccess.Instance) { + if (right_side == EmptyExpression.OutAccess) { code = 1657; msg = "Cannot pass `{0}' as a ref or out argument because it is a `{1}'"; } else if (right_side == EmptyExpression.LValueMemberAccess) { code = 1654; msg = "Cannot assign to members of `{0}' because it is a `{1}'"; @@ -5243,7 +5158,7 @@ namespace Mono.CSharp arguments.Resolve (ec, out dynamic_arg); TypeSpec expr_type = member_expr.Type; - if (expr_type == InternalType.Dynamic) + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) return DoResolveDynamic (ec, member_expr); mg = member_expr as MethodGroupExpr; @@ -5286,7 +5201,7 @@ namespace Mono.CSharp var method = mg.BestCandidate; type = mg.BestCandidateReturnType; - if (arguments == null && method.DeclaringType == TypeManager.object_type && method.Name == Destructor.MetadataName) { + if (arguments == null && method.DeclaringType.BuiltinType == BuiltinTypeSpec.Type.Object && method.Name == Destructor.MetadataName) { if (mg.IsBase) ec.Report.Error (250, loc, "Do not directly call your base class Finalize method. It is called automatically from your destructor"); else @@ -5381,7 +5296,7 @@ namespace Mono.CSharp case MemberKind.Field: case MemberKind.Property: var m = member as IInterfaceMemberSpec; - return m.MemberType.IsDelegate || m.MemberType == InternalType.Dynamic; + return m.MemberType.IsDelegate || m.MemberType.BuiltinType == BuiltinTypeSpec.Type.Dynamic; default: return false; } @@ -5464,7 +5379,7 @@ namespace Mono.CSharp LocalTemporary this_arg = null; // Speed up the check by not doing it on not allowed targets - if (method.ReturnType == TypeManager.void_type && method.IsConditionallyExcluded (loc)) + if (method.ReturnType.Kind == MemberKind.Void && method.IsConditionallyExcluded (ec.Module.Compiler, loc)) return; OpCode call_op; @@ -5492,7 +5407,7 @@ namespace Mono.CSharp // Push the instance expression // if ((iexpr_type.IsStruct && (call_op == OpCodes.Callvirt || (call_op == OpCodes.Call && method.DeclaringType == iexpr_type))) || - iexpr_type.IsGenericParameter || TypeManager.IsNullableType (method.DeclaringType)) { + iexpr_type.IsGenericParameter || method.DeclaringType.IsNullableType) { // // If the expression implements IMemoryLocation, then // we can optimize and use AddressOf on the @@ -5512,11 +5427,11 @@ namespace Mono.CSharp // avoid the overhead of doing this all the time. if (dup_args) - t = ReferenceContainer.MakeType (iexpr_type); + t = ReferenceContainer.MakeType (ec.Module, iexpr_type); } else if (iexpr_type.IsEnum || iexpr_type.IsStruct) { instance_expr.Emit (ec); ec.Emit (OpCodes.Box, iexpr_type); - t = iexpr_type = TypeManager.object_type; + t = iexpr_type = ec.BuiltinTypes.Object; } else { instance_expr.Emit (ec); } @@ -5576,7 +5491,7 @@ namespace Mono.CSharp // // Pop the return value if there is one // - if (type != TypeManager.void_type) + if (type.Kind != MemberKind.Void) ec.Emit (OpCodes.Pop); } @@ -5652,35 +5567,39 @@ namespace Mono.CSharp /// public static Constant Constantify (TypeSpec t, Location loc) { - if (t == TypeManager.int32_type) - return new IntConstant (0, loc); - if (t == TypeManager.uint32_type) - return new UIntConstant (0, loc); - if (t == TypeManager.int64_type) - return new LongConstant (0, loc); - if (t == TypeManager.uint64_type) - return new ULongConstant (0, loc); - if (t == TypeManager.float_type) - return new FloatConstant (0, loc); - if (t == TypeManager.double_type) - return new DoubleConstant (0, loc); - if (t == TypeManager.short_type) - return new ShortConstant (0, loc); - if (t == TypeManager.ushort_type) - return new UShortConstant (0, loc); - if (t == TypeManager.sbyte_type) - return new SByteConstant (0, loc); - if (t == TypeManager.byte_type) - return new ByteConstant (0, loc); - if (t == TypeManager.char_type) - return new CharConstant ('\0', loc); - if (t == TypeManager.bool_type) - return new BoolConstant (false, loc); - if (t == TypeManager.decimal_type) - return new DecimalConstant (0, loc); - if (TypeManager.IsEnumType (t)) + switch (t.BuiltinType) { + case BuiltinTypeSpec.Type.Int: + return new IntConstant (t, 0, loc); + case BuiltinTypeSpec.Type.UInt: + return new UIntConstant (t, 0, loc); + case BuiltinTypeSpec.Type.Long: + return new LongConstant (t, 0, loc); + case BuiltinTypeSpec.Type.ULong: + return new ULongConstant (t, 0, loc); + case BuiltinTypeSpec.Type.Float: + return new FloatConstant (t, 0, loc); + case BuiltinTypeSpec.Type.Double: + return new DoubleConstant (t, 0, loc); + case BuiltinTypeSpec.Type.Short: + return new ShortConstant (t, 0, loc); + case BuiltinTypeSpec.Type.UShort: + return new UShortConstant (t, 0, loc); + case BuiltinTypeSpec.Type.SByte: + return new SByteConstant (t, 0, loc); + case BuiltinTypeSpec.Type.Byte: + return new ByteConstant (t, 0, loc); + case BuiltinTypeSpec.Type.Char: + return new CharConstant (t, '\0', loc); + case BuiltinTypeSpec.Type.Bool: + return new BoolConstant (t, false, loc); + case BuiltinTypeSpec.Type.Decimal: + return new DecimalConstant (t, 0, loc); + } + + if (t.IsEnum) return new EnumConstant (Constantify (EnumSpec.GetUnderlyingType (t), loc), t); - if (TypeManager.IsNullableType (t)) + + if (t.IsNullableType) return Nullable.LiftedNull.Create (t, loc); return null; @@ -5741,7 +5660,7 @@ namespace Mono.CSharp if (arguments == null) { Constant c = Constantify (type, RequestedType.Location); if (c != null) - return ReducedExpression.Create (c.Resolve (ec), this); + return ReducedExpression.Create (c, this); } if (TypeManager.IsDelegateType (type)) { @@ -5812,17 +5731,11 @@ namespace Mono.CSharp bool DoEmitTypeParameter (EmitContext ec) { - var activator = ec.MemberContext.Module.PredefinedTypes.Activator; - var t = activator.Resolve (loc); - if (t == null) + var m = ec.Module.PredefinedMembers.ActivatorCreateInstance.Resolve (loc); + if (m == null) return true; - if (TypeManager.activator_create_instance == null) { - TypeManager.activator_create_instance = TypeManager.GetPredefinedMethod ( - t, MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null), loc); - } - - var ctor_factory = TypeManager.activator_create_instance.MakeGenericMethod (type); + var ctor_factory = m.MakeGenericMethod (ec.MemberContext, type); var tparam = (TypeParameterSpec) type; if (tparam.IsReferenceType) { @@ -5957,16 +5870,6 @@ namespace Mono.CSharp return value_target; } - if (!TypeManager.IsStruct (type)){ - // - // We throw an exception. So far, I believe we only need to support - // value types: - // foreach (int j in new StructType ()) - // see bug 42390 - // - throw new Exception ("AddressOf should not be used for classes"); - } - value_target.AddressOf (ec, AddressOp.Store); if (method == null) { @@ -6326,23 +6229,17 @@ namespace Mono.CSharp return CreateExpressionFactoryCall (ec, "NewArrayInit", args); } - public void UpdateIndices () + void UpdateIndices (ResolveContext rc) { int i = 0; for (var probe = initializers; probe != null;) { - if (probe.Count > 0 && probe [0] is ArrayInitializer) { - Expression e = new IntConstant (probe.Count, Location.Null); - arguments.Add (e); - - bounds [i++] = probe.Count; + Expression e = new IntConstant (rc.BuiltinTypes, probe.Count, Location.Null); + arguments.Add (e); + bounds[i++] = probe.Count; + if (probe.Count > 0 && probe [0] is ArrayInitializer) { probe = (ArrayInitializer) probe[0]; - } else { - Expression e = new IntConstant (probe.Count, Location.Null); - arguments.Add (e); - - bounds [i++] = probe.Count; return; } } @@ -6385,7 +6282,7 @@ namespace Mono.CSharp if (!CheckIndices (ec, initializers, 0, false, dimensions)) return false; - UpdateIndices (); + UpdateIndices (ec); return true; } @@ -6451,7 +6348,7 @@ namespace Mono.CSharp if (TypeManager.IsEnumType (element_type)) element_type = EnumSpec.GetUnderlyingType (element_type); - factor = GetTypeSize (element_type); + factor = BuiltinTypeSpec.GetSize (element_type); if (factor == 0) throw new Exception ("unrecognized type in MakeByteBlob: " + element_type); @@ -6459,130 +6356,111 @@ namespace Mono.CSharp int idx = 0; for (int i = 0; i < count; ++i) { - object v = array_data [i]; - - if (v is EnumConstant) - v = ((EnumConstant) v).Child; - - if (v is Constant && !(v is StringConstant)) - v = ((Constant) v).GetValue (); - else { + var c = array_data[i] as Constant; + if (c == null) { idx += factor; continue; } - - if (element_type == TypeManager.int64_type){ - if (!(v is Expression)){ - long val = (long) v; - - for (int j = 0; j < factor; ++j) { - data [idx + j] = (byte) (val & 0xFF); - val = (val >> 8); - } - } - } else if (element_type == TypeManager.uint64_type){ - if (!(v is Expression)){ - ulong val = (ulong) v; - for (int j = 0; j < factor; ++j) { - data [idx + j] = (byte) (val & 0xFF); - val = (val >> 8); - } - } - } else if (element_type == TypeManager.float_type) { - if (!(v is Expression)){ - element = BitConverter.GetBytes ((float) v); - - for (int j = 0; j < factor; ++j) - data [idx + j] = element [j]; - if (!BitConverter.IsLittleEndian) - System.Array.Reverse (data, idx, 4); - } - } else if (element_type == TypeManager.double_type) { - if (!(v is Expression)){ - element = BitConverter.GetBytes ((double) v); + object v = c.GetValue (); - for (int j = 0; j < factor; ++j) - data [idx + j] = element [j]; + switch (element_type.BuiltinType) { + case BuiltinTypeSpec.Type.Long: + long lval = (long) v; - // FIXME: Handle the ARM float format. - if (!BitConverter.IsLittleEndian) - System.Array.Reverse (data, idx, 8); + for (int j = 0; j < factor; ++j) { + data[idx + j] = (byte) (lval & 0xFF); + lval = (lval >> 8); } - } else if (element_type == TypeManager.char_type){ - if (!(v is Expression)){ - int val = (int) ((char) v); - - data [idx] = (byte) (val & 0xff); - data [idx+1] = (byte) (val >> 8); - } - } else if (element_type == TypeManager.short_type){ - if (!(v is Expression)){ - int val = (int) ((short) v); - - data [idx] = (byte) (val & 0xff); - data [idx+1] = (byte) (val >> 8); - } - } else if (element_type == TypeManager.ushort_type){ - if (!(v is Expression)){ - int val = (int) ((ushort) v); - - data [idx] = (byte) (val & 0xff); - data [idx+1] = (byte) (val >> 8); - } - } else if (element_type == TypeManager.int32_type) { - if (!(v is Expression)){ - int val = (int) v; - - data [idx] = (byte) (val & 0xff); - data [idx+1] = (byte) ((val >> 8) & 0xff); - data [idx+2] = (byte) ((val >> 16) & 0xff); - data [idx+3] = (byte) (val >> 24); - } - } else if (element_type == TypeManager.uint32_type) { - if (!(v is Expression)){ - uint val = (uint) v; - - data [idx] = (byte) (val & 0xff); - data [idx+1] = (byte) ((val >> 8) & 0xff); - data [idx+2] = (byte) ((val >> 16) & 0xff); - data [idx+3] = (byte) (val >> 24); - } - } else if (element_type == TypeManager.sbyte_type) { - if (!(v is Expression)){ - sbyte val = (sbyte) v; - data [idx] = (byte) val; - } - } else if (element_type == TypeManager.byte_type) { - if (!(v is Expression)){ - byte val = (byte) v; - data [idx] = (byte) val; - } - } else if (element_type == TypeManager.bool_type) { - if (!(v is Expression)){ - bool val = (bool) v; - data [idx] = (byte) (val ? 1 : 0); + break; + case BuiltinTypeSpec.Type.ULong: + ulong ulval = (ulong) v; + + for (int j = 0; j < factor; ++j) { + data[idx + j] = (byte) (ulval & 0xFF); + ulval = (ulval >> 8); } - } else if (element_type == TypeManager.decimal_type){ - if (!(v is Expression)){ - int [] bits = Decimal.GetBits ((decimal) v); - int p = idx; - - // FIXME: For some reason, this doesn't work on the MS runtime. - int [] nbits = new int [4]; - nbits [0] = bits [3]; - nbits [1] = bits [2]; - nbits [2] = bits [0]; - nbits [3] = bits [1]; - - for (int j = 0; j < 4; j++){ - data [p++] = (byte) (nbits [j] & 0xff); - data [p++] = (byte) ((nbits [j] >> 8) & 0xff); - data [p++] = (byte) ((nbits [j] >> 16) & 0xff); - data [p++] = (byte) (nbits [j] >> 24); - } + break; + case BuiltinTypeSpec.Type.Float: + element = BitConverter.GetBytes ((float) v); + + for (int j = 0; j < factor; ++j) + data[idx + j] = element[j]; + if (!BitConverter.IsLittleEndian) + System.Array.Reverse (data, idx, 4); + break; + case BuiltinTypeSpec.Type.Double: + element = BitConverter.GetBytes ((double) v); + + for (int j = 0; j < factor; ++j) + data[idx + j] = element[j]; + + // FIXME: Handle the ARM float format. + if (!BitConverter.IsLittleEndian) + System.Array.Reverse (data, idx, 8); + break; + case BuiltinTypeSpec.Type.Char: + int chval = (int) ((char) v); + + data[idx] = (byte) (chval & 0xff); + data[idx + 1] = (byte) (chval >> 8); + break; + case BuiltinTypeSpec.Type.Short: + int sval = (int) ((short) v); + + data[idx] = (byte) (sval & 0xff); + data[idx + 1] = (byte) (sval >> 8); + break; + case BuiltinTypeSpec.Type.UShort: + int usval = (int) ((ushort) v); + + data[idx] = (byte) (usval & 0xff); + data[idx + 1] = (byte) (usval >> 8); + break; + case BuiltinTypeSpec.Type.Int: + int val = (int) v; + + data[idx] = (byte) (val & 0xff); + data[idx + 1] = (byte) ((val >> 8) & 0xff); + data[idx + 2] = (byte) ((val >> 16) & 0xff); + data[idx + 3] = (byte) (val >> 24); + break; + case BuiltinTypeSpec.Type.UInt: + uint uval = (uint) v; + + data[idx] = (byte) (uval & 0xff); + data[idx + 1] = (byte) ((uval >> 8) & 0xff); + data[idx + 2] = (byte) ((uval >> 16) & 0xff); + data[idx + 3] = (byte) (uval >> 24); + break; + case BuiltinTypeSpec.Type.SByte: + data[idx] = (byte) (sbyte) v; + break; + case BuiltinTypeSpec.Type.Byte: + data[idx] = (byte) v; + break; + case BuiltinTypeSpec.Type.Bool: + data[idx] = (byte) ((bool) v ? 1 : 0); + break; + case BuiltinTypeSpec.Type.Decimal: + int[] bits = Decimal.GetBits ((decimal) v); + int p = idx; + + // FIXME: For some reason, this doesn't work on the MS runtime. + int[] nbits = new int[4]; + nbits[0] = bits[3]; + nbits[1] = bits[2]; + nbits[2] = bits[0]; + nbits[3] = bits[1]; + + for (int j = 0; j < 4; j++) { + data[p++] = (byte) (nbits[j] & 0xff); + data[p++] = (byte) ((nbits[j] >> 8) & 0xff); + data[p++] = (byte) ((nbits[j] >> 16) & 0xff); + data[p++] = (byte) (nbits[j] >> 24); } - } else { + break; + default: throw new Exception ("Unrecognized type in MakeByteBlob: " + element_type); } @@ -6610,22 +6488,15 @@ namespace Mono.CSharp #endif } #endif +#if STATIC // // Emits the initializers for the array // void EmitStaticInitializers (EmitContext ec) { - if (TypeManager.void_initializearray_array_fieldhandle == null) { - var helper = ec.CurrentTypeDefinition.Module.PredefinedTypes.RuntimeHelpers.Resolve (loc); - if (helper == null) - return; - - TypeManager.void_initializearray_array_fieldhandle = TypeManager.GetPredefinedMethod ( - helper, "InitializeArray", loc, - TypeManager.array_type, TypeManager.runtime_field_handle_type); - if (TypeManager.void_initializearray_array_fieldhandle == null) - return; - } + var m = ec.Module.PredefinedMembers.RuntimeHelpersInitializeArray.Resolve (loc); + if (m == null) + return; // // First, the static data @@ -6635,8 +6506,9 @@ namespace Mono.CSharp ec.Emit (OpCodes.Dup); ec.Emit (OpCodes.Ldtoken, fb); - ec.Emit (OpCodes.Call, TypeManager.void_initializearray_array_fieldhandle); + ec.Emit (OpCodes.Call, m); } +#endif // // Emits pieces of the array that can not be computed at compile @@ -6667,11 +6539,25 @@ namespace Mono.CSharp // If we are dealing with a struct, get the // address of it, so we can store it. // - if ((dims == 1) && TypeManager.IsStruct (etype) && - (!TypeManager.IsBuiltinOrEnum (etype) || - etype == TypeManager.decimal_type)) { - - ec.Emit (OpCodes.Ldelema, etype); + if (dims == 1 && etype.IsStruct) { + switch (etype.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Bool: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.Double: + break; + default: + ec.Emit (OpCodes.Ldelema, etype); + break; + } } e.Emit (ec); @@ -6706,17 +6592,20 @@ namespace Mono.CSharp if (initializers == null) return; +#if STATIC // Emit static initializer for arrays which have contain more than 2 items and // the static initializer will initialize at least 25% of array values or there // is more than 10 items to be initialized // NOTE: const_initializers_count does not contain default constant values. if (const_initializers_count > 2 && (array_data.Count > 10 || const_initializers_count * 4 > (array_data.Count)) && - (TypeManager.IsPrimitiveType (array_element_type) || TypeManager.IsEnumType (array_element_type))) { + (BuiltinTypeSpec.IsPrimitiveType (array_element_type) || array_element_type.IsEnum)) { EmitStaticInitializers (ec); if (!only_constant_initializers) EmitDynamicInitializers (ec, false); - } else { + } else +#endif + { EmitDynamicInitializers (ec, true); } @@ -6734,7 +6623,7 @@ namespace Mono.CSharp // No array covariance, except for array -> object if (type != targetType) { - if (targetType != TypeManager.object_type) { + if (targetType.BuiltinType != BuiltinTypeSpec.Type.Object) { base.EncodeAttributeValue (rc, enc, targetType); return; } @@ -6864,7 +6753,7 @@ namespace Mono.CSharp // UnifyInitializerElement (ec); - type = ArrayContainer.MakeType (array_element_type, dimensions); + type = ArrayContainer.MakeType (ec.Module, array_element_type, dimensions); eclass = ExprClass.Value; return this; } @@ -6893,25 +6782,15 @@ namespace Mono.CSharp sealed class CompilerGeneratedThis : This { - public static This Instance = new CompilerGeneratedThis (); - - private CompilerGeneratedThis () - : base (Location.Null) - { - } - public CompilerGeneratedThis (TypeSpec type, Location loc) : base (loc) { this.type = type; + eclass = ExprClass.Variable; } protected override Expression DoResolve (ResolveContext ec) { - eclass = ExprClass.Variable; - if (type == null) - type = ec.CurrentType; - return this; } @@ -7032,7 +6911,7 @@ namespace Mono.CSharp if (ignoreAnonymous || ec.CurrentAnonymousMethod == null) return true; - if (TypeManager.IsStruct (ec.CurrentType) && ec.CurrentIterator == null) + if (ec.CurrentType.IsStruct && ec.CurrentIterator == null) return false; return true; @@ -7091,7 +6970,7 @@ namespace Mono.CSharp if (type.IsClass){ if (right_side == EmptyExpression.UnaryAddress) ec.Report.Error (459, loc, "Cannot take the address of `this' because it is read-only"); - else if (right_side == EmptyExpression.OutAccess.Instance) + else if (right_side == EmptyExpression.OutAccess) ec.Report.Error (1605, loc, "Cannot pass `this' as a ref or out argument because it is read-only"); else ec.Report.Error (1604, loc, "Cannot assign to `this' because it is read-only"); @@ -7241,6 +7120,94 @@ namespace Mono.CSharp } } + class RefValueExpr : ShimExpression + { + FullNamedExpression texpr; + + public RefValueExpr (Expression expr, FullNamedExpression texpr, Location loc) + : base (expr) + { + this.texpr = texpr; + this.loc = loc; + } + + protected override Expression DoResolve (ResolveContext rc) + { + expr = expr.Resolve (rc); + texpr = texpr.ResolveAsTypeTerminal (rc, false); + if (expr == null || texpr == null) + return null; + + type = texpr.Type; + expr = Convert.ImplicitConversionRequired (rc, expr, rc.Module.PredefinedTypes.TypedReference.Resolve (loc), loc); + eclass = ExprClass.Value; + return this; + } + + public override void Emit (EmitContext ec) + { + expr.Emit (ec); + ec.Emit (OpCodes.Refanyval, type); + ec.EmitLoadFromPtr (type); + } + } + + class RefTypeExpr : ShimExpression + { + public RefTypeExpr (Expression expr, Location loc) + : base (expr) + { + this.loc = loc; + } + + protected override Expression DoResolve (ResolveContext rc) + { + expr = expr.Resolve (rc); + if (expr == null) + return null; + + expr = Convert.ImplicitConversionRequired (rc, expr, rc.Module.PredefinedTypes.TypedReference.Resolve (loc), loc); + if (expr == null) + return null; + + type = rc.BuiltinTypes.Type; + eclass = ExprClass.Value; + return this; + } + + public override void Emit (EmitContext ec) + { + expr.Emit (ec); + ec.Emit (OpCodes.Refanytype); + var m = ec.Module.PredefinedMembers.TypeGetTypeFromHandle.Resolve (loc); + if (m != null) + ec.Emit (OpCodes.Call, m); + } + } + + class MakeRefExpr : ShimExpression + { + public MakeRefExpr (Expression expr, Location loc) + : base (expr) + { + this.loc = loc; + } + + protected override Expression DoResolve (ResolveContext rc) + { + expr = expr.ResolveLValue (rc, EmptyExpression.LValueMemberAccess); + type = rc.Module.PredefinedTypes.TypedReference.Resolve (loc); + eclass = ExprClass.Value; + return this; + } + + public override void Emit (EmitContext ec) + { + ((IMemoryLocation) expr).AddressOf (ec, AddressOp.Load); + ec.Emit (OpCodes.Mkrefany, expr.Type); + } + } + /// /// Implements the typeof operator /// @@ -7293,26 +7260,16 @@ namespace Mono.CSharp typearg = texpr.Type; - if (typearg == TypeManager.void_type && !(QueriedType is TypeExpression)) { + if (typearg.Kind == MemberKind.Void && !(QueriedType is TypeExpression)) { ec.Report.Error (673, loc, "System.Void cannot be used from C#. Use typeof (void) to get the void type object"); } else if (texpr is DynamicTypeExpr) { ec.Report.Error (1962, QueriedType.Location, "The typeof operator cannot be used on the dynamic type"); } - type = TypeManager.type_type; + type = ec.BuiltinTypes.Type; QueriedType = texpr; - return DoResolveBase (); - } - - protected Expression DoResolveBase () - { - if (TypeManager.system_type_get_type_from_handle == null) { - TypeManager.system_type_get_type_from_handle = TypeManager.GetPredefinedMethod ( - TypeManager.type_type, "GetTypeFromHandle", loc, TypeManager.runtime_handle_type); - } - // Even though what is returned is a type object, it's treated as a value by the compiler. // In particular, 'typeof (Foo).X' is something totally different from 'Foo.X'. eclass = ExprClass.Value; @@ -7321,7 +7278,7 @@ namespace Mono.CSharp static bool ContainsDynamicType (TypeSpec type) { - if (type == InternalType.Dynamic) + if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) return true; var element_container = type as ElementTypeSpec; @@ -7348,7 +7305,7 @@ namespace Mono.CSharp var gt = typearg; while (gt != null) { if (InflatedTypeSpec.ContainsTypeParameter (gt)) { - rc.Compiler.Report.Error (416, loc, "`{0}': an attribute argument cannot use type parameters", + rc.Module.Compiler.Report.Error (416, loc, "`{0}': an attribute argument cannot use type parameters", typearg.GetSignatureForError ()); return; } @@ -7368,7 +7325,9 @@ namespace Mono.CSharp public override void Emit (EmitContext ec) { ec.Emit (OpCodes.Ldtoken, typearg); - ec.Emit (OpCodes.Call, TypeManager.system_type_get_type_from_handle); + var m = ec.Module.PredefinedMembers.TypeGetTypeFromHandle.Resolve (loc); + if (m != null) + ec.Emit (OpCodes.Call, m); } protected override void CloneTo (CloneContext clonectx, Expression t) @@ -7384,7 +7343,7 @@ namespace Mono.CSharp } } - class TypeOfMethod : TypeOfMember + sealed class TypeOfMethod : TypeOfMember { public TypeOfMethod (MethodSpec method, Location loc) : base (method, loc) @@ -7413,36 +7372,14 @@ namespace Mono.CSharp ec.Emit (OpCodes.Castclass, type); } - protected override string GetMethodName { - get { return "GetMethodFromHandle"; } - } - - protected override PredefinedType GetDeclaringType (PredefinedTypes types) + protected override PredefinedMember GetTypeFromHandle (EmitContext ec) { - return types.MethodBase; + return ec.Module.PredefinedMembers.MethodInfoGetMethodFromHandle; } - protected override PredefinedType GetRuntimeHandle (PredefinedTypes types) + protected override PredefinedMember GetTypeFromHandleGeneric (EmitContext ec) { - return types.RuntimeMethodHandle; - } - - protected override MethodSpec TypeFromHandle { - get { - return TypeManager.methodbase_get_type_from_handle; - } - set { - TypeManager.methodbase_get_type_from_handle = value; - } - } - - protected override MethodSpec TypeFromHandleGeneric { - get { - return TypeManager.methodbase_get_type_from_handle_generic; - } - set { - TypeManager.methodbase_get_type_from_handle_generic = value; - } + return ec.Module.PredefinedMembers.MethodInfoGetMethodFromHandle2; } } @@ -7466,27 +7403,6 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext ec) { - bool is_generic = member.DeclaringType.IsGenericOrParentIsGeneric; - var mi = is_generic ? TypeFromHandleGeneric : TypeFromHandle; - - if (mi == null) { - TypeSpec declaring_type = GetDeclaringType (ec.Module.PredefinedTypes).Resolve (loc); - TypeSpec handle_type = GetRuntimeHandle (ec.Module.PredefinedTypes).Resolve (loc); - - if (handle_type == null || declaring_type == null) - return null; - - mi = TypeManager.GetPredefinedMethod (declaring_type, GetMethodName, loc, - is_generic ? - new TypeSpec[] { handle_type, TypeManager.runtime_handle_type } : - new TypeSpec[] { handle_type } ); - - if (is_generic) - TypeFromHandleGeneric = mi; - else - TypeFromHandle = mi; - } - eclass = ExprClass.Value; return this; } @@ -7494,25 +7410,24 @@ namespace Mono.CSharp public override void Emit (EmitContext ec) { bool is_generic = member.DeclaringType.IsGenericOrParentIsGeneric; - MethodSpec mi; + PredefinedMember p; if (is_generic) { - mi = TypeFromHandleGeneric; + p = GetTypeFromHandleGeneric (ec); ec.Emit (OpCodes.Ldtoken, member.DeclaringType); } else { - mi = TypeFromHandle; + p = GetTypeFromHandle (ec); } - ec.Emit (OpCodes.Call, mi); + var mi = p.Resolve (loc); + if (mi != null) + ec.Emit (OpCodes.Call, mi); } - protected abstract PredefinedType GetDeclaringType (PredefinedTypes types); - protected abstract string GetMethodName { get; } - protected abstract PredefinedType GetRuntimeHandle (PredefinedTypes types); - protected abstract MethodSpec TypeFromHandle { get; set; } - protected abstract MethodSpec TypeFromHandleGeneric { get; set; } + protected abstract PredefinedMember GetTypeFromHandle (EmitContext ec); + protected abstract PredefinedMember GetTypeFromHandleGeneric (EmitContext ec); } - class TypeOfField : TypeOfMember + sealed class TypeOfField : TypeOfMember { public TypeOfField (FieldSpec field, Location loc) : base (field, loc) @@ -7534,36 +7449,14 @@ namespace Mono.CSharp base.Emit (ec); } - protected override PredefinedType GetDeclaringType (PredefinedTypes types) + protected override PredefinedMember GetTypeFromHandle (EmitContext ec) { - return types.FieldInfo; + return ec.Module.PredefinedMembers.FieldInfoGetFieldFromHandle; } - protected override string GetMethodName { - get { return "GetFieldFromHandle"; } - } - - protected override PredefinedType GetRuntimeHandle (PredefinedTypes types) + protected override PredefinedMember GetTypeFromHandleGeneric (EmitContext ec) { - return types.RuntimeFieldHandle; - } - - protected override MethodSpec TypeFromHandle { - get { - return TypeManager.fieldinfo_get_field_from_handle; - } - set { - TypeManager.fieldinfo_get_field_from_handle = value; - } - } - - protected override MethodSpec TypeFromHandleGeneric { - get { - return TypeManager.fieldinfo_get_field_from_handle_generic; - } - set { - TypeManager.fieldinfo_get_field_from_handle_generic = value; - } + return ec.Module.PredefinedMembers.FieldInfoGetFieldFromHandle2; } } @@ -7596,12 +7489,12 @@ namespace Mono.CSharp if (TypeManager.IsEnumType (type_queried)) type_queried = EnumSpec.GetUnderlyingType (type_queried); - int size_of = GetTypeSize (type_queried); + int size_of = BuiltinTypeSpec.GetSize (type_queried); if (size_of > 0) { - return new IntConstant (size_of, loc).Resolve (ec); + return new IntConstant (ec.BuiltinTypes, size_of, loc); } - if (!TypeManager.VerifyUnmanaged (ec.Compiler, type_queried, loc)){ + if (!TypeManager.VerifyUnmanaged (ec.Module, type_queried, loc)){ return null; } @@ -7611,7 +7504,7 @@ namespace Mono.CSharp TypeManager.CSharpName (type_queried)); } - type = TypeManager.int32_type; + type = ec.BuiltinTypes.Int; eclass = ExprClass.Value; return this; } @@ -7664,11 +7557,11 @@ namespace Mono.CSharp return base.ResolveAsTypeStep (ec, silent); } - int errors = ec.Compiler.Report.Errors; + int errors = ec.Module.Compiler.Report.Errors; expr = ec.LookupNamespaceAlias (alias); if (expr == null) { - if (errors == ec.Compiler.Report.Errors) - ec.Compiler.Report.Error (432, loc, "Alias `{0}' not found", alias); + if (errors == ec.Module.Compiler.Report.Errors) + ec.Module.Compiler.Report.Error (432, loc, "Alias `{0}' not found", alias); return null; } @@ -7678,7 +7571,7 @@ namespace Mono.CSharp if (expr.eclass == ExprClass.Type) { if (!silent) { - ec.Compiler.Report.Error (431, loc, + ec.Module.Compiler.Report.Error (431, loc, "Alias `{0}' cannot be used with '::' since it denotes a type. Consider replacing '::' with '.'", alias); } return null; @@ -7694,7 +7587,7 @@ namespace Mono.CSharp protected override void Error_IdentifierNotFound (IMemberContext rc, TypeSpec expr_type, string identifier) { - rc.Compiler.Report.Error (687, loc, + rc.Module.Compiler.Report.Error (687, loc, "A namespace alias qualifier `{0}' did not resolve to a namespace or a type", GetSignatureForError ()); } @@ -7822,7 +7715,7 @@ namespace Mono.CSharp Namespace ns = expr as Namespace; if (ns != null) { - FullNamedExpression retval = ns.Lookup (rc.Compiler, Name, Arity, loc); + FullNamedExpression retval = ns.Lookup (rc, Name, Arity, loc); if (retval == null) { ns.Error_NamespaceDoesNotExist (loc, Name, Arity, rc); @@ -7837,7 +7730,7 @@ namespace Mono.CSharp MemberExpr me; TypeSpec expr_type = expr.Type; - if (expr_type == InternalType.Dynamic) { + if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { me = expr as MemberExpr; if (me != null) me.ResolveInstanceExpression (rc, null); @@ -7850,20 +7743,19 @@ namespace Mono.CSharp const MemberKind dot_kinds = MemberKind.Class | MemberKind.Struct | MemberKind.Delegate | MemberKind.Enum | MemberKind.Interface | MemberKind.TypeParameter | MemberKind.ArrayType; - if ((expr_type.Kind & dot_kinds) == 0 || expr_type == TypeManager.void_type) { - if (expr_type == InternalType.Null && rc.Compiler.IsRuntimeBinder) + if ((expr_type.Kind & dot_kinds) == 0) { + if (expr_type == InternalType.NullLiteral && rc.IsRuntimeBinder) rc.Report.Error (Report.RuntimeErrorId, loc, "Cannot perform member binding on `null' value"); else Unary.Error_OperatorCannotBeApplied (rc, loc, ".", expr_type); return null; } - var current_type = rc.CurrentType; var lookup_arity = Arity; bool errorMode = false; Expression member_lookup; while (true) { - member_lookup = MemberLookup (errorMode ? null : rc, current_type, expr_type, Name, lookup_arity, restrictions, loc); + member_lookup = MemberLookup (rc, errorMode, expr_type, Name, lookup_arity, restrictions, loc); if (member_lookup == null) { // // Try to look for extension method when member lookup failed @@ -7908,7 +7800,6 @@ namespace Mono.CSharp if (member_lookup != null) break; - current_type = null; lookup_arity = 0; restrictions &= ~MemberLookupRestrictions.InvocableOnly; errorMode = true; @@ -7925,7 +7816,7 @@ namespace Mono.CSharp } } - if (!texpr.Type.IsAccessible (rc.CurrentType)) { + if (!texpr.Type.IsAccessible (rc)) { rc.Report.SymbolRelatedToPreviousError (member_lookup.Type); ErrorIsInaccesible (rc, member_lookup.Type.GetSignatureForError (), loc); return null; @@ -7977,7 +7868,7 @@ namespace Mono.CSharp Namespace ns = expr_resolved as Namespace; if (ns != null) { - FullNamedExpression retval = ns.Lookup (rc.Compiler, Name, Arity, loc); + FullNamedExpression retval = ns.Lookup (rc, Name, Arity, loc); if (retval == null) { if (!silent) @@ -7995,7 +7886,7 @@ namespace Mono.CSharp TypeSpec expr_type = tnew_expr.Type; if (TypeManager.IsGenericParameter (expr_type)) { - rc.Compiler.Report.Error (704, loc, "A nested type cannot be specified through a type parameter `{0}'", + rc.Module.Compiler.Report.Error (704, loc, "A nested type cannot be specified through a type parameter `{0}'", tnew_expr.GetSignatureForError ()); return null; } @@ -8018,7 +7909,7 @@ namespace Mono.CSharp break; } - if (nested.IsAccessible (rc.CurrentType)) + if (nested.IsAccessible (rc)) break; // Keep looking after inaccessible candidate @@ -8044,23 +7935,23 @@ namespace Mono.CSharp var nested = MemberCache.FindNestedType (expr_type, Name, -System.Math.Max (1, Arity)); if (nested != null) { - Error_TypeArgumentsCannotBeUsed (rc.Compiler.Report, expr.Location, nested, Arity); + Error_TypeArgumentsCannotBeUsed (rc.Module.Compiler.Report, expr.Location, nested, Arity); return; } - var any_other_member = MemberLookup (null, rc.CurrentType, expr_type, Name, 0, MemberLookupRestrictions.None, loc); + var any_other_member = MemberLookup (rc, true, expr_type, Name, 0, MemberLookupRestrictions.None, loc); if (any_other_member != null) { - any_other_member.Error_UnexpectedKind (rc.Compiler.Report, null, "type", loc); + any_other_member.Error_UnexpectedKind (rc.Module.Compiler.Report, null, "type", loc); return; } - rc.Compiler.Report.Error (426, loc, "The nested type `{0}' does not exist in the type `{1}'", + rc.Module.Compiler.Report.Error (426, loc, "The nested type `{0}' does not exist in the type `{1}'", Name, expr_type.GetSignatureForError ()); } protected override void Error_TypeDoesNotContainDefinition (ResolveContext ec, TypeSpec type, string name) { - if (RootContext.Version > LanguageVersion.ISO_2 && !ec.Compiler.IsRuntimeBinder && MethodGroupExpr.IsExtensionMethodArgument (expr)) { + if (ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2 && !ec.IsRuntimeBinder && MethodGroupExpr.IsExtensionMethodArgument (expr)) { ec.Report.SymbolRelatedToPreviousError (type); ec.Report.Error (1061, loc, "Type `{0}' does not contain a definition for `{1}' and no extension method `{1}' of type `{0}' could be found (are you missing a using directive or an assembly reference?)", @@ -8252,7 +8143,7 @@ namespace Mono.CSharp } var indexers = MemberCache.FindMembers (type, MemberCache.IndexerNameAlias, false); - if (indexers != null || type == InternalType.Dynamic) { + if (indexers != null || type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return new IndexerExpr (indexers, type, this); } @@ -8463,7 +8354,7 @@ namespace Mono.CSharp // Same cannot be done for reference type because array covariance and the // check in ldelema requires to specify the type of array element stored at the index // - if (t.IsStruct && ((prepare_for_load && !(source is DynamicExpressionStatement)) || !TypeManager.IsPrimitiveType (t))) { + if (t.IsStruct && ((prepare_for_load && !(source is DynamicExpressionStatement)) || !BuiltinTypeSpec.IsPrimitiveType (t))) { LoadArrayAndArguments (ec); ec.EmitArrayAddress (ac); @@ -8697,7 +8588,7 @@ namespace Mono.CSharp bool dynamic; arguments.Resolve (rc, out dynamic); - if (indexers == null && InstanceExpression.Type == InternalType.Dynamic) { + if (indexers == null && InstanceExpression.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { dynamic = true; } else { var res = new OverloadResolver (indexers, OverloadResolver.Restrictions.None, loc); @@ -8807,9 +8698,10 @@ namespace Mono.CSharp { base.Emit (ec); - if (ec.CurrentType.IsStruct) { - ec.Emit (OpCodes.Ldobj, ec.CurrentType); - ec.Emit (OpCodes.Box, ec.CurrentType); + var context_type = ec.CurrentType; + if (context_type.IsStruct) { + ec.Emit (OpCodes.Ldobj, context_type); + ec.Emit (OpCodes.Box, context_type); } } @@ -8844,12 +8736,14 @@ namespace Mono.CSharp /// This is also now used as a placeholder where a no-action expression /// is needed (the `New' class). /// - public class EmptyExpression : Expression { - public static readonly Expression Null = new EmptyExpression (); - - public class OutAccess : EmptyExpression + class EmptyExpression : Expression + { + sealed class OutAccessExpression : EmptyExpression { - public static readonly OutAccess Instance = new OutAccess (); + public OutAccessExpression (TypeSpec t) + : base (t) + { + } public override Expression DoResolveLValue (ResolveContext rc, Expression right_side) { @@ -8860,33 +8754,14 @@ namespace Mono.CSharp } } - public static readonly EmptyExpression LValueMemberAccess = new EmptyExpression (); - public static readonly EmptyExpression LValueMemberOutAccess = new EmptyExpression (); - public static readonly EmptyExpression UnaryAddress = new EmptyExpression (); - public static readonly EmptyExpression EventAddition = new EmptyExpression (); - public static readonly EmptyExpression EventSubtraction = new EmptyExpression (); + public static readonly EmptyExpression LValueMemberAccess = new EmptyExpression (InternalType.FakeInternalType); + public static readonly EmptyExpression LValueMemberOutAccess = new EmptyExpression (InternalType.FakeInternalType); + public static readonly EmptyExpression UnaryAddress = new EmptyExpression (InternalType.FakeInternalType); + public static readonly EmptyExpression EventAddition = new EmptyExpression (InternalType.FakeInternalType); + public static readonly EmptyExpression EventSubtraction = new EmptyExpression (InternalType.FakeInternalType); public static readonly EmptyExpression MissingValue = new EmptyExpression (InternalType.FakeInternalType); - - static EmptyExpression temp = new EmptyExpression (); - public static EmptyExpression Grab () - { - EmptyExpression retval = temp == null ? new EmptyExpression () : temp; - temp = null; - return retval; - } - - public static void Release (EmptyExpression e) - { - temp = e; - } - - EmptyExpression () - { - // FIXME: Don't set to object - type = TypeManager.object_type; - eclass = ExprClass.Value; - loc = Location.Null; - } + public static readonly Expression Null = new EmptyExpression (InternalType.FakeInternalType); + public static readonly EmptyExpression OutAccess = new OutAccessExpression (InternalType.FakeInternalType); public EmptyExpression (TypeSpec t) { @@ -8913,16 +8788,6 @@ namespace Mono.CSharp public override void EmitSideEffect (EmitContext ec) { } - - // - // This is just because we might want to reuse this bad boy - // instead of creating gazillions of EmptyExpressions. - // (CanImplicitConversion uses it) - // - public void SetType (TypeSpec t) - { - type = t; - } } // @@ -8950,7 +8815,7 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext ec) { eclass = ExprClass.Value; - type = TypeManager.object_type; + type = ec.BuiltinTypes.Object; return this; } @@ -9131,40 +8996,40 @@ namespace Mono.CSharp single_spec = single_spec.Next; } else if (single_spec.IsPointer) { - if (!TypeManager.VerifyUnmanaged (ec.Compiler, type, loc)) + if (!TypeManager.VerifyUnmanaged (ec.Module, type, loc)) return null; if (!ec.IsUnsafe) { - UnsafeError (ec.Compiler.Report, loc); + UnsafeError (ec.Module.Compiler.Report, loc); } do { - type = PointerContainer.MakeType (type); + type = PointerContainer.MakeType (ec.Module, type); single_spec = single_spec.Next; } while (single_spec != null && single_spec.IsPointer); } if (single_spec != null && single_spec.Dimension > 0) { - if (TypeManager.IsSpecialType (type)) { - ec.Compiler.Report.Error (611, loc, "Array elements cannot be of type `{0}'", type.GetSignatureForError ()); + if (type.IsSpecialRuntimeType) { + ec.Module.Compiler.Report.Error (611, loc, "Array elements cannot be of type `{0}'", type.GetSignatureForError ()); } else if (type.IsStatic) { - ec.Compiler.Report.SymbolRelatedToPreviousError (type); - ec.Compiler.Report.Error (719, loc, "Array elements cannot be of static type `{0}'", + ec.Module.Compiler.Report.SymbolRelatedToPreviousError (type); + ec.Module.Compiler.Report.Error (719, loc, "Array elements cannot be of static type `{0}'", type.GetSignatureForError ()); } else { - MakeArray (single_spec); + MakeArray (ec.Module, single_spec); } } return this; } - void MakeArray (ComposedTypeSpecifier spec) + void MakeArray (ModuleContainer module, ComposedTypeSpecifier spec) { if (spec.Next != null) - MakeArray (spec.Next); + MakeArray (module, spec.Next); - type = ArrayContainer.MakeType (type, spec.Dimension); + type = ArrayContainer.MakeType (module, type, spec.Dimension); } public override string GetSignatureForError () @@ -9178,16 +9043,15 @@ namespace Mono.CSharp } } - public class FixedBufferPtr : Expression { - Expression array; + class FixedBufferPtr : Expression + { + readonly Expression array; public FixedBufferPtr (Expression array, TypeSpec array_type, Location l) { + this.type = array_type; this.array = array; this.loc = l; - - type = PointerContainer.MakeType (array_type); - eclass = ExprClass.Value; } public override Expression CreateExpressionTree (ResolveContext ec) @@ -9203,9 +9067,8 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext ec) { - // - // We are born fully resolved - // + type = PointerContainer.MakeType (ec.Module, type); + eclass = ExprClass.Value; return this; } } @@ -9216,13 +9079,11 @@ namespace Mono.CSharp // only by the Fixed statement, this generates "&a [0]" construct // for fixed (char *pa = a) // - public class ArrayPtr : FixedBufferPtr { - TypeSpec array_type; - + class ArrayPtr : FixedBufferPtr + { public ArrayPtr (Expression array, TypeSpec array_type, Location l): base (array, array_type, l) { - this.array_type = array_type; } public override void Emit (EmitContext ec) @@ -9230,7 +9091,7 @@ namespace Mono.CSharp base.Emit (ec); ec.EmitInt (0); - ec.Emit (OpCodes.Ldelema, array_type); + ec.Emit (OpCodes.Ldelema, ((PointerContainer) type).Element); } } @@ -9239,10 +9100,10 @@ namespace Mono.CSharp // public class ArrayIndexCast : TypeCast { - public ArrayIndexCast (Expression expr) - : base (expr, TypeManager.int32_type) + public ArrayIndexCast (Expression expr, TypeSpec returnType) + : base (expr, returnType) { - if (expr.Type == TypeManager.int32_type) + if (expr.Type == returnType) // int -> int throw new ArgumentException ("unnecessary array index conversion"); } @@ -9257,16 +9118,19 @@ namespace Mono.CSharp { child.Emit (ec); - var expr_type = child.Type; - - if (expr_type == TypeManager.uint32_type) + switch (child.Type.BuiltinType) { + case BuiltinTypeSpec.Type.UInt: ec.Emit (OpCodes.Conv_U); - else if (expr_type == TypeManager.int64_type) + break; + case BuiltinTypeSpec.Type.Long: ec.Emit (OpCodes.Conv_Ovf_I); - else if (expr_type == TypeManager.uint64_type) + break; + case BuiltinTypeSpec.Type.ULong: ec.Emit (OpCodes.Conv_Ovf_I_Un); - else + break; + default: throw new InternalErrorException ("Cannot emit cast to unknown array element type", type); + } } } @@ -9304,8 +9168,8 @@ namespace Mono.CSharp if (count == null) return null; - if (count.Type != TypeManager.uint32_type){ - count = Convert.ImplicitConversionRequired (ec, count, TypeManager.int32_type, loc); + if (count.Type.BuiltinType != BuiltinTypeSpec.Type.UInt){ + count = Convert.ImplicitConversionRequired (ec, count, ec.BuiltinTypes.Int, loc); if (count == null) return null; } @@ -9325,10 +9189,10 @@ namespace Mono.CSharp otype = texpr.Type; - if (!TypeManager.VerifyUnmanaged (ec.Compiler, otype, loc)) + if (!TypeManager.VerifyUnmanaged (ec.Module, otype, loc)) return null; - type = PointerContainer.MakeType (otype); + type = PointerContainer.MakeType (ec.Module, otype); eclass = ExprClass.Value; return this; @@ -9336,7 +9200,7 @@ namespace Mono.CSharp public override void Emit (EmitContext ec) { - int size = GetTypeSize (otype); + int size = BuiltinTypeSpec.GetSize (otype); count.Emit (ec); @@ -9402,15 +9266,15 @@ namespace Mono.CSharp return EmptyExpressionStatement.Instance; var t = ec.CurrentInitializerVariable.Type; - if (t == InternalType.Dynamic) { + if (t.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments args = new Arguments (1); args.Add (new Argument (ec.CurrentInitializerVariable)); target = new DynamicMemberBinder (Name, args, loc); } else { - var member = MemberLookup (ec, ec.CurrentType, t, Name, 0, MemberLookupRestrictions.ExactArity, loc); + var member = MemberLookup (ec, false, t, Name, 0, MemberLookupRestrictions.ExactArity, loc); if (member == null) { - member = Expression.MemberLookup (null, ec.CurrentType, t, Name, 0, MemberLookupRestrictions.ExactArity, loc); + member = Expression.MemberLookup (ec, true, t, Name, 0, MemberLookupRestrictions.ExactArity, loc); if (member != null) { // TODO: ec.Report.SymbolRelatedToPreviousError (member); @@ -9609,12 +9473,12 @@ namespace Mono.CSharp } else { var t = ec.CurrentInitializerVariable.Type; // LAMESPEC: The collection must implement IEnumerable only, no dynamic support - if (!t.ImplementsInterface (TypeManager.ienumerable_type, false) && t != InternalType.Dynamic) { + if (!t.ImplementsInterface (ec.BuiltinTypes.IEnumerable, false) && t.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { ec.Report.Error (1922, loc, "A field or property `{0}' cannot be initialized with a collection " + "object initializer because type `{1}' does not implement `{2}' interface", ec.CurrentInitializerVariable.GetSignatureForError (), TypeManager.CSharpName (ec.CurrentInitializerVariable.Type), - TypeManager.CSharpName (TypeManager.ienumerable_type)); + TypeManager.CSharpName (ec.BuiltinTypes.IEnumerable)); return null; } is_collection_initialization = true; @@ -9853,7 +9717,7 @@ namespace Mono.CSharp if (type != null) return type; - type = AnonymousTypeClass.Create (ec.Compiler, parent, parameters, loc); + type = AnonymousTypeClass.Create (parent, parameters, loc); if (type == null) return null; @@ -9970,8 +9834,7 @@ namespace Mono.CSharp } type = e.Type; - if (type == TypeManager.void_type || type == InternalType.Null || - type == InternalType.AnonymousMethod || type.IsPointer) { + if (type.Kind == MemberKind.Void || type == InternalType.NullLiteral || type == InternalType.AnonymousMethod || type.IsPointer) { Error_InvalidInitializer (ec, e.GetSignatureForError ()); return null; } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/field.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/field.cs index 739cfdebe..3fb807f53 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/field.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/field.cs @@ -199,7 +199,7 @@ namespace Mono.CSharp public virtual Constant ConvertInitializer (ResolveContext rc, Constant expr) { - return expr.ConvertImplicitly (rc, MemberType); + return expr.ConvertImplicitly (MemberType); } protected override void DoMemberTypeDependentChecks () @@ -225,7 +225,7 @@ namespace Mono.CSharp public override void Emit () { - if (member_type == InternalType.Dynamic) { + if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder); } else if (!(Parent is CompilerGeneratedClass) && member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder, member_type, Location); @@ -385,7 +385,7 @@ namespace Mono.CSharp public override Constant ConvertInitializer (ResolveContext rc, Constant expr) { - return expr.ImplicitConversionRequired (rc, TypeManager.int32_type, Location); + return expr.ImplicitConversionRequired (rc, rc.BuiltinTypes.Int, Location); } public override bool Define () @@ -393,7 +393,7 @@ namespace Mono.CSharp if (!base.Define ()) return false; - if (!TypeManager.IsPrimitiveType (MemberType)) { + if (!BuiltinTypeSpec.IsPrimitiveType (MemberType)) { Report.Error (1663, Location, "`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double", GetSignatureForError ()); @@ -411,12 +411,14 @@ namespace Mono.CSharp // Create nested fixed buffer container string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++); fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name, - TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, TypeManager.value_type.GetMetaInfo ()); + TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, + Compiler.BuiltinTypes.ValueType.GetMetaInfo ()); - fixed_buffer_type.DefineField (FixedElementName, MemberType.GetMetaInfo (), FieldAttributes.Public); + var ffield = fixed_buffer_type.DefineField (FixedElementName, MemberType.GetMetaInfo (), FieldAttributes.Public); FieldBuilder = Parent.TypeBuilder.DefineField (Name, fixed_buffer_type, ModifiersExtensions.FieldAttr (ModFlags)); - var element_spec = new FieldSpec (null, this, MemberType, FieldBuilder, ModFlags); + + var element_spec = new FieldSpec (null, this, MemberType, ffield, ModFlags); spec = new FixedFieldSpec (Parent.Definition, this, FieldBuilder, element_spec, ModFlags); Parent.MemberCache.AddMember (spec); @@ -455,14 +457,6 @@ namespace Mono.CSharp return; } - int type_size = Expression.GetTypeSize (MemberType); - - if (buffer_size > int.MaxValue / type_size) { - Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit", - GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType)); - return; - } - EmitFieldSize (buffer_size); #if STATIC @@ -479,19 +473,22 @@ namespace Mono.CSharp void EmitFieldSize (int buffer_size) { - PredefinedAttribute pa; - AttributeEncoder encoder; + int type_size = BuiltinTypeSpec.GetSize (MemberType); - pa = Module.PredefinedAttributes.StructLayout; - if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.short_type)) + if (buffer_size > int.MaxValue / type_size) { + Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit", + GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType)); return; + } - var char_set_type = Module.PredefinedTypes.CharSet.Resolve (Location); - if (char_set_type == null) + AttributeEncoder encoder; + + var ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location); + if (ctor == null) return; - var field_size = pa.GetField ("Size", TypeManager.int32_type, Location); - var field_charset = pa.GetField ("CharSet", char_set_type, Location); + var field_size = Module.PredefinedMembers.StructLayoutSize.Resolve (Location); + var field_charset = Module.PredefinedMembers.StructLayoutCharSet.Resolve (Location); if (field_size == null || field_charset == null) return; @@ -501,10 +498,13 @@ namespace Mono.CSharp encoder.Encode ((short)LayoutKind.Sequential); encoder.EncodeNamedArguments ( new [] { field_size, field_charset }, - new Constant [] { new IntConstant (buffer_size, Location), new IntConstant ((int) char_set, Location) } + new Constant [] { + new IntConstant (Compiler.BuiltinTypes, buffer_size * type_size, Location), + new IntConstant (Compiler.BuiltinTypes, (int) char_set, Location) + } ); - pa.EmitAttribute (fixed_buffer_type, encoder); + fixed_buffer_type.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); // // Don't emit FixedBufferAttribute attribute for private types @@ -512,8 +512,8 @@ namespace Mono.CSharp if ((ModFlags & Modifiers.PRIVATE) != 0) return; - pa = Module.PredefinedAttributes.FixedBuffer; - if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.type_type, TypeManager.int32_type)) + ctor = Module.PredefinedMembers.FixedBufferAttributeCtor.Resolve (Location); + if (ctor == null) return; encoder = new AttributeEncoder (); @@ -521,7 +521,7 @@ namespace Mono.CSharp encoder.Encode (buffer_size); encoder.EncodeEmptyNamedArguments (); - pa.EmitAttribute (FieldBuilder, encoder); + FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); } } @@ -580,13 +580,20 @@ namespace Mono.CSharp if (TypeManager.IsReferenceType (MemberType)) return true; - if (MemberType == TypeManager.bool_type || MemberType == TypeManager.char_type || - MemberType == TypeManager.sbyte_type || MemberType == TypeManager.byte_type || - MemberType == TypeManager.short_type || MemberType == TypeManager.ushort_type || - MemberType == TypeManager.int32_type || MemberType == TypeManager.uint32_type || - MemberType == TypeManager.float_type || - MemberType == TypeManager.intptr_type || MemberType == TypeManager.uintptr_type) + switch (MemberType.BuiltinType) { + case BuiltinTypeSpec.Type.Bool: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.UIntPtr: + case BuiltinTypeSpec.Type.IntPtr: return true; + } if (MemberType.IsEnum) return true; @@ -638,6 +645,10 @@ namespace Mono.CSharp } } +/* + if ((ModFlags & (Modifiers.STATIC | Modifiers.READONLY | Modifiers.COMPILER_GENERATED)) == Modifiers.STATIC) + Console.WriteLine ("{0}: {1}", Location.ToString (), GetSignatureForError ()); +*/ return true; } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs index 07c9233b1..eb8e6570b 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs @@ -1124,6 +1124,10 @@ namespace Mono.CSharp for (int i = 0; i < struct_info.Count; i++) { var field = struct_info.Fields [i]; + // Fixed size buffers are not subject to definite assignment checking + if (field is FixedFieldSpec) + continue; + if (!branching.IsFieldAssigned (vi, field.Name)) { if (field.MemberDefinition is Property.BackingField) { ec.Report.Error (843, loc, @@ -1260,7 +1264,7 @@ namespace Mono.CSharp public static StructInfo GetStructInfo (TypeSpec type) { - if (!type.IsStruct || TypeManager.IsBuiltinType (type)) + if (!type.IsStruct || type.BuiltinType > 0) return null; StructInfo info; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs index 51f480a19..826555276 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs @@ -104,7 +104,7 @@ namespace Mono.CSharp { public static bool CheckConflictingInheritedConstraint (TypeParameterSpec spec, TypeSpec bb, IMemberContext context, Location loc) { if (spec.HasSpecialClass && bb.IsStruct) { - context.Compiler.Report.Error (455, loc, + context.Module.Compiler.Report.Error (455, loc, "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'", spec.Name, "class", bb.GetSignatureForError ()); @@ -122,7 +122,7 @@ namespace Mono.CSharp { if (TypeSpec.IsBaseClass (ba, bb, false) || TypeSpec.IsBaseClass (bb, ba, false)) return true; - context.Compiler.Report.Error (455, loc, + context.Module.Compiler.Report.Error (455, loc, "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'", spec.Name, ba.GetSignatureForError (), bb.GetSignatureForError ()); return false; @@ -154,7 +154,7 @@ namespace Mono.CSharp { List tparam_types = null; bool iface_found = false; - spec.BaseType = TypeManager.object_type; + spec.BaseType = context.Module.Compiler.BuiltinTypes.Object; for (int i = 0; i < constraints.Count; ++i) { var constraint = constraints[i]; @@ -162,7 +162,7 @@ namespace Mono.CSharp { if (constraint is SpecialContraintExpr) { spec.SpecialConstraint |= ((SpecialContraintExpr) constraint).Constraint; if (spec.HasSpecialStruct) - spec.BaseType = TypeManager.value_type; + spec.BaseType = context.Module.Compiler.BuiltinTypes.ValueType; // Set to null as it does not have a type constraints[i] = null; @@ -175,7 +175,7 @@ namespace Mono.CSharp { var gexpr = type_expr as GenericTypeExpr; if (gexpr != null && gexpr.HasDynamicArguments ()) { - context.Compiler.Report.Error (1968, constraint.Location, + context.Module.Compiler.Report.Error (1968, constraint.Location, "A constraint cannot be the dynamic type `{0}'", gexpr.GetSignatureForError ()); continue; } @@ -183,15 +183,15 @@ namespace Mono.CSharp { var type = type_expr.Type; if (!context.CurrentMemberDefinition.IsAccessibleAs (type)) { - context.Compiler.Report.SymbolRelatedToPreviousError (type); - context.Compiler.Report.Error (703, loc, + context.Module.Compiler.Report.SymbolRelatedToPreviousError (type); + context.Module.Compiler.Report.Error (703, loc, "Inconsistent accessibility: constraint type `{0}' is less accessible than `{1}'", type.GetSignatureForError (), context.GetSignatureForError ()); } if (type.IsInterface) { if (!spec.AddInterface (type)) { - context.Compiler.Report.Error (405, constraint.Location, + context.Module.Compiler.Report.Error (405, constraint.Location, "Duplicate constraint `{0}' for type parameter `{1}'", type.GetSignatureForError (), tparam.Value); } @@ -205,7 +205,7 @@ namespace Mono.CSharp { if (tparam_types == null) { tparam_types = new List (2); } else if (tparam_types.Contains (constraint_tp)) { - context.Compiler.Report.Error (405, constraint.Location, + context.Module.Compiler.Report.Error (405, constraint.Location, "Duplicate constraint `{0}' for type parameter `{1}'", type.GetSignatureForError (), tparam.Value); continue; } @@ -220,7 +220,7 @@ namespace Mono.CSharp { var tp_def = constraint_tp.MemberDefinition as TypeParameter; if (tp_def != null && !tp_def.ResolveConstraints (context)) { - context.Compiler.Report.Error (454, constraint.Location, + context.Module.Compiler.Report.Error (454, constraint.Location, "Circular constraint dependency involving `{0}' and `{1}'", constraint_tp.GetSignatureForError (), tp.GetSignatureForError ()); continue; @@ -251,7 +251,7 @@ namespace Mono.CSharp { } if (constraint_tp.HasSpecialStruct) { - context.Compiler.Report.Error (456, constraint.Location, + context.Module.Compiler.Report.Error (456, constraint.Location, "Type parameter `{0}' has the `struct' constraint, so it cannot be used as a constraint for `{1}'", constraint_tp.GetSignatureForError (), tp.GetSignatureForError ()); continue; @@ -262,39 +262,44 @@ namespace Mono.CSharp { } if (iface_found || spec.HasTypeConstraint) { - context.Compiler.Report.Error (406, constraint.Location, + context.Module.Compiler.Report.Error (406, constraint.Location, "The class type constraint `{0}' must be listed before any other constraints. Consider moving type constraint to the beginning of the constraint list", type.GetSignatureForError ()); } if (spec.HasSpecialStruct || spec.HasSpecialClass) { - context.Compiler.Report.Error (450, type_expr.Location, + context.Module.Compiler.Report.Error (450, type_expr.Location, "`{0}': cannot specify both a constraint class and the `class' or `struct' constraint", type.GetSignatureForError ()); } - if (type == InternalType.Dynamic) { - context.Compiler.Report.Error (1967, constraint.Location, "A constraint cannot be the dynamic type"); + switch (type.BuiltinType) { + case BuiltinTypeSpec.Type.Array: + case BuiltinTypeSpec.Type.Delegate: + case BuiltinTypeSpec.Type.MulticastDelegate: + case BuiltinTypeSpec.Type.Enum: + case BuiltinTypeSpec.Type.ValueType: + case BuiltinTypeSpec.Type.Object: + context.Module.Compiler.Report.Error (702, constraint.Location, + "A constraint cannot be special class `{0}'", type.GetSignatureForError ()); + continue; + case BuiltinTypeSpec.Type.Dynamic: + context.Module.Compiler.Report.Error (1967, constraint.Location, + "A constraint cannot be the dynamic type"); continue; } if (type.IsSealed || !type.IsClass) { - context.Compiler.Report.Error (701, loc, + context.Module.Compiler.Report.Error (701, loc, "`{0}' is not a valid constraint. A constraint must be an interface, a non-sealed class or a type parameter", TypeManager.CSharpName (type)); continue; } if (type.IsStatic) { - context.Compiler.Report.Error (717, constraint.Location, + context.Module.Compiler.Report.Error (717, constraint.Location, "`{0}' is not a valid constraint. Static classes cannot be used as constraints", type.GetSignatureForError ()); - } else if (type == TypeManager.array_type || type == TypeManager.delegate_type || - type == TypeManager.enum_type || type == TypeManager.value_type || - type == TypeManager.object_type || type == TypeManager.multicast_delegate_type) { - context.Compiler.Report.Error (702, constraint.Location, - "A constraint cannot be special class `{0}'", type.GetSignatureForError ()); - continue; } spec.BaseType = type; @@ -510,7 +515,7 @@ namespace Mono.CSharp { if (spec.HasSpecialConstructor) attr |= GenericParameterAttributes.DefaultConstructorConstraint; - if (spec.BaseType != TypeManager.object_type) + if (spec.BaseType.BuiltinType != BuiltinTypeSpec.Type.Object) builder.SetBaseTypeConstraint (spec.BaseType.GetMetaInfo ()); if (spec.InterfacesDefined != null) @@ -573,7 +578,7 @@ namespace Mono.CSharp { bool ITypeDefinition.IsInternalAsPublic (IAssemblyDefinition assembly) { - throw new NotImplementedException (); + return spec.GetEffectiveBase ().MemberDefinition.DeclaringAssembly == assembly; } public void LoadMembers (TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) @@ -590,7 +595,7 @@ namespace Mono.CSharp { return constraints.Resolve (context, this); if (spec.BaseType == null) - spec.BaseType = TypeManager.object_type; + spec.BaseType = context.Module.Compiler.BuiltinTypes.Object; return true; } @@ -676,7 +681,8 @@ namespace Mono.CSharp { public bool HasTypeConstraint { get { - return BaseType != TypeManager.object_type && BaseType != TypeManager.value_type; + var bt = BaseType.BuiltinType; + return bt != BuiltinTypeSpec.Type.Object && bt != BuiltinTypeSpec.Type.ValueType; } } @@ -720,7 +726,7 @@ namespace Mono.CSharp { return ifaces_defined; } set { - ifaces_defined = value; + ifaces = ifaces_defined = value; } } @@ -823,9 +829,8 @@ namespace Mono.CSharp { // public TypeSpec GetEffectiveBase () { - if (HasSpecialStruct) { - return TypeManager.value_type; - } + if (HasSpecialStruct) + return BaseType; if (BaseType != null && targs == null) return BaseType; @@ -839,7 +844,7 @@ namespace Mono.CSharp { if (types != null) return Convert.FindMostEncompassedType (types.Select (l => l.BaseType)); - return TypeManager.object_type; + return BaseType; } public override string GetSignatureForError () @@ -1006,7 +1011,7 @@ namespace Mono.CSharp { for (int i = 0; i < tparams.Length; ++i) { var tp = tparams[i]; - if (tp.HasTypeConstraint || tp.Interfaces != null || tp.TypeArguments != null) { + if (tp.HasTypeConstraint || tp.InterfacesDefined != null || tp.TypeArguments != null) { if (constraints == null) { constraints = new TypeParameterSpec[tparams.Length]; Array.Copy (tparams, constraints, constraints.Length); @@ -1064,7 +1069,7 @@ namespace Mono.CSharp { // For a type parameter the membercache is the union of the sets of members of the types // specified as a primary constraint or secondary constraint // - if (BaseType != TypeManager.object_type && BaseType != TypeManager.value_type) + if (BaseType.BuiltinType != BuiltinTypeSpec.Type.Object && BaseType.BuiltinType != BuiltinTypeSpec.Type.ValueType) cache.AddBaseType (BaseType); if (ifaces != null) { @@ -1075,8 +1080,9 @@ namespace Mono.CSharp { if (targs != null) { foreach (var ta in targs) { - if (ta.BaseType != TypeManager.object_type && ta.BaseType != TypeManager.value_type) - cache.AddBaseType (ta.BaseType); + var b_type = ta.BaseType; + if (b_type.BuiltinType != BuiltinTypeSpec.Type.Object && b_type.BuiltinType != BuiltinTypeSpec.Type.ValueType) + cache.AddBaseType (b_type); if (ta.Interfaces != null) { foreach (var iface_type in ta.Interfaces) { @@ -1117,17 +1123,19 @@ namespace Mono.CSharp { readonly TypeSpec type; readonly TypeParameterSpec[] tparams; readonly TypeSpec[] targs; + readonly IModuleContext context; public TypeParameterInflator (TypeParameterInflator nested, TypeSpec type) - : this (type, nested.tparams, nested.targs) + : this (nested.context, type, nested.tparams, nested.targs) { } - public TypeParameterInflator (TypeSpec type, TypeParameterSpec[] tparams, TypeSpec[] targs) + public TypeParameterInflator (IModuleContext context, TypeSpec type, TypeParameterSpec[] tparams, TypeSpec[] targs) { if (tparams.Length != targs.Length) throw new ArgumentException ("Invalid arguments"); + this.context = context; this.tparams = tparams; this.targs = targs; this.type = type; @@ -1135,8 +1143,16 @@ namespace Mono.CSharp { #region Properties + public IModuleContext Context { + get { + return context; + } + } + public TypeSpec TypeInstance { - get { return type; } + get { + return type; + } } // @@ -1160,7 +1176,7 @@ namespace Mono.CSharp { if (ac != null) { var et = Inflate (ac.Element); if (et != ac.Element) - return ArrayContainer.MakeType (et, ac.Rank); + return ArrayContainer.MakeType (context.Module, et, ac.Rank); return ac; } @@ -1202,7 +1218,7 @@ namespace Mono.CSharp { for (; i < targs.Length; ++i) inflated_targs[i] = Inflate (targs[i]); - type = type.MakeGenericType (inflated_targs); + type = type.MakeGenericType (context, inflated_targs); } return type; @@ -1231,7 +1247,7 @@ namespace Mono.CSharp { targs[i++] = Inflate (ds_tp); } - return type.MakeGenericType (targs); + return type.MakeGenericType (context, targs); } public TypeSpec Inflate (TypeParameterSpec tp) @@ -1252,9 +1268,9 @@ namespace Mono.CSharp { // public class TypeParameterMutator { - TypeParameter[] mvar; - TypeParameter[] var; - Dictionary mutated_typespec = new Dictionary (); + readonly TypeParameter[] mvar; + readonly TypeParameter[] var; + Dictionary mutated_typespec; public TypeParameterMutator (TypeParameter[] mvar, TypeParameter[] var) { @@ -1291,10 +1307,13 @@ namespace Mono.CSharp { public TypeSpec Mutate (TypeSpec ts) { TypeSpec value; - if (mutated_typespec.TryGetValue (ts, out value)) + if (mutated_typespec != null && mutated_typespec.TryGetValue (ts, out value)) return value; value = ts.Mutate (this); + if (mutated_typespec == null) + mutated_typespec = new Dictionary (); + mutated_typespec.Add (ts, value); return value; } @@ -1350,19 +1369,21 @@ namespace Mono.CSharp { TypeSpec[] targs; TypeParameterSpec[] constraints; readonly TypeSpec open_type; + readonly IModuleContext context; - public InflatedTypeSpec (TypeSpec openType, TypeSpec declaringType, TypeSpec[] targs) + public InflatedTypeSpec (IModuleContext context, TypeSpec openType, TypeSpec declaringType, TypeSpec[] targs) : base (openType.Kind, declaringType, openType.MemberDefinition, null, openType.Modifiers) { if (targs == null) throw new ArgumentNullException ("targs"); // this.state = openType.state; + this.context = context; this.open_type = openType; this.targs = targs; foreach (var arg in targs) { - if (arg.HasDynamicElement || arg == InternalType.Dynamic) { + if (arg.HasDynamicElement || arg.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { state |= StateFlags.HasDynamicElement; break; } @@ -1389,7 +1410,7 @@ namespace Mono.CSharp { public TypeParameterSpec[] Constraints { get { if (constraints == null) { - constraints = TypeParameterSpec.InflateConstraints (MemberDefinition.TypeParameters, l => l.CreateLocalInflator (), this); + constraints = TypeParameterSpec.InflateConstraints (MemberDefinition.TypeParameters, l => l.CreateLocalInflator (context), this); } return constraints; @@ -1405,6 +1426,24 @@ namespace Mono.CSharp { } } + public override bool IsExpressionTreeType { + get { + return (open_type.state & StateFlags.InflatedExpressionType) != 0; + } + } + + public override bool IsGenericIterateInterface { + get { + return (open_type.state & StateFlags.GenericIterateInterface) != 0; + } + } + + public override bool IsNullableType { + get { + return (open_type.state & StateFlags.InflatedNullableType) != 0; + } + } + // // Types used to inflate the generic type // @@ -1434,7 +1473,7 @@ namespace Mono.CSharp { return false; } - TypeParameterInflator CreateLocalInflator () + TypeParameterInflator CreateLocalInflator (IModuleContext context) { TypeParameterSpec[] tparams_full; TypeSpec[] targs_full = targs; @@ -1483,7 +1522,7 @@ namespace Mono.CSharp { tparams_full = open_type.MemberDefinition.TypeParameters; } - return new TypeParameterInflator (this, tparams_full, targs_full); + return new TypeParameterInflator (context, this, tparams_full, targs_full); } MetaType CreateMetaInfo (TypeParameterMutator mutator) @@ -1543,7 +1582,7 @@ namespace Mono.CSharp { public override string GetSignatureForError () { - if (TypeManager.IsNullableType (open_type)) + if (IsNullableType) return targs[0].GetSignatureForError () + "?"; return base.GetSignatureForError (); @@ -1559,10 +1598,16 @@ namespace Mono.CSharp { protected override void InitializeMemberCache (bool onlyTypes) { - if (cache == null) - cache = new MemberCache (onlyTypes ? open_type.MemberCacheTypes : open_type.MemberCache); + if (cache == null) { + var open_cache = onlyTypes ? open_type.MemberCacheTypes : open_type.MemberCache; - var inflator = CreateLocalInflator (); + // Surprisingly, calling MemberCache on open type could meantime create cache on this type + // for imported type parameter constraints referencing nested type of this declaration + if (cache == null) + cache = new MemberCache (open_cache); + } + + var inflator = CreateLocalInflator (context); // // Two stage inflate due to possible nested types recursive @@ -1588,6 +1633,9 @@ namespace Mono.CSharp { ifaces = new List (open_type.Interfaces.Count); foreach (var iface in open_type.Interfaces) { var iface_inflated = inflator.Inflate (iface); + if (iface_inflated == null) + continue; + AddInterface (iface_inflated); } } @@ -1754,13 +1802,13 @@ namespace Mono.CSharp { atypes[i] = te.Type; if (te.Type.IsStatic) { - ec.Compiler.Report.Error (718, te.Location, "`{0}': static classes cannot be used as generic arguments", + ec.Module.Compiler.Report.Error (718, te.Location, "`{0}': static classes cannot be used as generic arguments", te.GetSignatureForError ()); ok = false; } - if (te.Type.IsPointer || TypeManager.IsSpecialType (te.Type)) { - ec.Compiler.Report.Error (306, te.Location, + if (te.Type.IsPointer || te.Type.IsSpecialRuntimeType) { + ec.Module.Compiler.Report.Error (306, te.Location, "The type `{0}' may not be used as a type argument", te.GetSignatureForError ()); ok = false; @@ -1873,7 +1921,7 @@ namespace Mono.CSharp { // // Now bind the parameters // - type = open_type.MakeGenericType (atypes); + type = open_type.MakeGenericType (ec, atypes); // // Check constraints when context is not method/base type @@ -1913,7 +1961,7 @@ namespace Mono.CSharp { for (int i = 0; i < args.Length; ++i) { var item = args[i]; - if (item == InternalType.Dynamic) + if (item.BuiltinType == BuiltinTypeSpec.Type.Dynamic) return true; if (TypeManager.IsGenericType (item)) @@ -1924,7 +1972,7 @@ namespace Mono.CSharp { item = ((ArrayContainer) item).Element; } - if (item == InternalType.Dynamic) + if (item.BuiltinType == BuiltinTypeSpec.Type.Dynamic) return true; } } @@ -1998,7 +2046,7 @@ namespace Mono.CSharp { public bool CheckAll (MemberSpec context, TypeSpec[] targs, TypeParameterSpec[] tparams, Location loc) { for (int i = 0; i < tparams.Length; i++) { - if (ignore_inferred_dynamic && targs[i] == InternalType.Dynamic) + if (ignore_inferred_dynamic && targs[i].BuiltinType == BuiltinTypeSpec.Type.Dynamic) continue; if (!CheckConstraint (context, targs [i], tparams [i], loc)) @@ -2015,7 +2063,7 @@ namespace Mono.CSharp { // if (tparam.HasSpecialClass && !TypeManager.IsReferenceType (atype)) { if (mc != null) { - mc.Compiler.Report.Error (452, loc, + mc.Module.Compiler.Report.Error (452, loc, "The type `{0}' must be a reference type in order to use it as type parameter `{1}' in the generic type or method `{2}'", TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ()); } @@ -2023,9 +2071,9 @@ namespace Mono.CSharp { return false; } - if (tparam.HasSpecialStruct && (!TypeManager.IsValueType (atype) || TypeManager.IsNullableType (atype))) { + if (tparam.HasSpecialStruct && (!TypeManager.IsValueType (atype) || atype.IsNullableType)) { if (mc != null) { - mc.Compiler.Report.Error (453, loc, + mc.Module.Compiler.Report.Error (453, loc, "The type `{0}' must be a non-nullable value type in order to use it as type parameter `{1}' in the generic type or method `{2}'", TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ()); } @@ -2060,11 +2108,11 @@ namespace Mono.CSharp { // Check the interfaces constraints // if (tparam.Interfaces != null) { - if (TypeManager.IsNullableType (atype)) { + if (atype.IsNullableType) { if (mc == null) return false; - mc.Compiler.Report.Error (313, loc, + mc.Module.Compiler.Report.Error (313, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. The nullable type `{0}' never satisfies interface constraint", atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ()); ok = false; @@ -2115,8 +2163,8 @@ namespace Mono.CSharp { if (!HasDefaultConstructor (atype)) { if (mc != null) { - mc.Compiler.Report.SymbolRelatedToPreviousError (atype); - mc.Compiler.Report.Error (310, loc, + mc.Module.Compiler.Report.SymbolRelatedToPreviousError (atype); + mc.Module.Compiler.Report.Error (310, loc, "The type `{0}' must have a public parameterless constructor in order to use it as parameter `{1}' in the generic type or method `{2}'", TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ()); } @@ -2130,7 +2178,7 @@ namespace Mono.CSharp { { for (int i = 0; i < targs.Length; ++i) { var targ = targs [i]; - if (targ == InternalType.Dynamic) + if (targ.BuiltinType == BuiltinTypeSpec.Type.Dynamic) return true; if (HasDynamicTypeArgument (targ.TypeArguments)) @@ -2146,13 +2194,12 @@ namespace Mono.CSharp { if (atype == ttype || Convert.ImplicitBoxingConversion (null, atype, ttype) != null) return true; } else { - var expr = new EmptyExpression (atype); - if (atype.IsGenericParameter) { - if (Convert.ImplicitTypeParameterConversion (expr, ttype) != null) + if (Convert.ImplicitTypeParameterConversion (null, (TypeParameterSpec) atype, ttype) != null) return true; } + var expr = new EmptyExpression (atype); if (Convert.ImplicitStandardConversionExists (expr, ttype)) return true; } @@ -2166,17 +2213,17 @@ namespace Mono.CSharp { return true; if (mc != null) { - mc.Compiler.Report.SymbolRelatedToPreviousError (tparam); + mc.Module.Compiler.Report.SymbolRelatedToPreviousError (tparam); if (TypeManager.IsValueType (atype)) { - mc.Compiler.Report.Error (315, loc, + mc.Module.Compiler.Report.Error (315, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no boxing conversion from `{0}' to `{3}'", atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError (), ttype.GetSignatureForError ()); } else if (atype.IsGenericParameter) { - mc.Compiler.Report.Error (314, loc, + mc.Module.Compiler.Report.Error (314, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no boxing or type parameter conversion from `{0}' to `{3}'", atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError (), ttype.GetSignatureForError ()); } else { - mc.Compiler.Report.Error (311, loc, + mc.Module.Compiler.Report.Error (311, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'", atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError (), ttype.GetSignatureForError ()); } @@ -2471,7 +2518,7 @@ namespace Mono.CSharp { continue; } - if (a.Expr.Type == InternalType.Null) + if (a.Expr.Type == InternalType.NullLiteral) continue; if (TypeManager.IsValueType (method_parameter)) { @@ -2518,13 +2565,13 @@ namespace Mono.CSharp { TypeSpec t_i = methodParameters [i >= methodParameters.Length ? methodParameters.Length - 1: i]; if (!TypeManager.IsDelegateType (t_i)) { - if (t_i.GetDefinition () != TypeManager.expression_type) + if (!t_i.IsExpressionTreeType) continue; t_i = TypeManager.GetTypeArguments (t_i) [0]; } - var mi = Delegate.GetInvokeMethod (ec.Compiler, t_i); + var mi = Delegate.GetInvokeMethod (t_i); TypeSpec rtype = mi.ReturnType; if (tic.IsReturnTypeNonDependent (ec, mi, rtype)) @@ -2629,7 +2676,7 @@ namespace Mono.CSharp { // // Some types cannot be used as type arguments // - if (bound.Type == TypeManager.void_type || bound.Type.IsPointer) + if (bound.Type.Kind == MemberKind.Void || bound.Type.IsPointer) return; var a = bounds [index]; @@ -2747,7 +2794,7 @@ namespace Mono.CSharp { TypeSpec t = methodParameters[i]; if (!TypeManager.IsDelegateType (t)) { - if (TypeManager.expression_type == null || t.MemberDefinition != TypeManager.expression_type.MemberDefinition) + if (!t.IsExpressionTreeType) continue; t = TypeManager.GetTypeArguments (t) [0]; @@ -2756,7 +2803,7 @@ namespace Mono.CSharp { if (t.IsGenericParameter) continue; - var invoke = Delegate.GetInvokeMethod (ec.Compiler, t); + var invoke = Delegate.GetInvokeMethod (t); TypeSpec rtype = invoke.ReturnType; if (!rtype.IsGenericParameter && !TypeManager.IsGenericType (rtype)) continue; @@ -2797,7 +2844,7 @@ namespace Mono.CSharp { if (candidates.Count == 1) { TypeSpec t = candidates[0].Type; - if (t == InternalType.Null) + if (t == InternalType.NullLiteral) return false; fixed_types [i] = t; @@ -2891,10 +2938,10 @@ namespace Mono.CSharp { // if (best_candidate != null) { - if (best_candidate == InternalType.Dynamic) + if (best_candidate.BuiltinType == BuiltinTypeSpec.Type.Dynamic) continue; - if (bound.Type != InternalType.Dynamic && best_candidate != bound.Type) + if (bound.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic && best_candidate != bound.Type) return false; } @@ -2912,7 +2959,7 @@ namespace Mono.CSharp { // Uses inferred or partially infered types to inflate delegate type argument. Returns // null when type parameter has not been fixed // - public TypeSpec InflateGenericArgument (TypeSpec parameter) + public TypeSpec InflateGenericArgument (IModuleContext context, TypeSpec parameter) { var tp = parameter as TypeParameterSpec; if (tp != null) { @@ -2935,14 +2982,14 @@ namespace Mono.CSharp { if (gt != null) { var inflated_targs = new TypeSpec [gt.TypeArguments.Length]; for (int ii = 0; ii < inflated_targs.Length; ++ii) { - var inflated = InflateGenericArgument (gt.TypeArguments [ii]); + var inflated = InflateGenericArgument (context, gt.TypeArguments [ii]); if (inflated == null) return null; inflated_targs[ii] = inflated; } - return gt.GetDefinition ().MakeGenericType (inflated_targs); + return gt.GetDefinition ().MakeGenericType (context, inflated_targs); } return parameter; @@ -2959,7 +3006,7 @@ namespace Mono.CSharp { return false; } else if (TypeManager.IsGenericType (returnType)) { if (TypeManager.IsDelegateType (returnType)) { - invoke = Delegate.GetInvokeMethod (ec.Compiler, returnType); + invoke = Delegate.GetInvokeMethod (returnType); return IsReturnTypeNonDependent (ec, invoke, invoke.ReturnType); } @@ -3033,23 +3080,17 @@ namespace Mono.CSharp { return LowerBoundInference (u_ac.Element, v_ac.Element, inversed); } - if (u_ac.Rank != 1) + if (u_ac.Rank != 1 || !v.IsGenericIterateInterface) return 0; - if (TypeManager.IsGenericType (v)) { - TypeSpec g_v = v.GetDefinition (); - if (g_v != TypeManager.generic_ilist_type && - g_v != TypeManager.generic_icollection_type && - g_v != TypeManager.generic_ienumerable_type) - return 0; - - var v_i = TypeManager.GetTypeArguments (v) [0]; - if (TypeManager.IsValueType (u_ac.Element)) - return ExactInference (u_ac.Element, v_i); + var v_i = TypeManager.GetTypeArguments (v) [0]; + if (TypeManager.IsValueType (u_ac.Element)) + return ExactInference (u_ac.Element, v_i); - return LowerBoundInference (u_ac.Element, v_i); - } - } else if (TypeManager.IsGenericType (v)) { + return LowerBoundInference (u_ac.Element, v_i); + } + + if (TypeManager.IsGenericType (v)) { // // if V is a constructed type C and there is a unique type C // such that U is identical to, inherits from (directly or indirectly), @@ -3066,7 +3107,7 @@ namespace Mono.CSharp { // Using this trick for dynamic type inference, the spec says the type arguments are "unknown" but // that would complicate the process a lot, instead I treat them as dynamic // - if (t == InternalType.Dynamic) + if (t.BuiltinType == BuiltinTypeSpec.Type.Dynamic) u_candidates.Add (t); if (t.Interfaces != null) { @@ -3107,7 +3148,7 @@ namespace Mono.CSharp { // // dynamic becomes both T and U when the arguments are of dynamic type // - if (u_candidate == InternalType.Dynamic) { + if (u_candidate.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { unique_candidate_targs = new TypeSpec[ga_v.Length]; for (int i = 0; i < unique_candidate_targs.Length; ++i) unique_candidate_targs[i] = u_candidate; @@ -3150,7 +3191,7 @@ namespace Mono.CSharp { AnonymousMethodExpression ame = e as AnonymousMethodExpression; if (ame != null) { TypeSpec rt = ame.InferReturnType (ec, this, t); - var invoke = Delegate.GetInvokeMethod (ec.Compiler, t); + var invoke = Delegate.GetInvokeMethod (t); if (rt == null) { AParametersCollection pd = invoke.Parameters; @@ -3169,13 +3210,13 @@ namespace Mono.CSharp { // if (e is MethodGroupExpr) { if (!TypeManager.IsDelegateType (t)) { - if (TypeManager.expression_type == null || t.MemberDefinition != TypeManager.expression_type.MemberDefinition) + if (!t.IsExpressionTreeType) return 0; t = TypeManager.GetTypeArguments (t)[0]; } - var invoke = Delegate.GetInvokeMethod (ec.Compiler, t); + var invoke = Delegate.GetInvokeMethod (t); TypeSpec rtype = invoke.ReturnType; if (!rtype.IsGenericParameter && !TypeManager.IsGenericType (rtype)) @@ -3187,7 +3228,7 @@ namespace Mono.CSharp { // if all delegate generic arguments are fixed. TypeSpec[] param_types = new TypeSpec [invoke.Parameters.Count]; for (int i = 0; i < param_types.Length; ++i) { - var inflated = InflateGenericArgument (invoke.Parameters.Types[i]); + var inflated = InflateGenericArgument (ec, invoke.Parameters.Types[i]); if (inflated == null) return 0; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs index af647f158..779cfbc70 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs @@ -120,11 +120,14 @@ namespace Mono.CSharp protected readonly Dictionary import_cache; protected readonly Dictionary compiled_types; protected readonly Dictionary assembly_2_definition; + readonly ModuleContainer module; public static readonly string CompilerServicesNamespace = "System.Runtime.CompilerServices"; - protected MetadataImporter () + protected MetadataImporter (ModuleContainer module) { + this.module = module; + import_cache = new Dictionary (1024, ReferenceEquality.Default); compiled_types = new Dictionary (40, ReferenceEquality.Default); assembly_2_definition = new Dictionary (ReferenceEquality.Default); @@ -193,7 +196,7 @@ namespace Mono.CSharp } if ((fa & FieldAttributes.InitOnly) != 0) { - if (field_type == TypeManager.decimal_type) { + if (field_type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { var dc = ReadDecimalConstant (CustomAttributeData.GetCustomAttributes (fi)); if (dc != null) return new ConstSpec (declaringType, definition, field_type, fi, mod, dc); @@ -213,7 +216,7 @@ namespace Mono.CSharp if (declaringType.IsStruct && field_type.IsStruct && field_type.IsNested && HasAttribute (CustomAttributeData.GetCustomAttributes (fi), "FixedBufferAttribute", CompilerServicesNamespace)) { - // TODO: Sanity check on field_type (only few type are allowed) + // TODO: Sanity check on field_type (only few types are allowed) var element_field = CreateField (fi.FieldType.GetField (FixedField.FixedElementName), declaringType); return new FixedFieldSpec (declaringType, definition, fi, element_field, mod); } @@ -282,7 +285,7 @@ namespace Mono.CSharp var type = tparams[pos]; int index = pos - first; - tspec [index] = (TypeParameterSpec) CreateType (type, new DynamicTypeReader (), false); + tspec[index] = (TypeParameterSpec) CreateType (type, new DynamicTypeReader (), false); } return tspec; @@ -307,7 +310,7 @@ namespace Mono.CSharp throw new NotImplementedException ("Unknown element type " + type.ToString ()); } - spec = ArrayContainer.MakeType (spec, type.GetArrayRank ()); + spec = ArrayContainer.MakeType (module, spec, type.GetArrayRank ()); } else { spec = CreateType (type, dtype, true); @@ -323,7 +326,7 @@ namespace Mono.CSharp // if (!IsMissingType (type) && type.IsGenericTypeDefinition) { var targs = CreateGenericArguments (0, type.GetGenericArguments (), dtype); - spec = spec.MakeGenericType (targs); + spec = spec.MakeGenericType (module, targs); } } @@ -354,7 +357,7 @@ namespace Mono.CSharp TypeSpec returnType; if (mb.MemberType == MemberTypes.Constructor) { kind = MemberKind.Constructor; - returnType = TypeManager.void_type; + returnType = module.Compiler.BuiltinTypes.Void; } else { // // Detect operators and destructors @@ -371,7 +374,7 @@ namespace Mono.CSharp } } else if (parameters.IsEmpty && name == Destructor.MetadataName) { kind = MemberKind.Destructor; - if (declaringType == TypeManager.object_type) { + if (declaringType.BuiltinType == BuiltinTypeSpec.Type.Object) { mod &= ~Modifiers.OVERRIDE; mod |= Modifiers.VIRTUAL; } @@ -404,7 +407,12 @@ namespace Mono.CSharp IMemberDefinition definition; if (tparams != null) { - definition = new ImportedGenericMethodDefinition ((MethodInfo) mb, returnType, parameters, tparams, this); + var gmd = new ImportedGenericMethodDefinition ((MethodInfo) mb, returnType, parameters, tparams, this); + foreach (var tp in gmd.TypeParameters) { + ImportTypeParameterTypeConstraints (tp, tp.GetMetaInfo ()); + } + + definition = gmd; } else { definition = new ImportedParameterMemberDefinition (mb, returnType, parameters, this); } @@ -463,20 +471,20 @@ namespace Mono.CSharp var ptype = types[i]; if ((p.Attributes & ParameterAttributes.HasDefault) != 0 && ptype.Kind != MemberKind.TypeParameter && (value != null || TypeManager.IsReferenceType (ptype))) { if (value == null) { - default_value = Constant.CreateConstant (null, ptype, null, Location.Null); + default_value = Constant.CreateConstant (ptype, null, Location.Null); } else { - default_value = ImportParameterConstant (value).Resolve (null); + default_value = ImportParameterConstant (value); if (ptype.IsEnum) { - default_value = new EnumConstant ((Constant) default_value, ptype).Resolve (null); + default_value = new EnumConstant ((Constant) default_value, ptype); } } } else if (value == Missing.Value) { default_value = EmptyExpression.MissingValue; } else if (value == null) { default_value = new DefaultValueExpression (new TypeExpression (ptype, Location.Null), Location.Null); - } else if (ptype == TypeManager.decimal_type) { - default_value = ImportParameterConstant (value).Resolve (null); + } else if (ptype.BuiltinType == BuiltinTypeSpec.Type.Decimal) { + default_value = ImportParameterConstant (value); } } } @@ -510,7 +518,7 @@ namespace Mono.CSharp bool is_valid_property = true; if (set != null) { - if (set.ReturnType != TypeManager.void_type) + if (set.ReturnType.Kind != MemberKind.Void) is_valid_property = false; var set_param_count = set.Parameters.Count - 1; @@ -636,9 +644,9 @@ namespace Mono.CSharp { TypeSpec spec; if (import_cache.TryGetValue (type, out spec)) { - if (spec == TypeManager.object_type) { + if (spec.BuiltinType == BuiltinTypeSpec.Type.Object) { if (dtype.IsDynamicObject (this)) - return InternalType.Dynamic; + return module.Compiler.BuiltinTypes.Dynamic; return spec; } @@ -669,7 +677,7 @@ namespace Mono.CSharp if (declaringType == null) { // Simple case, no nesting spec = CreateType (type_def, null, new DynamicTypeReader (), canImportBaseType); - spec = spec.MakeGenericType (targs); + spec = spec.MakeGenericType (module, targs); } else { // // Nested type case, converting .NET types like @@ -684,7 +692,7 @@ namespace Mono.CSharp int targs_pos = 0; if (declaringType.Arity > 0) { - spec = declaringType.MakeGenericType (targs.Skip (targs_pos).Take (declaringType.Arity).ToArray ()); + spec = declaringType.MakeGenericType (module, targs.Skip (targs_pos).Take (declaringType.Arity).ToArray ()); targs_pos = spec.Arity; } else { spec = declaringType; @@ -694,7 +702,7 @@ namespace Mono.CSharp var t = nested_hierarchy [i - 1]; spec = MemberCache.FindNestedType (spec, t.Name, t.Arity); if (t.Arity > 0) { - spec = spec.MakeGenericType (targs.Skip (targs_pos).Take (spec.Arity).ToArray ()); + spec = spec.MakeGenericType (module, targs.Skip (targs_pos).Take (spec.Arity).ToArray ()); targs_pos += t.Arity; } } @@ -705,8 +713,11 @@ namespace Mono.CSharp name = name.Substring (0, index); spec = MemberCache.FindNestedType (spec, name, targs.Length - targs_pos); + if (spec == null) + return null; + if (spec.Arity > 0) { - spec = spec.MakeGenericType (targs.Skip (targs_pos).ToArray ()); + spec = spec.MakeGenericType (module, targs.Skip (targs_pos).ToArray ()); } } @@ -789,15 +800,9 @@ namespace Mono.CSharp kind = MemberKind.Class; } else if (kind == MemberKind.TypeParameter) { - // Return as type_cache was updated - return CreateTypeParameter (type, declaringType); + spec = CreateTypeParameter (type, declaringType); } else if (type.IsGenericTypeDefinition) { definition.TypeParameters = CreateGenericParameters (type, declaringType); - - // Constraints are not loaded on demand and can reference this type - if (import_cache.TryGetValue (type, out spec)) - return spec; - } else if (compiled_types.TryGetValue (type, out pt)) { // // Same type was found in inside compiled types. It's @@ -805,7 +810,7 @@ namespace Mono.CSharp // which point into just compiled assembly. // spec = pt; - BuildinTypeSpec bts = pt as BuildinTypeSpec; + BuiltinTypeSpec bts = pt as BuiltinTypeSpec; if (bts != null) bts.SetDefinition (definition, type, mod); } @@ -879,39 +884,12 @@ namespace Mono.CSharp TypeParameterSpec spec; var def = new ImportedTypeParameterDefinition (type, this); - if (type.DeclaringMethod != null) + if (type.DeclaringMethod != null) { spec = new TypeParameterSpec (type.GenericParameterPosition, def, special, variance, type); - else + } else { spec = new TypeParameterSpec (declaringType, type.GenericParameterPosition, def, special, variance, type); - - // Add it now, so any constraint can reference it and get same instance - import_cache.Add (type, spec); - - var constraints = type.GetGenericParameterConstraints (); - List tparams = null; - foreach (var ct in constraints) { - if (ct.IsGenericParameter) { - if (tparams == null) - tparams = new List (); - - tparams.Add (CreateType (ct)); - continue; - } - - if (!IsMissingType (ct) && ct.IsClass) { - spec.BaseType = CreateType (ct); - continue; - } - - spec.AddInterface (CreateType (ct)); } - if (spec.BaseType == null) - spec.BaseType = TypeManager.object_type; - - if (tparams != null) - spec.TypeArguments = tparams.ToArray (); - return spec; } @@ -937,7 +915,7 @@ namespace Mono.CSharp void ImportTypeBase (TypeSpec spec, MetaType type) { if (spec.Kind == MemberKind.Interface) - spec.BaseType = TypeManager.object_type; + spec.BaseType = module.Compiler.BuiltinTypes.Object; else if (type.BaseType != null) { TypeSpec base_type; if (!IsMissingType (type.BaseType) && type.BaseType.IsGenericType) @@ -952,8 +930,21 @@ namespace Mono.CSharp #if STATIC ifaces = type.__GetDeclaredInterfaces (); if (ifaces.Length != 0) { - foreach (var iface in ifaces) - spec.AddInterface (CreateType (iface)); + foreach (var iface in ifaces) { + var it = CreateType (iface); + if (it == null) + continue; + + spec.AddInterface (it); + + // Unfortunately not all languages expand inherited interfaces + var bifaces = it.Interfaces; + if (bifaces != null) { + foreach (var biface in bifaces) { + spec.AddInterface (biface); + } + } + } } if (spec.BaseType != null) { @@ -972,6 +963,13 @@ namespace Mono.CSharp } } #endif + + if (spec.MemberDefinition.TypeParametersCount > 0) { + foreach (var tp in spec.MemberDefinition.TypeParameters) { + ImportTypeParameterTypeConstraints (tp, tp.GetMetaInfo ()); + } + } + } protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool hasExtensionTypes) @@ -998,7 +996,7 @@ namespace Mono.CSharp prev_namespace = t.Namespace; } - ns.AddType (it); + ns.AddType (module, it); if (it.IsStatic && hasExtensionTypes && HasAttribute (CustomAttributeData.GetCustomAttributes (t), "ExtensionAttribute", CompilerServicesNamespace)) { @@ -1007,41 +1005,70 @@ namespace Mono.CSharp } } - static Constant ImportParameterConstant (object value) + void ImportTypeParameterTypeConstraints (TypeParameterSpec spec, MetaType type) + { + var constraints = type.GetGenericParameterConstraints (); + List tparams = null; + foreach (var ct in constraints) { + if (ct.IsGenericParameter) { + if (tparams == null) + tparams = new List (); + + tparams.Add (CreateType (ct)); + continue; + } + + if (!IsMissingType (ct) && ct.IsClass) { + spec.BaseType = CreateType (ct); + continue; + } + + spec.AddInterface (CreateType (ct)); + } + + if (spec.BaseType == null) + spec.BaseType = module.Compiler.BuiltinTypes.Object; + + if (tparams != null) + spec.TypeArguments = tparams.ToArray (); + } + + Constant ImportParameterConstant (object value) { // // Get type of underlying value as int constant can be used for object // parameter type. This is not allowed in C# but other languages can do that // + var types = module.Compiler.BuiltinTypes; switch (System.Type.GetTypeCode (value.GetType ())) { case TypeCode.Boolean: - return new BoolConstant ((bool) value, Location.Null); + return new BoolConstant (types, (bool) value, Location.Null); case TypeCode.Byte: - return new ByteConstant ((byte) value, Location.Null); + return new ByteConstant (types, (byte) value, Location.Null); case TypeCode.Char: - return new CharConstant ((char) value, Location.Null); + return new CharConstant (types, (char) value, Location.Null); case TypeCode.Decimal: - return new DecimalConstant ((decimal) value, Location.Null); + return new DecimalConstant (types, (decimal) value, Location.Null); case TypeCode.Double: - return new DoubleConstant ((double) value, Location.Null); + return new DoubleConstant (types, (double) value, Location.Null); case TypeCode.Int16: - return new ShortConstant ((short) value, Location.Null); + return new ShortConstant (types, (short) value, Location.Null); case TypeCode.Int32: - return new IntConstant ((int) value, Location.Null); + return new IntConstant (types, (int) value, Location.Null); case TypeCode.Int64: - return new LongConstant ((long) value, Location.Null); + return new LongConstant (types, (long) value, Location.Null); case TypeCode.SByte: - return new SByteConstant ((sbyte) value, Location.Null); + return new SByteConstant (types, (sbyte) value, Location.Null); case TypeCode.Single: - return new FloatConstant ((float) value, Location.Null); + return new FloatConstant (types, (float) value, Location.Null); case TypeCode.String: - return new StringConstant ((string) value, Location.Null); + return new StringConstant (types, (string) value, Location.Null); case TypeCode.UInt16: - return new UShortConstant ((ushort) value, Location.Null); + return new UShortConstant (types, (ushort) value, Location.Null); case TypeCode.UInt32: - return new UIntConstant ((uint) value, Location.Null); + return new UIntConstant (types, (uint) value, Location.Null); case TypeCode.UInt64: - return new ULongConstant ((ulong) value, Location.Null); + return new ULongConstant (types, (ulong) value, Location.Null); } throw new NotImplementedException (value.GetType ().ToString ()); @@ -1060,11 +1087,11 @@ namespace Mono.CSharp var spec = ImportType (element, dtype); if (type.IsArray) - return ArrayContainer.MakeType (spec, type.GetArrayRank ()); + return ArrayContainer.MakeType (module, spec, type.GetArrayRank ()); if (type.IsByRef) - return ReferenceContainer.MakeType (spec); + return ReferenceContainer.MakeType (module, spec); if (type.IsPointer) - return PointerContainer.MakeType (spec); + return PointerContainer.MakeType (module, spec); throw new NotImplementedException ("Unknown element type " + type.ToString ()); } @@ -1104,7 +1131,7 @@ namespace Mono.CSharp (byte) ca.ConstructorArguments[1].Value != 0, (byte) ca.ConstructorArguments[0].Value); - return new DecimalConstant (value, Location.Null).Resolve (null); + return new DecimalConstant (module.Compiler.BuiltinTypes, value, Location.Null); } return null; @@ -1754,15 +1781,15 @@ namespace Mono.CSharp string name = t.GetSignatureForError (); if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) { - ctx.Compiler.Report.Error (1683, loc, + ctx.Module.Compiler.Report.Error (1683, loc, "Reference to type `{0}' claims it is defined in this assembly, but it is not defined in source or any added modules", name); } else if (t.MemberDefinition.DeclaringAssembly.IsMissing) { - ctx.Compiler.Report.Error (12, loc, + ctx.Module.Compiler.Report.Error (12, loc, "The type `{0}' is defined in an assembly that is not referenced. Consider adding a reference to assembly `{1}'", name, t.MemberDefinition.DeclaringAssembly.FullName); } else { - ctx.Compiler.Report.Error (1684, loc, + ctx.Module.Compiler.Report.Error (1684, loc, "Reference to type `{0}' claims it is defined assembly `{1}', but it could not be found", name, t.MemberDefinition.DeclaringAssembly.FullName); } @@ -1845,7 +1872,7 @@ namespace Mono.CSharp var t = (MetaType) member; // Ignore compiler generated types, mostly lambda containers - if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate) + if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && importer.IgnorePrivateMembers) continue; imported = importer.CreateNestedType (t, declaringType); @@ -1858,7 +1885,7 @@ namespace Mono.CSharp var t = (MetaType) member; - if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate) + if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && importer.IgnorePrivateMembers) continue; importer.ImportTypeBase (t); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs index ea2b6e648..2c9e66709 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs @@ -59,9 +59,6 @@ namespace Mono.CSharp { if (expr == null) return false; - Report.Debug (64, "RESOLVE YIELD #1", this, ec, expr, expr.GetType (), - ec.CurrentAnonymousMethod, ec.CurrentIterator); - if (!CheckContext (ec, loc)) return false; @@ -164,7 +161,7 @@ namespace Mono.CSharp { init = new List (host.hoisted_params == null ? 1 : host.HoistedParameters.Count + 1); HoistedThis ht = host.hoisted_this; FieldExpr from = new FieldExpr (ht.Field, loc); - from.InstanceExpression = CompilerGeneratedThis.Instance; + from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); init.Add (new ElementInitializer (ht.Field.Name, from, loc)); } @@ -177,7 +174,7 @@ namespace Mono.CSharp { HoistedParameter hp_cp = (HoistedParameter) host.hoisted_params_copy [i]; FieldExpr from = new FieldExpr (hp_cp.Field, loc); - from.InstanceExpression = CompilerGeneratedThis.Instance; + from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); init.Add (new ElementInitializer (hp.Field.Name, from, loc)); } @@ -194,22 +191,6 @@ namespace Mono.CSharp { if (new_storey != null) new_storey = Convert.ImplicitConversionRequired (ec, new_storey, host_method.MemberType, loc); - var t = ec.Module.PredefinedTypes.Interlocked.Resolve (loc); - if (t != null) { - var p = new ParametersImported ( - new[] { - new ParameterData (null, Parameter.Modifier.REF), - new ParameterData (null, Parameter.Modifier.NONE), - new ParameterData (null, Parameter.Modifier.NONE) - }, - new[] { - TypeManager.int32_type, TypeManager.int32_type, TypeManager.int32_type - }, - false); - var f = new MemberFilter ("CompareExchange", 0, MemberKind.Method, p, TypeManager.int32_type); - TypeManager.int_interlocked_compare_exchange = TypeManager.GetPredefinedMethod (t, f, loc); - } - ec.CurrentBranching.CurrentUsageVector.Goto (); return true; } @@ -222,7 +203,10 @@ namespace Mono.CSharp { ec.Emit (OpCodes.Ldflda, host.PC.Spec); ec.EmitInt ((int) Iterator.State.Start); ec.EmitInt ((int) Iterator.State.Uninitialized); - ec.Emit (OpCodes.Call, TypeManager.int_interlocked_compare_exchange); + + var m = ec.Module.PredefinedMembers.InterlockedCompareExchange.Resolve (loc); + if (m != null) + ec.Emit (OpCodes.Call, m); ec.EmitInt ((int) Iterator.State.Uninitialized); ec.Emit (OpCodes.Bne_Un_S, label_init); @@ -273,7 +257,7 @@ namespace Mono.CSharp { } public DisposeMethod (IteratorStorey host) - : base (host, new TypeExpression (TypeManager.void_type, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, + : base (host, new TypeExpression (host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Dispose", host.Location)) { host.AddMethod (this); @@ -369,23 +353,19 @@ namespace Mono.CSharp { var list = new List (); if (Iterator.IsEnumerable) { - enumerable_type = new TypeExpression ( - TypeManager.ienumerable_type, Location); + enumerable_type = new TypeExpression (Compiler.BuiltinTypes.IEnumerable, Location); list.Add (enumerable_type); - if (TypeManager.generic_ienumerable_type != null) { - generic_enumerable_type = new GenericTypeExpr ( - TypeManager.generic_ienumerable_type, - generic_args, Location); + if (Module.PredefinedTypes.IEnumerableGeneric.Define ()) { + generic_enumerable_type = new GenericTypeExpr (Module.PredefinedTypes.IEnumerableGeneric.TypeSpec, generic_args, Location); list.Add (generic_enumerable_type); } } - enumerator_type = new TypeExpression ( - TypeManager.ienumerator_type, Location); + enumerator_type = new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location); list.Add (enumerator_type); - list.Add (new TypeExpression (TypeManager.idisposable_type, Location)); + list.Add (new TypeExpression (Compiler.BuiltinTypes.IDisposable, Location)); var ienumerator_generic = Module.PredefinedTypes.IEnumeratorGeneric; if (ienumerator_generic.Define ()) { @@ -411,7 +391,7 @@ namespace Mono.CSharp { void DefineIteratorMembers () { - pc_field = AddCompilerGeneratedField ("$PC", new TypeExpression (TypeManager.int32_type, Location)); + pc_field = AddCompilerGeneratedField ("$PC", new TypeExpression (Compiler.BuiltinTypes.Int, Location)); current_field = AddCompilerGeneratedField ("$current", iterator_type_expr); if (hoisted_params != null) { @@ -482,7 +462,7 @@ namespace Mono.CSharp { type = iterator_type_expr; } else { name = new MemberName (name, "IEnumerator"); - type = new TypeExpression (TypeManager.object_type, Location); + type = new TypeExpression (Compiler.BuiltinTypes.Object, Location); } name = new MemberName (name, "Current", Location); @@ -500,7 +480,7 @@ namespace Mono.CSharp { void Define_Reset () { Method reset = new Method ( - this, null, new TypeExpression (TypeManager.void_type, Location), + this, null, new TypeExpression (Compiler.BuiltinTypes.Void, Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Reset", Location), ParametersCompiled.EmptyReadOnlyParameters, null); @@ -643,7 +623,7 @@ namespace Mono.CSharp { return; } - current_pc = ec.GetTemporaryLocal (TypeManager.uint32_type); + current_pc = ec.GetTemporaryLocal (ec.BuiltinTypes.UInt); ec.Emit (OpCodes.Ldarg_0); ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec); ec.Emit (OpCodes.Stloc, current_pc); @@ -664,7 +644,7 @@ namespace Mono.CSharp { } if (need_skip_finally) { - skip_finally = ec.GetTemporaryLocal (TypeManager.bool_type); + skip_finally = ec.GetTemporaryLocal (ec.BuiltinTypes.Bool); ec.Emit (OpCodes.Ldc_I4_0); ec.Emit (OpCodes.Stloc, skip_finally); } @@ -719,7 +699,7 @@ namespace Mono.CSharp { } if (labels != null) { - current_pc = ec.GetTemporaryLocal (TypeManager.uint32_type); + current_pc = ec.GetTemporaryLocal (ec.BuiltinTypes.UInt); ec.Emit (OpCodes.Ldarg_0); ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec); ec.Emit (OpCodes.Stloc, current_pc); @@ -782,7 +762,7 @@ namespace Mono.CSharp { // Our constructor // public Iterator (ParametersBlock block, IMethodData method, TypeContainer host, TypeSpec iterator_type, bool is_enumerable) - : base (block, TypeManager.bool_type, block.StartLocation) + : base (block, host.Compiler.BuiltinTypes.Bool, block.StartLocation) { this.OriginalMethod = method; this.OriginalIteratorType = iterator_type; @@ -819,7 +799,7 @@ namespace Mono.CSharp { Block.Resolve (ctx); ctx.EndFlowBranching (); - var move_next = new IteratorMethod (IteratorHost, new TypeExpression (TypeManager.bool_type, loc), + var move_next = new IteratorMethod (IteratorHost, new TypeExpression (ec.BuiltinTypes.Bool, loc), Modifiers.PUBLIC, new MemberName ("MoveNext", Location)); move_next.Block.AddStatement (new MoveNextMethodStatement (this)); IteratorHost.AddMethod (move_next); @@ -856,7 +836,7 @@ namespace Mono.CSharp { throw new NotSupportedException ("ET"); } - public static void CreateIterator (IMethodData method, TypeContainer parent, Modifiers modifiers, CompilerContext ctx) + public static void CreateIterator (IMethodData method, TypeContainer parent, Modifiers modifiers) { bool is_enumerable; TypeSpec iterator_type; @@ -865,8 +845,8 @@ namespace Mono.CSharp { if (ret == null) return; - if (!CheckType (ret, out iterator_type, out is_enumerable)) { - ctx.Report.Error (1624, method.Location, + if (!CheckType (ret, parent, out iterator_type, out is_enumerable)) { + parent.Compiler.Report.Error (1624, method.Location, "The body of `{0}' cannot be an iterator block " + "because `{1}' is not an iterator interface type", method.GetSignatureForError (), @@ -879,19 +859,19 @@ namespace Mono.CSharp { Parameter p = parameters [i]; Parameter.Modifier mod = p.ModFlags; if ((mod & Parameter.Modifier.ISBYREF) != 0) { - ctx.Report.Error (1623, p.Location, + parent.Compiler.Report.Error (1623, p.Location, "Iterators cannot have ref or out parameters"); return; } if (p is ArglistParameter) { - ctx.Report.Error (1636, method.Location, + parent.Compiler.Report.Error (1636, method.Location, "__arglist is not allowed in parameter list of iterators"); return; } if (parameters.Types [i].IsPointer) { - ctx.Report.Error (1637, p.Location, + parent.Compiler.Report.Error (1637, p.Location, "Iterators cannot have unsafe parameters or " + "yield types"); return; @@ -899,24 +879,24 @@ namespace Mono.CSharp { } if ((modifiers & Modifiers.UNSAFE) != 0) { - ctx.Report.Error (1629, method.Location, "Unsafe code may not appear in iterators"); + parent.Compiler.Report.Error (1629, method.Location, "Unsafe code may not appear in iterators"); } method.Block.WrapIntoIterator (method, parent, iterator_type, is_enumerable); } - static bool CheckType (TypeSpec ret, out TypeSpec original_iterator_type, out bool is_enumerable) + static bool CheckType (TypeSpec ret, TypeContainer parent, out TypeSpec original_iterator_type, out bool is_enumerable) { original_iterator_type = null; is_enumerable = false; - if (ret == TypeManager.ienumerable_type) { - original_iterator_type = TypeManager.object_type; + if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerable) { + original_iterator_type = parent.Compiler.BuiltinTypes.Object; is_enumerable = true; return true; } - if (ret == TypeManager.ienumerator_type) { - original_iterator_type = TypeManager.object_type; + if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerator) { + original_iterator_type = parent.Compiler.BuiltinTypes.Object; is_enumerable = false; return true; } @@ -925,14 +905,17 @@ namespace Mono.CSharp { if (inflated == null) return false; - ret = inflated.GetDefinition (); - if (ret == TypeManager.generic_ienumerable_type) { + var member_definition = inflated.MemberDefinition; + PredefinedType ptype = parent.Module.PredefinedTypes.IEnumerableGeneric; + + if (ptype.Define () && ptype.TypeSpec.MemberDefinition == member_definition) { original_iterator_type = inflated.TypeArguments[0]; is_enumerable = true; return true; } - - if (ret == TypeManager.generic_ienumerator_type) { + + ptype = parent.Module.PredefinedTypes.IEnumeratorGeneric; + if (ptype.Define () && ptype.TypeSpec.MemberDefinition == member_definition) { original_iterator_type = inflated.TypeArguments[0]; is_enumerable = false; return true; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs index f0d095628..c98f46db6 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs @@ -33,7 +33,7 @@ namespace Mono.CSharp { if (ec.IsInProbingMode) return this; - BlockContext bc = new BlockContext (ec.MemberContext, ec.ConstructorBlock, TypeManager.void_type) { + BlockContext bc = new BlockContext (ec.MemberContext, ec.ConstructorBlock, ec.BuiltinTypes.Void) { CurrentAnonymousMethod = ec.CurrentAnonymousMethod }; @@ -61,7 +61,7 @@ namespace Mono.CSharp { if (!delegateType.IsDelegate) return null; - AParametersCollection d_params = Delegate.GetParameters (ec.Compiler, delegateType); + AParametersCollection d_params = Delegate.GetParameters (delegateType); if (HasExplicitParameters) { if (!VerifyExplicitParameters (ec, delegateType, d_params)) @@ -89,7 +89,7 @@ namespace Mono.CSharp { // When type inference context exists try to apply inferred type arguments // if (tic != null) { - d_param = tic.InflateGenericArgument (d_param); + d_param = tic.InflateGenericArgument (ec, d_param); } ptypes [i] = d_param; @@ -206,7 +206,7 @@ namespace Mono.CSharp { // // When delegate returns void, only expression statements can be used // - if (ec.ReturnType == TypeManager.void_type) { + if (ec.ReturnType.Kind == MemberKind.Void) { Expr = Expr.Resolve (ec); if (Expr == null) return false; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/linq.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/linq.cs index 4a597a137..3046ae240 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/linq.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/linq.cs @@ -16,7 +16,7 @@ namespace Mono.CSharp.Linq public class QueryExpression : AQueryClause { public QueryExpression (AQueryClause start) - : base (null, null, Location.Null) + : base (null, null, start.Location) { this.next = start; } @@ -121,7 +121,7 @@ namespace Mono.CSharp.Linq TypeInferenceContext tic = new TypeInferenceContext (source_type.TypeArguments); tic.OutputTypeInference (rc, a.Expr, source_type); if (tic.FixAllTypes (rc)) { - source_type = source_type.GetDefinition ().MakeGenericType (tic.InferredTypeArguments); + source_type = source_type.GetDefinition ().MakeGenericType (rc, tic.InferredTypeArguments); } } @@ -354,8 +354,6 @@ namespace Mono.CSharp.Linq public Expression CreateReferenceExpression (ResolveContext rc, Location loc) { - Expression expr = null; - // // We know the variable name is somewhere in the scope. This generates // an access expression from current block @@ -368,6 +366,7 @@ namespace Mono.CSharp.Linq if (p.Name == Name) return pb.GetParameterReference (i, loc); + Expression expr = null; var tp = p as QueryBlock.TransparentParameter; while (tp != null) { if (expr == null) @@ -384,8 +383,6 @@ namespace Mono.CSharp.Linq tp = tp.Parent as QueryBlock.TransparentParameter; } } - - expr = null; } if (pb == block) @@ -666,7 +663,7 @@ namespace Mono.CSharp.Linq } else { result_selector_expr = CreateRangeVariableType (ec, parameter, target, new SimpleName (target.Name, target.Location)); - result_block = new QueryBlock (ec.Compiler, block.Parent, block.StartLocation); + result_block = new QueryBlock (block.Parent, block.StartLocation); result_block.SetParameters (parameter, target_param); } @@ -689,7 +686,7 @@ namespace Mono.CSharp.Linq public class Where : AQueryClause { - public Where (QueryBlock block, BooleanExpression expr, Location loc) + public Where (QueryBlock block, Expression expr, Location loc) : base (block, expr, loc) { } @@ -796,13 +793,13 @@ namespace Mono.CSharp.Linq Identifier = identifier.Name; } - public new static void Reset () + public static void Reset () { Counter = 0; } } - public QueryBlock (CompilerContext ctx, Block parent, Location start) + public QueryBlock (Block parent, Location start) : base (parent, ParametersCompiled.EmptyReadOnlyParameters, start) { flags |= Flags.CompilerGenerated; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs index 2ef541d1c..cf48e07cc 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs @@ -38,7 +38,7 @@ namespace Mono.CSharp { // Default type of null is an object // public NullLiteral (Location loc) - : base (InternalType.Null, loc) + : base (InternalType.NullLiteral, loc) { } @@ -75,28 +75,9 @@ namespace Mono.CSharp { } } - // - // A null literal in a pointer context - // - class NullPointer : NullLiteral { - public NullPointer (Location loc): - base (loc) - { - type = TypeManager.object_type; - } - - public override void Emit (EmitContext ec) - { - // - // Emits null pointer - // - ec.Emit (OpCodes.Ldc_I4_0); - ec.Emit (OpCodes.Conv_U); - } - } - public class BoolLiteral : BoolConstant { - public BoolLiteral (bool val, Location loc) : base (val, loc) + public BoolLiteral (BuiltinTypes types, bool val, Location loc) + : base (types, val, loc) { } @@ -106,7 +87,8 @@ namespace Mono.CSharp { } public class CharLiteral : CharConstant { - public CharLiteral (char c, Location loc) : base (c, loc) + public CharLiteral (BuiltinTypes types, char c, Location loc) + : base (types, c, loc) { } @@ -116,24 +98,25 @@ namespace Mono.CSharp { } public class IntLiteral : IntConstant { - public IntLiteral (int l, Location loc) : base (l, loc) + public IntLiteral (BuiltinTypes types, int l, Location loc) + : base (types, l, loc) { } - public override Constant ConvertImplicitly (ResolveContext rc, TypeSpec type) + public override Constant ConvertImplicitly (TypeSpec type) { // // The 0 literal can be converted to an enum value // if (Value == 0 && TypeManager.IsEnumType (type)) { - Constant c = ConvertImplicitly (rc, EnumSpec.GetUnderlyingType (type)); + Constant c = ConvertImplicitly (EnumSpec.GetUnderlyingType (type)); if (c == null) return null; - return new EnumConstant (c, type).Resolve (rc); + return new EnumConstant (c, type); } - return base.ConvertImplicitly (rc, type); + return base.ConvertImplicitly (type); } public override bool IsLiteral { @@ -142,7 +125,8 @@ namespace Mono.CSharp { } public class UIntLiteral : UIntConstant { - public UIntLiteral (uint l, Location loc) : base (l, loc) + public UIntLiteral (BuiltinTypes types, uint l, Location loc) + : base (types, l, loc) { } @@ -152,7 +136,8 @@ namespace Mono.CSharp { } public class LongLiteral : LongConstant { - public LongLiteral (long l, Location loc) : base (l, loc) + public LongLiteral (BuiltinTypes types, long l, Location loc) + : base (types, l, loc) { } @@ -162,7 +147,8 @@ namespace Mono.CSharp { } public class ULongLiteral : ULongConstant { - public ULongLiteral (ulong l, Location loc) : base (l, loc) + public ULongLiteral (BuiltinTypes types, ulong l, Location loc) + : base (types, l, loc) { } @@ -172,8 +158,9 @@ namespace Mono.CSharp { } public class FloatLiteral : FloatConstant { - - public FloatLiteral (float f, Location loc) : base (f, loc) + + public FloatLiteral (BuiltinTypes types, float f, Location loc) + : base (types, f, loc) { } @@ -184,18 +171,19 @@ namespace Mono.CSharp { } public class DoubleLiteral : DoubleConstant { - public DoubleLiteral (double d, Location loc) : base (d, loc) + public DoubleLiteral (BuiltinTypes types, double d, Location loc) + : base (types, d, loc) { } public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) { - if (target == TypeManager.float_type) { + if (target.BuiltinType == BuiltinTypeSpec.Type.Float) { Error_664 (ec, loc, "float", "f"); return; } - if (target == TypeManager.decimal_type) { + if (target.BuiltinType == BuiltinTypeSpec.Type.Decimal) { Error_664 (ec, loc, "decimal", "m"); return; } @@ -217,7 +205,8 @@ namespace Mono.CSharp { } public class DecimalLiteral : DecimalConstant { - public DecimalLiteral (decimal d, Location loc) : base (d, loc) + public DecimalLiteral (BuiltinTypes types, decimal d, Location loc) + : base (types, d, loc) { } @@ -227,7 +216,8 @@ namespace Mono.CSharp { } public class StringLiteral : StringConstant { - public StringLiteral (string s, Location loc) : base (s, loc) + public StringLiteral (BuiltinTypes types, string s, Location loc) + : base (types, s, loc) { } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs index ce70c0e21..60faf9ca1 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs @@ -25,22 +25,21 @@ namespace Mono.CSharp { /// This is intentionally a class and not a struct since we need /// to pass this by reference. /// - public class SourceFile : ISourceFile { + public class SourceFile : ISourceFile, IEquatable + { public readonly string Name; - public readonly string Path; + public readonly string FullPathName; public readonly int Index; public bool AutoGenerated; - public bool IsIncludeFile; SourceFileEntry file; byte[] guid, checksum; - public SourceFile (string name, string path, int index, bool is_include) + public SourceFile (string name, string path, int index) { this.Index = index; this.Name = name; - this.Path = path; - this.IsIncludeFile = is_include; + this.FullPathName = path; } public SourceFileEntry SourceFileEntry { @@ -60,32 +59,56 @@ namespace Mono.CSharp { public virtual void DefineSymbolInfo (MonoSymbolWriter symwriter) { if (guid != null) - file = symwriter.DefineDocument (Path, guid, checksum); + file = symwriter.DefineDocument (FullPathName, guid, checksum); else { - file = symwriter.DefineDocument (Path); + file = symwriter.DefineDocument (FullPathName); if (AutoGenerated) file.SetAutoGenerated (); } } + public bool Equals (SourceFile other) + { + return FullPathName == other.FullPathName; + } + public override string ToString () { return String.Format ("SourceFile ({0}:{1}:{2}:{3})", - Name, Path, Index, SourceFileEntry); + Name, FullPathName, Index, SourceFileEntry); } } - public class CompilationUnit : SourceFile, ICompileUnit + public class CompilationSourceFile : SourceFile, ICompileUnit { CompileUnitEntry comp_unit; Dictionary include_files; Dictionary conditionals; + NamespaceEntry ns_container; + + public CompilationSourceFile (string name, string fullPathName, int index) + : base (name, fullPathName, index) + { + } + + CompileUnitEntry ICompileUnit.Entry { + get { return comp_unit; } + } - public CompilationUnit (string name, string path, int index) - : base (name, path, index, false) - { } + public CompileUnitEntry CompileUnitEntry { + get { return comp_unit; } + } - public void AddFile (SourceFile file) + public NamespaceEntry NamespaceContainer { + get { + return ns_container; + } + set { + ns_container = value; + } + } + + public void AddIncludeFile (SourceFile file) { if (file == this) return; @@ -93,8 +116,8 @@ namespace Mono.CSharp { if (include_files == null) include_files = new Dictionary (); - if (!include_files.ContainsKey (file.Path)) - include_files.Add (file.Path, file); + if (!include_files.ContainsKey (file.FullPathName)) + include_files.Add (file.FullPathName, file); } public void AddDefine (string value) @@ -113,14 +136,6 @@ namespace Mono.CSharp { conditionals [value] = false; } - CompileUnitEntry ICompileUnit.Entry { - get { return comp_unit; } - } - - public CompileUnitEntry CompileUnitEntry { - get { return comp_unit; } - } - public override void DefineSymbolInfo (MonoSymbolWriter symwriter) { base.DefineSymbolInfo (symwriter); @@ -135,7 +150,7 @@ namespace Mono.CSharp { } } - public bool IsConditionalDefined (string value) + public bool IsConditionalDefined (CompilerContext ctx, string value) { if (conditionals != null) { bool res; @@ -147,7 +162,7 @@ namespace Mono.CSharp { return false; } - return RootContext.IsConditionalDefined (value); + return ctx.Settings.IsConditionalSymbolDefined (value); } } @@ -169,8 +184,6 @@ namespace Mono.CSharp { /// public struct Location : IEquatable { - int token; - struct Checkpoint { public readonly int LineOffset; public readonly int CompilationUnit; @@ -184,17 +197,26 @@ namespace Mono.CSharp { } } +#if FULL_AST + long token; + + const int column_bits = 24; + const int line_delta_bits = 24; +#else + int token; + + const int column_bits = 8; + const int line_delta_bits = 8; +#endif + const int checkpoint_bits = 16; + + // -2 because the last one is used for hidden + const int max_column = (1 << column_bits) - 2; + const int column_mask = (1 << column_bits) - 1; + static List source_list; - static List compile_units; - static Dictionary source_files; - static int checkpoint_bits; - static int source_count; static int current_source; static int current_compile_unit; - static int line_delta_bits; - static int line_delta_mask; - static int column_bits; - static int column_mask; static Checkpoint [] checkpoints; static int checkpoint_index; @@ -204,45 +226,21 @@ namespace Mono.CSharp { static Location () { Reset (); - checkpoints = new Checkpoint [10]; } public static void Reset () { - source_files = new Dictionary (); source_list = new List (); - compile_units = new List (); current_source = 0; current_compile_unit = 0; - source_count = 0; - } - - // - // This must be called before parsing/tokenizing any files. - // - static public void AddFile (Report r, string name) - { - string path = Path.GetFullPath (name); - int id; - if (source_files.TryGetValue (path, out id)){ - string other_name = source_list [id - 1].Name; - if (name.Equals (other_name)) - r.Warning (2002, 1, "Source file `{0}' specified multiple times", other_name); - else - r.Warning (2002, 1, "Source filenames `{0}' and `{1}' both refer to the same file: {2}", name, other_name, path); - return; - } - - source_files.Add (path, ++source_count); - CompilationUnit unit = new CompilationUnit (name, path, source_count); - source_list.Add (unit); - compile_units.Add (unit); + checkpoint_index = 0; } - public static IList SourceFiles { - get { - return compile_units; - } + public static SourceFile AddFile (string name, string fullName) + { + var source = new SourceFile (name, fullName, source_list.Count + 1); + source_list.Add (source); + return source; } // @@ -251,63 +249,25 @@ namespace Mono.CSharp { // source file. We reserve some extra space for files we encounter via #line // directives while parsing. // - static public void Initialize () + static public void Initialize (List files) { +#if NET_4_0 + source_list.AddRange (files); +#else + source_list.AddRange (files.ToArray ()); +#endif + checkpoints = new Checkpoint [source_list.Count * 2]; if (checkpoints.Length > 0) checkpoints [0] = new Checkpoint (0, 0, 0); - - column_bits = 8; - column_mask = 0xFF; - line_delta_bits = 8; - line_delta_mask = 0xFF00; - checkpoint_index = 0; - checkpoint_bits = 16; } - // - // This is used when we encounter a #line preprocessing directive. - // - static public SourceFile LookupFile (CompilationUnit comp_unit, string name) - { - string path; - if (!Path.IsPathRooted (name)) { - string root = Path.GetDirectoryName (comp_unit.Path); - path = Path.Combine (root, name); - } else - path = name; - - if (!source_files.ContainsKey (path)) { - if (source_count >= (1 << checkpoint_bits)) - return new SourceFile (name, path, 0, true); - - source_files.Add (path, ++source_count); - SourceFile retval = new SourceFile (name, path, source_count, true); - source_list.Add (retval); - return retval; - } - - int index = (int) source_files [path]; - return source_list [index - 1]; - } - - static public void Push (CompilationUnit compile_unit, SourceFile file) + static public void Push (CompilationSourceFile compile_unit, SourceFile file) { current_source = file != null ? file.Index : -1; current_compile_unit = compile_unit != null ? compile_unit.Index : -1; // File is always pushed before being changed. } - - // - // If we're compiling with debugging support, this is called between parsing - // and code generation to register all the source files with the - // symbol writer. - // - static public void DefineSymbolDocuments (MonoSymbolWriter symwriter) - { - foreach (CompilationUnit unit in compile_units) - unit.DefineSymbolInfo (symwriter); - } public Location (int row) : this (row, 0) @@ -319,12 +279,15 @@ namespace Mono.CSharp { if (row <= 0) token = 0; else { - if (column > 254) - column = 254; - if (column < 0) - column = 255; - int target = -1; - int delta = 0; + if (column > max_column) + column = max_column; + else if (column < 0) + column = max_column + 1; + + long target = -1; + long delta = 0; + + // FIXME: This value is certainly wrong but what was the intension int max = checkpoint_index < 10 ? checkpoint_index : 10; for (int i = 0; i < max; i++) { @@ -342,10 +305,15 @@ namespace Mono.CSharp { target = checkpoint_index; delta = row % (1 << line_delta_bits); } + long l = column + - (long) (delta << column_bits) + - (long) (target << (line_delta_bits + column_bits)); + (delta << column_bits) + + (target << (line_delta_bits + column_bits)); +#if FULL_AST + token = l; +#else token = l > 0xFFFFFFFF ? 0 : (int) l; +#endif } } @@ -357,9 +325,7 @@ namespace Mono.CSharp { static void AddCheckpoint (int compile_unit, int file, int row) { if (checkpoints.Length == ++checkpoint_index) { - Checkpoint [] tmp = new Checkpoint [checkpoint_index * 2]; - Array.Copy (checkpoints, tmp, checkpoints.Length); - checkpoints = tmp; + Array.Resize (ref checkpoints, checkpoint_index * 2); } checkpoints [checkpoint_index] = new Checkpoint (compile_unit, file, row); } @@ -370,7 +336,7 @@ namespace Mono.CSharp { return fileName + "(" + Row.ToString () + "):"; return fileName + "(" + Row.ToString () + "," + Column.ToString () + - (Column == column_mask ? "+):" : "):"); + (Column == max_column ? "+):" : "):"); } public override string ToString () @@ -409,19 +375,26 @@ namespace Mono.CSharp { if (token == 0 || index == 0) return "Internal"; - return source_list [index - 1].Path; + return source_list[index - 1].FullPathName; } } int CheckpointIndex { - get { return (int) ((token & 0xFFFF0000) >> (line_delta_bits + column_bits)); } + get { + const int checkpoint_mask = (1 << checkpoint_bits) - 1; + return ((int) (token >> (line_delta_bits + column_bits))) & checkpoint_mask; + } } public int Row { get { if (token == 0) return 1; - return checkpoints [CheckpointIndex].LineOffset + ((token & line_delta_mask) >> column_bits); + + int offset = checkpoints[CheckpointIndex].LineOffset; + + const int line_delta_mask = (1 << column_bits) - 1; + return offset + (((int)(token >> column_bits)) & line_delta_mask); } } @@ -430,13 +403,13 @@ namespace Mono.CSharp { if (token == 0) return 1; int col = (int) (token & column_mask); - return col == 255 ? 1 : col; + return col > max_column ? 1 : col; } } public bool Hidden { get { - return (int) (token & column_mask) == 255; + return (int) (token & column_mask) == max_column + 1; } } @@ -479,12 +452,12 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" } } - public CompilationUnit CompilationUnit { + public CompilationSourceFile CompilationUnit { get { int index = CompilationUnitIndex; if (index == 0) return null; - return (CompilationUnit) source_list [index - 1]; + return (CompilationSourceFile) source_list [index - 1]; } } @@ -815,18 +788,40 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" } } - public class Using + public class Using { public readonly Location UsingLocation; public readonly MemberName NSpace; public readonly Location SemicolonLocation; - + public Using (Location usingLocation, MemberName nSpace, Location semicolonLocation) { this.UsingLocation = usingLocation; this.NSpace = nSpace; this.SemicolonLocation = semicolonLocation; } + + public virtual void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); + } + } + + public class ExternAlias + { + public readonly Location ExternLocation; + public readonly Location AliasLocation; + public readonly Tokenizer.LocatedToken Identifier; + public readonly Location SemicolonLocation; + + public ExternAlias (Location externLocation, Location aliasLocation, Tokenizer.LocatedToken identifier, Location semicolonLocation) + { + this.ExternLocation = externLocation; + this.AliasLocation = aliasLocation; + this.Identifier = identifier; + this.SemicolonLocation = semicolonLocation; + } + public virtual void Accept (StructuralVisitor visitor) { visitor.Visit (this); @@ -858,6 +853,12 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" { curNamespace.Peek ().usings.Add (new Using (usingLocation, nspace, semicolonLocation)); } + + [Conditional ("FULL_AST")] + public void AddExternAlias (Location externLocation, Location aliasLocation, Tokenizer.LocatedToken identifier, Location semicolonLocation) + { + curNamespace.Peek ().usings.Add (new ExternAlias (externLocation, aliasLocation, identifier, semicolonLocation)); + } [Conditional ("FULL_AST")] public void DeclareNamespace (Location namespaceLocation, MemberName nspace) diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/membercache.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/membercache.cs index d182959e2..9ffe5276e 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/membercache.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/membercache.cs @@ -39,11 +39,11 @@ namespace Mono.CSharp { PointerType = 1 << 20, InternalCompilerType = 1 << 21, MissingType = 1 << 22, + Void = 1 << 23, NestedMask = Class | Struct | Delegate | Enum | Interface, GenericMask = Method | Class | Struct | Delegate | Interface, - MaskType = Constructor | Event | Field | Method | Property | Indexer | Operator | Destructor | NestedMask, - All = MaskType + MaskType = Constructor | Event | Field | Method | Property | Indexer | Operator | Destructor | NestedMask } [Flags] @@ -69,8 +69,7 @@ namespace Mono.CSharp { public readonly MemberKind Kind; public readonly AParametersCollection Parameters; public readonly TypeSpec MemberType; - - int arity; // -1 to ignore the check + public readonly int Arity; // -1 to ignore the check private MemberFilter (string name, MemberKind kind) { @@ -78,7 +77,7 @@ namespace Mono.CSharp { Kind = kind; Parameters = null; MemberType = null; - arity = -1; + Arity = -1; } public MemberFilter (MethodSpec m) @@ -87,7 +86,7 @@ namespace Mono.CSharp { Kind = MemberKind.Method; Parameters = m.Parameters; MemberType = m.ReturnType; - arity = m.Arity; + Arity = m.Arity; } public MemberFilter (string name, int arity, MemberKind kind, AParametersCollection param, TypeSpec type) @@ -96,7 +95,7 @@ namespace Mono.CSharp { Kind = kind; Parameters = param; MemberType = type; - this.arity = arity; + this.Arity = arity; } public static MemberFilter Constructor (AParametersCollection param) @@ -129,7 +128,7 @@ namespace Mono.CSharp { return false; // Check arity when not disabled - if (arity >= 0 && arity != other.Arity) + if (Arity >= 0 && Arity != other.Arity) return false; if (Parameters != null) { @@ -169,6 +168,7 @@ namespace Mono.CSharp { // public class MemberCache { + [Flags] enum StateFlags { HasConversionOperator = 1 << 1, @@ -178,7 +178,7 @@ namespace Mono.CSharp { readonly Dictionary> member_hash; Dictionary locase_members; IList missing_abstract; - StateFlags state; + StateFlags state; // TODO: Move to TypeSpec or ITypeDefinition public static readonly string IndexerNameAlias = ""; @@ -302,16 +302,24 @@ namespace Mono.CSharp { { if (member.Kind == MemberKind.Operator) { var dt = member.DeclaringType; - if (dt == TypeManager.string_type || dt == TypeManager.delegate_type || dt == TypeManager.multicast_delegate_type) { + switch (dt.BuiltinType) { + case BuiltinTypeSpec.Type.String: + case BuiltinTypeSpec.Type.Delegate: + case BuiltinTypeSpec.Type.MulticastDelegate: // Some core types have user operators but they cannot be used as normal // user operators as they are predefined and therefore having different // rules (e.g. binary operators) by not setting the flag we hide them for // user conversions // TODO: Should I do this for all core types ? - } else if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) { - state |= StateFlags.HasConversionOperator; - } else { - state |= StateFlags.HasUserOperator; + break; + default: + if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) { + state |= StateFlags.HasConversionOperator; + } else { + state |= StateFlags.HasUserOperator; + } + + break; } } @@ -490,7 +498,7 @@ namespace Mono.CSharp { // // Looks for extension methods with defined name and extension type // - public List FindExtensionMethods (TypeContainer invocationType, TypeSpec extensionType, string name, int arity) + public List FindExtensionMethods (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity) { IList entries; if (!member_hash.TryGetValue (name, out entries)) @@ -505,10 +513,13 @@ namespace Mono.CSharp { if (!ms.IsExtensionMethod) continue; - if (!ms.IsAccessible (invocationType.CurrentType)) + if (!ms.IsAccessible (invocationContext)) continue; - if ((ms.DeclaringType.Modifiers & Modifiers.INTERNAL) != 0 && !ms.DeclaringType.MemberDefinition.IsInternalAsPublic (invocationType.DeclaringAssembly)) + // + // Extension methods cannot be nested hence checking parent is enough + // + if ((ms.DeclaringType.Modifiers & Modifiers.INTERNAL) != 0 && !ms.DeclaringType.MemberDefinition.IsInternalAsPublic (invocationContext.Module.DeclaringAssembly)) continue; if (candidates == null) @@ -663,7 +674,7 @@ namespace Mono.CSharp { throw new NotImplementedException (member.GetType ().ToString ()); } - public static IList GetCompletitionMembers (TypeSpec container, string name) + public static IList GetCompletitionMembers (IMemberContext ctx, TypeSpec container, string name) { var matches = new List (); foreach (var entry in container.MemberCache.member_hash) { @@ -674,7 +685,7 @@ namespace Mono.CSharp { if ((name_entry.Kind & (MemberKind.Constructor | MemberKind.Destructor | MemberKind.Operator)) != 0) continue; - if (!name_entry.IsAccessible (InternalType.FakeInternalType)) + if (!name_entry.IsAccessible (ctx)) continue; if (name == null || name_entry.Name.StartsWith (name)) { diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs index da8a86775..d9c319368 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs @@ -54,6 +54,12 @@ namespace Mono.CSharp { this.parameters = parameters; } + public override Variance ExpectedMemberTypeVariance { + get { + return Variance.Covariant; + } + } + // // Returns the System.Type array for the parameters of this method // @@ -124,9 +130,9 @@ namespace Mono.CSharp { // Returns a string that represents the signature for this // member which should be used in XML documentation. // - public override string GetDocCommentName (DeclSpace ds) + public override string GetDocCommentName () { - return DocUtil.GetMethodDocCommentName (this, parameters, ds); + return DocumentationBuilder.GetMethodDocCommentName (this, parameters); } // @@ -138,7 +144,7 @@ namespace Mono.CSharp { // internal override void OnGenerateDocComment (XmlElement el) { - DocUtil.OnMethodGenerateDocComment (this, el, Report); + DocumentationBuilder.OnMethodGenerateDocComment (this, el, Report); } // @@ -392,7 +398,7 @@ namespace Mono.CSharp { return ms; } - public MethodSpec MakeGenericMethod (params TypeSpec[] targs) + public MethodSpec MakeGenericMethod (IMemberContext context, params TypeSpec[] targs) { if (targs == null) throw new ArgumentNullException (); @@ -403,7 +409,7 @@ namespace Mono.CSharp { //if (generic_intances == null) // generic_intances = new Dictionary (TypeSpecArrayComparer.Default); - var inflator = new TypeParameterInflator (DeclaringType, GenericDefinition.TypeParameters, targs); + var inflator = new TypeParameterInflator (context, DeclaringType, GenericDefinition.TypeParameters, targs); var inflated = (MethodSpec) MemberwiseClone (); inflated.declaringType = inflator.TypeInstance; @@ -482,7 +488,7 @@ namespace Mono.CSharp { SecurityType declarative_security; protected MethodData MethodData; - static string[] attribute_targets = new string [] { "method", "return" }; + static readonly string[] attribute_targets = new string [] { "method", "return" }; protected MethodOrOperator (DeclSpace parent, GenericMethod generic, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, @@ -623,7 +629,7 @@ namespace Mono.CSharp { if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder); - if (ReturnType == InternalType.Dynamic) { + if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return_attributes = new ReturnParameter (this, MethodBuilder, Location); Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder); } else if (ReturnType.HasDynamicElement) { @@ -880,8 +886,7 @@ namespace Mono.CSharp { bool IsEntryPoint () { - if (ReturnType != TypeManager.void_type && - ReturnType != TypeManager.int32_type) + if (ReturnType.Kind != MemberKind.Void && ReturnType.BuiltinType != BuiltinTypeSpec.Type.Int) return false; if (parameters.IsEmpty) @@ -891,7 +896,7 @@ namespace Mono.CSharp { return false; var ac = parameters.Types [0] as ArrayContainer; - return ac != null && ac.Rank == 1 && ac.Element == TypeManager.string_type && + return ac != null && ac.Rank == 1 && ac.Element.BuiltinType == BuiltinTypeSpec.Type.String && (parameters[0].ModFlags & ~Parameter.Modifier.PARAMS) == Parameter.Modifier.NONE; } @@ -922,7 +927,7 @@ namespace Mono.CSharp { return; } - if (ReturnType != TypeManager.void_type) { + if (ReturnType.Kind != MemberKind.Void) { Report.Error (578, Location, "Conditional not valid on `{0}' because its return type is not void", GetSignatureForError ()); return; } @@ -1031,7 +1036,7 @@ namespace Mono.CSharp { var local_tparam = tp.Type; local_tparam.SpecialConstraint = base_tparam.SpecialConstraint; - var inflator = new TypeParameterInflator (CurrentType, base_decl_tparams, base_targs); + var inflator = new TypeParameterInflator (this, CurrentType, base_decl_tparams, base_targs); base_tparam.InflateConstraints (inflator, local_tparam); // @@ -1081,24 +1086,25 @@ namespace Mono.CSharp { // public override bool Define () { - if (type_expr.Type == TypeManager.void_type && parameters.IsEmpty && MemberName.Arity == 0 && MemberName.Name == Destructor.MetadataName) { - Report.Warning (465, 1, Location, "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?"); - } - if (!base.Define ()) return false; + if (type_expr.Type.Kind == MemberKind.Void && parameters.IsEmpty && MemberName.Arity == 0 && MemberName.Name == Destructor.MetadataName) { + Report.Warning (465, 1, Location, + "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?"); + } + if (partialMethodImplementation != null && IsPartialDefinition) MethodBuilder = partialMethodImplementation.MethodBuilder; - if (RootContext.StdLib && TypeManager.IsSpecialType (ReturnType)) { + if (Compiler.Settings.StdLib && ReturnType.IsSpecialRuntimeType) { Error1599 (Location, ReturnType, Report); return false; } if (CurrentTypeParameters == null) { if (base_method != null) { - if (parameters.Count == 1 && ParameterTypes[0] == TypeManager.object_type && Name == "Equals") + if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && Name == "Equals") Parent.PartialContainer.Mark_HasEquals (); else if (parameters.IsEmpty && Name == "GetHashCode") Parent.PartialContainer.Mark_HasGetHashCode (); @@ -1113,7 +1119,7 @@ namespace Mono.CSharp { // Current method is turned into automatically generated // wrapper which creates an instance of iterator // - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler); + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); ModFlags |= Modifiers.DEBUGGER_HIDDEN; } @@ -1146,12 +1152,9 @@ namespace Mono.CSharp { // // This is used to track the Entry Point, // - if (RootContext.NeedsEntryPoint && - Name == "Main" && - (RootContext.MainClass == null || - RootContext.MainClass == Parent.TypeBuilder.FullName)){ + var settings = Compiler.Settings; + if (settings.NeedsEntryPoint && Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) { if (IsEntryPoint ()) { - if (Parent.DeclaringAssembly.EntryPoint == null) { if (Parent.IsGeneric || MemberName.IsGeneric) { Report.Warning (402, 4, Location, "`{0}': an entry point cannot be generic or in a generic type", @@ -1337,7 +1340,7 @@ namespace Mono.CSharp { // // struct D { public D (int a) : this () {} // - if (TypeManager.IsStruct (ec.CurrentType) && argument_list == null) + if (ec.CurrentType.IsStruct && argument_list == null) return this; } @@ -1524,14 +1527,14 @@ namespace Mono.CSharp { ca, CallingConventions, parameters.GetMetaInfo ()); - spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, TypeManager.void_type, ConstructorBuilder, parameters, ModFlags); + spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, ConstructorBuilder, parameters, ModFlags); Parent.MemberCache.AddMember (spec); // It's here only to report an error if (block != null && block.IsIterator) { - member_type = TypeManager.void_type; - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler); + member_type = Compiler.BuiltinTypes.Void; + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); } return true; @@ -1569,7 +1572,7 @@ namespace Mono.CSharp { bool emit_field_initializers = ((ModFlags & Modifiers.STATIC) != 0) || !(Initializer is ConstructorThisInitializer); - BlockContext bc = new BlockContext (this, block, TypeManager.void_type); + BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void); bc.Set (ResolveContext.Options.ConstructorScope); if (emit_field_initializers) @@ -1701,7 +1704,7 @@ namespace Mono.CSharp { /// /// Interface for MethodData class. Holds links to parent members to avoid member duplication. /// - public interface IMethodData + public interface IMethodData : IMemberContext { CallingConventions CallingConventions { get; } Location Location { get; } @@ -1715,15 +1718,18 @@ namespace Mono.CSharp { ToplevelBlock Block { get; set; } EmitContext CreateEmitContext (ILGenerator ig); - string GetSignatureForError (); void EmitExtraSymbolInfo (SourceMethod source); } // // Encapsulates most of the Method's state // - public class MethodData { + public class MethodData + { +#if !STATIC static FieldInfo methodbuilder_attrs_field; +#endif + public readonly IMethodData method; public readonly GenericMethod GenericMethod; @@ -2075,7 +2081,7 @@ namespace Mono.CSharp { protected override bool ResolveMemberType () { - member_type = TypeManager.void_type; + member_type = Compiler.BuiltinTypes.Void; return true; } @@ -2214,7 +2220,7 @@ namespace Mono.CSharp { if (((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)) Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (method_data.MethodBuilder); - if (ReturnType == InternalType.Dynamic) { + if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location); Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder); } else if (ReturnType.HasDynamicElement) { @@ -2395,7 +2401,7 @@ namespace Mono.CSharp { // Current method is turned into automatically generated // wrapper which creates an instance of iterator // - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler); + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); ModFlags |= Modifiers.DEBUGGER_HIDDEN; } @@ -2410,12 +2416,12 @@ namespace Mono.CSharp { TypeSpec first_arg_type = ParameterTypes [0]; TypeSpec first_arg_type_unwrap = first_arg_type; - if (TypeManager.IsNullableType (first_arg_type)) - first_arg_type_unwrap = TypeManager.GetTypeArguments (first_arg_type) [0]; + if (first_arg_type.IsNullableType) + first_arg_type_unwrap = Nullable.NullableInfo.GetUnderlyingType (first_arg_type); TypeSpec return_type_unwrap = return_type; - if (TypeManager.IsNullableType (return_type)) - return_type_unwrap = TypeManager.GetTypeArguments (return_type) [0]; + if (return_type.IsNullableType) + return_type_unwrap = Nullable.NullableInfo.GetUnderlyingType (return_type); // // Rules for conversion operators @@ -2438,7 +2444,7 @@ namespace Mono.CSharp { return false; } - if (conv_type == InternalType.Dynamic) { + if (conv_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Report.Error (1964, Location, "User-defined conversion `{0}' cannot convert to or from the dynamic type", GetSignatureForError ()); @@ -2466,7 +2472,7 @@ namespace Mono.CSharp { } } } else if (OperatorType == OpType.LeftShift || OperatorType == OpType.RightShift) { - if (first_arg_type != declaring_type || parameters.Types[1] != TypeManager.int32_type) { + if (first_arg_type != declaring_type || parameters.Types[1].BuiltinType != BuiltinTypeSpec.Type.Int) { Report.Error (564, Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int"); return false; } @@ -2493,7 +2499,7 @@ namespace Mono.CSharp { } if (OperatorType == OpType.True || OperatorType == OpType.False) { - if (return_type != TypeManager.bool_type) { + if (return_type.BuiltinType != BuiltinTypeSpec.Type.Bool) { Report.Error ( 215, Location, "The return type of operator True or False " + @@ -2506,8 +2512,8 @@ namespace Mono.CSharp { // Checks for Binary operators var second_arg_type = ParameterTypes[1]; - if (TypeManager.IsNullableType (second_arg_type)) - second_arg_type = TypeManager.GetTypeArguments (second_arg_type)[0]; + if (second_arg_type.IsNullableType) + second_arg_type = Nullable.NullableInfo.GetUnderlyingType (second_arg_type); if (second_arg_type != declaring_type) { Report.Error (563, Location, diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/namespace.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/namespace.cs index 80b642904..05afdc29b 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/namespace.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/namespace.cs @@ -66,7 +66,7 @@ namespace Mono.CSharp { public override void Error_NamespaceDoesNotExist (Location loc, string name, int arity, IMemberContext ctx) { - ctx.Compiler.Report.Error (400, loc, + ctx.Module.Compiler.Report.Error (400, loc, "The type or namespace name `{0}' could not be found in the global namespace (are you missing an assembly reference?)", name); } @@ -161,19 +161,19 @@ namespace Mono.CSharp { public virtual void Error_NamespaceDoesNotExist (Location loc, string name, int arity, IMemberContext ctx) { - FullNamedExpression retval = Lookup (ctx.Compiler, name, -System.Math.Max (1, arity), loc); + FullNamedExpression retval = Lookup (ctx, name, -System.Math.Max (1, arity), loc); if (retval != null) { - Error_TypeArgumentsCannotBeUsed (ctx.Compiler.Report, loc, retval.Type, arity); + Error_TypeArgumentsCannotBeUsed (ctx.Module.Compiler.Report, loc, retval.Type, arity); return; } Namespace ns; if (arity > 0 && namespaces.TryGetValue (name, out ns)) { - ns.Error_TypeArgumentsCannotBeUsed (ctx.Compiler.Report, loc, null, arity); + ns.Error_TypeArgumentsCannotBeUsed (ctx.Module.Compiler.Report, loc, null, arity); return; } - ctx.Compiler.Report.Error (234, loc, + ctx.Module.Compiler.Report.Error (234, loc, "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing an assembly reference?", name, GetSignatureForError ()); } @@ -208,7 +208,7 @@ namespace Mono.CSharp { return ns; } - public TypeExpr LookupType (CompilerContext ctx, string name, int arity, bool silent, Location loc) + public TypeExpr LookupType (IMemberContext ctx, string name, int arity, bool silent, Location loc) { if (types == null) return null; @@ -229,16 +229,16 @@ namespace Mono.CSharp { continue; } - var pts = best as BuildinTypeSpec; + var pts = best as BuiltinTypeSpec; if (pts == null) - pts = ts as BuildinTypeSpec; + pts = ts as BuiltinTypeSpec; if (pts != null) { - ctx.Report.SymbolRelatedToPreviousError (best); - ctx.Report.SymbolRelatedToPreviousError (ts); + ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best); + ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts); // TODO: This should use different warning number but we want to be csc compatible - ctx.Report.Warning (1685, 1, loc, + ctx.Module.Compiler.Report.Warning (1685, 1, loc, "The predefined type `{0}.{1}' is redefined in the source code. Ignoring the local type definition", pts.Namespace, pts.Name); best = pts; @@ -246,14 +246,14 @@ namespace Mono.CSharp { } if (best.MemberDefinition.IsImported && ts.MemberDefinition.IsImported) { - ctx.Report.SymbolRelatedToPreviousError (best); - ctx.Report.SymbolRelatedToPreviousError (ts); + ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best); + ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts); if (silent) { - ctx.Report.Warning (1685, 1, loc, + ctx.Module.Compiler.Report.Warning (1685, 1, loc, "The predefined type `{0}' is defined in multiple assemblies. Using definition from `{1}'", ts.GetSignatureForError (), best.MemberDefinition.DeclaringAssembly.Name); } else { - ctx.Report.Error (433, loc, "The imported type `{0}' is defined multiple times", ts.GetSignatureForError ()); + ctx.Module.Compiler.Report.Error (433, loc, "The imported type `{0}' is defined multiple times", ts.GetSignatureForError ()); } break; @@ -262,16 +262,16 @@ namespace Mono.CSharp { if (best.MemberDefinition.IsImported) best = ts; - if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (RootContext.ToplevelTypes.DeclaringAssembly)) + if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly)) continue; if (silent) continue; if (ts.MemberDefinition.IsImported) - ctx.Report.SymbolRelatedToPreviousError (ts); + ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts); - ctx.Report.Warning (436, 2, loc, + ctx.Module.Compiler.Report.Warning (436, 2, loc, "The type `{0}' conflicts with the imported type of same name'. Ignoring the imported type definition", best.GetSignatureForError ()); } @@ -291,7 +291,7 @@ namespace Mono.CSharp { if (best == null) return null; - if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (RootContext.ToplevelTypes.DeclaringAssembly)) + if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly)) return null; te = new TypeExpression (best, Location.Null); @@ -334,7 +334,7 @@ namespace Mono.CSharp { return null; } - public FullNamedExpression Lookup (CompilerContext ctx, string name, int arity, Location loc) + public FullNamedExpression Lookup (IMemberContext ctx, string name, int arity, Location loc) { if (arity == 0 && namespaces.ContainsKey (name)) return namespaces [name]; @@ -363,7 +363,7 @@ namespace Mono.CSharp { /// /// Looks for extension method in this namespace /// - public List LookupExtensionMethod (TypeSpec extensionType, TypeContainer invocationContext, string name, int arity) + public List LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity) { if (types == null) return null; @@ -392,7 +392,7 @@ namespace Mono.CSharp { return found; } - public void AddType (TypeSpec ts) + public void AddType (ModuleContainer module, TypeSpec ts) { if (types == null) { types = new Dictionary> (64); @@ -406,7 +406,7 @@ namespace Mono.CSharp { if (existing.Count == 1) { found = existing[0]; if (ts.Arity == found.Arity) { - better_type = IsImportedTypeOverride (ts, found); + better_type = IsImportedTypeOverride (module, ts, found); if (better_type == found) return; @@ -425,7 +425,7 @@ namespace Mono.CSharp { if (ts.Arity != found.Arity) continue; - better_type = IsImportedTypeOverride (ts, found); + better_type = IsImportedTypeOverride (module, ts, found); if (better_type == found) return; @@ -448,10 +448,10 @@ namespace Mono.CSharp { // but one has better visibility (either public or internal with friend) // the less visible type is removed from the namespace cache // - public static TypeSpec IsImportedTypeOverride (TypeSpec ts, TypeSpec found) + public static TypeSpec IsImportedTypeOverride (ModuleContainer module, TypeSpec ts, TypeSpec found) { - var ts_accessible = (ts.Modifiers & Modifiers.PUBLIC) != 0 || ts.MemberDefinition.IsInternalAsPublic (RootContext.ToplevelTypes.DeclaringAssembly); - var found_accessible = (found.Modifiers & Modifiers.PUBLIC) != 0 || found.MemberDefinition.IsInternalAsPublic (RootContext.ToplevelTypes.DeclaringAssembly); + var ts_accessible = (ts.Modifiers & Modifiers.PUBLIC) != 0 || ts.MemberDefinition.IsInternalAsPublic (module.DeclaringAssembly); + var found_accessible = (found.Modifiers & Modifiers.PUBLIC) != 0 || found.MemberDefinition.IsInternalAsPublic (module.DeclaringAssembly); if (ts_accessible && !found_accessible) return ts; @@ -466,9 +466,10 @@ namespace Mono.CSharp { public void RemoveDeclSpace (string name) { types.Remove (name); + cached_types.Remove (name); } - public void ReplaceTypeWithPredefined (TypeSpec ts, BuildinTypeSpec pts) + public void ReplaceTypeWithPredefined (TypeSpec ts, BuiltinTypeSpec pts) { var found = types [ts.Name]; cached_types.Remove (ts.Name); @@ -578,8 +579,8 @@ namespace Mono.CSharp { resolved = fne as Namespace; if (resolved == null) { - rc.Compiler.Report.SymbolRelatedToPreviousError (fne.Type); - rc.Compiler.Report.Error (138, Location, + rc.Module.Compiler.Report.SymbolRelatedToPreviousError (fne.Type); + rc.Module.Compiler.Report.Error (138, Location, "`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces", GetSignatureForError ()); } @@ -606,7 +607,7 @@ namespace Mono.CSharp { { FullNamedExpression fne = rc.Module.GetRootNamespace (Alias); if (fne == null) { - rc.Compiler.Report.Error (430, Location, + rc.Module.Compiler.Report.Error (430, Location, "The extern alias `{0}' was not specified in -reference option", Alias); } @@ -658,8 +659,12 @@ namespace Mono.CSharp { } Namespace ns; - NamespaceEntry parent, implicit_parent; - CompilationUnit file; + + readonly ModuleContainer module; + readonly NamespaceEntry parent; + readonly CompilationSourceFile file; + + NamespaceEntry implicit_parent; int symfile_id; // Namespace using import block @@ -668,64 +673,50 @@ namespace Mono.CSharp { public bool DeclarationFound; // End + bool resolved; + public readonly bool IsImplicit; - public readonly DeclSpace SlaveDeclSpace; + public readonly TypeContainer SlaveDeclSpace; static readonly Namespace [] empty_namespaces = new Namespace [0]; - Namespace [] namespace_using_table; - ModuleContainer ctx; - - static List entries = new List (); + static readonly string[] empty_using_list = new string[0]; - public static void Reset () - { - entries = new List (); - } + Namespace [] namespace_using_table; - public NamespaceEntry (ModuleContainer ctx, NamespaceEntry parent, CompilationUnit file, string name) + public NamespaceEntry (ModuleContainer module, NamespaceEntry parent, CompilationSourceFile sourceFile, string name) { - this.ctx = ctx; + this.module = module; this.parent = parent; - this.file = file; - entries.Add (this); + this.file = sourceFile; if (parent != null) ns = parent.NS.GetNamespace (name, true); else if (name != null) - ns = ctx.GlobalRootNamespace.GetNamespace (name, true); + ns = module.GlobalRootNamespace.GetNamespace (name, true); else - ns = ctx.GlobalRootNamespace; + ns = module.GlobalRootNamespace; - SlaveDeclSpace = new RootDeclSpace (this); + SlaveDeclSpace = new RootDeclSpace (module, this); } - private NamespaceEntry (ModuleContainer ctx, NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave) + private NamespaceEntry (ModuleContainer module, NamespaceEntry parent, CompilationSourceFile file, Namespace ns, bool slave) { - this.ctx = ctx; + this.module = module; this.parent = parent; this.file = file; this.IsImplicit = true; this.ns = ns; - this.SlaveDeclSpace = slave ? new RootDeclSpace (this) : null; + this.SlaveDeclSpace = slave ? new RootDeclSpace (module, this) : null; } - // - // Populates the Namespace with some using declarations, used by the - // eval mode. - // - public void Populate (List source_using_aliases, List source_using_clauses) - { - foreach (UsingAliasEntry uae in source_using_aliases){ - if (using_aliases == null) - using_aliases = new List (); - - using_aliases.Add (uae); + public CompilationSourceFile SourceFile { + get { + return file; } + } - foreach (UsingEntry ue in source_using_clauses){ - if (using_clauses == null) - using_clauses = new List (); - - using_clauses.Add (ue); + public List Usings { + get { + return using_clauses; } } @@ -783,7 +774,7 @@ namespace Mono.CSharp { NamespaceEntry Doppelganger { get { if (!IsImplicit && doppelganger == null) { - doppelganger = new NamespaceEntry (ctx, ImplicitParent, file, ns, true); + doppelganger = new NamespaceEntry (module, ImplicitParent, file, ns, true); doppelganger.using_aliases = using_aliases; } return doppelganger; @@ -805,7 +796,7 @@ namespace Mono.CSharp { if (implicit_parent == null) { implicit_parent = (parent.NS == ns.Parent) ? parent - : new NamespaceEntry (ctx, parent, file, ns.Parent, false); + : new NamespaceEntry (module, parent, file, ns.Parent, false); } return implicit_parent; } @@ -842,10 +833,6 @@ namespace Mono.CSharp { Compiler.Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations"); } - if (RootContext.Version != LanguageVersion.ISO_1 && alias == "global") - Compiler.Report.Warning (440, 2, loc, "An alias named `global' will not be used when resolving 'global::';" + - " the global namespace will be used instead"); - AddUsingAlias (new LocalUsingAliasEntry (alias, name, loc)); } @@ -891,15 +878,15 @@ namespace Mono.CSharp { using_aliases.Add (uae); } - /// - /// Does extension methods look up to find a method which matches name and extensionType. - /// Search starts from this namespace and continues hierarchically up to top level. - /// + // + // Does extension methods look up to find a method which matches name and extensionType. + // Search starts from this namespace and continues hierarchically up to top level. + // public IList LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope) { List candidates = null; foreach (Namespace n in GetUsingTable ()) { - var a = n.LookupExtensionMethod (extensionType, RootContext.ToplevelTypes, name, arity); + var a = n.LookupExtensionMethod (this, extensionType, name, arity); if (a == null) continue; @@ -921,7 +908,7 @@ namespace Mono.CSharp { // Namespace parent_ns = ns.Parent; do { - candidates = parent_ns.LookupExtensionMethod (extensionType, RootContext.ToplevelTypes, name, arity); + candidates = parent_ns.LookupExtensionMethod (this, extensionType, name, arity); if (candidates != null) return candidates; @@ -988,7 +975,7 @@ namespace Mono.CSharp { // // Check whether it's in the namespace. // - FullNamedExpression fne = ns.Lookup (Compiler, name, arity, loc); + FullNamedExpression fne = ns.Lookup (this, name, arity, loc); // // Check aliases. @@ -1015,7 +1002,7 @@ namespace Mono.CSharp { } if (fne != null) { - if (!((fne.Type.Modifiers & Modifiers.INTERNAL) != 0 && !fne.Type.MemberDefinition.IsInternalAsPublic (RootContext.ToplevelTypes.DeclaringAssembly))) + if (!((fne.Type.Modifiers & Modifiers.INTERNAL) != 0 && !fne.Type.MemberDefinition.IsInternalAsPublic (module.DeclaringAssembly))) return fne; } @@ -1029,7 +1016,7 @@ namespace Mono.CSharp { foreach (Namespace using_ns in GetUsingTable ()) { // A using directive imports only types contained in the namespace, it // does not import any nested namespaces - fne = using_ns.LookupType (Compiler, name, arity, false, loc); + fne = using_ns.LookupType (this, name, arity, false, loc); if (fne == null) continue; @@ -1052,7 +1039,7 @@ namespace Mono.CSharp { return match; // It can be top level accessibility only - var better = Namespace.IsImportedTypeOverride (texpr_match.Type, texpr_fne.Type); + var better = Namespace.IsImportedTypeOverride (module, texpr_match.Type, texpr_fne.Type); if (better == null) { Compiler.Report.SymbolRelatedToPreviousError (texpr_match.Type); Compiler.Report.SymbolRelatedToPreviousError (texpr_fne.Type); @@ -1092,8 +1079,6 @@ namespace Mono.CSharp { return namespace_using_table; } - static readonly string [] empty_using_list = new string [0]; - public int SymbolFileID { get { if (symfile_id == 0 && file.SourceFileEntry != null) { @@ -1134,15 +1119,15 @@ namespace Mono.CSharp { switch (name) { case "Gtk": case "GtkSharp": - MsgtryPkg ("gtk-sharp"); + MsgtryPkg ("gtk-sharp-2.0"); break; case "Gdk": case "GdkSharp": - MsgtryPkg ("gdk-sharp"); + MsgtryPkg ("gdk-sharp-2.0"); break; case "Glade": case "GladeSharp": - MsgtryPkg ("glade-sharp"); + MsgtryPkg ("glade-sharp-2.0"); break; case "System.Drawing": @@ -1159,8 +1144,13 @@ namespace Mono.CSharp { /// Used to validate that all the using clauses are correct /// after we are finished parsing all the files. /// - void VerifyUsing () + public void Resolve () { + if (resolved) + return; + + resolved = true; + if (using_aliases != null) { foreach (UsingAliasEntry ue in using_aliases) ue.Resolve (Doppelganger, Doppelganger == null); @@ -1170,16 +1160,9 @@ namespace Mono.CSharp { foreach (UsingEntry ue in using_clauses) ue.Resolve (Doppelganger); } - } - /// - /// Used to validate that all the using clauses are correct - /// after we are finished parsing all the files. - /// - static public void VerifyAllUsing () - { - foreach (NamespaceEntry entry in entries) - entry.VerifyUsing (); + if (parent != null) + parent.Resolve (); } public string GetSignatureForError () @@ -1187,15 +1170,10 @@ namespace Mono.CSharp { return ns.GetSignatureForError (); } - public override string ToString () - { - return ns.ToString (); - } - #region IMemberContext Members - public CompilerContext Compiler { - get { return ctx.Compiler; } + CompilerContext Compiler { + get { return module.Compiler; } } public TypeSpec CurrentType { @@ -1228,7 +1206,7 @@ namespace Mono.CSharp { } public ModuleContainer Module { - get { return SlaveDeclSpace.Module; } + get { return module; } } #endregion diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/nullable.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/nullable.cs index 9b3ef44b0..e12a7316a 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/nullable.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/nullable.cs @@ -53,7 +53,8 @@ namespace Mono.CSharp.Nullable { public static MethodSpec GetConstructor (TypeSpec nullableType) { - return TypeManager.GetPredefinedConstructor (nullableType, Location.Null, GetUnderlyingType (nullableType)); + return (MethodSpec) MemberCache.FindMember (nullableType, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (GetUnderlyingType (nullableType))), BindingRestriction.DeclaredOnly); } public static MethodSpec GetHasValue (TypeSpec nullableType) @@ -78,11 +79,6 @@ namespace Mono.CSharp.Nullable { return ((InflatedTypeSpec) nullableType).TypeArguments[0]; } - - public static bool IsNullableType (TypeSpec type) - { - throw new NotImplementedException ("net"); - } } public class Unwrap : Expression, IMemoryLocation, IAssignMethod @@ -405,7 +401,7 @@ namespace Mono.CSharp.Nullable // if (unwrap == null) { // S -> T? is wrap only - if (TypeManager.IsNullableType (type)) + if (type.IsNullableType) return Wrap.Create (expr, type); // S -> T can be simplified @@ -413,7 +409,7 @@ namespace Mono.CSharp.Nullable } // Wrap target for T? - if (TypeManager.IsNullableType (type)) { + if (type.IsNullableType) { expr = Wrap.Create (expr, type); if (expr == null) return null; @@ -534,9 +530,9 @@ namespace Mono.CSharp.Nullable return expr; } - protected override Expression ResolveEnumOperator (ResolveContext ec, Expression expr) + protected override Expression ResolveEnumOperator (ResolveContext ec, Expression expr, TypeSpec[] predefined) { - expr = base.ResolveEnumOperator (ec, expr); + expr = base.ResolveEnumOperator (ec, expr, predefined); if (expr == null) return null; @@ -577,8 +573,8 @@ namespace Mono.CSharp.Nullable bool IsBitwiseBoolean { get { return (Oper == Operator.BitwiseAnd || Oper == Operator.BitwiseOr) && - ((left_unwrap != null && left_unwrap.Type == TypeManager.bool_type) || - (right_unwrap != null && right_unwrap.Type == TypeManager.bool_type)); + ((left_unwrap != null && left_unwrap.Type.BuiltinType == BuiltinTypeSpec.Type.Bool) || + (right_unwrap != null && right_unwrap.Type.BuiltinType == BuiltinTypeSpec.Type.Bool)); } } @@ -610,7 +606,7 @@ namespace Mono.CSharp.Nullable Constant CreateNullConstant (ResolveContext ec, Expression expr) { // FIXME: Handle side effect constants - Constant c = new BoolConstant (Oper == Operator.Inequality, loc).Resolve (ec); + Constant c = new BoolConstant (ec.BuiltinTypes, Oper == Operator.Inequality, loc); if ((Oper & Operator.EqualityMask) != 0) { ec.Report.Warning (472, 2, loc, "The result of comparing value type `{0}' with null is `{1}'", @@ -632,14 +628,14 @@ namespace Mono.CSharp.Nullable bool use_default_call = (Oper & (Operator.BitwiseMask | Operator.EqualityMask)) != 0; left_orig = left; - if (TypeManager.IsNullableType (left.Type)) { + if (left.Type.IsNullableType) { left = left_unwrap = Unwrap.Create (left, use_default_call); if (left == null) return null; } right_orig = right; - if (TypeManager.IsNullableType (right.Type)) { + if (right.Type.IsNullableType) { right = right_unwrap = Unwrap.Create (right, use_default_call); if (right == null) return null; @@ -653,17 +649,17 @@ namespace Mono.CSharp.Nullable if (left_orig is NullLiteral) { left = right; state |= State.LeftNullLifted; - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; } if (right_orig.IsNull) { if ((Oper & Operator.ShiftMask) != 0) - right = new EmptyExpression (TypeManager.int32_type); + right = new EmptyExpression (ec.BuiltinTypes.Int); else right = left; state |= State.RightNullLifted; - type = TypeManager.bool_type; + type = ec.BuiltinTypes.Bool; } eclass = ExprClass.Value; @@ -861,7 +857,7 @@ namespace Mono.CSharp.Nullable return; } - if (TypeManager.IsNullableType (l)) + if (l.IsNullableType) l = TypeManager.GetTypeArguments (l) [0]; base.EmitOperator (ec, l); @@ -918,7 +914,7 @@ namespace Mono.CSharp.Nullable // // Special case for bool?, the result depends on both null right side and left side value // - if ((Oper == Operator.BitwiseAnd || Oper == Operator.BitwiseOr) && NullableInfo.GetUnderlyingType (type) == TypeManager.bool_type) { + if ((Oper == Operator.BitwiseAnd || Oper == Operator.BitwiseOr) && NullableInfo.GetUnderlyingType (type).BuiltinType == BuiltinTypeSpec.Type.Bool) { return res_expr; } @@ -929,7 +925,7 @@ namespace Mono.CSharp.Nullable // Value types and null comparison // if (right_unwrap == null || (Oper & Operator.RelationalMask) != 0) - return CreateNullConstant (ec, right_orig).Resolve (ec); + return CreateNullConstant (ec, right_orig); } if (IsRightNullLifted) { @@ -938,7 +934,7 @@ namespace Mono.CSharp.Nullable // // Special case for bool?, the result depends on both null right side and left side value // - if ((Oper == Operator.BitwiseAnd || Oper == Operator.BitwiseOr) && NullableInfo.GetUnderlyingType (type) == TypeManager.bool_type) { + if ((Oper == Operator.BitwiseAnd || Oper == Operator.BitwiseOr) && NullableInfo.GetUnderlyingType (type).BuiltinType == BuiltinTypeSpec.Type.Bool) { return res_expr; } @@ -1075,7 +1071,7 @@ namespace Mono.CSharp.Nullable // If left is a nullable type and an implicit conversion exists from right to underlying type of left, // the result is underlying type of left // - if (TypeManager.IsNullableType (ltype)) { + if (ltype.IsNullableType) { unwrap = Unwrap.Create (left, false); if (unwrap == null) return null; @@ -1093,7 +1089,7 @@ namespace Mono.CSharp.Nullable // // If right is a dynamic expression, the result type is dynamic // - if (right.Type == InternalType.Dynamic) { + if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { type = right.Type; // Need to box underlying value type @@ -1110,7 +1106,7 @@ namespace Mono.CSharp.Nullable // // If right is a dynamic expression, the result type is dynamic // - if (right.Type == InternalType.Dynamic) { + if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { type = right.Type; return this; } @@ -1120,18 +1116,26 @@ namespace Mono.CSharp.Nullable // Constant lc = left as Constant; if (lc != null && !lc.IsDefaultValue) - return ReducedExpression.Create (lc, this).Resolve (ec); + return ReducedExpression.Create (lc, this); // // Reduce (left ?? null) to left OR (null-constant ?? right) to right // if (right.IsNull || lc != null) - return ReducedExpression.Create (lc != null ? right : left, this).Resolve (ec); + return ReducedExpression.Create (lc != null ? right : left, this); right = Convert.ImplicitConversion (ec, right, ltype, loc); type = ltype; return this; } + + // + // Special case null ?? null + // + if (ltype == right.Type) { + type = ltype; + return this; + } } else { return null; } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs index fe6715a3e..26028250d 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs @@ -153,7 +153,7 @@ namespace Mono.CSharp { var ac = parameter_type as ArrayContainer; if (ac == null || ac.Rank != 1) { - ec.Compiler.Report.Error (225, Location, "The params parameter must be a single dimensional array"); + ec.Module.Compiler.Report.Error (225, Location, "The params parameter must be a single dimensional array"); return null; } @@ -218,7 +218,7 @@ namespace Mono.CSharp { This = 128 } - static string[] attribute_targets = new string [] { "param" }; + static readonly string[] attribute_targets = new string[] { "param" }; FullNamedExpression texpr; readonly Modifier modFlags; @@ -230,7 +230,6 @@ namespace Mono.CSharp { public bool HasAddressTaken; TemporaryVariableReference expr_tree_variable; - static TypeExpr parameter_expr_tree_type; HoistedVariable hoisted_variant; @@ -343,11 +342,6 @@ namespace Mono.CSharp { return member.IsAccessibleAs (parameter_type); } - public static void Reset () - { - parameter_expr_tree_type = null; - } - // // Resolve is used in method definitions // @@ -367,9 +361,8 @@ namespace Mono.CSharp { texpr = expr; parameter_type = texpr.Type; - if ((modFlags & Parameter.Modifier.ISBYREF) != 0 && - TypeManager.IsSpecialType (parameter_type)) { - rc.Compiler.Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'", + if ((modFlags & Parameter.Modifier.ISBYREF) != 0 && parameter_type.IsSpecialRuntimeType) { + rc.Module.Compiler.Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'", GetSignatureForError ()); return null; } @@ -379,13 +372,13 @@ namespace Mono.CSharp { rc); if (parameter_type.IsStatic) { - rc.Compiler.Report.Error (721, Location, "`{0}': static types cannot be used as parameters", + rc.Module.Compiler.Report.Error (721, Location, "`{0}': static types cannot be used as parameters", texpr.GetSignatureForError ()); return parameter_type; } - if ((modFlags & Modifier.This) != 0 && (parameter_type.IsPointer || parameter_type == InternalType.Dynamic)) { - rc.Compiler.Report.Error (1103, Location, "The extension method cannot be of type `{0}'", + if ((modFlags & Modifier.This) != 0 && (parameter_type.IsPointer || parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)) { + rc.Module.Compiler.Report.Error (1103, Location, "The extension method cannot be of type `{0}'", TypeManager.CSharpName (parameter_type)); } @@ -423,12 +416,12 @@ namespace Mono.CSharp { Constant c = default_expr as Constant; if (c == null) { - if (parameter_type == TypeManager.object_type) { - rc.Compiler.Report.Error (1910, default_expr.Location, + if (parameter_type.BuiltinType == BuiltinTypeSpec.Type.Object) { + rc.Report.Error (1910, default_expr.Location, "Argument of type `{0}' is not applicable for the DefaultParameterValue attribute", default_expr.Type.GetSignatureForError ()); } else { - rc.Compiler.Report.Error (1909, default_expr.Location, + rc.Report.Error (1909, default_expr.Location, "The DefaultParameterValue attribute is not applicable on parameters of type `{0}'", default_expr.Type.GetSignatureForError ()); ; } @@ -439,7 +432,7 @@ namespace Mono.CSharp { if (TypeSpecComparer.IsEqual (default_expr.Type, parameter_type) || (default_expr is NullConstant && TypeManager.IsReferenceType (parameter_type) && !parameter_type.IsGenericParameter) || - TypeSpecComparer.IsEqual (parameter_type, TypeManager.object_type)) { + parameter_type.BuiltinType == BuiltinTypeSpec.Type.Object) { return; } @@ -457,7 +450,7 @@ namespace Mono.CSharp { return; } - rc.Compiler.Report.Error (1908, default_expr.Location, "The type of the default value should match the type of the parameter"); + rc.Report.Error (1908, default_expr.Location, "The type of the default value should match the type of the parameter"); return; } @@ -537,7 +530,7 @@ namespace Mono.CSharp { if (parameter_type.IsCLSCompliant ()) return; - ctx.Compiler.Report.Warning (3001, 1, Location, + ctx.Module.Compiler.Report.Warning (3001, 1, Location, "Argument type `{0}' is not CLS-compliant", parameter_type.GetSignatureForError ()); } @@ -566,7 +559,7 @@ namespace Mono.CSharp { var def_value = DefaultValue; Constant c = def_value != null ? def_value.Child as Constant : default_expr as Constant; if (c != null) { - if (default_expr.Type == TypeManager.decimal_type) { + if (default_expr.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { pa.DecimalConstant.EmitAttribute (builder, (decimal) c.GetValue (), c.Location); } else { builder.SetConstant (c.GetValue ()); @@ -582,7 +575,7 @@ namespace Mono.CSharp { } if (parameter_type != null) { - if (parameter_type == InternalType.Dynamic) { + if (parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { pa.Dynamic.EmitAttribute (builder); } else if (parameter_type.HasDynamicElement) { pa.Dynamic.EmitAttribute (builder, parameter_type, Location); @@ -610,7 +603,7 @@ namespace Mono.CSharp { Arguments arguments = new Arguments (2); arguments.Add (new Argument (new TypeOf ( new TypeExpression (parameter_type, Location), Location))); - arguments.Add (new Argument (new StringConstant (Name, Location))); + arguments.Add (new Argument (new StringConstant (ec.BuiltinTypes, Name, Location))); return new SimpleAssign (ExpressionTreeVariableReference (), Expression.CreateExpressionFactoryCall (ec, "Parameter", null, arguments, Location)); } @@ -664,14 +657,8 @@ namespace Mono.CSharp { // public static TypeExpr ResolveParameterExpressionType (IMemberContext ec, Location location) { - if (parameter_expr_tree_type != null) - return parameter_expr_tree_type; - TypeSpec p_type = ec.Module.PredefinedTypes.ParameterExpression.Resolve (location); - parameter_expr_tree_type = new TypeExpression (p_type, location). - ResolveAsTypeTerminal (ec, false); - - return parameter_expr_tree_type; + return new TypeExpression (p_type, location); } public void Warning_UselessOptionalParameter (Report Report) @@ -986,7 +973,7 @@ namespace Mono.CSharp { // TODO: This does not fit here, it should go to different version of AParametersCollection // as the underlying type is not Parameter and some methods will fail to cast // - public static AParametersCollection CreateFullyResolved (TypeSpec[] types) + public static AParametersCollection CreateFullyResolved (params TypeSpec[] types) { var pd = new ParameterData [types.Length]; for (int i = 0; i < pd.Length; ++i) @@ -1219,7 +1206,7 @@ namespace Mono.CSharp { expr = Child; if (!(expr is Constant || expr is DefaultValueExpression || (expr is New && ((New) expr).IsDefaultStruct))) { - rc.Compiler.Report.Error (1736, Location, + rc.Report.Error (1736, Location, "The expression being assigned to optional parameter `{0}' must be a constant or default value", p.Name); @@ -1232,19 +1219,19 @@ namespace Mono.CSharp { var res = Convert.ImplicitConversionStandard (rc, expr, parameter_type, Location); if (res != null) { - if (TypeManager.IsNullableType (parameter_type) && res is Nullable.Wrap) { + if (parameter_type.IsNullableType && res is Nullable.Wrap) { Nullable.Wrap wrap = (Nullable.Wrap) res; res = wrap.Child; if (!(res is Constant)) { - rc.Compiler.Report.Error (1770, Location, + rc.Report.Error (1770, Location, "The expression being assigned to nullable optional parameter `{0}' must be default value", p.Name); return; } } - if (!expr.IsNull && TypeManager.IsReferenceType (parameter_type) && parameter_type != TypeManager.string_type) { - rc.Compiler.Report.Error (1763, Location, + if (!expr.IsNull && TypeManager.IsReferenceType (parameter_type) && parameter_type.BuiltinType != BuiltinTypeSpec.Type.String) { + rc.Report.Error (1763, Location, "Optional parameter `{0}' of type `{1}' can only be initialized with `null'", p.Name, parameter_type.GetSignatureForError ()); @@ -1255,9 +1242,14 @@ namespace Mono.CSharp { return; } - rc.Compiler.Report.Error (1750, Location, + rc.Report.Error (1750, Location, "Optional parameter expression of type `{0}' cannot be converted to parameter type `{1}'", type.GetSignatureForError (), parameter_type.GetSignatureForError ()); } + + public virtual object Accept (StructuralVisitor visitor) + { + return visitor.Visit (this); + } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/pending.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/pending.cs index 1970d4b9e..038960728 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/pending.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/pending.cs @@ -107,7 +107,7 @@ namespace Mono.CSharp { } } - static MissingInterfacesInfo [] EmptyMissingInterfacesInfo = new MissingInterfacesInfo [0]; + static readonly MissingInterfacesInfo [] EmptyMissingInterfacesInfo = new MissingInterfacesInfo [0]; static MissingInterfacesInfo [] GetMissingInterfaces (TypeContainer container) { diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs index b570b7197..05e1721ce 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs @@ -197,7 +197,7 @@ namespace Mono.CSharp public class GetMethod : PropertyMethod { - static string[] attribute_targets = new string [] { "method", "return" }; + static readonly string[] attribute_targets = new string [] { "method", "return" }; internal const string Prefix = "get_"; @@ -243,7 +243,7 @@ namespace Mono.CSharp public class SetMethod : PropertyMethod { - static string[] attribute_targets = new string [] { "method", "param", "return" }; + static readonly string[] attribute_targets = new string[] { "method", "param", "return" }; internal const string Prefix = "set_"; @@ -291,7 +291,7 @@ namespace Mono.CSharp public override TypeSpec ReturnType { get { - return TypeManager.void_type; + return Parent.Compiler.BuiltinTypes.Void; } } @@ -302,7 +302,7 @@ namespace Mono.CSharp } } - static string[] attribute_targets = new string [] { "property" }; + static readonly string[] attribute_targets = new string[] { "property" }; public abstract class PropertyMethod : AbstractPropertyEventMethod { @@ -372,7 +372,7 @@ namespace Mono.CSharp CheckProtectedModifier (); if (block != null && block.IsIterator) - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags, Compiler); + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); return null; } @@ -438,6 +438,15 @@ namespace Mono.CSharp } } + public override Variance ExpectedMemberTypeVariance { + get { + return (get != null && set != null) ? + Variance.None : set == null ? + Variance.Covariant : + Variance.Contravariant; + } + } + public PropertyMethod Get { get { return get; @@ -653,7 +662,7 @@ namespace Mono.CSharp if (OptAttributes != null) OptAttributes.Emit (); - if (member_type == InternalType.Dynamic) { + if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute (PropertyBuilder); } else if (member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute (PropertyBuilder, member_type, Location); @@ -768,8 +777,8 @@ namespace Mono.CSharp if (!IsInterface && (ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 && AccessorSecond != null && Get.Block == null && Set.Block == null) { - if (RootContext.Version <= LanguageVersion.ISO_2) - Report.FeatureIsNotAvailable (Location, "automatically implemented properties"); + if (Compiler.Settings.Version <= LanguageVersion.ISO_2) + Report.FeatureIsNotAvailable (Compiler, Location, "automatically implemented properties"); Get.ModFlags |= Modifiers.COMPILER_GENERATED; Set.ModFlags |= Modifiers.COMPILER_GENERATED; @@ -797,9 +806,9 @@ namespace Mono.CSharp base.Emit (); } - public override string GetDocCommentName (DeclSpace ds) + public override string GetDocCommentName () { - return String.Concat (DocCommentHeader, ds.Name, ".", GetFullName (ShortName).Replace ('.', '#')); + return String.Concat (DocCommentHeader, Parent.Name, ".", GetFullName (ShortName).Replace ('.', '#')); } } @@ -883,7 +892,7 @@ namespace Mono.CSharp { } - protected abstract MethodSpec Operation { get; } + protected abstract MethodSpec GetOperation (Location loc); public override void Emit (DeclSpace parent) { @@ -897,28 +906,6 @@ namespace Mono.CSharp void FabricateBodyStatement () { - var cas = TypeManager.gen_interlocked_compare_exchange; - if (cas == null) { - var t = Module.PredefinedTypes.Interlocked.Resolve (Location); - if (t == null) - return; - - var p = new ParametersImported ( - new[] { - new ParameterData (null, Parameter.Modifier.REF), - new ParameterData (null, Parameter.Modifier.NONE), - new ParameterData (null, Parameter.Modifier.NONE) - }, - new[] { - new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), - new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), - new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), - }, false); - - var filter = new MemberFilter ("CompareExchange", 1, MemberKind.Method, p, null); - cas = TypeManager.gen_interlocked_compare_exchange = TypeManager.GetPredefinedMethod (t, filter, Location); - } - // // Delegate obj1 = backing_field // do { @@ -950,14 +937,20 @@ namespace Mono.CSharp args_oper.Add (new Argument (new LocalVariableReference (obj2, Location))); args_oper.Add (new Argument (block.GetParameterReference (0, Location))); + var op_method = GetOperation (Location); + var args = new Arguments (3); args.Add (new Argument (f_expr, Argument.AType.Ref)); args.Add (new Argument (new Cast ( new TypeExpression (field_info.MemberType, Location), - new Invocation (MethodGroupExpr.CreatePredefined (Operation, Operation.DeclaringType, Location), args_oper), + new Invocation (MethodGroupExpr.CreatePredefined (op_method, op_method.DeclaringType, Location), args_oper), Location))); args.Add (new Argument (new LocalVariableReference (obj1, Location))); + var cas = Module.PredefinedMembers.InterlockedCompareExchange_T.Resolve (Location); + if (cas == null) + return; + body.AddStatement (new StatementExpression (new SimpleAssign ( new LocalVariableReference (obj1, Location), new Invocation (MethodGroupExpr.CreatePredefined (cas, cas.DeclaringType, Location), args)))); @@ -971,15 +964,9 @@ namespace Mono.CSharp { } - protected override MethodSpec Operation { - get { - if (TypeManager.delegate_combine_delegate_delegate == null) { - TypeManager.delegate_combine_delegate_delegate = TypeManager.GetPredefinedMethod ( - TypeManager.delegate_type, "Combine", Location, TypeManager.delegate_type, TypeManager.delegate_type); - } - - return TypeManager.delegate_combine_delegate_delegate; - } + protected override MethodSpec GetOperation (Location loc) + { + return Module.PredefinedMembers.DelegateCombine.Resolve (loc); } } @@ -990,15 +977,9 @@ namespace Mono.CSharp { } - protected override MethodSpec Operation { - get { - if (TypeManager.delegate_remove_delegate_delegate == null) { - TypeManager.delegate_remove_delegate_delegate = TypeManager.GetPredefinedMethod ( - TypeManager.delegate_type, "Remove", Location, TypeManager.delegate_type, TypeManager.delegate_type); - } - - return TypeManager.delegate_remove_delegate_delegate; - } + protected override MethodSpec GetOperation (Location loc) + { + return Module.PredefinedMembers.DelegateRemove.Resolve (loc); } } @@ -1206,7 +1187,7 @@ namespace Mono.CSharp public override TypeSpec ReturnType { get { - return TypeManager.void_type; + return Parent.Compiler.BuiltinTypes.Void; } } @@ -1259,6 +1240,12 @@ namespace Mono.CSharp } } + public override Variance ExpectedMemberTypeVariance { + get { + return Variance.Contravariant; + } + } + public AEventAccessor Remove { get { return this.remove; @@ -1589,9 +1576,9 @@ namespace Mono.CSharp return base.EnableOverloadChecks (overload); } - public override string GetDocCommentName (DeclSpace ds) + public override string GetDocCommentName () { - return DocUtil.GetMethodDocCommentName (this, parameters, ds); + return DocumentationBuilder.GetMethodDocCommentName (this, parameters); } public override string GetSignatureForError () diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/reflection.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/reflection.cs index 55ee6527d..d5b7d1753 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/reflection.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/reflection.cs @@ -22,7 +22,7 @@ namespace Mono.CSharp #if STATIC public class ReflectionImporter { - public ReflectionImporter (BuildinTypes buildin) + public ReflectionImporter (ModuleContainer module, BuiltinTypes builtin) { throw new NotSupportedException (); } @@ -45,9 +45,10 @@ namespace Mono.CSharp #else public sealed class ReflectionImporter : MetadataImporter { - public ReflectionImporter (BuildinTypes buildin) + public ReflectionImporter (ModuleContainer module, BuiltinTypes builtin) + : base (module) { - Initialize (buildin); + Initialize (builtin); } public override void AddCompiledType (TypeBuilder builder, TypeSpec spec) @@ -124,46 +125,46 @@ namespace Mono.CSharp return module_definition; } - void Initialize (BuildinTypes buildin) + void Initialize (BuiltinTypes builtin) { // // Setup mapping for build-in types to avoid duplication of their definition // - compiled_types.Add (typeof (object), buildin.Object); - compiled_types.Add (typeof (System.ValueType), buildin.ValueType); - compiled_types.Add (typeof (System.Attribute), buildin.Attribute); - - compiled_types.Add (typeof (int), buildin.Int); - compiled_types.Add (typeof (long), buildin.Long); - compiled_types.Add (typeof (uint), buildin.UInt); - compiled_types.Add (typeof (ulong), buildin.ULong); - compiled_types.Add (typeof (byte), buildin.Byte); - compiled_types.Add (typeof (sbyte), buildin.SByte); - compiled_types.Add (typeof (short), buildin.Short); - compiled_types.Add (typeof (ushort), buildin.UShort); - - compiled_types.Add (typeof (System.Collections.IEnumerator), buildin.IEnumerator); - compiled_types.Add (typeof (System.Collections.IEnumerable), buildin.IEnumerable); - compiled_types.Add (typeof (System.IDisposable), buildin.IDisposable); - - compiled_types.Add (typeof (char), buildin.Char); - compiled_types.Add (typeof (string), buildin.String); - compiled_types.Add (typeof (float), buildin.Float); - compiled_types.Add (typeof (double), buildin.Double); - compiled_types.Add (typeof (decimal), buildin.Decimal); - compiled_types.Add (typeof (bool), buildin.Bool); - compiled_types.Add (typeof (System.IntPtr), buildin.IntPtr); - compiled_types.Add (typeof (System.UIntPtr), buildin.UIntPtr); - - compiled_types.Add (typeof (System.MulticastDelegate), buildin.MulticastDelegate); - compiled_types.Add (typeof (System.Delegate), buildin.Delegate); - compiled_types.Add (typeof (System.Enum), buildin.Enum); - compiled_types.Add (typeof (System.Array), buildin.Array); - compiled_types.Add (typeof (void), buildin.Void); - compiled_types.Add (typeof (System.Type), buildin.Type); - compiled_types.Add (typeof (System.Exception), buildin.Exception); - compiled_types.Add (typeof (System.RuntimeFieldHandle), buildin.RuntimeFieldHandle); - compiled_types.Add (typeof (System.RuntimeTypeHandle), buildin.RuntimeTypeHandle); + compiled_types.Add (typeof (object), builtin.Object); + compiled_types.Add (typeof (System.ValueType), builtin.ValueType); + compiled_types.Add (typeof (System.Attribute), builtin.Attribute); + + compiled_types.Add (typeof (int), builtin.Int); + compiled_types.Add (typeof (long), builtin.Long); + compiled_types.Add (typeof (uint), builtin.UInt); + compiled_types.Add (typeof (ulong), builtin.ULong); + compiled_types.Add (typeof (byte), builtin.Byte); + compiled_types.Add (typeof (sbyte), builtin.SByte); + compiled_types.Add (typeof (short), builtin.Short); + compiled_types.Add (typeof (ushort), builtin.UShort); + + compiled_types.Add (typeof (System.Collections.IEnumerator), builtin.IEnumerator); + compiled_types.Add (typeof (System.Collections.IEnumerable), builtin.IEnumerable); + compiled_types.Add (typeof (System.IDisposable), builtin.IDisposable); + + compiled_types.Add (typeof (char), builtin.Char); + compiled_types.Add (typeof (string), builtin.String); + compiled_types.Add (typeof (float), builtin.Float); + compiled_types.Add (typeof (double), builtin.Double); + compiled_types.Add (typeof (decimal), builtin.Decimal); + compiled_types.Add (typeof (bool), builtin.Bool); + compiled_types.Add (typeof (System.IntPtr), builtin.IntPtr); + compiled_types.Add (typeof (System.UIntPtr), builtin.UIntPtr); + + compiled_types.Add (typeof (System.MulticastDelegate), builtin.MulticastDelegate); + compiled_types.Add (typeof (System.Delegate), builtin.Delegate); + compiled_types.Add (typeof (System.Enum), builtin.Enum); + compiled_types.Add (typeof (System.Array), builtin.Array); + compiled_types.Add (typeof (void), builtin.Void); + compiled_types.Add (typeof (System.Type), builtin.Type); + compiled_types.Add (typeof (System.Exception), builtin.Exception); + compiled_types.Add (typeof (System.RuntimeFieldHandle), builtin.RuntimeFieldHandle); + compiled_types.Add (typeof (System.RuntimeTypeHandle), builtin.RuntimeTypeHandle); } } @@ -228,18 +229,9 @@ namespace Mono.CSharp ResolveAssemblySecurityAttributes (); var an = CreateAssemblyName (); - try { - Builder = file_name == null ? - domain.DefineDynamicAssembly (an, access) : - domain.DefineDynamicAssembly (an, access, Dirname (file_name)); - } catch (ArgumentException) { - // specified key may not be exportable outside it's container - if (RootContext.StrongNameKeyContainer != null) { - Report.Error (1548, "Could not access the key inside the container `" + - RootContext.StrongNameKeyContainer + "'."); - } - throw; - } + Builder = file_name == null ? + domain.DefineDynamicAssembly (an, access) : + domain.DefineDynamicAssembly (an, access, Dirname (file_name)); module.Create (this, CreateModuleBuilder ()); builder_extra = new AssemblyBuilderMonoSpecific (Builder, Compiler); @@ -436,9 +428,9 @@ namespace Mono.CSharp default_references.Add ("System.Windows.Browser"); #endif - if (RootContext.Version > LanguageVersion.ISO_2) + if (compiler.Settings.Version > LanguageVersion.ISO_2) default_references.Add ("System.Core"); - if (RootContext.Version > LanguageVersion.V_3) + if (compiler.Settings.Version > LanguageVersion.V_3) default_references.Add ("Microsoft.CSharp"); return default_references.ToArray (); @@ -454,7 +446,7 @@ namespace Mono.CSharp public override bool HasObjectType (Assembly assembly) { - return assembly.GetType (compiler.BuildinTypes.Object.FullName) != null; + return assembly.GetType (compiler.BuiltinTypes.Object.FullName) != null; } public override Assembly LoadAssemblyFile (string fileName) @@ -544,10 +536,7 @@ namespace Mono.CSharp public void LoadModules (AssemblyDefinitionDynamic assembly, RootNamespace targetNamespace) { - if (RootContext.Modules.Count == 0) - return; - - foreach (var moduleName in RootContext.Modules) { + foreach (var moduleName in compiler.Settings.Modules) { var m = LoadModuleFile (assembly, moduleName); if (m == null) continue; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs index addcbd747..1b8b19af8 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs @@ -27,8 +27,6 @@ namespace Mono.CSharp { List warnings_as_error; List warnings_only; - public static int DebugFlags = 0; - public const int RuntimeErrorId = 10000; // @@ -57,7 +55,7 @@ namespace Mono.CSharp { 105, 108, 109, 114, 162, 164, 168, 169, 183, 184, 197, 219, 251, 252, 253, 278, 282, 402, 414, 419, 420, 429, 436, 440, 458, 464, 465, 467, 469, 472, - 612, 618, 626, 628, 642, 649, 652, 658, 659, 660, 661, 665, 672, 675, 693, + 612, 618, 626, 628, 642, 649, 652, 657, 658, 659, 660, 661, 665, 672, 675, 693, 728, 809, 824, 1030, 1058, 1066, @@ -92,10 +90,10 @@ namespace Mono.CSharp { --reporting_disabled; } - public void FeatureIsNotAvailable (Location loc, string feature) + public void FeatureIsNotAvailable (CompilerContext compiler, Location loc, string feature) { string version; - switch (RootContext.Version) { + switch (compiler.Settings.Version) { case LanguageVersion.ISO_1: version = "1.0"; break; @@ -106,7 +104,7 @@ namespace Mono.CSharp { version = "3.0"; break; default: - throw new InternalErrorException ("Invalid feature version", RootContext.Version); + throw new InternalErrorException ("Invalid feature version", compiler.Settings.Version); } Error (1644, loc, @@ -299,10 +297,12 @@ namespace Mono.CSharp { return; AbstractMessage msg; - if (IsWarningAsError (code)) + if (IsWarningAsError (code)) { + message = "Warning as Error: " + message; msg = new ErrorMessage (code, loc, message, extra_information); - else + } else { msg = new WarningMessage (code, loc, message, extra_information); + } extra_information.Clear (); printer.Print (msg); @@ -446,8 +446,8 @@ namespace Mono.CSharp { [Conditional ("MCS_DEBUG")] static public void Debug (int category, string message, params object[] args) { - if ((category & DebugFlags) == 0) - return; +// if ((category & DebugFlags) == 0) +// return; StringBuilder sb = new StringBuilder (message); @@ -601,27 +601,23 @@ namespace Mono.CSharp { // // Generic base for any message writer // - public abstract class ReportPrinter { - /// - /// Whether to dump a stack trace on errors. - /// - public bool Stacktrace; - - int warnings, errors; + public abstract class ReportPrinter + { + #region Properties - public int WarningsCount { - get { return warnings; } - } - - public int ErrorsCount { - get { return errors; } - } + public int FatalCounter { get; set; } - protected virtual string FormatText (string txt) - { - return txt; - } + public int ErrorsCount { get; protected set; } + + public bool ShowFullPaths { get; set; } + // + // Whether to dump a stack trace on errors. + // + public bool Stacktrace { get; set; } + + public int WarningsCount { get; private set; } + // // When (symbols related to previous ...) can be used // @@ -629,19 +625,31 @@ namespace Mono.CSharp { get { return true; } } + #endregion + + + protected virtual string FormatText (string txt) + { + return txt; + } + public virtual void Print (AbstractMessage msg) { - if (msg.IsWarning) - ++warnings; - else - ++errors; + if (msg.IsWarning) { + ++WarningsCount; + } else { + ++ErrorsCount; + + if (ErrorsCount == FatalCounter) + throw new Exception (msg.Text); + } } protected void Print (AbstractMessage msg, TextWriter output) { StringBuilder txt = new StringBuilder (); if (!msg.Location.IsNull) { - if (RootContext.ShowFullPaths) + if (ShowFullPaths) txt.Append (msg.Location.ToStringFullName ()); else txt.Append (msg.Location.ToString ()); @@ -664,8 +672,8 @@ namespace Mono.CSharp { public void Reset () { - // Temporary hack for broken repl flow - errors = warnings = 0; + // HACK: Temporary hack for broken repl flow + ErrorsCount = WarningsCount = 0; } } @@ -784,7 +792,7 @@ namespace Mono.CSharp { } } - class StreamReportPrinter : ReportPrinter + public class StreamReportPrinter : ReportPrinter { readonly TextWriter writer; @@ -800,7 +808,7 @@ namespace Mono.CSharp { } } - class ConsoleReportPrinter : StreamReportPrinter + public class ConsoleReportPrinter : StreamReportPrinter { static readonly string prefix, postfix; @@ -860,8 +868,6 @@ namespace Mono.CSharp { { } - public int Fatal { get; set; } - static int NameToCode (string s) { switch (s) { @@ -951,16 +957,12 @@ namespace Mono.CSharp { return sb.ToString (); } - int print_count; public override void Print (AbstractMessage msg) { base.Print (msg); if (Stacktrace) Console.WriteLine (FriendlyStackTrace (new StackTrace (true))); - - if (++print_count == Fatal) - throw new Exception (msg.Text); } public static string FriendlyStackTrace (Exception e) @@ -985,7 +987,7 @@ namespace Mono.CSharp { ReferencesImporting, PredefinedTypesInit, ModuleDefinitionTotal, - UsingVerification, + UsingResolve, EmitTotal, CloseTypes, Resouces, @@ -1044,7 +1046,7 @@ namespace Mono.CSharp { { TimerType.ReferencesImporting, "Referenced assemblies importing" }, { TimerType.PredefinedTypesInit, "Predefined types initialization" }, { TimerType.ModuleDefinitionTotal, "Module definition" }, - { TimerType.UsingVerification, "Usings verification" }, + { TimerType.UsingResolve, "Top-level usings resolve" }, { TimerType.EmitTotal, "Resolving and emitting members blocks" }, { TimerType.CloseTypes, "Module types closed" }, { TimerType.Resouces, "Embedding resources" }, @@ -1053,7 +1055,7 @@ namespace Mono.CSharp { }; int counter = 0; - double percentage = total.ElapsedMilliseconds / 100; + double percentage = (double) total.ElapsedMilliseconds / 100; long subtotal = total.ElapsedMilliseconds; foreach (var timer in timers) { string msg = timer_names[(TimerType) counter++]; diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/rootcontext.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/rootcontext.cs index 69c7e5602..a3b379ce6 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/rootcontext.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/rootcontext.cs @@ -14,18 +14,20 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Globalization; +using System; namespace Mono.CSharp { public enum LanguageVersion { - ISO_1 = 1, - ISO_2 = 2, - V_3 = 3, - V_4 = 4, - Future = 100, + ISO_1 = 1, + ISO_2 = 2, + V_3 = 3, + V_4 = 4, + Future = 100, - Default = LanguageVersion.V_4, + Default = LanguageVersion.V_4, } public enum RuntimeVersion @@ -35,12 +37,6 @@ namespace Mono.CSharp { v4 } - public enum SdkVersion - { - v2, - v4 - } - public enum Target { Library, Exe, Module, WinExe @@ -51,211 +47,1413 @@ namespace Mono.CSharp { AnyCPU, X86, X64, IA64 } - public class RootContext { - - // - // COMPILER OPTIONS CLASS - // - public static Target Target; - public static Platform Platform; - public static string TargetExt; - public static bool VerifyClsCompliance; - public static bool Optimize; - public static LanguageVersion Version; - public static bool EnhancedWarnings; - public static bool LoadDefaultReferences; - public static SdkVersion SdkVersion; + public class CompilerSettings + { + public Target Target; + public Platform Platform; + public string TargetExt; + public bool VerifyClsCompliance; + public bool Optimize; + public LanguageVersion Version; + public bool EnhancedWarnings; + public bool LoadDefaultReferences; + public string SdkVersion; - // - // We keep strongname related info here because - // it's also used as complier options from CSC 8.x - // - public static string StrongNameKeyFile; - public static string StrongNameKeyContainer; - public static bool StrongNameDelaySign; + public string StrongNameKeyFile; + public string StrongNameKeyContainer; + public bool StrongNameDelaySign; // // Assemblies references to be loaded // - public static List AssemblyReferences; + public List AssemblyReferences; // // External aliases for assemblies // - public static List> AssemblyReferencesAliases; + public List> AssemblyReferencesAliases; // // Modules to be embedded // - public static List Modules; + public List Modules; // // Lookup paths for referenced assemblies // - public static List ReferencesLookupPaths; + public List ReferencesLookupPaths; // // Encoding. // - public static Encoding Encoding; + public Encoding Encoding; // // If set, enable XML documentation generation // - public static Documentation Documentation; + public string DocumentationFile; - static public string MainClass; + public string MainClass; // // Output file // - static string output_file; - public static string OutputFile { - set { - output_file = value; - } - get { - return output_file; - } - } - + public string OutputFile; // // The default compiler checked state // - static public bool Checked; - - // - // If true, it means that the compiler is executing as - // in eval mode so unresolved variables are resolved in - // static classes maintained by the eval engine. - // - static public bool EvalMode; + public bool Checked; // // If true, the compiler is operating in statement mode, // this currently turns local variable declaration into // static variables of a class // - static public bool StatementMode; + public bool StatementMode; // TODO: SUPER UGLY // // Whether to allow Unsafe code // - static public bool Unsafe; + public bool Unsafe; - static public string Win32ResourceFile; - static public string Win32IconFile; + public string Win32ResourceFile; + public string Win32IconFile; // // A list of resource files for embedding // - static public List Resources; + public List Resources; - static public bool GenerateDebugInfo; + public bool GenerateDebugInfo; // Compiler debug flags only - public static bool ParseOnly, TokenizeOnly, Timestamps; - - public static bool ShowFullPaths; + public bool ParseOnly, TokenizeOnly, Timestamps; + public int DebugFlags; // // Whether we are being linked against the standard libraries. // This is only used to tell whether `System.Object' should // have a base class or not. // - public static bool StdLib; + public bool StdLib; - public static RuntimeVersion StdLibRuntimeVersion; + public RuntimeVersion StdLibRuntimeVersion; - public static bool NeedsEntryPoint { - get { return Target == Target.Exe || Target == Target.WinExe; } - } + readonly List conditional_symbols; - // - // COMPILER OPTIONS CLASS END - // - - // - // Contains the parsed tree - // - static ModuleContainer root; - - // - // This hashtable contains all of the #definitions across the source code - // it is used by the ConditionalAttribute handler. - // - static List AllDefines; + readonly List source_files; - // - // Constructor - // - static RootContext () - { - Reset (true); - } - - public static void PartialReset () + public CompilerSettings () { - Reset (false); - } - - public static void Reset (bool full) - { - if (!full) - return; - - Checked = false; - Unsafe = false; StdLib = true; - StrongNameKeyFile = null; - StrongNameKeyContainer = null; - StrongNameDelaySign = false; - MainClass = null; - OutputFile = null; Target = Target.Exe; - SdkVersion = SdkVersion.v4; TargetExt = ".exe"; Platform = Platform.AnyCPU; Version = LanguageVersion.Default; VerifyClsCompliance = true; Optimize = true; - Encoding = Encoding.Default; - Documentation = null; - GenerateDebugInfo = false; - ParseOnly = false; - TokenizeOnly = false; - Timestamps = false; - Win32IconFile = null; - Win32ResourceFile = null; - Resources = null; + Encoding = Encoding.UTF8; LoadDefaultReferences = true; + StdLibRuntimeVersion = RuntimeVersion.v4; + AssemblyReferences = new List (); AssemblyReferencesAliases = new List> (); Modules = new List (); ReferencesLookupPaths = new List (); - StdLibRuntimeVersion = RuntimeVersion.v2; - ShowFullPaths = false; + conditional_symbols = new List (); // - // Setup default defines + // Add default mcs define // - AllDefines = new List (); - AddConditional ("__MonoCS__"); + conditional_symbols.Add ("__MonoCS__"); + + source_files = new List (); + } + + #region Properties + + public CompilationSourceFile FirstSourceFile { + get { + return source_files.Count > 0 ? source_files [0] : null; + } } - public static void AddConditional (string p) + public bool HasKeyFileOrContainer { + get { + return StrongNameKeyFile != null || StrongNameKeyContainer != null; + } + } + + public bool NeedsEntryPoint { + get { + return Target == Target.Exe || Target == Target.WinExe; + } + } + + public List SourceFiles { + get { + return source_files; + } + } + + #endregion + + public void AddConditionalSymbol (string symbol) { - if (AllDefines.Contains (p)) + if (!conditional_symbols.Contains (symbol)) + conditional_symbols.Add (symbol); + } + + public bool IsConditionalSymbolDefined (string symbol) + { + return conditional_symbols.Contains (symbol); + } + } + + public class CommandLineParser + { + enum ParseResult + { + Success, + Error, + Stop, + UnknownOption + } + + static readonly char[] argument_value_separator = new char[] { ';', ',' }; + static readonly char[] numeric_value_separator = new char[] { ';', ',', ' ' }; + + readonly Report report; + readonly TextWriter output; + bool stop_argument; + + Dictionary source_file_index; + + public event Func UnknownOptionHandler; + + public CommandLineParser (Report report) + : this (report, Console.Out) + { + } + + public CommandLineParser (Report report, TextWriter messagesOutput) + { + this.report = report; + this.output = messagesOutput; + } + + public bool HasBeenStopped { + get { + return stop_argument; + } + } + + void About () + { + output.WriteLine ( + "The Mono C# compiler is Copyright 2001-2011, Novell, Inc.\n\n" + + "The compiler source code is released under the terms of the \n" + + "MIT X11 or GNU GPL licenses\n\n" + + + "For more information on Mono, visit the project Web site\n" + + " http://www.mono-project.com\n\n" + + + "The compiler was written by Miguel de Icaza, Ravi Pratap, Martin Baulig, Marek Safar, Raja R Harinath, Atushi Enomoto"); + } + + public CompilerSettings ParseArguments (string[] args) + { + CompilerSettings settings = new CompilerSettings (); + List response_file_list = null; + bool parsing_options = true; + stop_argument = false; + source_file_index = new Dictionary (); + + for (int i = 0; i < args.Length; i++) { + string arg = args[i]; + if (arg.Length == 0) + continue; + + if (arg[0] == '@') { + string[] extra_args; + string response_file = arg.Substring (1); + + if (response_file_list == null) + response_file_list = new List (); + + if (response_file_list.Contains (response_file)) { + report.Error (1515, "Response file `{0}' specified multiple times", response_file); + return null; + } + + response_file_list.Add (response_file); + + extra_args = LoadArgs (response_file); + if (extra_args == null) { + report.Error (2011, "Unable to open response file: " + response_file); + return null; + } + + args = AddArgs (args, extra_args); + continue; + } + + if (parsing_options) { + if (arg == "--") { + parsing_options = false; + continue; + } + + bool dash_opt = arg[0] == '-'; + bool slash_opt = arg[0] == '/'; + if (dash_opt) { + switch (ParseOptionUnix (arg, ref args, ref i, settings)) { + case ParseResult.Error: + case ParseResult.Success: + continue; + case ParseResult.Stop: + stop_argument = true; + return settings; + case ParseResult.UnknownOption: + if (UnknownOptionHandler != null) { + var ret = UnknownOptionHandler (args, i); + if (ret != -1) { + i = ret; + continue; + } + } + break; + } + } + + if (dash_opt || slash_opt) { + // Try a -CSCOPTION + string csc_opt = dash_opt ? "/" + arg.Substring (1) : arg; + switch (ParseOption (csc_opt, ref args, settings)) { + case ParseResult.Error: + case ParseResult.Success: + continue; + case ParseResult.UnknownOption: + // Need to skip `/home/test.cs' however /test.cs is considered as error + if ((slash_opt && arg.Length > 3 && arg.IndexOf ('/', 2) > 0)) + break; + + if (UnknownOptionHandler != null) { + var ret = UnknownOptionHandler (args, i); + if (ret != -1) { + i = ret; + continue; + } + } + + Error_WrongOption (arg); + return null; + + case ParseResult.Stop: + stop_argument = true; + return settings; + } + } + } + + ProcessSourceFiles (arg, false, settings.SourceFiles); + } + + return settings; + } + + void ProcessSourceFiles (string spec, bool recurse, List sourceFiles) + { + string path, pattern; + + SplitPathAndPattern (spec, out path, out pattern); + if (pattern.IndexOf ('*') == -1) { + AddSourceFile (spec, sourceFiles); + return; + } + + string[] files = null; + try { + files = Directory.GetFiles (path, pattern); + } catch (System.IO.DirectoryNotFoundException) { + report.Error (2001, "Source file `" + spec + "' could not be found"); return; - AllDefines.Add (p); + } catch (System.IO.IOException) { + report.Error (2001, "Source file `" + spec + "' could not be found"); + return; + } + foreach (string f in files) { + AddSourceFile (f, sourceFiles); + } + + if (!recurse) + return; + + string[] dirs = null; + + try { + dirs = Directory.GetDirectories (path); + } catch { + } + + foreach (string d in dirs) { + + // Don't include path in this string, as each + // directory entry already does + ProcessSourceFiles (d + "/" + pattern, true, sourceFiles); + } + } + + static string[] AddArgs (string[] args, string[] extra_args) + { + string[] new_args; + new_args = new string[extra_args.Length + args.Length]; + + // if args contains '--' we have to take that into account + // split args into first half and second half based on '--' + // and add the extra_args before -- + int split_position = Array.IndexOf (args, "--"); + if (split_position != -1) { + Array.Copy (args, new_args, split_position); + extra_args.CopyTo (new_args, split_position); + Array.Copy (args, split_position, new_args, split_position + extra_args.Length, args.Length - split_position); + } else { + args.CopyTo (new_args, 0); + extra_args.CopyTo (new_args, args.Length); + } + + return new_args; + } + + void AddAssemblyReference (string alias, string assembly, CompilerSettings settings) + { + if (assembly.Length == 0) { + report.Error (1680, "Invalid reference alias `{0}='. Missing filename", alias); + return; + } + + if (!IsExternAliasValid (alias)) { + report.Error (1679, "Invalid extern alias for -reference. Alias `{0}' is not a valid identifier", alias); + return; + } + + settings.AssemblyReferencesAliases.Add (Tuple.Create (alias, assembly)); + } + + void AddResource (AssemblyResource res, CompilerSettings settings) + { + if (settings.Resources == null) { + settings.Resources = new List (); + settings.Resources.Add (res); + return; + } + + if (settings.Resources.Contains (res)) { + report.Error (1508, "The resource identifier `{0}' has already been used in this assembly", res.Name); + return; + } + + settings.Resources.Add (res); + } + + void AddSourceFile (string fileName, List sourceFiles) + { + string path = Path.GetFullPath (fileName); + + int index; + if (source_file_index.TryGetValue (path, out index)) { + string other_name = sourceFiles[index - 1].Name; + if (fileName.Equals (other_name)) + report.Warning (2002, 1, "Source file `{0}' specified multiple times", other_name); + else + report.Warning (2002, 1, "Source filenames `{0}' and `{1}' both refer to the same file: {2}", fileName, other_name, path); + + return; + } + + var unit = new CompilationSourceFile (fileName, path, sourceFiles.Count + 1); + sourceFiles.Add (unit); + source_file_index.Add (path, unit.Index); + } + + void Error_RequiresArgument (string option) + { + report.Error (2006, "Missing argument for `{0}' option", option); } - public static bool IsConditionalDefined (string value) + void Error_RequiresFileName (string option) { - return AllDefines.Contains (value); + report.Error (2005, "Missing file specification for `{0}' option", option); } + void Error_WrongOption (string option) + { + report.Error (2007, "Unrecognized command-line option: `{0}'", option); + } + + static bool IsExternAliasValid (string identifier) + { + if (identifier.Length == 0) + return false; + if (identifier[0] != '_' && !char.IsLetter (identifier[0])) + return false; + + for (int i = 1; i < identifier.Length; i++) { + char c = identifier[i]; + if (char.IsLetter (c) || char.IsDigit (c)) + continue; + + UnicodeCategory category = char.GetUnicodeCategory (c); + if (category != UnicodeCategory.Format || category != UnicodeCategory.NonSpacingMark || + category != UnicodeCategory.SpacingCombiningMark || + category != UnicodeCategory.ConnectorPunctuation) + return false; + } + + return true; + } + + static string[] LoadArgs (string file) + { + StreamReader f; + var args = new List (); + string line; + try { + f = new StreamReader (file); + } catch { + return null; + } + + StringBuilder sb = new StringBuilder (); + + while ((line = f.ReadLine ()) != null) { + int t = line.Length; + + for (int i = 0; i < t; i++) { + char c = line[i]; + + if (c == '"' || c == '\'') { + char end = c; + + for (i++; i < t; i++) { + c = line[i]; + + if (c == end) + break; + sb.Append (c); + } + } else if (c == ' ') { + if (sb.Length > 0) { + args.Add (sb.ToString ()); + sb.Length = 0; + } + } else + sb.Append (c); + } + if (sb.Length > 0) { + args.Add (sb.ToString ()); + sb.Length = 0; + } + } + + return args.ToArray (); + } + + void OtherFlags () + { + output.WriteLine ( + "Other flags in the compiler\n" + + " --fatal[=COUNT] Makes errors after COUNT fatal\n" + + " --lint Enhanced warnings\n" + + " --parse Only parses the source file\n" + + " --runtime:VERSION Sets mscorlib.dll metadata version: v1, v2, v4\n" + + " --stacktrace Shows stack trace at error location\n" + + " --timestamp Displays time stamps of various compiler events\n" + + " -v Verbose parsing (for debugging the parser)\n" + + " --mcs-debug X Sets MCS debugging level to X\n"); + } + + // + // This parses the -arg and /arg options to the compiler, even if the strings + // in the following text use "/arg" on the strings. + // + ParseResult ParseOption (string option, ref string[] args, CompilerSettings settings) + { + int idx = option.IndexOf (':'); + string arg, value; + + if (idx == -1) { + arg = option; + value = ""; + } else { + arg = option.Substring (0, idx); + + value = option.Substring (idx + 1); + } + + switch (arg.ToLowerInvariant ()) { + case "/nologo": + return ParseResult.Success; + + case "/t": + case "/target": + switch (value) { + case "exe": + settings.Target = Target.Exe; + break; + + case "winexe": + settings.Target = Target.WinExe; + break; + + case "library": + settings.Target = Target.Library; + settings.TargetExt = ".dll"; + break; + + case "module": + settings.Target = Target.Module; + settings.TargetExt = ".netmodule"; + break; + + default: + report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'"); + return ParseResult.Error; + } + return ParseResult.Success; + + case "/out": + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + settings.OutputFile = value; + return ParseResult.Success; + + case "/o": + case "/o+": + case "/optimize": + case "/optimize+": + settings.Optimize = true; + return ParseResult.Success; + + case "/o-": + case "/optimize-": + settings.Optimize = false; + return ParseResult.Success; + + // TODO: Not supported by csc 3.5+ + case "/incremental": + case "/incremental+": + case "/incremental-": + // nothing. + return ParseResult.Success; + + case "/d": + case "/define": { + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + foreach (string d in value.Split (argument_value_separator)) { + string conditional = d.Trim (); + if (!Tokenizer.IsValidIdentifier (conditional)) { + report.Warning (2029, 1, "Invalid conditional define symbol `{0}'", conditional); + continue; + } + + settings.AddConditionalSymbol (conditional); + } + return ParseResult.Success; + } + + case "/bugreport": + // + // We should collect data, runtime, etc and store in the file specified + // + output.WriteLine ("To file bug reports, please visit: http://www.mono-project.com/Bugs"); + return ParseResult.Success; + + case "/pkg": { + string packages; + + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + packages = String.Join (" ", value.Split (new Char[] { ';', ',', '\n', '\r' })); + string pkgout = Driver.GetPackageFlags (packages, report); + + if (pkgout == null) + return ParseResult.Error; + + string[] xargs = pkgout.Trim (new Char[] { ' ', '\n', '\r', '\t' }).Split (new Char[] { ' ', '\t' }); + args = AddArgs (args, xargs); + return ParseResult.Success; + } + + case "/linkres": + case "/linkresource": + case "/res": + case "/resource": + AssemblyResource res = null; + string[] s = value.Split (argument_value_separator, StringSplitOptions.RemoveEmptyEntries); + switch (s.Length) { + case 1: + if (s[0].Length == 0) + goto default; + res = new AssemblyResource (s[0], Path.GetFileName (s[0])); + break; + case 2: + res = new AssemblyResource (s[0], s[1]); + break; + case 3: + if (s[2] != "public" && s[2] != "private") { + report.Error (1906, "Invalid resource visibility option `{0}'. Use either `public' or `private' instead", s[2]); + return ParseResult.Error; + } + res = new AssemblyResource (s[0], s[1], s[2] == "private"); + break; + default: + report.Error (-2005, "Wrong number of arguments for option `{0}'", option); + return ParseResult.Error; + } + + if (res != null) { + res.IsEmbeded = arg[1] == 'r' || arg[1] == 'R'; + AddResource (res, settings); + } + + return ParseResult.Success; + + case "/recurse": + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + ProcessSourceFiles (value, true, settings.SourceFiles); + return ParseResult.Success; + + case "/r": + case "/reference": { + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + + string[] refs = value.Split (argument_value_separator); + foreach (string r in refs) { + if (r.Length == 0) + continue; + + string val = r; + int index = val.IndexOf ('='); + if (index > -1) { + string alias = r.Substring (0, index); + string assembly = r.Substring (index + 1); + AddAssemblyReference (alias, assembly, settings); + if (refs.Length != 1) { + report.Error (2034, "Cannot specify multiple aliases using single /reference option"); + return ParseResult.Error; + } + } else { + settings.AssemblyReferences.Add (val); + } + } + return ParseResult.Success; + } + case "/addmodule": { + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + + string[] refs = value.Split (argument_value_separator); + foreach (string r in refs) { + settings.Modules.Add (r); + } + return ParseResult.Success; + } + case "/win32res": { + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + + if (settings.Win32IconFile != null) + report.Error (1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time"); + + settings.Win32ResourceFile = value; + return ParseResult.Success; + } + case "/win32icon": { + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + + if (settings.Win32ResourceFile != null) + report.Error (1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time"); + + settings.Win32IconFile = value; + return ParseResult.Success; + } + case "/doc": { + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + + settings.DocumentationFile = value; + return ParseResult.Success; + } + case "/lib": { + string[] libdirs; + + if (value.Length == 0) { + return ParseResult.Error; + } + + libdirs = value.Split (argument_value_separator); + foreach (string dir in libdirs) + settings.ReferencesLookupPaths.Add (dir); + return ParseResult.Success; + } + + case "/debug-": + settings.GenerateDebugInfo = false; + return ParseResult.Success; + + case "/debug": + if (value == "full" || value == "") + settings.GenerateDebugInfo = true; + + return ParseResult.Success; + + case "/debug+": + settings.GenerateDebugInfo = true; + return ParseResult.Success; + + case "/checked": + case "/checked+": + settings.Checked = true; + return ParseResult.Success; + + case "/checked-": + settings.Checked = false; + return ParseResult.Success; + + case "/clscheck": + case "/clscheck+": + settings.VerifyClsCompliance = true; + return ParseResult.Success; + + case "/clscheck-": + settings.VerifyClsCompliance = false; + return ParseResult.Success; + + case "/unsafe": + case "/unsafe+": + settings.Unsafe = true; + return ParseResult.Success; + + case "/unsafe-": + settings.Unsafe = false; + return ParseResult.Success; + + case "/warnaserror": + case "/warnaserror+": + if (value.Length == 0) { + report.WarningsAreErrors = true; + } else { + foreach (string wid in value.Split (numeric_value_separator)) + report.AddWarningAsError (wid); + } + return ParseResult.Success; + + case "/warnaserror-": + if (value.Length == 0) { + report.WarningsAreErrors = false; + } else { + foreach (string wid in value.Split (numeric_value_separator)) + report.RemoveWarningAsError (wid); + } + return ParseResult.Success; + + case "/warn": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + SetWarningLevel (value); + return ParseResult.Success; + + case "/nowarn": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + var warns = value.Split (numeric_value_separator); + foreach (string wc in warns) { + try { + if (wc.Trim ().Length == 0) + continue; + + int warn = Int32.Parse (wc); + if (warn < 1) { + throw new ArgumentOutOfRangeException ("warn"); + } + report.SetIgnoreWarning (warn); + } catch { + report.Error (1904, "`{0}' is not a valid warning number", wc); + return ParseResult.Error; + } + } + return ParseResult.Success; + + case "/noconfig": + settings.LoadDefaultReferences = false; + return ParseResult.Success; + + case "/platform": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + switch (value.ToLower (CultureInfo.InvariantCulture)) { + case "anycpu": + settings.Platform = Platform.AnyCPU; + break; + case "x86": + settings.Platform = Platform.X86; + break; + case "x64": + settings.Platform = Platform.X64; + break; + case "itanium": + settings.Platform = Platform.IA64; + break; + default: + report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'"); + return ParseResult.Error; + } + + return ParseResult.Success; + + case "/sdk": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + settings.SdkVersion = value; + return ParseResult.Success; + + // We just ignore this. + case "/errorreport": + case "/filealign": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + return ParseResult.Success; + + case "/helpinternal": + OtherFlags (); + return ParseResult.Stop; + + case "/help": + case "/?": + Usage (); + return ParseResult.Stop; + + case "/main": + case "/m": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + settings.MainClass = value; + return ParseResult.Success; + + case "/nostdlib": + case "/nostdlib+": + settings.StdLib = false; + return ParseResult.Success; + + case "/nostdlib-": + settings.StdLib = true; + return ParseResult.Success; + + case "/fullpaths": + report.Printer.ShowFullPaths = true; + return ParseResult.Success; + + case "/keyfile": + if (value.Length == 0) { + Error_RequiresFileName (option); + return ParseResult.Error; + } + + settings.StrongNameKeyFile = value; + return ParseResult.Success; + + case "/keycontainer": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + settings.StrongNameKeyContainer = value; + return ParseResult.Success; + + case "/delaysign+": + case "/delaysign": + settings.StrongNameDelaySign = true; + return ParseResult.Success; + + case "/delaysign-": + settings.StrongNameDelaySign = false; + return ParseResult.Success; + + case "/langversion": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + switch (value.ToLowerInvariant ()) { + case "iso-1": + settings.Version = LanguageVersion.ISO_1; + return ParseResult.Success; + case "default": + settings.Version = LanguageVersion.Default; + return ParseResult.Success; + case "iso-2": + settings.Version = LanguageVersion.ISO_2; + return ParseResult.Success; + case "3": + settings.Version = LanguageVersion.V_3; + return ParseResult.Success; + case "future": + settings.Version = LanguageVersion.Future; + return ParseResult.Success; + } + + report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or `Default'", value); + return ParseResult.Error; + + case "/codepage": + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } + + switch (value) { + case "utf8": + settings.Encoding = Encoding.UTF8; + break; + case "reset": + settings.Encoding = Encoding.Default; + break; + default: + try { + settings.Encoding = Encoding.GetEncoding (int.Parse (value)); + } catch { + report.Error (2016, "Code page `{0}' is invalid or not installed", value); + } + return ParseResult.Error; + } + return ParseResult.Success; + + default: + return ParseResult.UnknownOption; + } + } + + // + // Currently handles the Unix-like command line options, but will be + // deprecated in favor of the CSCParseOption, which will also handle the + // options that start with a dash in the future. + // + ParseResult ParseOptionUnix (string arg, ref string[] args, ref int i, CompilerSettings settings) + { + switch (arg){ + case "-v": + CSharpParser.yacc_verbose_flag++; + return ParseResult.Success; + + case "--version": + Version (); + return ParseResult.Stop; + + case "--parse": + settings.ParseOnly = true; + return ParseResult.Success; + + case "--main": case "-m": + report.Warning (-29, 1, "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + settings.MainClass = args[++i]; + return ParseResult.Success; + + case "--unsafe": + report.Warning (-29, 1, "Compatibility: Use -unsafe instead of --unsafe"); + settings.Unsafe = true; + return ParseResult.Success; + + case "/?": case "/h": case "/help": + case "--help": + Usage (); + return ParseResult.Stop; + + case "--define": + report.Warning (-29, 1, "Compatibility: Use -d:SYMBOL instead of --define SYMBOL"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + settings.AddConditionalSymbol (args [++i]); + return ParseResult.Success; + + case "--tokenize": + settings.TokenizeOnly = true; + return ParseResult.Success; + + case "-o": + case "--output": + report.Warning (-29, 1, "Compatibility: Use -out:FILE instead of --output FILE or -o FILE"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + settings.OutputFile = args[++i]; + return ParseResult.Success; + + case "--checked": + report.Warning (-29, 1, "Compatibility: Use -checked instead of --checked"); + settings.Checked = true; + return ParseResult.Success; + + case "--stacktrace": + report.Printer.Stacktrace = true; + return ParseResult.Success; + + case "--linkresource": + case "--linkres": + report.Warning (-29, 1, "Compatibility: Use -linkres:VALUE instead of --linkres VALUE"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + AddResource (new AssemblyResource (args[++i], args[i]), settings); + return ParseResult.Success; + + case "--resource": + case "--res": + report.Warning (-29, 1, "Compatibility: Use -res:VALUE instead of --res VALUE"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + AddResource (new AssemblyResource (args[++i], args[i], true), settings); + return ParseResult.Success; + + case "--target": + report.Warning (-29, 1, "Compatibility: Use -target:KIND instead of --target KIND"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + string type = args [++i]; + switch (type){ + case "library": + settings.Target = Target.Library; + settings.TargetExt = ".dll"; + break; + + case "exe": + settings.Target = Target.Exe; + break; + + case "winexe": + settings.Target = Target.WinExe; + break; + + case "module": + settings.Target = Target.Module; + settings.TargetExt = ".dll"; + break; + default: + report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'"); + break; + } + return ParseResult.Success; + + case "-r": + report.Warning (-29, 1, "Compatibility: Use -r:LIBRARY instead of -r library"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + string val = args [++i]; + int idx = val.IndexOf ('='); + if (idx > -1) { + string alias = val.Substring (0, idx); + string assembly = val.Substring (idx + 1); + AddAssemblyReference (alias, assembly, settings); + return ParseResult.Success; + } + + settings.AssemblyReferences.Add (val); + return ParseResult.Success; + + case "-L": + report.Warning (-29, 1, "Compatibility: Use -lib:ARG instead of --L arg"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + settings.ReferencesLookupPaths.Add (args [++i]); + return ParseResult.Success; + + case "--lint": + settings.EnhancedWarnings = true; + return ParseResult.Success; + + case "--nostdlib": + report.Warning (-29, 1, "Compatibility: Use -nostdlib instead of --nostdlib"); + settings.StdLib = false; + return ParseResult.Success; + + case "--nowarn": + report.Warning (-29, 1, "Compatibility: Use -nowarn instead of --nowarn"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + int warn = 0; + + try { + warn = int.Parse (args [++i]); + } catch { + Usage (); + Environment.Exit (1); + } + report.SetIgnoreWarning (warn); + return ParseResult.Success; + + case "--wlevel": + report.Warning (-29, 1, "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + SetWarningLevel (args [++i]); + return ParseResult.Success; + + case "--mcs-debug": + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + try { + settings.DebugFlags = int.Parse (args [++i]); + } catch { + Error_RequiresArgument (arg); + return ParseResult.Error; + } + + return ParseResult.Success; + + case "--about": + About (); + return ParseResult.Stop; + + case "--recurse": + report.Warning (-29, 1, "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN"); + if ((i + 1) >= args.Length){ + Error_RequiresArgument (arg); + return ParseResult.Error; + } + ProcessSourceFiles (args [++i], true, settings.SourceFiles); + return ParseResult.Success; + + case "--timestamp": + settings.Timestamps = true; + return ParseResult.Success; + + case "--debug": case "-g": + report.Warning (-29, 1, "Compatibility: Use -debug option instead of -g or --debug"); + settings.GenerateDebugInfo = true; + return ParseResult.Success; + + case "--noconfig": + report.Warning (-29, 1, "Compatibility: Use -noconfig option instead of --noconfig"); + settings.LoadDefaultReferences = false; + return ParseResult.Success; + + default: + if (arg.StartsWith ("--fatal")){ + int fatal = 1; + if (arg.StartsWith ("--fatal=")) + int.TryParse (arg.Substring (8), out fatal); + + report.Printer.FatalCounter = fatal; + return ParseResult.Success; + } + if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) { + string version = arg.Substring (10); + + switch (version) { + case "v1": + case "V1": + settings.StdLibRuntimeVersion = RuntimeVersion.v1; + break; + case "v2": + case "V2": + settings.StdLibRuntimeVersion = RuntimeVersion.v2; + break; + case "v4": + case "V4": + settings.StdLibRuntimeVersion = RuntimeVersion.v4; + break; + } + return ParseResult.Success; + } + + return ParseResult.UnknownOption; + } + } + + void SetWarningLevel (string s) + { + int level = -1; + + try { + level = int.Parse (s); + } catch { + } + if (level < 0 || level > 4) { + report.Error (1900, "Warning level must be in the range 0-4"); + return; + } + report.WarningLevel = level; + } + + // + // Given a path specification, splits the path from the file/pattern + // + static void SplitPathAndPattern (string spec, out string path, out string pattern) + { + int p = spec.LastIndexOf ('/'); + if (p != -1) { + // + // Windows does not like /file.cs, switch that to: + // "\", "file.cs" + // + if (p == 0) { + path = "\\"; + pattern = spec.Substring (1); + } else { + path = spec.Substring (0, p); + pattern = spec.Substring (p + 1); + } + return; + } + + p = spec.LastIndexOf ('\\'); + if (p != -1) { + path = spec.Substring (0, p); + pattern = spec.Substring (p + 1); + return; + } + + path = "."; + pattern = spec; + } + + void Usage () + { + output.WriteLine ( + "Mono C# compiler, Copyright 2001 - 2011 Novell, Inc.\n" + + "mcs [options] source-files\n" + + " --about About the Mono C# compiler\n" + + " -addmodule:M1[,Mn] Adds the module to the generated assembly\n" + + " -checked[+|-] Sets default aritmetic overflow context\n" + + " -clscheck[+|-] Disables CLS Compliance verifications\n" + + " -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n" + + " -define:S1[;S2] Defines one or more conditional symbols (short: -d)\n" + + " -debug[+|-], -g Generate debugging information\n" + + " -delaysign[+|-] Only insert the public key into the assembly (no signing)\n" + + " -doc:FILE Process documentation comments to XML file\n" + + " -fullpaths Any issued error or warning uses absolute file path\n" + + " -help Lists all compiler options (short: -?)\n" + + " -keycontainer:NAME The key pair container used to sign the output assembly\n" + + " -keyfile:FILE The key file used to strongname the ouput assembly\n" + + " -langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, Default or Future\n" + + " -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n" + + " -main:CLASS Specifies the class with the Main method (short: -m)\n" + + " -noconfig Disables implicitly referenced assemblies\n" + + " -nostdlib[+|-] Does not reference mscorlib.dll library\n" + + " -nowarn:W1[,Wn] Suppress one or more compiler warnings\n" + + " -optimize[+|-] Enables advanced compiler optimizations (short: -o)\n" + + " -out:FILE Specifies output assembly name\n" + + " -pkg:P1[,Pn] References packages P1..Pn\n" + + " -platform:ARCH Specifies the target platform of the output assembly\n" + + " ARCH can be one of: anycpu, x86, x64 or itanium\n" + + " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" + + " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + + " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + + " -sdk:VERSION Specifies SDK version of referenced assemblies\n" + + " VERSION can be one of: 2, 4 (default) or custom value\n" + + " -target:KIND Specifies the format of the output assembly (short: -t)\n" + + " KIND can be one of: exe, winexe, library, module\n" + + " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" + + " -warnaserror[+|-] Treats all warnings as errors\n" + + " -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors\n" + + " -warn:0-4 Sets warning level, the default is 4 (short -w:)\n" + + " -helpinternal Shows internal and advanced compiler options\n" + + "\n" + + "Resources:\n" + + " -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)\n" + + " -resource:FILE[,ID] Embed FILE as a resource (short: -res)\n" + + " -win32res:FILE Specifies Win32 resource file (.res)\n" + + " -win32icon:FILE Use this icon for the output\n" + + " @file Read response file for more options\n\n" + + "Options can be of the form -option or /option"); + } + + void Version () + { + string version = System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType.Assembly.GetName ().Version.ToString (); + output.WriteLine ("Mono C# compiler version {0}", version); + } + } + + public class RootContext + { + // + // Contains the parsed tree + // + static ModuleContainer root; + static public ModuleContainer ToplevelTypes { get { return root; } set { root = value; } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs index 85dd1699c..12c213d58 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs @@ -28,18 +28,16 @@ namespace Mono.CSharp // // Module (top-level type) container // - public class ModuleContainer : TypeContainer + public sealed class ModuleContainer : TypeContainer { +#if STATIC // // Compiler generated container for static data // sealed class StaticDataContainer : CompilerGeneratedClass { - Dictionary size_types; + readonly Dictionary size_types; new int fields; -#if !STATIC - static MethodInfo set_data; -#endif public StaticDataContainer (ModuleContainer module) : base (module, new MemberName ("" + module.builder.ModuleVersionId.ToString ("B"), Location.Null), Modifiers.STATIC) @@ -70,22 +68,21 @@ namespace Mono.CSharp size_type.DefineType (); size_types.Add (data.Length, size_type); - - var pa = Module.PredefinedAttributes.StructLayout; - if (pa.Constructor != null || pa.ResolveConstructor (Location, TypeManager.short_type)) { + var ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location); + if (ctor != null) { var argsEncoded = new AttributeEncoder (); argsEncoded.Encode ((short) LayoutKind.Explicit); - var field_size = pa.GetField ("Size", TypeManager.int32_type, Location); - var pack = pa.GetField ("Pack", TypeManager.int32_type, Location); - if (field_size != null) { + var field_size = Module.PredefinedMembers.StructLayoutSize.Resolve (Location); + var pack = Module.PredefinedMembers.StructLayoutPack.Resolve (Location); + if (field_size != null && pack != null) { argsEncoded.EncodeNamedArguments ( new[] { field_size, pack }, - new[] { new IntConstant ((int) data.Length, Location), new IntConstant (1, Location) } + new[] { new IntConstant (Compiler.BuiltinTypes, (int) data.Length, Location), new IntConstant (Compiler.BuiltinTypes, 1, Location) } ); - } - pa.EmitAttribute (size_type.TypeBuilder, argsEncoded); + size_type.TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), argsEncoded.ToArray ()); + } } } @@ -93,33 +90,44 @@ namespace Mono.CSharp ++fields; const Modifiers fmod = Modifiers.STATIC | Modifiers.INTERNAL; var fbuilder = TypeBuilder.DefineField (name, size_type.CurrentType.GetMetaInfo (), ModifiersExtensions.FieldAttr (fmod) | FieldAttributes.HasFieldRVA); -#if STATIC fbuilder.__SetDataAndRVA (data); -#else - if (set_data == null) - set_data = typeof (FieldBuilder).GetMethod ("SetRVAData", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - - try { - set_data.Invoke (fbuilder, new object[] { data }); - } catch { - Report.RuntimeMissingSupport (loc, "SetRVAData"); - } -#endif return new FieldSpec (CurrentType, null, size_type.CurrentType, fbuilder, fmod); } } + StaticDataContainer static_data; + + // + // Makes const data field inside internal type container + // + public FieldSpec MakeStaticData (byte[] data, Location loc) + { + if (static_data == null) { + static_data = new StaticDataContainer (this); + static_data.CreateType (); + static_data.DefineType (); + + AddCompilerGeneratedClass (static_data); + } + + return static_data.DefineInitializedData (data, loc); + } +#endif + public CharSet? DefaultCharSet; public TypeAttributes DefaultCharSetType = TypeAttributes.AnsiClass; - Dictionary> anonymous_types; - StaticDataContainer static_data; + readonly Dictionary> anonymous_types; + readonly Dictionary array_types; + readonly Dictionary pointer_types; + readonly Dictionary reference_types; + readonly Dictionary attrs_cache; AssemblyDefinition assembly; readonly CompilerContext context; readonly RootNamespace global_ns; - Dictionary alias_ns; + readonly Dictionary alias_ns; ModuleBuilder builder; @@ -127,6 +135,7 @@ namespace Mono.CSharp PredefinedAttributes predefined_attributes; PredefinedTypes predefined_types; + PredefinedMembers predefined_members; static readonly string[] attribute_targets = new string[] { "assembly", "module" }; @@ -141,10 +150,29 @@ namespace Mono.CSharp anonymous_types = new Dictionary> (); global_ns = new GlobalRootNamespace (); alias_ns = new Dictionary (); + array_types = new Dictionary (); + pointer_types = new Dictionary (); + reference_types = new Dictionary (); + attrs_cache = new Dictionary (); } #region Properties + internal Dictionary ArrayTypesCache { + get { + return array_types; + } + } + + // + // Cache for parameter-less attributes + // + internal Dictionary AttributeConstructorCache { + get { + return attrs_cache; + } + } + public override AttributeTargets AttributeTargets { get { return AttributeTargets.Assembly; @@ -169,6 +197,10 @@ namespace Mono.CSharp } } + public Evaluator Evaluator { + get; set; + } + public bool HasDefaultCharSet { get { return DefaultCharSet.HasValue; @@ -199,18 +231,36 @@ namespace Mono.CSharp } } + internal Dictionary PointerTypesCache { + get { + return pointer_types; + } + } + internal PredefinedAttributes PredefinedAttributes { get { return predefined_attributes; } } + internal PredefinedMembers PredefinedMembers { + get { + return predefined_members; + } + } + internal PredefinedTypes PredefinedTypes { get { return predefined_types; } } + internal Dictionary ReferenceTypesCache { + get { + return reference_types; + } + } + public override string[] ValidAttributeTargets { get { return attribute_targets; @@ -219,6 +269,11 @@ namespace Mono.CSharp #endregion + public override void Accept (StructuralVisitor visitor) + { + visitor.Visit (this); + } + public void AddAnonymousType (AnonymousTypeClass type) { List existing; @@ -231,21 +286,16 @@ namespace Mono.CSharp existing.Add (type); } - public void AddAttributes (List attrs) - { - AddAttributes (attrs, this); - } - - public void AddAttributes (List attrs, IMemberContext context) + public void AddAttribute (Attribute attr, IMemberContext context) { - foreach (Attribute a in attrs) - a.AttachTo (this, context); + attr.AttachTo (this, context); if (attributes == null) { - attributes = new Attributes (attrs); + attributes = new Attributes (attr); return; } - attributes.AddAttributes (attrs); + + attributes.AddAttribute (attr); } public override TypeContainer AddPartial (TypeContainer nextPart) @@ -343,11 +393,6 @@ namespace Mono.CSharp public new void Define () { - // FIXME: Temporary hack for repl to reset - static_data = null; - - InitializePredefinedTypes (); - foreach (TypeContainer tc in types) tc.DefineType (); @@ -368,7 +413,7 @@ namespace Mono.CSharp if (OptAttributes != null) OptAttributes.Emit (); - if (RootContext.Unsafe) { + if (Compiler.Settings.Unsafe) { var pa = PredefinedAttributes.UnverifiableCode; if (pa.IsDefined) pa.EmitAttribute (builder); @@ -391,6 +436,12 @@ namespace Mono.CSharp c.EmitType (); } + internal override void GenerateDocComment (DocumentationBuilder builder) + { + foreach (var tc in types) + tc.GenerateDocComment (builder); + } + public AnonymousTypeClass GetAnonymousType (IList parameters) { List candidates; @@ -427,6 +478,7 @@ namespace Mono.CSharp { predefined_attributes = new PredefinedAttributes (this); predefined_types = new PredefinedTypes (this); + predefined_members = new PredefinedMembers (this); } public override bool IsClsComplianceRequired () @@ -434,40 +486,19 @@ namespace Mono.CSharp return DeclaringAssembly.IsCLSCompliant; } - // - // Makes const data field inside internal type container - // - public FieldSpec MakeStaticData (byte[] data, Location loc) - { - if (static_data == null) { - static_data = new StaticDataContainer (this); - static_data.CreateType (); - static_data.DefineType (); - - AddCompilerGeneratedClass (static_data); - } - - return static_data.DefineInitializedData (data, loc); - } - protected override bool AddMemberType (TypeContainer ds) { if (!AddToContainer (ds, ds.Name)) return false; - ds.NamespaceEntry.NS.AddType (ds.Definition); + ds.NamespaceEntry.NS.AddType (this, ds.Definition); return true; } - protected override void RemoveMemberType (DeclSpace ds) + protected override void RemoveMemberType (TypeContainer ds) { ds.NamespaceEntry.NS.RemoveDeclSpace (ds.Basename); base.RemoveMemberType (ds); } - - public override void Accept (StructuralVisitor visitor) - { - visitor.Visit (this); - } public Attribute ResolveAssemblyAttribute (PredefinedAttribute a_type) { @@ -485,11 +516,11 @@ namespace Mono.CSharp } } - class RootDeclSpace : TypeContainer { - public RootDeclSpace (NamespaceEntry ns) + sealed class RootDeclSpace : TypeContainer { + public RootDeclSpace (ModuleContainer module, NamespaceEntry ns) : base (ns, null, MemberName.Null, null, 0) { - PartialContainer = RootContext.ToplevelTypes; + PartialContainer = module; } public override AttributeTargets AttributeTargets { @@ -517,11 +548,21 @@ namespace Mono.CSharp } } + public override void Accept (StructuralVisitor visitor) + { + throw new InternalErrorException ("should not be called"); + } + public override bool IsClsComplianceRequired () { return PartialContainer.IsClsComplianceRequired (); } + public override IList LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope) + { + return null; + } + public override FullNamedExpression LookupNamespaceAlias (string name) { return NamespaceEntry.LookupNamespaceAlias (name); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs index 8e5fa7010..c840d0b7e 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs @@ -87,14 +87,7 @@ namespace Mono.CSharp { ec.Report.Error (834, loc, "A lambda expression with statement body cannot be converted to an expresion tree"); return null; } - - public Statement PerformClone () - { - CloneContext clonectx = new CloneContext (); - - return Clone (clonectx); - } - + public virtual object Accept (StructuralVisitor visitor) { return visitor.Visit (this); @@ -169,8 +162,6 @@ namespace Mono.CSharp { { bool ok = true; - Report.Debug (1, "START IF BLOCK", loc); - expr = expr.Resolve (ec); if (expr == null) { ok = false; @@ -216,8 +207,6 @@ namespace Mono.CSharp { ec.EndFlowBranching (); - Report.Debug (1, "END IF BLOCK", loc); - return ok; } @@ -779,7 +768,7 @@ namespace Mono.CSharp { protected override bool DoResolve (BlockContext ec) { if (Expr == null) { - if (ec.ReturnType == TypeManager.void_type) + if (ec.ReturnType.Kind == MemberKind.Void) return true; if (ec.CurrentIterator != null) { @@ -797,7 +786,7 @@ namespace Mono.CSharp { AnonymousExpression am = ec.CurrentAnonymousMethod; if (am == null) { - if (ec.ReturnType == TypeManager.void_type) { + if (ec.ReturnType.Kind == MemberKind.Void) { ec.Report.Error (127, loc, "`{0}': A return keyword must not be followed by any expression when method returns void", ec.GetSignatureForError ()); @@ -1037,7 +1026,7 @@ namespace Mono.CSharp { protected override void DoEmit (EmitContext ec) { - ec.Emit (OpCodes.Br, ec.Switch.DefaultTarget); + ec.Emit (OpCodes.Br, ec.Switch.DefaultLabel); } public override object Accept (StructuralVisitor visitor) @@ -1082,34 +1071,31 @@ namespace Mono.CSharp { return false; } - TypeSpec type = ec.Switch.SwitchType; - Constant res = c.TryReduce (ec, type, c.Location); - if (res == null) { - c.Error_ValueCannotBeConverted (ec, loc, type, true); - return false; - } + Constant res; + if (ec.Switch.IsNullable && c is NullLiteral) { + res = c; + } else { + TypeSpec type = ec.Switch.SwitchType; + res = c.TryReduce (ec, type, c.Location); + if (res == null) { + c.Error_ValueCannotBeConverted (ec, loc, type, true); + return false; + } - if (!Convert.ImplicitStandardConversionExists (c, type)) - ec.Report.Warning (469, 2, loc, - "The `goto case' value is not implicitly convertible to type `{0}'", - TypeManager.CSharpName (type)); + if (!Convert.ImplicitStandardConversionExists (c, type)) + ec.Report.Warning (469, 2, loc, + "The `goto case' value is not implicitly convertible to type `{0}'", + TypeManager.CSharpName (type)); - object val = res.GetValue (); - if (val == null) - val = SwitchLabel.NullStringCase; - - if (!ec.Switch.Elements.TryGetValue (val, out sl)) { - FlowBranchingBlock.Error_UnknownLabel (loc, "case " + - (c.GetValue () == null ? "null" : val.ToString ()), ec.Report); - return false; } + sl = ec.Switch.ResolveGotoCase (ec, res); return true; } protected override void DoEmit (EmitContext ec) { - ec.Emit (OpCodes.Br, sl.GetILLabelCode (ec)); + ec.Emit (OpCodes.Br, sl.GetILLabel (ec)); } protected override void CloneTo (CloneContext clonectx, Statement t) @@ -1151,8 +1137,9 @@ namespace Mono.CSharp { if (expr == null) return false; - if (Convert.ImplicitConversionExists (ec, expr, TypeManager.exception_type)) - expr = Convert.ImplicitConversion (ec, expr, TypeManager.exception_type, loc); + var et = ec.BuiltinTypes.Exception; + if (Convert.ImplicitConversionExists (ec, expr, et)) + expr = Convert.ImplicitConversion (ec, expr, et, loc); else ec.Report.Error (155, expr.Location, "The type caught or thrown must be derived from System.Exception"); @@ -1370,7 +1357,6 @@ namespace Mono.CSharp { container.AddField (f); f.Define (); - Evaluator.QueueField (f); li.HoistedVariant = new HoistedEvaluatorVariable (f); li.SetIsUsed (); @@ -1387,8 +1373,8 @@ namespace Mono.CSharp { // var texpr = type_expr.ResolveAsTypeTerminal (bc, true); if (texpr == null) { - if (RootContext.Version < LanguageVersion.V_3) - bc.Report.FeatureIsNotAvailable (loc, "implicitly typed local variable"); + if (bc.Module.Compiler.Settings.Version < LanguageVersion.V_3) + bc.Report.FeatureIsNotAvailable (bc.Module.Compiler, loc, "implicitly typed local variable"); if (li.IsFixed) { bc.Report.Error (821, loc, "A fixed statement cannot use an implicitly typed local variable"); @@ -1433,13 +1419,10 @@ namespace Mono.CSharp { if (type.IsStatic) FieldBase.Error_VariableOfStaticClass (loc, li.Name, type, bc.Report); - if (type.IsPointer && !bc.IsUnsafe) - Expression.UnsafeError (bc, loc); - li.Type = type; } - bool eval_global = RootContext.StatementMode && bc.CurrentBlock is ToplevelBlock; + bool eval_global = bc.Module.Compiler.Settings.StatementMode && bc.CurrentBlock is ToplevelBlock; if (eval_global) { CreateEvaluatorVariable (bc, li); } else { @@ -1537,7 +1520,7 @@ namespace Mono.CSharp { return null; } - c = c.ConvertImplicitly (bc, li.Type); + c = c.ConvertImplicitly (li.Type); if (c == null) { if (TypeManager.IsReferenceType (li.Type)) initializer.Error_ConstantCanBeInitializedWithNullOnly (bc, li.Type, initializer.Location, li.Name); @@ -1751,7 +1734,7 @@ namespace Mono.CSharp { public Expression CreateReferenceExpression (ResolveContext rc, Location loc) { if (IsConstant && const_value != null) - return Constant.CreateConstantFromValue (Type, const_value.GetValue (), loc).Resolve (rc); + return Constant.CreateConstantFromValue (Type, const_value.GetValue (), loc); return new LocalVariableReference (this, loc); } @@ -2069,8 +2052,6 @@ namespace Mono.CSharp { ec.CurrentBlock = this; ec.StartFlowBranching (this); - Report.Debug (4, "RESOLVE BLOCK", StartLocation, ec.CurrentBranching); - // // Compiler generated scope statements // @@ -2134,9 +2115,6 @@ namespace Mono.CSharp { throw new InternalErrorException ("should not happen"); } - Report.Debug (4, "RESOLVE BLOCK DONE", StartLocation, - ec.CurrentBranching, statement_count); - while (ec.CurrentBranching is FlowBranchingLabeled) ec.EndFlowBranching (); @@ -2220,6 +2198,8 @@ namespace Mono.CSharp { #endif clonectx.AddBlockMap (this, target); + if (original != this) + clonectx.AddBlockMap (original, target); target.ParametersBlock = (ParametersBlock) (ParametersBlock == this ? target : clonectx.RemapBlockCopy (ParametersBlock)); target.Explicit = (ExplicitBlock) (Explicit == this ? target : clonectx.LookupBlock (Explicit)); @@ -2351,9 +2331,6 @@ namespace Mono.CSharp { } am_storey.CreateType (); - if (am_storey.Mutator == null && ec.CurrentTypeParameters != null) - am_storey.Mutator = new TypeParameterMutator (ec.CurrentTypeParameters, am_storey.CurrentTypeParameters); - am_storey.DefineType (); am_storey.ResolveTypeParameters (); @@ -2625,6 +2602,12 @@ namespace Mono.CSharp { return new ParameterReference (parameter_info[index], loc); } + public Statement PerformClone () + { + CloneContext clonectx = new CloneContext (); + return Clone (clonectx); + } + protected void ProcessParameters () { if (parameters.Count == 0) @@ -2673,11 +2656,11 @@ namespace Mono.CSharp { rc.Report.Error (587, "Internal compiler error: {0}", e.Message); } - if (Report.DebugFlags > 0) + if (rc.Module.Compiler.Settings.DebugFlags > 0) throw; } - if (rc.ReturnType != TypeManager.void_type && !unreachable) { + if (rc.ReturnType.Kind != MemberKind.Void && !unreachable) { if (rc.CurrentAnonymousMethod == null) { // FIXME: Missing FlowAnalysis for generated iterator MoveNext method if (md is IteratorMethod) { @@ -3070,7 +3053,7 @@ namespace Mono.CSharp { // if (ec.HasReturnLabel || !unreachable) { - if (ec.ReturnType != TypeManager.void_type) + if (ec.ReturnType.Kind != MemberKind.Void) ec.Emit (OpCodes.Ldloc, ec.TemporaryReturn ()); ec.Emit (OpCodes.Ret); } @@ -3099,15 +3082,10 @@ namespace Mono.CSharp { public class SwitchLabel { Expression label; - object converted; - Location loc; - - Label il_label; - bool il_label_set; - Label il_label_code; - bool il_label_code_set; + Constant converted; + readonly Location loc; - public static readonly object NullStringCase = new object (); + Label? il_label; // // if expr == null, then it is the default case. @@ -3118,6 +3096,12 @@ namespace Mono.CSharp { loc = l; } + public bool IsDefault { + get { + return label == null; + } + } + public Expression Label { get { return label; @@ -3125,33 +3109,29 @@ namespace Mono.CSharp { } public Location Location { - get { return loc; } + get { + return loc; + } } - public object Converted { + public Constant Converted { get { return converted; } + set { + converted = value; + } } public Label GetILLabel (EmitContext ec) { - if (!il_label_set){ + if (il_label == null){ il_label = ec.DefineLabel (); - il_label_set = true; } - return il_label; + + return il_label.Value; } - public Label GetILLabelCode (EmitContext ec) - { - if (!il_label_code_set){ - il_label_code = ec.DefineLabel (); - il_label_code_set = true; - } - return il_label_code; - } - // // Resolves the expression, reduces it to a literal if possible // and then converts it to the requested type. @@ -3169,22 +3149,13 @@ namespace Mono.CSharp { return false; } - if (required_type == TypeManager.string_type && c.GetValue () == null) { - converted = NullStringCase; + if (allow_nullable && c is NullLiteral) { + converted = c; return true; } - if (allow_nullable && c.GetValue () == null) { - converted = NullStringCase; - return true; - } - - c = c.ImplicitConversionRequired (ec, required_type, loc); - if (c == null) - return false; - - converted = c.GetValue (); - return true; + converted = c.ImplicitConversionRequired (ec, required_type, loc); + return converted != null; } public void Error_AlreadyOccurs (ResolveContext ec, TypeSpec switch_type, SwitchLabel collision_with) @@ -3192,10 +3163,8 @@ namespace Mono.CSharp { string label; if (converted == null) label = "default"; - else if (converted == NullStringCase) - label = "null"; else - label = converted.ToString (); + label = converted.GetValueAsLiteral (); ec.Report.SymbolRelatedToPreviousError (collision_with.loc, null); ec.Report.Error (152, loc, "The label `case {0}:' already occurs in this switch statement", label); @@ -3231,14 +3200,66 @@ namespace Mono.CSharp { } } - public class Switch : Statement { + public class Switch : Statement + { + // structure used to hold blocks of keys while calculating table switch + sealed class LabelsRange : IComparable + { + public readonly long min; + public long max; + public readonly List label_values; + + public LabelsRange (long value) + { + min = max = value; + label_values = new List (); + label_values.Add (value); + } + + public LabelsRange (long min, long max, ICollection values) + { + this.min = min; + this.max = max; + this.label_values = new List (values); + } + + public long Range { + get { + return max - min + 1; + } + } + + public bool AddValue (long value) + { + var gap = value - min + 1; + // Ensure the range has > 50% occupancy + if (gap > 2 * (label_values.Count + 1) || gap <= 0) + return false; + + max = value; + label_values.Add (value); + return true; + } + + public int CompareTo (LabelsRange other) + { + int nLength = label_values.Count; + int nLengthOther = other.label_values.Count; + if (nLengthOther == nLength) + return (int) (other.min - min); + + return nLength - nLengthOther; + } + } + public List Sections; public Expression Expr; - /// - /// Maps constants whose type type SwitchType to their SwitchLabels. - /// - public IDictionary Elements; + // + // Mapping of all labels to their SwitchLabels + // + Dictionary labels; + Dictionary string_labels; /// /// The governing switch type @@ -3252,9 +3273,10 @@ namespace Mono.CSharp { Label null_target; Expression new_expr; bool is_constant; - bool has_null_case; + SwitchSection constant_section; SwitchSection default_section; + SwitchLabel null_section; ExpressionStatement string_dictionary; FieldExpr switch_cache_field; @@ -3266,16 +3288,6 @@ namespace Mono.CSharp { // Nullable.Unwrap unwrap; - protected bool HaveUnwrap { - get { return unwrap != null; } - } - - // - // The types allowed to be implicitly cast from - // on the governing type - // - static TypeSpec [] allowed_types; - public Switch (Expression e, ExplicitBlock block, List sects, Location l) { Expr = e; @@ -3290,57 +3302,49 @@ namespace Mono.CSharp { } } + public Label DefaultLabel { + get { + return default_target; + } + } + public bool GotDefault { get { return default_section != null; } } - public Label DefaultTarget { + public bool IsNullable { get { - return default_target; + return unwrap != null; } } // // Determines the governing type for a switch. The returned // expression might be the expression from the switch, or an - // expression that includes any potential conversions to the - // integral types or to string. + // expression that includes any potential conversions to // Expression SwitchGoverningType (ResolveContext ec, Expression expr) { - TypeSpec t = expr.Type; - - if (t == TypeManager.byte_type || - t == TypeManager.sbyte_type || - t == TypeManager.ushort_type || - t == TypeManager.short_type || - t == TypeManager.uint32_type || - t == TypeManager.int32_type || - t == TypeManager.uint64_type || - t == TypeManager.int64_type || - t == TypeManager.char_type || - t == TypeManager.string_type || - t == TypeManager.bool_type || - TypeManager.IsEnumType (t)) + switch (expr.Type.BuiltinType) { + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.String: + case BuiltinTypeSpec.Type.Bool: return expr; - - if (allowed_types == null){ - allowed_types = new TypeSpec [] { - TypeManager.sbyte_type, - TypeManager.byte_type, - TypeManager.short_type, - TypeManager.ushort_type, - TypeManager.int32_type, - TypeManager.uint32_type, - TypeManager.int64_type, - TypeManager.uint64_type, - TypeManager.char_type, - TypeManager.string_type - }; } + if (expr.Type.IsEnum) + return expr; + // // Try to find a *user* defined implicit conversion. // @@ -3348,7 +3352,7 @@ namespace Mono.CSharp { // conversions, we have to report an error // Expression converted = null; - foreach (TypeSpec tt in allowed_types){ + foreach (TypeSpec tt in ec.BuiltinTypes.SwitchUserTypes) { Expression e; e = Convert.ImplicitUserConversion (ec, expr, tt, loc); @@ -3372,6 +3376,23 @@ namespace Mono.CSharp { return converted; } + public static TypeSpec[] CreateSwitchUserTypes (BuiltinTypes types) + { + // LAMESPEC: For some reason it does not contain bool which looks like csc bug + return new[] { + types.SByte, + types.Byte, + types.Short, + types.UShort, + types.Int, + types.UInt, + types.Long, + types.ULong, + types.Char, + types.String + }; + } + // // Performs the basic sanity checks on the switch statement // (looks for duplicate keys and non-constant expressions). @@ -3382,325 +3403,230 @@ namespace Mono.CSharp { bool CheckSwitch (ResolveContext ec) { bool error = false; - Elements = new Dictionary (); + if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.String) + string_labels = new Dictionary (Sections.Count + 1); + else + labels = new Dictionary (Sections.Count + 1); foreach (SwitchSection ss in Sections){ foreach (SwitchLabel sl in ss.Labels){ - if (sl.Label == null){ + if (sl.IsDefault){ if (default_section != null){ - sl.Error_AlreadyOccurs (ec, SwitchType, (SwitchLabel)default_section.Labels [0]); + sl.Error_AlreadyOccurs (ec, SwitchType, default_section.Labels [0]); error = true; } default_section = ss; continue; } - if (!sl.ResolveAndReduce (ec, SwitchType, HaveUnwrap)) { + if (!sl.ResolveAndReduce (ec, SwitchType, IsNullable)) { error = true; continue; } - object key = sl.Converted; - if (key == SwitchLabel.NullStringCase) - has_null_case = true; - try { - Elements.Add (key, sl); + if (string_labels != null) { + string s = sl.Converted.GetValue () as string; + if (s == null) + null_section = sl; + else + string_labels.Add (s, sl); + } else { + if (sl.Converted is NullLiteral) { + null_section = sl; + } else { + labels.Add (sl.Converted.GetValueAsLong (), sl); + } + } } catch (ArgumentException) { - sl.Error_AlreadyOccurs (ec, SwitchType, Elements [key]); + if (string_labels != null) + sl.Error_AlreadyOccurs (ec, SwitchType, string_labels[(string) sl.Converted.GetValue ()]); + else + sl.Error_AlreadyOccurs (ec, SwitchType, labels[sl.Converted.GetValueAsLong ()]); + error = true; } } } return !error; } - - void EmitObjectInteger (EmitContext ec, object k) - { - if (k is int) - ec.EmitInt ((int) k); - else if (k is Constant) { - EmitObjectInteger (ec, ((Constant) k).GetValue ()); - } - else if (k is uint) - ec.EmitInt (unchecked ((int) (uint) k)); - else if (k is long) - { - if ((long) k >= int.MinValue && (long) k <= int.MaxValue) - { - ec.EmitInt ((int) (long) k); - ec.Emit (OpCodes.Conv_I8); - } - else - ec.EmitLong ((long) k); - } - else if (k is ulong) - { - ulong ul = (ulong) k; - if (ul < (1L<<32)) - { - ec.EmitInt (unchecked ((int) ul)); - ec.Emit (OpCodes.Conv_U8); - } - else - { - ec.EmitLong (unchecked ((long) ul)); - } - } - else if (k is char) - ec.EmitInt ((int) ((char) k)); - else if (k is sbyte) - ec.EmitInt ((int) ((sbyte) k)); - else if (k is byte) - ec.EmitInt ((int) ((byte) k)); - else if (k is short) - ec.EmitInt ((int) ((short) k)); - else if (k is ushort) - ec.EmitInt ((int) ((ushort) k)); - else if (k is bool) - ec.EmitInt (((bool) k) ? 1 : 0); - else - throw new Exception ("Unhandled case"); - } - // structure used to hold blocks of keys while calculating table switch - class KeyBlock : IComparable + // + // This method emits code for a lookup-based switch statement (non-string) + // Basically it groups the cases into blocks that are at least half full, + // and then spits out individual lookup opcodes for each block. + // It emits the longest blocks first, and short blocks are just + // handled with direct compares. + // + void EmitTableSwitch (EmitContext ec, Expression val) { - public KeyBlock (long _first) - { - first = last = _first; - } - public long first; - public long last; - public List element_keys; - // how many items are in the bucket - public int Size = 1; - public int Length - { - get { return (int) (last - first + 1); } - } - public static long TotalLength (KeyBlock kb_first, KeyBlock kb_last) - { - return kb_last.last - kb_first.first + 1; - } - public int CompareTo (object obj) - { - KeyBlock kb = (KeyBlock) obj; - int nLength = Length; - int nLengthOther = kb.Length; - if (nLengthOther == nLength) - return (int) (kb.first - first); - return nLength - nLengthOther; - } - } + Label lbl_default = default_target; - /// - /// This method emits code for a lookup-based switch statement (non-string) - /// Basically it groups the cases into blocks that are at least half full, - /// and then spits out individual lookup opcodes for each block. - /// It emits the longest blocks first, and short blocks are just - /// handled with direct compares. - /// - /// - /// - /// - void TableSwitchEmit (EmitContext ec, Expression val) - { - int element_count = Elements.Count; - object [] element_keys = new object [element_count]; - Elements.Keys.CopyTo (element_keys, 0); - Array.Sort (element_keys); - - // initialize the block list with one element per key - var key_blocks = new List (element_count); - foreach (object key in element_keys) - key_blocks.Add (new KeyBlock (System.Convert.ToInt64 (key))); - - KeyBlock current_kb; - // iteratively merge the blocks while they are at least half full - // there's probably a really cool way to do this with a tree... - while (key_blocks.Count > 1) - { - var key_blocks_new = new List (); - current_kb = (KeyBlock) key_blocks [0]; - for (int ikb = 1; ikb < key_blocks.Count; ikb++) - { - KeyBlock kb = (KeyBlock) key_blocks [ikb]; - if ((current_kb.Size + kb.Size) * 2 >= KeyBlock.TotalLength (current_kb, kb)) - { - // merge blocks - current_kb.last = kb.last; - current_kb.Size += kb.Size; - } - else - { - // start a new block - key_blocks_new.Add (current_kb); - current_kb = kb; - } - } - key_blocks_new.Add (current_kb); - if (key_blocks.Count == key_blocks_new.Count) - break; - key_blocks = key_blocks_new; - } + if (labels.Count > 0) { + List ranges; + if (string_labels != null) { + // We have done all hard work for string already + // setup single range only + ranges = new List (1); + ranges.Add (new LabelsRange (0, labels.Count - 1, labels.Keys)); + } else { + var element_keys = new long[labels.Count]; + labels.Keys.CopyTo (element_keys, 0); + Array.Sort (element_keys); - // initialize the key lists - foreach (KeyBlock kb in key_blocks) - kb.element_keys = new List (); + // + // Build possible ranges of switch labes to reduce number + // of comparisons + // + ranges = new List (element_keys.Length); + var range = new LabelsRange (element_keys[0]); + ranges.Add (range); + for (int i = 1; i < element_keys.Length; ++i) { + var l = element_keys[i]; + if (range.AddValue (l)) + continue; + + range = new LabelsRange (l); + ranges.Add (range); + } - // fill the key lists - int iBlockCurr = 0; - if (key_blocks.Count > 0) { - current_kb = (KeyBlock) key_blocks [0]; - foreach (object key in element_keys) - { - bool next_block = (key is UInt64) ? (ulong) key > (ulong) current_kb.last : - System.Convert.ToInt64 (key) > current_kb.last; - if (next_block) - current_kb = (KeyBlock) key_blocks [++iBlockCurr]; - current_kb.element_keys.Add (key); + // sort the blocks so we can tackle the largest ones first + ranges.Sort (); } - } - // sort the blocks so we can tackle the largest ones first - key_blocks.Sort (); + TypeSpec compare_type = TypeManager.IsEnumType (SwitchType) ? EnumSpec.GetUnderlyingType (SwitchType) : SwitchType; + + for (int range_index = ranges.Count - 1; range_index >= 0; --range_index) { + LabelsRange kb = ranges[range_index]; + lbl_default = (range_index == 0) ? default_target : ec.DefineLabel (); + + // Optimize small ranges using simple equality check + if (kb.Range <= 2) { + foreach (var key in kb.label_values) { + SwitchLabel sl = labels[key]; + if (sl.Converted.IsDefaultValue) { + val.EmitBranchable (ec, sl.GetILLabel (ec), false); + } else { + val.Emit (ec); + sl.Converted.Emit (ec); + ec.Emit (OpCodes.Beq, sl.GetILLabel (ec)); + } + } + } else { + // TODO: if all the keys in the block are the same and there are + // no gaps/defaults then just use a range-check. + if (compare_type.BuiltinType == BuiltinTypeSpec.Type.Long || compare_type.BuiltinType == BuiltinTypeSpec.Type.ULong) { + // TODO: optimize constant/I4 cases - // okay now we can start... - Label lbl_end = ec.DefineLabel (); // at the end ;-) - Label lbl_default = default_target; + // check block range (could be > 2^31) + val.Emit (ec); + ec.EmitLong (kb.min); + ec.Emit (OpCodes.Blt, lbl_default); - Type type_keys = null; - if (element_keys.Length > 0) - type_keys = element_keys [0].GetType (); // used for conversions + val.Emit (ec); + ec.EmitLong (kb.max); + ec.Emit (OpCodes.Bgt, lbl_default); - TypeSpec compare_type; - - if (TypeManager.IsEnumType (SwitchType)) - compare_type = EnumSpec.GetUnderlyingType (SwitchType); - else - compare_type = SwitchType; - - for (int iBlock = key_blocks.Count - 1; iBlock >= 0; --iBlock) - { - KeyBlock kb = ((KeyBlock) key_blocks [iBlock]); - lbl_default = (iBlock == 0) ? default_target : ec.DefineLabel (); - if (kb.Length <= 2) - { - foreach (object key in kb.element_keys) { - SwitchLabel sl = (SwitchLabel) Elements [key]; - if (key is int && (int) key == 0) { - val.EmitBranchable (ec, sl.GetILLabel (ec), false); + // normalize range + val.Emit (ec); + if (kb.min != 0) { + ec.EmitLong (kb.min); + ec.Emit (OpCodes.Sub); + } + + ec.Emit (OpCodes.Conv_I4); // assumes < 2^31 labels! } else { + // normalize range val.Emit (ec); - EmitObjectInteger (ec, key); - ec.Emit (OpCodes.Beq, sl.GetILLabel (ec)); - } - } - } - else - { - // TODO: if all the keys in the block are the same and there are - // no gaps/defaults then just use a range-check. - if (compare_type == TypeManager.int64_type || - compare_type == TypeManager.uint64_type) - { - // TODO: optimize constant/I4 cases - - // check block range (could be > 2^31) - val.Emit (ec); - EmitObjectInteger (ec, System.Convert.ChangeType (kb.first, type_keys)); - ec.Emit (OpCodes.Blt, lbl_default); - val.Emit (ec); - EmitObjectInteger (ec, System.Convert.ChangeType (kb.last, type_keys)); - ec.Emit (OpCodes.Bgt, lbl_default); - - // normalize range - val.Emit (ec); - if (kb.first != 0) - { - EmitObjectInteger (ec, System.Convert.ChangeType (kb.first, type_keys)); - ec.Emit (OpCodes.Sub); - } - ec.Emit (OpCodes.Conv_I4); // assumes < 2^31 labels! - } - else - { - // normalize range - val.Emit (ec); - int first = (int) kb.first; - if (first > 0) - { - ec.EmitInt (first); - ec.Emit (OpCodes.Sub); - } - else if (first < 0) - { - ec.EmitInt (-first); - ec.Emit (OpCodes.Add); + int first = (int) kb.min; + if (first > 0) { + ec.EmitInt (first); + ec.Emit (OpCodes.Sub); + } else if (first < 0) { + ec.EmitInt (-first); + ec.Emit (OpCodes.Add); + } } - } - // first, build the list of labels for the switch - int iKey = 0; - int cJumps = kb.Length; - Label [] switch_labels = new Label [cJumps]; - for (int iJump = 0; iJump < cJumps; iJump++) - { - object key = kb.element_keys [iKey]; - if (System.Convert.ToInt64 (key) == kb.first + iJump) - { - SwitchLabel sl = (SwitchLabel) Elements [key]; - switch_labels [iJump] = sl.GetILLabel (ec); - iKey++; + // first, build the list of labels for the switch + int iKey = 0; + long cJumps = kb.Range; + Label[] switch_labels = new Label[cJumps]; + for (int iJump = 0; iJump < cJumps; iJump++) { + var key = kb.label_values[iKey]; + if (key == kb.min + iJump) { + switch_labels[iJump] = labels[key].GetILLabel (ec); + iKey++; + } else { + switch_labels[iJump] = lbl_default; + } } - else - switch_labels [iJump] = lbl_default; + + // emit the switch opcode + ec.Emit (OpCodes.Switch, switch_labels); } - // emit the switch opcode - ec.Emit (OpCodes.Switch, switch_labels); + + // mark the default for this block + if (range_index != 0) + ec.MarkLabel (lbl_default); } - // mark the default for this block - if (iBlock != 0) - ec.MarkLabel (lbl_default); + // the last default just goes to the end + if (ranges.Count > 0) + ec.Emit (OpCodes.Br, lbl_default); } - // TODO: find the default case and emit it here, - // to prevent having to do the following jump. - // make sure to mark other labels in the default section - - // the last default just goes to the end - if (element_keys.Length > 0) - ec.Emit (OpCodes.Br, lbl_default); - // now emit the code for the sections bool found_default = false; foreach (SwitchSection ss in Sections) { foreach (SwitchLabel sl in ss.Labels) { - if (sl.Converted == SwitchLabel.NullStringCase) { - ec.MarkLabel (null_target); - } else if (sl.Label == null) { + if (sl.IsDefault) { ec.MarkLabel (lbl_default); found_default = true; - if (!has_null_case) + if (null_section == null) ec.MarkLabel (null_target); + } else if (sl.Converted.IsNull) { + ec.MarkLabel (null_target); } + ec.MarkLabel (sl.GetILLabel (ec)); - ec.MarkLabel (sl.GetILLabelCode (ec)); } + ss.Block.Emit (ec); } if (!found_default) { ec.MarkLabel (lbl_default); - if (!has_null_case) { + if (null_section == null) { ec.MarkLabel (null_target); } } - - ec.MarkLabel (lbl_end); + } + + SwitchLabel FindLabel (Constant value) + { + SwitchLabel sl = null; + + if (string_labels != null) { + string s = value.GetValue () as string; + if (s == null) { + if (null_section != null) + sl = null_section; + else if (default_section != null) + sl = default_section.Labels[0]; + } else { + string_labels.TryGetValue (s, out sl); + } + } else { + if (value is NullLiteral) { + sl = null_section; + } else { + labels.TryGetValue (value.GetValueAsLong (), out sl); + } + } + + return sl; } SwitchSection FindSection (SwitchLabel label) @@ -3718,7 +3644,6 @@ namespace Mono.CSharp { public static void Reset () { unique_counter = 0; - allowed_types = null; } public override bool Resolve (BlockContext ec) @@ -3729,7 +3654,7 @@ namespace Mono.CSharp { new_expr = SwitchGoverningType (ec, Expr); - if ((new_expr == null) && TypeManager.IsNullableType (Expr.Type)) { + if (new_expr == null && Expr.Type.IsNullableType) { unwrap = Nullable.Unwrap.Create (Expr, false); if (unwrap == null) return false; @@ -3747,30 +3672,25 @@ namespace Mono.CSharp { // Validate switch. SwitchType = new_expr.Type; - if (RootContext.Version == LanguageVersion.ISO_1 && SwitchType == TypeManager.bool_type) { - ec.Report.FeatureIsNotAvailable (loc, "switch expression of boolean type"); + if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.Bool && ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) { + ec.Report.FeatureIsNotAvailable (ec.Module.Compiler, loc, "switch expression of boolean type"); return false; } if (!CheckSwitch (ec)) return false; - if (HaveUnwrap) - Elements.Remove (SwitchLabel.NullStringCase); - Switch old_switch = ec.Switch; ec.Switch = this; ec.Switch.SwitchType = SwitchType; - Report.Debug (1, "START OF SWITCH BLOCK", loc, ec.CurrentBranching); ec.StartFlowBranching (FlowBranching.BranchingType.Switch, loc); var constant = new_expr as Constant; if (constant != null) { is_constant = true; - object key = constant.GetValue (); - SwitchLabel label; - if (Elements.TryGetValue (key, out label)) + SwitchLabel label = FindLabel (constant); + if (label != null) constant_section = FindSection (label); if (constant_section == null) @@ -3807,12 +3727,10 @@ namespace Mono.CSharp { ec.EndFlowBranching (); ec.Switch = old_switch; - Report.Debug (1, "END OF SWITCH BLOCK", loc, ec.CurrentBranching); - if (!ok) return false; - if (SwitchType == TypeManager.string_type && !is_constant) { + if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.String && !is_constant) { // TODO: Optimize single case, and single+default case ResolveStringSwitchMap (ec); } @@ -3820,22 +3738,30 @@ namespace Mono.CSharp { return true; } + public SwitchLabel ResolveGotoCase (ResolveContext rc, Constant value) + { + var sl = FindLabel (value); + + if (sl == null) { + FlowBranchingBlock.Error_UnknownLabel (loc, "case " + value.GetValueAsLiteral (), rc.Report); + } + + return sl; + } + void ResolveStringSwitchMap (ResolveContext ec) { FullNamedExpression string_dictionary_type; - if (TypeManager.generic_ienumerable_type != null) { - MemberAccess system_collections_generic = new MemberAccess (new MemberAccess ( - new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc), "Generic", loc); - - string_dictionary_type = new MemberAccess (system_collections_generic, "Dictionary", - new TypeArguments ( - new TypeExpression (TypeManager.string_type, loc), - new TypeExpression (TypeManager.int32_type, loc)), loc); + if (ec.Module.PredefinedTypes.Dictionary.Define ()) { + string_dictionary_type = new TypeExpression ( + ec.Module.PredefinedTypes.Dictionary.TypeSpec.MakeGenericType (ec, + new [] { ec.BuiltinTypes.String, ec.BuiltinTypes.Int }), + loc); + } else if (ec.Module.PredefinedTypes.Hashtable.Define ()) { + string_dictionary_type = new TypeExpression (ec.Module.PredefinedTypes.Hashtable.TypeSpec, loc); } else { - MemberAccess system_collections_generic = new MemberAccess ( - new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc); - - string_dictionary_type = new MemberAccess (system_collections_generic, "Hashtable", loc); + ec.Module.PredefinedTypes.Dictionary.Resolve (loc); + return; } var ctype = ec.CurrentMemberDefinition.Parent.PartialContainer; @@ -3848,33 +3774,38 @@ namespace Mono.CSharp { var init = new List (); int counter = 0; - Elements.Clear (); + labels = new Dictionary (string_labels.Count); string value = null; foreach (SwitchSection section in Sections) { - int last_count = init.Count; + bool contains_label = false; foreach (SwitchLabel sl in section.Labels) { - if (sl.Label == null || sl.Converted == SwitchLabel.NullStringCase) + if (sl.IsDefault || sl.Converted.IsNull) continue; - value = (string) sl.Converted; + if (!contains_label) { + labels.Add (counter, sl); + contains_label = true; + } + + value = (string) sl.Converted.GetValue (); var init_args = new List (2); - init_args.Add (new StringLiteral (value, sl.Location)); - init_args.Add (new IntConstant (counter, loc)); + init_args.Add (new StringLiteral (ec.BuiltinTypes, value, sl.Location)); + + sl.Converted = new IntConstant (ec.BuiltinTypes, counter, loc); + init_args.Add (sl.Converted); + init.Add (new CollectionElementInitializer (init_args, loc)); } // // Don't add empty sections // - if (last_count == init.Count) - continue; - - Elements.Add (counter, section.Labels [0]); - ++counter; + if (contains_label) + ++counter; } Arguments args = new Arguments (1); - args.Add (new Argument (new IntConstant (init.Count, loc))); + args.Add (new Argument (new IntConstant (ec.BuiltinTypes, init.Count, loc))); Expression initializer = new NewInitialize (string_dictionary_type, args, new CollectionOrObjectInitializers (init, loc), loc); @@ -3898,11 +3829,11 @@ namespace Mono.CSharp { string_dictionary.EmitStatement (ec); ec.MarkLabel (l_initialized); - LocalTemporary string_switch_variable = new LocalTemporary (TypeManager.int32_type); + LocalTemporary string_switch_variable = new LocalTemporary (ec.BuiltinTypes.Int); ResolveContext rc = new ResolveContext (ec.MemberContext); - if (TypeManager.generic_ienumerable_type != null) { + if (switch_cache_field.Type.IsGeneric) { Arguments get_value_args = new Arguments (2); get_value_args.Add (new Argument (value)); get_value_args.Add (new Argument (string_switch_variable, Argument.AType.Out)); @@ -3922,18 +3853,18 @@ namespace Mono.CSharp { if (get_item == null) return; - LocalTemporary get_item_object = new LocalTemporary (TypeManager.object_type); + LocalTemporary get_item_object = new LocalTemporary (ec.BuiltinTypes.Object); get_item_object.EmitAssign (ec, get_item, true, false); ec.Emit (OpCodes.Brfalse, default_target); ExpressionStatement get_item_int = (ExpressionStatement) new SimpleAssign (string_switch_variable, - new Cast (new TypeExpression (TypeManager.int32_type, loc), get_item_object, loc)).Resolve (rc); + new Cast (new TypeExpression (ec.BuiltinTypes.Int, loc), get_item_object, loc)).Resolve (rc); get_item_int.EmitStatement (ec); get_item_object.Release (ec); } - TableSwitchEmit (ec, string_switch_variable); + EmitTableSwitch (ec, string_switch_variable); string_switch_variable.Release (ec); } @@ -3951,7 +3882,7 @@ namespace Mono.CSharp { // Store variable for comparission purposes // TODO: Don't duplicate non-captured VariableReference LocalTemporary value; - if (HaveUnwrap) { + if (IsNullable) { value = new LocalTemporary (SwitchType); unwrap.EmitCheck (ec); ec.Emit (OpCodes.Brfalse, null_target); @@ -3980,7 +3911,7 @@ namespace Mono.CSharp { } else if (string_dictionary != null) { DoEmitStringSwitch (value, ec); } else { - TableSwitchEmit (ec, value); + EmitTableSwitch (ec, value); } if (value != null) @@ -4238,7 +4169,7 @@ namespace Mono.CSharp { } if (expr.Type.IsGenericParameter) { - expr = Convert.ImplicitTypeParameterConversion (expr, TypeManager.object_type); + expr = Convert.ImplicitTypeParameterConversion (expr, (TypeParameterSpec)expr.Type, ec.BuiltinTypes.Object); } VariableReference lv = expr as VariableReference; @@ -4265,14 +4196,14 @@ namespace Mono.CSharp { // Have to keep original lock value around to unlock same location // in the case the original has changed or is null // - expr_copy = TemporaryVariableReference.Create (TypeManager.object_type, ec.CurrentBlock.Parent, loc); + expr_copy = TemporaryVariableReference.Create (ec.BuiltinTypes.Object, ec.CurrentBlock.Parent, loc); expr_copy.Resolve (ec); // // Ensure Monitor methods are available // if (ResolvePredefinedMethods (ec) > 1) { - lock_taken = TemporaryVariableReference.Create (TypeManager.bool_type, ec.CurrentBlock.Parent, loc); + lock_taken = TemporaryVariableReference.Create (ec.BuiltinTypes.Bool, ec.CurrentBlock.Parent, loc); lock_taken.Resolve (ec); } @@ -4287,13 +4218,13 @@ namespace Mono.CSharp { // // Initialize ref variable // - lock_taken.EmitAssign (ec, new BoolLiteral (false, loc)); + lock_taken.EmitAssign (ec, new BoolLiteral (ec.BuiltinTypes, false, loc)); } else { // // Monitor.Enter (expr_copy) // expr_copy.Emit (ec); - ec.Emit (OpCodes.Call, TypeManager.void_monitor_enter_object); + ec.Emit (OpCodes.Call, ec.Module.PredefinedMembers.MonitorEnter.Get ()); } } @@ -4306,7 +4237,7 @@ namespace Mono.CSharp { expr_copy.Emit (ec); lock_taken.LocalInfo.CreateBuilder (ec); lock_taken.AddressOf (ec, AddressOp.Load); - ec.Emit (OpCodes.Call, TypeManager.void_monitor_enter_object); + ec.Emit (OpCodes.Call, ec.Module.PredefinedMembers.MonitorEnter_v4.Get ()); } Statement.Emit (ec); @@ -4325,40 +4256,26 @@ namespace Mono.CSharp { } expr_copy.Emit (ec); - ec.Emit (OpCodes.Call, TypeManager.void_monitor_exit_object); + var m = ec.Module.PredefinedMembers.MonitorExit.Resolve (loc); + if (m != null) + ec.Emit (OpCodes.Call, m); + ec.MarkLabel (skip); } int ResolvePredefinedMethods (ResolveContext rc) { - if (TypeManager.void_monitor_enter_object == null || TypeManager.void_monitor_exit_object == null) { - TypeSpec monitor_type = rc.Module.PredefinedTypes.Monitor.Resolve (loc); - - if (monitor_type == null) - return 0; - - // Try 4.0 Monitor.Enter (object, ref bool) overload first - var filter = MemberFilter.Method ("Enter", 0, new ParametersImported ( - new[] { - new ParameterData (null, Parameter.Modifier.NONE), - new ParameterData (null, Parameter.Modifier.REF) - }, - new[] { - TypeManager.object_type, - TypeManager.bool_type - }, false), null); - - TypeManager.void_monitor_enter_object = TypeManager.GetPredefinedMethod (monitor_type, filter, true, loc); - if (TypeManager.void_monitor_enter_object == null) { - TypeManager.void_monitor_enter_object = TypeManager.GetPredefinedMethod ( - monitor_type, "Enter", loc, TypeManager.object_type); - } + // Try 4.0 Monitor.Enter (object, ref bool) overload first + var m = rc.Module.PredefinedMembers.MonitorEnter_v4.Get (); + if (m != null) + return 4; - TypeManager.void_monitor_exit_object = TypeManager.GetPredefinedMethod ( - monitor_type, "Exit", loc, TypeManager.object_type); - } + m = rc.Module.PredefinedMembers.MonitorEnter.Get (); + if (m != null) + return 1; - return TypeManager.void_monitor_enter_object.Parameters.Count; + rc.Module.PredefinedMembers.MonitorEnter_v4.Resolve (loc); + return 0; } protected override void CloneTo (CloneContext clonectx, Statement t) @@ -4542,19 +4459,10 @@ namespace Mono.CSharp { pinned_string = new LocalVariable (vi.Block, "$pinned", LocalVariable.Flags.FixedVariable | LocalVariable.Flags.CompilerGenerated | LocalVariable.Flags.Used, vi.Location); - - pinned_string.Type = TypeManager.string_type; - - if (TypeManager.int_get_offset_to_string_data == null) { - var helper = rc.Module.PredefinedTypes.RuntimeHelpers.Resolve (loc); - if (helper != null) { - TypeManager.int_get_offset_to_string_data = TypeManager.GetPredefinedProperty (helper, - "OffsetToStringData", pinned_string.Location, TypeManager.int32_type); - } - } + pinned_string.Type = rc.BuiltinTypes.String; eclass = ExprClass.Variable; - type = TypeManager.int32_type; + type = rc.BuiltinTypes.Int; return this; } @@ -4569,7 +4477,11 @@ namespace Mono.CSharp { pinned_string.Emit (ec); ec.Emit (OpCodes.Conv_I); - PropertyExpr pe = new PropertyExpr (TypeManager.int_get_offset_to_string_data, pinned_string.Location); + var m = ec.Module.PredefinedMembers.RuntimeHelpersOffsetToStringData.Resolve (loc); + if (m == null) + return; + + PropertyExpr pe = new PropertyExpr (m, pinned_string.Location); //pe.InstanceExpression = pinned_string; pe.Resolve (new ResolveContext (ec.MemberContext)).Emit (ec); @@ -4630,7 +4542,7 @@ namespace Mono.CSharp { // // Provided that array_type is unmanaged, // - if (!TypeManager.VerifyUnmanaged (bc.Compiler, array_type, loc)) + if (!TypeManager.VerifyUnmanaged (bc.Module, array_type, loc)) return null; // @@ -4639,8 +4551,7 @@ namespace Mono.CSharp { // ArrayPtr array_ptr = new ArrayPtr (initializer, array_type, loc); - Expression converted = Convert.ImplicitConversionRequired ( - bc, array_ptr, li.Type, loc); + Expression converted = Convert.ImplicitConversionRequired (bc, array_ptr.Resolve (bc), li.Type, loc); if (converted == null) return null; @@ -4649,8 +4560,8 @@ namespace Mono.CSharp { // converted = new Conditional (new BooleanExpression (new Binary (Binary.Operator.LogicalOr, new Binary (Binary.Operator.Equality, initializer, new NullLiteral (loc), loc), - new Binary (Binary.Operator.Equality, new MemberAccess (initializer, "Length"), new IntConstant (0, loc), loc), loc)), - new NullPointer (loc), + new Binary (Binary.Operator.Equality, new MemberAccess (initializer, "Length"), new IntConstant (bc.BuiltinTypes, 0, loc), loc), loc)), + new NullLiteral (loc), converted, loc); converted = converted.Resolve (bc); @@ -4661,7 +4572,7 @@ namespace Mono.CSharp { // // Case 2: string // - if (initializer.Type == TypeManager.string_type) { + if (initializer.Type.BuiltinType == BuiltinTypeSpec.Type.String) { return new StringEmitter (initializer, li, loc).Resolve (bc); } @@ -4832,7 +4743,7 @@ namespace Mono.CSharp { protected override void DoEmit (EmitContext ec) { if (IsGeneral) - ec.BeginCatchBlock (TypeManager.object_type); + ec.BeginCatchBlock (ec.BuiltinTypes.Object); else ec.BeginCatchBlock (CatchType); @@ -4871,7 +4782,7 @@ namespace Mono.CSharp { return false; type = te.Type; - if (type != TypeManager.exception_type && !TypeSpec.IsBaseClass (type, TypeManager.exception_type, false)) { + if (type.BuiltinType != BuiltinTypeSpec.Type.Exception && !TypeSpec.IsBaseClass (type, ec.BuiltinTypes.Exception, false)) { ec.Report.Error (155, loc, "The type caught or thrown must be derived from System.Exception"); } else if (li != null) { li.Type = type; @@ -5026,7 +4937,7 @@ namespace Mono.CSharp { if (General != null) { foreach (Catch c in Specific) { - if (c.CatchType != TypeManager.exception_type) + if (c.CatchType.BuiltinType != BuiltinTypeSpec.Type.Exception) continue; if (!ec.Module.DeclaringAssembly.WrapNonExceptionThrows) @@ -5152,7 +5063,7 @@ namespace Mono.CSharp { protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer) { - if (li.Type == InternalType.Dynamic) { + if (li.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { initializer = initializer.Resolve (bc); if (initializer == null) return null; @@ -5160,11 +5071,11 @@ namespace Mono.CSharp { // Once there is dynamic used defer conversion to runtime even if we know it will never succeed Arguments args = new Arguments (1); args.Add (new Argument (initializer)); - initializer = new DynamicConversion (TypeManager.idisposable_type, 0, args, initializer.Location).Resolve (bc); + initializer = new DynamicConversion (bc.BuiltinTypes.IDisposable, 0, args, initializer.Location).Resolve (bc); if (initializer == null) return null; - var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc); + var var = LocalVariable.CreateCompilerGenerated (initializer.Type, bc.CurrentBlock, loc); dispose_call = CreateDisposeCall (bc, var); dispose_call.Resolve (bc); @@ -5184,8 +5095,8 @@ namespace Mono.CSharp { { var type = li.Type; - if (type != TypeManager.idisposable_type && !type.ImplementsInterface (TypeManager.idisposable_type, false)) { - if (TypeManager.IsNullableType (type)) { + if (type.BuiltinType != BuiltinTypeSpec.Type.IDisposable && !type.ImplementsInterface (bc.BuiltinTypes.IDisposable, false)) { + if (type.IsNullableType) { // it's handled in CreateDisposeCall return; } @@ -5205,20 +5116,18 @@ namespace Mono.CSharp { var type = lv.Type; var loc = lv.Location; - if (TypeManager.void_dispose_void == null) { - TypeManager.void_dispose_void = TypeManager.GetPredefinedMethod ( - TypeManager.idisposable_type, "Dispose", loc, TypeSpec.EmptyTypes); - } + var idt = bc.BuiltinTypes.IDisposable; + var m = bc.Module.PredefinedMembers.IDisposableDispose.Resolve (loc); - var dispose_mg = MethodGroupExpr.CreatePredefined (TypeManager.void_dispose_void, TypeManager.idisposable_type, loc); - dispose_mg.InstanceExpression = TypeManager.IsNullableType (type) ? - new Cast (new TypeExpression (TypeManager.idisposable_type, loc), lvr, loc).Resolve (bc) : + var dispose_mg = MethodGroupExpr.CreatePredefined (m, idt, loc); + dispose_mg.InstanceExpression = type.IsNullableType ? + new Cast (new TypeExpression (idt, loc), lvr, loc).Resolve (bc) : lvr; Statement dispose = new StatementExpression (new Invocation (dispose_mg, null)); // Add conditional call when disposing possible null variable - if (!type.IsStruct || TypeManager.IsNullableType (type)) + if (!type.IsStruct || type.IsNullableType) dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, loc); return dispose; @@ -5396,7 +5305,7 @@ namespace Mono.CSharp { int rank = length_exprs.Length; Arguments list = new Arguments (rank); for (int i = 0; i < rank; i++) { - var v = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc); + var v = TemporaryVariableReference.Create (ec.BuiltinTypes.Int, variables_block, loc); variables[i] = v; counter[i] = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, v, loc)); counter[i].Resolve (ec); @@ -5404,11 +5313,11 @@ namespace Mono.CSharp { if (rank == 1) { length_exprs [i] = new MemberAccess (copy, "Length").Resolve (ec); } else { - lengths[i] = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc); + lengths[i] = TemporaryVariableReference.Create (ec.BuiltinTypes.Int, variables_block, loc); lengths[i].Resolve (ec); Arguments args = new Arguments (1); - args.Add (new Argument (new IntConstant (i, loc))); + args.Add (new Argument (new IntConstant (ec.BuiltinTypes, i, loc))); length_exprs [i] = new Invocation (new MemberAccess (copy, "GetLength"), args).Resolve (ec); } @@ -5471,7 +5380,7 @@ namespace Mono.CSharp { lengths [i].EmitAssign (ec, length_exprs [i]); } - IntConstant zero = new IntConstant (0, loc); + IntConstant zero = new IntConstant (ec.BuiltinTypes, 0, loc); for (int i = 0; i < rank; i++) { variables [i].EmitAssign (ec, zero); @@ -5571,10 +5480,7 @@ namespace Mono.CSharp { protected override Statement CreateDisposeCall (BlockContext bc, LocalVariable lv) { - if (TypeManager.void_dispose_void == null) { - TypeManager.void_dispose_void = TypeManager.GetPredefinedMethod ( - TypeManager.idisposable_type, "Dispose", loc, TypeSpec.EmptyTypes); - } + var idt = bc.BuiltinTypes.IDisposable; // // Fabricates code like @@ -5582,14 +5488,16 @@ namespace Mono.CSharp { // if ((temp = vr as IDisposable) != null) temp.Dispose (); // - var dispose_variable = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc); + var dispose_variable = LocalVariable.CreateCompilerGenerated (idt, bc.CurrentBlock, loc); var idisaposable_test = new Binary (Binary.Operator.Inequality, new CompilerAssign ( dispose_variable.CreateReferenceExpression (bc, loc), new As (lv.CreateReferenceExpression (bc, loc), new TypeExpression (dispose_variable.Type, loc), loc), loc), new NullLiteral (loc), loc); - var dispose_mg = MethodGroupExpr.CreatePredefined (TypeManager.void_dispose_void, TypeManager.idisposable_type, loc); + var m = bc.Module.PredefinedMembers.IDisposableDispose.Resolve (loc); + + var dispose_mg = MethodGroupExpr.CreatePredefined (m, idt, loc); dispose_mg.InstanceExpression = dispose_variable.CreateReferenceExpression (bc, loc); Statement dispose = new StatementExpression (new Invocation (dispose_mg, null)); @@ -5632,7 +5540,7 @@ namespace Mono.CSharp { // // Option 1: Try to match by name GetEnumerator first // - var mexpr = Expression.MemberLookup (rc, rc.CurrentType, expr.Type, + var mexpr = Expression.MemberLookup (rc, false, expr.Type, "GetEnumerator", 0, Expression.MemberLookupRestrictions.ExactArity, loc); // TODO: What if CS0229 ? var mg = mexpr as MethodGroupExpr; @@ -5653,28 +5561,36 @@ namespace Mono.CSharp { // // Option 2: Try to match using IEnumerable interfaces with preference of generic version // - TypeSpec iface_candidate = null; var t = expr.Type; + PredefinedMember iface_candidate = null; + var ptypes = rc.Module.PredefinedTypes; + var gen_ienumerable = ptypes.IEnumerableGeneric; + if (!gen_ienumerable.Define ()) + gen_ienumerable = null; + do { var ifaces = t.Interfaces; if (ifaces != null) { foreach (var iface in ifaces) { - if (TypeManager.generic_ienumerable_type != null && iface.MemberDefinition == TypeManager.generic_ienumerable_type.MemberDefinition) { - if (iface_candidate != null && iface_candidate != TypeManager.ienumerable_type) { + if (gen_ienumerable != null && iface.MemberDefinition == gen_ienumerable.TypeSpec.MemberDefinition) { + if (iface_candidate != null && iface_candidate != rc.Module.PredefinedMembers.IEnumerableGetEnumerator) { rc.Report.SymbolRelatedToPreviousError (expr.Type); rc.Report.Error (1640, loc, "foreach statement cannot operate on variables of type `{0}' because it contains multiple implementation of `{1}'. Try casting to a specific implementation", - expr.Type.GetSignatureForError (), TypeManager.generic_ienumerable_type.GetSignatureForError ()); + expr.Type.GetSignatureForError (), gen_ienumerable.TypeSpec.GetSignatureForError ()); return null; } - iface_candidate = iface; + // TODO: Cache this somehow + iface_candidate = new PredefinedMember (rc.Module, iface, + MemberFilter.Method ("GetEnumerator", 0, ParametersCompiled.EmptyReadOnlyParameters, null)); + continue; } - if (iface == TypeManager.ienumerable_type && iface_candidate == null) { - iface_candidate = iface; + if (iface.BuiltinType == BuiltinTypeSpec.Type.IEnumerable && iface_candidate == null) { + iface_candidate = rc.Module.PredefinedMembers.IEnumerableGetEnumerator; } } } @@ -5694,9 +5610,7 @@ namespace Mono.CSharp { return null; } - var method = TypeManager.GetPredefinedMethod (iface_candidate, - MemberFilter.Method ("GetEnumerator", 0, ParametersCompiled.EmptyReadOnlyParameters, null), loc); - + var method = iface_candidate.Resolve (loc); if (method == null) return null; @@ -5708,7 +5622,7 @@ namespace Mono.CSharp { MethodGroupExpr ResolveMoveNext (ResolveContext rc, MethodSpec enumerator) { var ms = MemberCache.FindMember (enumerator.ReturnType, - MemberFilter.Method ("MoveNext", 0, ParametersCompiled.EmptyReadOnlyParameters, TypeManager.bool_type), + MemberFilter.Method ("MoveNext", 0, ParametersCompiled.EmptyReadOnlyParameters, rc.BuiltinTypes.Bool), BindingRestriction.InstanceOnly) as MethodSpec; if (ms == null || !ms.IsPublic) { @@ -5735,11 +5649,11 @@ namespace Mono.CSharp { public override bool Resolve (BlockContext ec) { - bool is_dynamic = expr.Type == InternalType.Dynamic; + bool is_dynamic = expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; if (is_dynamic) { - expr = Convert.ImplicitConversionRequired (ec, expr, TypeManager.ienumerable_type, loc); - } else if (TypeManager.IsNullableType (expr.Type)) { + expr = Convert.ImplicitConversionRequired (ec, expr, ec.BuiltinTypes.IEnumerable, loc); + } else if (expr.Type.IsNullableType) { expr = new Nullable.UnwrapCall (expr).Resolve (ec); } @@ -5774,14 +5688,14 @@ namespace Mono.CSharp { if (ve != null) { if (is_dynamic) { // Source type is dynamic, set element type to dynamic too - var_type = new TypeExpression (InternalType.Dynamic, var_type.Location); + var_type = new TypeExpression (ec.BuiltinTypes.Dynamic, var_type.Location); } else { // Infer implicitly typed local variable from foreach enumerable type var_type = new TypeExpression (current_pe.Type, var_type.Location); } } else if (is_dynamic) { // Explicit cast of dynamic collection elements has to be done at runtime - current_pe = EmptyCast.Create (current_pe, InternalType.Dynamic); + current_pe = EmptyCast.Create (current_pe, ec.BuiltinTypes.Dynamic); } var_type = var_type.ResolveAsTypeTerminal (ec, false); @@ -5800,7 +5714,7 @@ namespace Mono.CSharp { // // Add Dispose method call when enumerator can be IDisposable // - if (!enum_type.ImplementsInterface (TypeManager.idisposable_type, false)) { + if (!enum_type.ImplementsInterface (ec.BuiltinTypes.IDisposable, false)) { if (!enum_type.IsSealed && !TypeManager.IsValueType (enum_type)) { // // Runtime Dispose check @@ -5910,7 +5824,7 @@ namespace Mono.CSharp { return false; } - if (expr.Type == TypeManager.string_type) { + if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.String) { statement = new ArrayForeach (this, 1); } else if (expr.Type is ArrayContainer) { statement = new ArrayForeach (this, ((ArrayContainer) expr.Type).Rank); diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs index 2694fb2d6..ea02af6d0 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs @@ -19,140 +19,120 @@ using System.Text; namespace Mono.CSharp { // - // All compiler build-in types (they have to exist otherwise the compile will not work) + // All compiler built-in types (they have to exist otherwise the compiler will not work) // - public class BuildinTypes - { - public readonly BuildinTypeSpec Object; - public readonly BuildinTypeSpec ValueType; - public readonly BuildinTypeSpec Attribute; - - public readonly BuildinTypeSpec Int; - public readonly BuildinTypeSpec UInt; - public readonly BuildinTypeSpec Long; - public readonly BuildinTypeSpec ULong; - public readonly BuildinTypeSpec Float; - public readonly BuildinTypeSpec Double; - public readonly BuildinTypeSpec Char; - public readonly BuildinTypeSpec Short; - public readonly BuildinTypeSpec Decimal; - public readonly BuildinTypeSpec Bool; - public readonly BuildinTypeSpec SByte; - public readonly BuildinTypeSpec Byte; - public readonly BuildinTypeSpec UShort; - public readonly BuildinTypeSpec String; - - public readonly BuildinTypeSpec Enum; - public readonly BuildinTypeSpec Delegate; - public readonly BuildinTypeSpec MulticastDelegate; - public readonly BuildinTypeSpec Void; - public readonly BuildinTypeSpec Array; - public readonly BuildinTypeSpec Type; - public readonly BuildinTypeSpec IEnumerator; - public readonly BuildinTypeSpec IEnumerable; - public readonly BuildinTypeSpec IDisposable; - public readonly BuildinTypeSpec IntPtr; - public readonly BuildinTypeSpec UIntPtr; - public readonly BuildinTypeSpec RuntimeFieldHandle; - public readonly BuildinTypeSpec RuntimeTypeHandle; - public readonly BuildinTypeSpec Exception; + public class BuiltinTypes + { + public readonly BuiltinTypeSpec Object; + public readonly BuiltinTypeSpec ValueType; + public readonly BuiltinTypeSpec Attribute; + + public readonly BuiltinTypeSpec Int; + public readonly BuiltinTypeSpec UInt; + public readonly BuiltinTypeSpec Long; + public readonly BuiltinTypeSpec ULong; + public readonly BuiltinTypeSpec Float; + public readonly BuiltinTypeSpec Double; + public readonly BuiltinTypeSpec Char; + public readonly BuiltinTypeSpec Short; + public readonly BuiltinTypeSpec Decimal; + public readonly BuiltinTypeSpec Bool; + public readonly BuiltinTypeSpec SByte; + public readonly BuiltinTypeSpec Byte; + public readonly BuiltinTypeSpec UShort; + public readonly BuiltinTypeSpec String; + + public readonly BuiltinTypeSpec Enum; + public readonly BuiltinTypeSpec Delegate; + public readonly BuiltinTypeSpec MulticastDelegate; + public readonly BuiltinTypeSpec Void; + public readonly BuiltinTypeSpec Array; + public readonly BuiltinTypeSpec Type; + public readonly BuiltinTypeSpec IEnumerator; + public readonly BuiltinTypeSpec IEnumerable; + public readonly BuiltinTypeSpec IDisposable; + public readonly BuiltinTypeSpec IntPtr; + public readonly BuiltinTypeSpec UIntPtr; + public readonly BuiltinTypeSpec RuntimeFieldHandle; + public readonly BuiltinTypeSpec RuntimeTypeHandle; + public readonly BuiltinTypeSpec Exception; // // These are internal buil-in types which depend on other // build-in type (mostly object) // - public readonly BuildinTypeSpec Dynamic; - public readonly BuildinTypeSpec Null; + public readonly BuiltinTypeSpec Dynamic; + + // Predefined operators tables + public readonly Binary.PredefinedOperator[] OperatorsBinaryStandard; + public readonly Binary.PredefinedOperator[] OperatorsBinaryEquality; + public readonly Binary.PredefinedOperator[] OperatorsBinaryUnsafe; + public readonly TypeSpec[][] OperatorsUnary; + public readonly TypeSpec[] OperatorsUnaryMutator; - readonly BuildinTypeSpec[] types; + public readonly TypeSpec[] BinaryPromotionsTypes; + public readonly TypeSpec[] SwitchUserTypes; - public BuildinTypes () + readonly BuiltinTypeSpec[] types; + + public BuiltinTypes () { - Object = new BuildinTypeSpec (MemberKind.Class, "System", "Object", BuildinTypeSpec.Type.Object); - ValueType = new BuildinTypeSpec (MemberKind.Class, "System", "ValueType", BuildinTypeSpec.Type.ValueType); - Attribute = new BuildinTypeSpec (MemberKind.Class, "System", "Attribute", BuildinTypeSpec.Type.Attribute); - - Int = new BuildinTypeSpec (MemberKind.Struct, "System", "Int32", BuildinTypeSpec.Type.Int); - Long = new BuildinTypeSpec (MemberKind.Struct, "System", "Int64", BuildinTypeSpec.Type.Long); - UInt = new BuildinTypeSpec (MemberKind.Struct, "System", "UInt32", BuildinTypeSpec.Type.UInt); - ULong = new BuildinTypeSpec (MemberKind.Struct, "System", "UInt64", BuildinTypeSpec.Type.ULong); - Byte = new BuildinTypeSpec (MemberKind.Struct, "System", "Byte", BuildinTypeSpec.Type.Byte); - SByte = new BuildinTypeSpec (MemberKind.Struct, "System", "SByte", BuildinTypeSpec.Type.SByte); - Short = new BuildinTypeSpec (MemberKind.Struct, "System", "Int16", BuildinTypeSpec.Type.Short); - UShort = new BuildinTypeSpec (MemberKind.Struct, "System", "UInt16", BuildinTypeSpec.Type.UShort); - - IEnumerator = new BuildinTypeSpec (MemberKind.Interface, "System.Collections", "IEnumerator", BuildinTypeSpec.Type.IEnumerator); - IEnumerable = new BuildinTypeSpec (MemberKind.Interface, "System.Collections", "IEnumerable", BuildinTypeSpec.Type.IEnumerable); - IDisposable = new BuildinTypeSpec (MemberKind.Interface, "System", "IDisposable", BuildinTypeSpec.Type.IDisposable); - - Char = new BuildinTypeSpec (MemberKind.Struct, "System", "Char", BuildinTypeSpec.Type.Char); - String = new BuildinTypeSpec (MemberKind.Class, "System", "String", BuildinTypeSpec.Type.String); - Float = new BuildinTypeSpec (MemberKind.Struct, "System", "Single", BuildinTypeSpec.Type.Float); - Double = new BuildinTypeSpec (MemberKind.Struct, "System", "Double", BuildinTypeSpec.Type.Double); - Decimal = new BuildinTypeSpec (MemberKind.Struct, "System", "Decimal", BuildinTypeSpec.Type.Decimal); - Bool = new BuildinTypeSpec (MemberKind.Struct, "System", "Boolean", BuildinTypeSpec.Type.Bool); - IntPtr = new BuildinTypeSpec (MemberKind.Struct, "System", "IntPtr", BuildinTypeSpec.Type.IntPtr); - UIntPtr = new BuildinTypeSpec (MemberKind.Struct, "System", "UIntPtr", BuildinTypeSpec.Type.UIntPtr); - - MulticastDelegate = new BuildinTypeSpec (MemberKind.Class, "System", "MulticastDelegate", BuildinTypeSpec.Type.MulticastDelegate); - Delegate = new BuildinTypeSpec (MemberKind.Class, "System", "Delegate", BuildinTypeSpec.Type.Delegate); - Enum = new BuildinTypeSpec (MemberKind.Class, "System", "Enum", BuildinTypeSpec.Type.Enum); - Array = new BuildinTypeSpec (MemberKind.Class, "System", "Array", BuildinTypeSpec.Type.Array); - Void = new BuildinTypeSpec (MemberKind.Struct, "System", "Void", BuildinTypeSpec.Type.Void); - Type = new BuildinTypeSpec (MemberKind.Class, "System", "Type", BuildinTypeSpec.Type.Type); - Exception = new BuildinTypeSpec (MemberKind.Class, "System", "Exception", BuildinTypeSpec.Type.Exception); - RuntimeFieldHandle = new BuildinTypeSpec (MemberKind.Struct, "System", "RuntimeFieldHandle", BuildinTypeSpec.Type.RuntimeFieldHandle); - RuntimeTypeHandle = new BuildinTypeSpec (MemberKind.Struct, "System", "RuntimeTypeHandle", BuildinTypeSpec.Type.RuntimeTypeHandle); - - Dynamic = new BuildinTypeSpec ("dynamic", BuildinTypeSpec.Type.Dynamic); - Null = new BuildinTypeSpec ("null", BuildinTypeSpec.Type.Null); - Null.MemberCache = MemberCache.Empty; - - types = new BuildinTypeSpec[] { + Object = new BuiltinTypeSpec (MemberKind.Class, "System", "Object", BuiltinTypeSpec.Type.Object); + ValueType = new BuiltinTypeSpec (MemberKind.Class, "System", "ValueType", BuiltinTypeSpec.Type.ValueType); + Attribute = new BuiltinTypeSpec (MemberKind.Class, "System", "Attribute", BuiltinTypeSpec.Type.Attribute); + + Int = new BuiltinTypeSpec (MemberKind.Struct, "System", "Int32", BuiltinTypeSpec.Type.Int); + Long = new BuiltinTypeSpec (MemberKind.Struct, "System", "Int64", BuiltinTypeSpec.Type.Long); + UInt = new BuiltinTypeSpec (MemberKind.Struct, "System", "UInt32", BuiltinTypeSpec.Type.UInt); + ULong = new BuiltinTypeSpec (MemberKind.Struct, "System", "UInt64", BuiltinTypeSpec.Type.ULong); + Byte = new BuiltinTypeSpec (MemberKind.Struct, "System", "Byte", BuiltinTypeSpec.Type.Byte); + SByte = new BuiltinTypeSpec (MemberKind.Struct, "System", "SByte", BuiltinTypeSpec.Type.SByte); + Short = new BuiltinTypeSpec (MemberKind.Struct, "System", "Int16", BuiltinTypeSpec.Type.Short); + UShort = new BuiltinTypeSpec (MemberKind.Struct, "System", "UInt16", BuiltinTypeSpec.Type.UShort); + + IEnumerator = new BuiltinTypeSpec (MemberKind.Interface, "System.Collections", "IEnumerator", BuiltinTypeSpec.Type.IEnumerator); + IEnumerable = new BuiltinTypeSpec (MemberKind.Interface, "System.Collections", "IEnumerable", BuiltinTypeSpec.Type.IEnumerable); + IDisposable = new BuiltinTypeSpec (MemberKind.Interface, "System", "IDisposable", BuiltinTypeSpec.Type.IDisposable); + + Char = new BuiltinTypeSpec (MemberKind.Struct, "System", "Char", BuiltinTypeSpec.Type.Char); + String = new BuiltinTypeSpec (MemberKind.Class, "System", "String", BuiltinTypeSpec.Type.String); + Float = new BuiltinTypeSpec (MemberKind.Struct, "System", "Single", BuiltinTypeSpec.Type.Float); + Double = new BuiltinTypeSpec (MemberKind.Struct, "System", "Double", BuiltinTypeSpec.Type.Double); + Decimal = new BuiltinTypeSpec (MemberKind.Struct, "System", "Decimal", BuiltinTypeSpec.Type.Decimal); + Bool = new BuiltinTypeSpec (MemberKind.Struct, "System", "Boolean", BuiltinTypeSpec.Type.Bool); + IntPtr = new BuiltinTypeSpec (MemberKind.Struct, "System", "IntPtr", BuiltinTypeSpec.Type.IntPtr); + UIntPtr = new BuiltinTypeSpec (MemberKind.Struct, "System", "UIntPtr", BuiltinTypeSpec.Type.UIntPtr); + + MulticastDelegate = new BuiltinTypeSpec (MemberKind.Class, "System", "MulticastDelegate", BuiltinTypeSpec.Type.MulticastDelegate); + Delegate = new BuiltinTypeSpec (MemberKind.Class, "System", "Delegate", BuiltinTypeSpec.Type.Delegate); + Enum = new BuiltinTypeSpec (MemberKind.Class, "System", "Enum", BuiltinTypeSpec.Type.Enum); + Array = new BuiltinTypeSpec (MemberKind.Class, "System", "Array", BuiltinTypeSpec.Type.Array); + Void = new BuiltinTypeSpec (MemberKind.Void, "System", "Void", BuiltinTypeSpec.Type.Other); + Type = new BuiltinTypeSpec (MemberKind.Class, "System", "Type", BuiltinTypeSpec.Type.Type); + Exception = new BuiltinTypeSpec (MemberKind.Class, "System", "Exception", BuiltinTypeSpec.Type.Exception); + RuntimeFieldHandle = new BuiltinTypeSpec (MemberKind.Struct, "System", "RuntimeFieldHandle", BuiltinTypeSpec.Type.Other); + RuntimeTypeHandle = new BuiltinTypeSpec (MemberKind.Struct, "System", "RuntimeTypeHandle", BuiltinTypeSpec.Type.Other); + + // TODO: Maybe I should promote it to different kind for faster compares + Dynamic = new BuiltinTypeSpec ("dynamic", BuiltinTypeSpec.Type.Dynamic); + + OperatorsBinaryStandard = Binary.CreateStandardOperatorsTable (this); + OperatorsBinaryEquality = Binary.CreateEqualityOperatorsTable (this); + OperatorsBinaryUnsafe = Binary.CreatePointerOperatorsTable (this); + OperatorsUnary = Unary.CreatePredefinedOperatorsTable (this); + OperatorsUnaryMutator = UnaryMutator.CreatePredefinedOperatorsTable (this); + + BinaryPromotionsTypes = ConstantFold.CreateBinaryPromotionsTypes (this); + SwitchUserTypes = Switch.CreateSwitchUserTypes (this); + + types = new BuiltinTypeSpec[] { Object, ValueType, Attribute, Int, UInt, Long, ULong, Float, Double, Char, Short, Decimal, Bool, SByte, Byte, UShort, String, Enum, Delegate, MulticastDelegate, Void, Array, Type, IEnumerator, IEnumerable, IDisposable, IntPtr, UIntPtr, RuntimeFieldHandle, RuntimeTypeHandle, Exception }; - - // Deal with obsolete static types - // TODO: remove - TypeManager.object_type = Object; - TypeManager.value_type = ValueType; - TypeManager.string_type = String; - TypeManager.int32_type = Int; - TypeManager.uint32_type = UInt; - TypeManager.int64_type = Long; - TypeManager.uint64_type = ULong; - TypeManager.float_type = Float; - TypeManager.double_type = Double; - TypeManager.char_type = Char; - TypeManager.short_type = Short; - TypeManager.decimal_type = Decimal; - TypeManager.bool_type = Bool; - TypeManager.sbyte_type = SByte; - TypeManager.byte_type = Byte; - TypeManager.ushort_type = UShort; - TypeManager.enum_type = Enum; - TypeManager.delegate_type = Delegate; - TypeManager.multicast_delegate_type = MulticastDelegate; ; - TypeManager.void_type = Void; - TypeManager.array_type = Array; ; - TypeManager.runtime_handle_type = RuntimeTypeHandle; - TypeManager.type_type = Type; - TypeManager.ienumerator_type = IEnumerator; - TypeManager.ienumerable_type = IEnumerable; - TypeManager.idisposable_type = IDisposable; - TypeManager.intptr_type = IntPtr; - TypeManager.uintptr_type = UIntPtr; - TypeManager.runtime_field_handle_type = RuntimeFieldHandle; - TypeManager.attribute_type = Attribute; - TypeManager.exception_type = Exception; - - InternalType.Dynamic = Dynamic; - InternalType.Null = Null; } - public BuildinTypeSpec[] AllTypes { + public BuiltinTypeSpec[] AllTypes { get { return types; } @@ -181,7 +161,6 @@ namespace Mono.CSharp // Set internal build-in types Dynamic.SetDefinition (Object); - Null.SetDefinition (Object); return true; } @@ -189,14 +168,13 @@ namespace Mono.CSharp // // Compiler predefined types. Usually used for compiler generated - // code or for comparison against well known framework type + // code or for comparison against well known framework type. They + // may not exist as they are optional // class PredefinedTypes { - // TODO: These two exist only to reject type comparison - public readonly PredefinedType TypedReference; public readonly PredefinedType ArgIterator; - + public readonly PredefinedType TypedReference; public readonly PredefinedType MarshalByRefObject; public readonly PredefinedType RuntimeHelpers; public readonly PredefinedType IAsyncResult; @@ -216,6 +194,8 @@ namespace Mono.CSharp public readonly PredefinedType RuntimeFieldHandle; public readonly PredefinedType RuntimeMethodHandle; public readonly PredefinedType SecurityAction; + public readonly PredefinedType Dictionary; + public readonly PredefinedType Hashtable; // // C# 3.0 @@ -240,6 +220,7 @@ namespace Mono.CSharp { TypedReference = new PredefinedType (module, MemberKind.Struct, "System", "TypedReference"); ArgIterator = new PredefinedType (module, MemberKind.Struct, "System", "ArgIterator"); + MarshalByRefObject = new PredefinedType (module, MemberKind.Class, "System", "MarshalByRefObject"); RuntimeHelpers = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "RuntimeHelpers"); IAsyncResult = new PredefinedType (module, MemberKind.Interface, "System", "IAsyncResult"); @@ -259,6 +240,8 @@ namespace Mono.CSharp RuntimeFieldHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeFieldHandle"); RuntimeMethodHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeMethodHandle"); SecurityAction = new PredefinedType (module, MemberKind.Enum, "System.Security.Permissions", "SecurityAction"); + Dictionary = new PredefinedType (module, MemberKind.Class, "System.Collections.Generic", "Dictionary", 2); + Hashtable = new PredefinedType (module, MemberKind.Class, "System.Collections", "Hashtable"); Expression = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression"); ExpressionGeneric = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression", 1); @@ -277,40 +260,212 @@ namespace Mono.CSharp // Define types which are used for comparison. It does not matter // if they don't exist as no error report is needed // - TypedReference.Define (); - ArgIterator.Define (); - MarshalByRefObject.Define (); - CharSet.Define (); - - IEnumerableGeneric.Define (); - IListGeneric.Define (); - ICollectionGeneric.Define (); - IEnumerableGeneric.Define (); - IEnumeratorGeneric.Define (); - Nullable.Define (); - ExpressionGeneric.Define (); - - // Deal with obsolete static types - // TODO: remove - TypeManager.typed_reference_type = TypedReference.TypeSpec; - TypeManager.arg_iterator_type = ArgIterator.TypeSpec; - TypeManager.mbr_type = MarshalByRefObject.TypeSpec; - TypeManager.generic_ilist_type = IListGeneric.TypeSpec; - TypeManager.generic_icollection_type = ICollectionGeneric.TypeSpec; - TypeManager.generic_ienumerator_type = IEnumeratorGeneric.TypeSpec; - TypeManager.generic_ienumerable_type = IEnumerableGeneric.TypeSpec; - TypeManager.generic_nullable_type = Nullable.TypeSpec; - TypeManager.expression_type = ExpressionGeneric.TypeSpec; + if (TypedReference.Define ()) + TypedReference.TypeSpec.IsSpecialRuntimeType = true; + + if (ArgIterator.Define ()) + ArgIterator.TypeSpec.IsSpecialRuntimeType = true; + + if (IEnumerableGeneric.Define ()) + IEnumerableGeneric.TypeSpec.IsGenericIterateInterface = true; + + if (IListGeneric.Define ()) + IListGeneric.TypeSpec.IsGenericIterateInterface = true; + + if (ICollectionGeneric.Define ()) + ICollectionGeneric.TypeSpec.IsGenericIterateInterface = true; + + if (Nullable.Define ()) + Nullable.TypeSpec.IsNullableType = true; + + if (ExpressionGeneric.Define ()) + ExpressionGeneric.TypeSpec.IsExpressionTreeType = true; + } + } + + class PredefinedMembers + { + public readonly PredefinedMember ActivatorCreateInstance; + public readonly PredefinedMember DecimalCtor; + public readonly PredefinedMember DecimalCtorInt; + public readonly PredefinedMember DecimalCtorLong; + public readonly PredefinedMember DecimalConstantAttributeCtor; + public readonly PredefinedMember DefaultMemberAttributeCtor; + public readonly PredefinedMember DelegateCombine; + public readonly PredefinedMember DelegateEqual; + public readonly PredefinedMember DelegateInequal; + public readonly PredefinedMember DelegateRemove; + public readonly PredefinedMember DynamicAttributeCtor; + public readonly PredefinedMember FieldInfoGetFieldFromHandle; + public readonly PredefinedMember FieldInfoGetFieldFromHandle2; + public readonly PredefinedMember IDisposableDispose; + public readonly PredefinedMember IEnumerableGetEnumerator; + public readonly PredefinedMember InterlockedCompareExchange; + public readonly PredefinedMember InterlockedCompareExchange_T; + public readonly PredefinedMember FixedBufferAttributeCtor; + public readonly PredefinedMember MethodInfoGetMethodFromHandle; + public readonly PredefinedMember MethodInfoGetMethodFromHandle2; + public readonly PredefinedMember MonitorEnter; + public readonly PredefinedMember MonitorEnter_v4; + public readonly PredefinedMember MonitorExit; + public readonly PredefinedMember RuntimeCompatibilityWrapNonExceptionThrows; + public readonly PredefinedMember RuntimeHelpersInitializeArray; + public readonly PredefinedMember RuntimeHelpersOffsetToStringData; + public readonly PredefinedMember SecurityActionRequestMinimum; + public readonly PredefinedMember StringEmpty; + public readonly PredefinedMember StringEqual; + public readonly PredefinedMember StringInequal; + public readonly PredefinedMember StructLayoutAttributeCtor; + public readonly PredefinedMember StructLayoutCharSet; + public readonly PredefinedMember StructLayoutPack; + public readonly PredefinedMember StructLayoutSize; + public readonly PredefinedMember TypeGetTypeFromHandle; + + public PredefinedMembers (ModuleContainer module) + { + var types = module.PredefinedTypes; + var atypes = module.PredefinedAttributes; + var btypes = module.Compiler.BuiltinTypes; + + ActivatorCreateInstance = new PredefinedMember (module, types.Activator, + MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); + + DecimalCtor = new PredefinedMember (module, btypes.Decimal, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( + btypes.Int, btypes.Int, btypes.Int, btypes.Bool, btypes.Byte))); + + DecimalCtorInt = new PredefinedMember (module, btypes.Decimal, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Int))); + + DecimalCtorLong = new PredefinedMember (module, btypes.Decimal, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Long))); + + DecimalConstantAttributeCtor = new PredefinedMember (module, atypes.DecimalConstant, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( + btypes.Byte, btypes.Byte, btypes.UInt, btypes.UInt, btypes.UInt))); + + DefaultMemberAttributeCtor = new PredefinedMember (module, atypes.DefaultMember, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.String))); + + DelegateCombine = new PredefinedMember (module, btypes.Delegate, "Combine", btypes.Delegate, btypes.Delegate); + DelegateRemove = new PredefinedMember (module, btypes.Delegate, "Remove", btypes.Delegate, btypes.Delegate); + + DelegateEqual = new PredefinedMember (module, btypes.Delegate, + new MemberFilter (Operator.GetMetadataName (Operator.OpType.Equality), 0, MemberKind.Operator, null, btypes.Bool)); + + DelegateInequal = new PredefinedMember (module, btypes.Delegate, + new MemberFilter (Operator.GetMetadataName (Operator.OpType.Inequality), 0, MemberKind.Operator, null, btypes.Bool)); + + DynamicAttributeCtor = new PredefinedMember (module, atypes.Dynamic, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( + ArrayContainer.MakeType (module, btypes.Bool)))); + + FieldInfoGetFieldFromHandle = new PredefinedMember (module, types.FieldInfo, + "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle); + + FieldInfoGetFieldFromHandle2 = new PredefinedMember (module, types.FieldInfo, + "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle, new PredefinedType (btypes.RuntimeTypeHandle)); + + FixedBufferAttributeCtor = new PredefinedMember (module, atypes.FixedBuffer, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Type, btypes.Int))); + + IDisposableDispose = new PredefinedMember (module, btypes.IDisposable, "Dispose", TypeSpec.EmptyTypes); + + IEnumerableGetEnumerator = new PredefinedMember (module, btypes.IEnumerable, + "GetEnumerator", TypeSpec.EmptyTypes); + + InterlockedCompareExchange = new PredefinedMember (module, types.Interlocked, + MemberFilter.Method ("CompareExchange", 0, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.NONE), + new ParameterData (null, Parameter.Modifier.NONE) + }, + new[] { + btypes.Int, btypes.Int, btypes.Int + }, + false), + btypes.Int)); + + InterlockedCompareExchange_T = new PredefinedMember (module, types.Interlocked, + MemberFilter.Method ("CompareExchange", 1, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.NONE), + new ParameterData (null, Parameter.Modifier.NONE) + }, + new[] { + new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), + }, false), + null)); + + MethodInfoGetMethodFromHandle = new PredefinedMember (module, types.MethodBase, + "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle); + + MethodInfoGetMethodFromHandle2 = new PredefinedMember (module, types.MethodBase, + "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType (btypes.RuntimeTypeHandle)); + + MonitorEnter = new PredefinedMember (module, types.Monitor, "Enter", btypes.Object); + + MonitorEnter_v4 = new PredefinedMember (module, types.Monitor, + MemberFilter.Method ("Enter", 0, + new ParametersImported (new[] { + new ParameterData (null, Parameter.Modifier.NONE), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + btypes.Object, btypes.Bool + }, false), null)); + + MonitorExit = new PredefinedMember (module, types.Monitor, "Exit", btypes.Object); + + RuntimeCompatibilityWrapNonExceptionThrows = new PredefinedMember (module, atypes.RuntimeCompatibility, + MemberFilter.Property ("WrapNonExceptionThrows", btypes.Bool)); + + RuntimeHelpersInitializeArray = new PredefinedMember (module, types.RuntimeHelpers, + "InitializeArray", btypes.Array, btypes.RuntimeFieldHandle); + + RuntimeHelpersOffsetToStringData = new PredefinedMember (module, types.RuntimeHelpers, + MemberFilter.Property ("OffsetToStringData", btypes.Int)); + + SecurityActionRequestMinimum = new PredefinedMember (module, types.SecurityAction, "RequestMinimum", + MemberKind.Field, types.SecurityAction); + + StringEmpty = new PredefinedMember (module, btypes.String, MemberFilter.Field ("Empty", btypes.String)); + + StringEqual = new PredefinedMember (module, btypes.String, + new MemberFilter (Operator.GetMetadataName (Operator.OpType.Equality), 0, MemberKind.Operator, null, btypes.Bool)); + + StringInequal = new PredefinedMember (module, btypes.String, + new MemberFilter (Operator.GetMetadataName (Operator.OpType.Inequality), 0, MemberKind.Operator, null, btypes.Bool)); + + StructLayoutAttributeCtor = new PredefinedMember (module, atypes.StructLayout, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Short))); + + StructLayoutCharSet = new PredefinedMember (module, atypes.StructLayout, "CharSet", + MemberKind.Field, types.CharSet); + + StructLayoutPack = new PredefinedMember (module, atypes.StructLayout, + MemberFilter.Field ("Pack", btypes.Int)); + + StructLayoutSize = new PredefinedMember (module, atypes.StructLayout, + MemberFilter.Field ("Size", btypes.Int)); + + TypeGetTypeFromHandle = new PredefinedMember (module, btypes.Type, "GetTypeFromHandle", btypes.RuntimeTypeHandle); } } public class PredefinedType { - string name; - string ns; - int arity; - MemberKind kind; - ModuleContainer module; + readonly string name; + readonly string ns; + readonly int arity; + readonly MemberKind kind; + protected readonly ModuleContainer module; protected TypeSpec type; public PredefinedType (ModuleContainer module, MemberKind kind, string ns, string name, int arity) @@ -327,6 +482,14 @@ namespace Mono.CSharp this.ns = ns; } + public PredefinedType (BuiltinTypeSpec type) + { + this.kind = type.Kind; + this.name = type.Name; + this.ns = type.Namespace; + this.type = type; + } + #region Properties public int Arity { @@ -367,22 +530,15 @@ namespace Mono.CSharp return true; Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, true); - var te = type_ns.LookupType (module.Compiler, name, arity, true, Location.Null); - if (te == null) - return false; - - if (te.Type.Kind != kind) + var te = type_ns.LookupType (module, name, arity, true, Location.Null); + if (te == null || te.Type.Kind != kind) { return false; + } type = te.Type; return true; } - public FieldSpec GetField (string name, TypeSpec memberType, Location loc) - { - return TypeManager.GetPredefinedField (type, name, loc, memberType); - } - public string GetSignatureForError () { return ns + "." + name; @@ -391,7 +547,7 @@ namespace Mono.CSharp public static TypeSpec Resolve (ModuleContainer module, MemberKind kind, string ns, string name, int arity, Location loc) { Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, true); - var te = type_ns.LookupType (module.Compiler, name, arity, false, Location.Null); + var te = type_ns.LookupType (module, name, arity, false, Location.Null); if (te == null) { module.Compiler.Report.Error (518, loc, "The predefined type `{0}.{1}' is not defined or imported", ns, name); return null; @@ -399,8 +555,13 @@ namespace Mono.CSharp var type = te.Type; if (type.Kind != kind) { - module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name); - return null; + if (type.Kind == MemberKind.Struct && kind == MemberKind.Void && type.MemberDefinition is TypeContainer) { + // Void is declared as struct but we keep it internally as + // special kind, the swap will be done by caller + } else { + module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name); + return null; + } } return type; @@ -415,122 +576,121 @@ namespace Mono.CSharp } } - partial class TypeManager { - // - // A list of core types that the compiler requires or uses - // - static public BuildinTypeSpec object_type; - static public BuildinTypeSpec value_type; - static public BuildinTypeSpec string_type; - static public BuildinTypeSpec int32_type; - static public BuildinTypeSpec uint32_type; - static public BuildinTypeSpec int64_type; - static public BuildinTypeSpec uint64_type; - static public BuildinTypeSpec float_type; - static public BuildinTypeSpec double_type; - static public BuildinTypeSpec char_type; - static public BuildinTypeSpec short_type; - static public BuildinTypeSpec decimal_type; - static public BuildinTypeSpec bool_type; - static public BuildinTypeSpec sbyte_type; - static public BuildinTypeSpec byte_type; - static public BuildinTypeSpec ushort_type; - static public BuildinTypeSpec enum_type; - static public BuildinTypeSpec delegate_type; - static public BuildinTypeSpec multicast_delegate_type; - static public BuildinTypeSpec void_type; - static public BuildinTypeSpec array_type; - static public BuildinTypeSpec runtime_handle_type; - static public BuildinTypeSpec type_type; - static public BuildinTypeSpec ienumerator_type; - static public BuildinTypeSpec ienumerable_type; - static public BuildinTypeSpec idisposable_type; - static public BuildinTypeSpec intptr_type; - static public BuildinTypeSpec uintptr_type; - static public BuildinTypeSpec runtime_field_handle_type; - static public BuildinTypeSpec attribute_type; - static public BuildinTypeSpec exception_type; - - - static public TypeSpec typed_reference_type; - static public TypeSpec arg_iterator_type; - static public TypeSpec mbr_type; - static public TypeSpec generic_ilist_type; - static public TypeSpec generic_icollection_type; - static public TypeSpec generic_ienumerator_type; - static public TypeSpec generic_ienumerable_type; - static public TypeSpec generic_nullable_type; - static internal TypeSpec expression_type; + class PredefinedMember where T : MemberSpec + { + readonly ModuleContainer module; + T member; + TypeSpec declaring_type; + readonly PredefinedType declaring_type_predefined; + readonly PredefinedType[] parameters_predefined; + MemberFilter filter; - // - // These methods are called by code generated by the compiler - // - static public FieldSpec string_empty; - static public MethodSpec system_type_get_type_from_handle; - static public MethodSpec bool_movenext_void; - static public MethodSpec void_dispose_void; - static public MethodSpec void_monitor_enter_object; - static public MethodSpec void_monitor_exit_object; - static public MethodSpec void_initializearray_array_fieldhandle; - static public MethodSpec delegate_combine_delegate_delegate; - static public MethodSpec delegate_remove_delegate_delegate; - static public PropertySpec int_get_offset_to_string_data; - static public MethodSpec int_interlocked_compare_exchange; - public static MethodSpec gen_interlocked_compare_exchange; - static public PropertySpec ienumerator_getcurrent; - public static MethodSpec methodbase_get_type_from_handle; - public static MethodSpec methodbase_get_type_from_handle_generic; - public static MethodSpec fieldinfo_get_field_from_handle; - public static MethodSpec fieldinfo_get_field_from_handle_generic; - public static MethodSpec activator_create_instance; + public PredefinedMember (ModuleContainer module, PredefinedType type, MemberFilter filter) + { + this.module = module; + this.declaring_type_predefined = type; + this.filter = filter; + } - // - // The constructors. - // - static public MethodSpec void_decimal_ctor_five_args; - static public MethodSpec void_decimal_ctor_int_arg; - public static MethodSpec void_decimal_ctor_long_arg; + public PredefinedMember (ModuleContainer module, TypeSpec type, MemberFilter filter) + { + this.module = module; + this.declaring_type = type; + this.filter = filter; + } - static TypeManager () - { - Reset (); - } + public PredefinedMember (ModuleContainer module, PredefinedType type, string name, params TypeSpec[] types) + : this (module, type, MemberFilter.Method (name, 0, ParametersCompiled.CreateFullyResolved (types), null)) + { + } - static public void Reset () - { -// object_type = null; - - // TODO: I am really bored by all this static stuff - system_type_get_type_from_handle = - bool_movenext_void = - void_dispose_void = - void_monitor_enter_object = - void_monitor_exit_object = - void_initializearray_array_fieldhandle = - int_interlocked_compare_exchange = - gen_interlocked_compare_exchange = - methodbase_get_type_from_handle = - methodbase_get_type_from_handle_generic = - fieldinfo_get_field_from_handle = - fieldinfo_get_field_from_handle_generic = - activator_create_instance = - delegate_combine_delegate_delegate = - delegate_remove_delegate_delegate = null; - - int_get_offset_to_string_data = - ienumerator_getcurrent = null; - - void_decimal_ctor_five_args = - void_decimal_ctor_int_arg = - void_decimal_ctor_long_arg = null; - - string_empty = null; - - typed_reference_type = arg_iterator_type = mbr_type = - generic_ilist_type = generic_icollection_type = generic_ienumerator_type = - generic_ienumerable_type = generic_nullable_type = expression_type = null; + public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, params PredefinedType[] types) + : this (module, type, new MemberFilter (name, 0, kind, null, null)) + { + parameters_predefined = types; + } + + public PredefinedMember (ModuleContainer module, BuiltinTypeSpec type, string name, params TypeSpec[] types) + : this (module, type, MemberFilter.Method (name, 0, ParametersCompiled.CreateFullyResolved (types), null)) + { + } + + public T Get () + { + if (member != null) + return member; + + if (declaring_type == null) { + if (!declaring_type_predefined.Define ()) + return null; + + declaring_type = declaring_type_predefined.TypeSpec; + } + + if (parameters_predefined != null) { + TypeSpec[] types = new TypeSpec [parameters_predefined.Length]; + for (int i = 0; i < types.Length; ++i) { + var p = parameters_predefined [i]; + if (!p.Define ()) + return null; + + types[i] = p.TypeSpec; + } + + if (filter.Kind == MemberKind.Field) + filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, null, types [0]); + else + filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, ParametersCompiled.CreateFullyResolved (types), filter.MemberType); + } + + member = MemberCache.FindMember (declaring_type, filter, BindingRestriction.DeclaredOnly) as T; + if (member == null) + return null; + + if (!member.IsAccessible (module)) + return null; + + return member; + } + + public T Resolve (Location loc) + { + if (member != null) + return member; + + if (Get () != null) + return member; + + if (declaring_type == null) { + if (declaring_type_predefined.Resolve (loc) == null) + return null; + } + + if (parameters_predefined != null) { + TypeSpec[] types = new TypeSpec[parameters_predefined.Length]; + for (int i = 0; i < types.Length; ++i) { + var p = parameters_predefined[i]; + types[i] = p.Resolve (loc); + if (types[i] == null) + return null; + } + + filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, ParametersCompiled.CreateFullyResolved (types), filter.MemberType); + } + + string method_args = null; + if (filter.Parameters != null) + method_args = filter.Parameters.GetSignatureForError (); + + module.Compiler.Report.Error (656, loc, "The compiler required member `{0}.{1}{2}' could not be found or is inaccessible", + declaring_type.GetSignatureForError (), filter.Name, method_args); + + return null; + } } + partial class TypeManager { + /// /// Returns the C# name of a type if possible, or the full type name otherwise /// @@ -564,88 +724,6 @@ namespace Mono.CSharp return mb.GetSignatureForError (); } - static MemberSpec GetPredefinedMember (TypeSpec t, MemberFilter filter, bool optional, Location loc) - { - var member = MemberCache.FindMember (t, filter, BindingRestriction.DeclaredOnly); - - if (member != null && member.IsAccessible (InternalType.FakeInternalType)) - return member; - - if (optional) - return member; - - string method_args = null; - if (filter.Parameters != null) - method_args = filter.Parameters.GetSignatureForError (); - - RootContext.ToplevelTypes.Compiler.Report.Error (656, loc, "The compiler required member `{0}.{1}{2}' could not be found or is inaccessible", - TypeManager.CSharpName (t), filter.Name, method_args); - - return null; - } - - // - // Returns the ConstructorInfo for "args" - // - public static MethodSpec GetPredefinedConstructor (TypeSpec t, Location loc, params TypeSpec [] args) - { - var pc = ParametersCompiled.CreateFullyResolved (args); - return GetPredefinedMember (t, MemberFilter.Constructor (pc), false, loc) as MethodSpec; - } - - // - // Returns the method specification for a method named `name' defined - // in type `t' which takes arguments of types `args' - // - public static MethodSpec GetPredefinedMethod (TypeSpec t, string name, Location loc, params TypeSpec [] args) - { - var pc = ParametersCompiled.CreateFullyResolved (args); - return GetPredefinedMethod (t, MemberFilter.Method (name, 0, pc, null), false, loc); - } - - public static MethodSpec GetPredefinedMethod (TypeSpec t, MemberFilter filter, Location loc) - { - return GetPredefinedMethod (t, filter, false, loc); - } - - public static MethodSpec GetPredefinedMethod (TypeSpec t, MemberFilter filter, bool optional, Location loc) - { - return GetPredefinedMember (t, filter, optional, loc) as MethodSpec; - } - - public static FieldSpec GetPredefinedField (TypeSpec t, string name, Location loc, TypeSpec type) - { - return GetPredefinedMember (t, MemberFilter.Field (name, type), false, loc) as FieldSpec; - } - - public static PropertySpec GetPredefinedProperty (TypeSpec t, string name, Location loc, TypeSpec type) - { - return GetPredefinedMember (t, MemberFilter.Property (name, type), false, loc) as PropertySpec; - } - - public static bool IsBuiltinType (TypeSpec t) - { - if (t == object_type || t == string_type || t == int32_type || t == uint32_type || - t == int64_type || t == uint64_type || t == float_type || t == double_type || - t == char_type || t == short_type || t == decimal_type || t == bool_type || - t == sbyte_type || t == byte_type || t == ushort_type || t == void_type) - return true; - else - return false; - } - - // - // This is like IsBuiltinType, but lacks decimal_type, we should also clean up - // the pieces in the code where we use IsBuiltinType and special case decimal_type. - // - public static bool IsPrimitiveType (TypeSpec t) - { - return (t == int32_type || t == uint32_type || - t == int64_type || t == uint64_type || t == float_type || t == double_type || - t == char_type || t == short_type || t == bool_type || - t == sbyte_type || t == byte_type || t == ushort_type); - } - // Obsolete public static bool IsDelegateType (TypeSpec t) { @@ -658,17 +736,6 @@ namespace Mono.CSharp return t.IsEnum; } - public static bool IsBuiltinOrEnum (TypeSpec t) - { - if (IsBuiltinType (t)) - return true; - - if (IsEnumType (t)) - return true; - - return false; - } - // // Whether a type is unmanaged. This is used by the unsafe code (25.2) // @@ -678,11 +745,7 @@ namespace Mono.CSharp if (ds != null) return ds.IsUnmanagedType (); - // some builtins that are not unmanaged types - if (t == TypeManager.object_type || t == TypeManager.string_type) - return false; - - if (IsBuiltinOrEnum (t)) + if (t.Kind == MemberKind.Void) return true; // Someone did the work of checking if the ElementType of t is unmanaged. Let's not repeat it. @@ -717,11 +780,6 @@ namespace Mono.CSharp return t.IsStruct || IsEnumType (t); } - public static bool IsStruct (TypeSpec t) - { - return t.IsStruct; - } - public static bool IsFamilyAccessible (TypeSpec type, TypeSpec parent) { // TypeParameter tparam = LookupTypeParameter (type); @@ -745,22 +803,6 @@ namespace Mono.CSharp return false; } - // - // Checks whether `type' is a subclass or nested child of `base_type'. - // - public static bool IsNestedFamilyAccessible (TypeSpec type, TypeSpec base_type) - { - do { - if (IsFamilyAccessible (type, base_type)) - return true; - - // Handle nested types. - type = type.DeclaringType; - } while (type != null); - - return false; - } - // // Checks whether `type' is a nested child of `parent'. // @@ -783,11 +825,6 @@ namespace Mono.CSharp return false; } - public static bool IsSpecialType (TypeSpec t) - { - return t == arg_iterator_type || t == typed_reference_type; - } - public static TypeSpec GetElementType (TypeSpec t) { return ((ElementTypeSpec)t).Element; @@ -801,82 +838,11 @@ namespace Mono.CSharp return t is ElementTypeSpec; } - static NumberFormatInfo nf_provider = CultureInfo.CurrentCulture.NumberFormat; - - // This is a custom version of Convert.ChangeType() which works - // with the TypeBuilder defined types when compiling corlib. - public static object ChangeType (object value, TypeSpec targetType, out bool error) - { - IConvertible convert_value = value as IConvertible; - - if (convert_value == null){ - error = true; - return null; - } - - // - // We cannot rely on build-in type conversions as they are - // more limited than what C# supports. - // See char -> float/decimal/double conversion - // - error = false; - try { - if (targetType == TypeManager.bool_type) - return convert_value.ToBoolean (nf_provider); - if (targetType == TypeManager.byte_type) - return convert_value.ToByte (nf_provider); - if (targetType == TypeManager.char_type) - return convert_value.ToChar (nf_provider); - if (targetType == TypeManager.short_type) - return convert_value.ToInt16 (nf_provider); - if (targetType == TypeManager.int32_type) - return convert_value.ToInt32 (nf_provider); - if (targetType == TypeManager.int64_type) - return convert_value.ToInt64 (nf_provider); - if (targetType == TypeManager.sbyte_type) - return convert_value.ToSByte (nf_provider); - - if (targetType == TypeManager.decimal_type) { - if (convert_value.GetType () == typeof (char)) - return (decimal) convert_value.ToInt32 (nf_provider); - return convert_value.ToDecimal (nf_provider); - } - - if (targetType == TypeManager.double_type) { - if (convert_value.GetType () == typeof (char)) - return (double) convert_value.ToInt32 (nf_provider); - return convert_value.ToDouble (nf_provider); - } - - if (targetType == TypeManager.float_type) { - if (convert_value.GetType () == typeof (char)) - return (float)convert_value.ToInt32 (nf_provider); - return convert_value.ToSingle (nf_provider); - } - - if (targetType == TypeManager.string_type) - return convert_value.ToString (nf_provider); - if (targetType == TypeManager.ushort_type) - return convert_value.ToUInt16 (nf_provider); - if (targetType == TypeManager.uint32_type) - return convert_value.ToUInt32 (nf_provider); - if (targetType == TypeManager.uint64_type) - return convert_value.ToUInt64 (nf_provider); - if (targetType == TypeManager.object_type) - return value; - - error = true; - } catch { - error = true; - } - return null; - } - /// /// Utility function that can be used to probe whether a type /// is managed or not. /// - public static bool VerifyUnmanaged (CompilerContext ctx, TypeSpec t, Location loc) + public static bool VerifyUnmanaged (ModuleContainer rc, TypeSpec t, Location loc) { while (t.IsPointer) t = GetElementType (t); @@ -884,8 +850,8 @@ namespace Mono.CSharp if (IsUnmanagedType (t)) return true; - ctx.Report.SymbolRelatedToPreviousError (t); - ctx.Report.Error (208, loc, + rc.Compiler.Report.SymbolRelatedToPreviousError (t); + rc.Compiler.Report.Error (208, loc, "Cannot take the address of, get the size of, or declare a pointer to a managed type `{0}'", CSharpName (t)); @@ -918,11 +884,6 @@ namespace Mono.CSharp { return type == parent || type.MemberDefinition == parent.MemberDefinition; } - - public static bool IsNullableType (TypeSpec t) - { - return generic_nullable_type == t.GetDefinition (); - } #endregion } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs index 488ad0d53..3bcc3b43a 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs @@ -75,9 +75,9 @@ namespace Mono.CSharp } } - public virtual BuildinTypeSpec.Type BuildinType { + public virtual BuiltinTypeSpec.Type BuiltinType { get { - return BuildinTypeSpec.Type.None; + return BuiltinTypeSpec.Type.None; } } @@ -112,7 +112,7 @@ namespace Mono.CSharp if (type.IsGeneric) return false; - if (type == TypeManager.attribute_type) + if (type.BuiltinType == BuiltinTypeSpec.Type.Attribute) return true; type = type.base_type; @@ -139,7 +139,25 @@ namespace Mono.CSharp if ((Kind & (MemberKind.Enum | MemberKind.Class | MemberKind.Interface | MemberKind.Delegate | MemberKind.ArrayType)) != 0) return true; - return TypeManager.IsPrimitiveType (this) || this == TypeManager.decimal_type || this == InternalType.Dynamic; + switch (BuiltinType) { + case BuiltinTypeSpec.Type.Int: + case BuiltinTypeSpec.Type.UInt: + case BuiltinTypeSpec.Type.Long: + case BuiltinTypeSpec.Type.ULong: + case BuiltinTypeSpec.Type.Float: + case BuiltinTypeSpec.Type.Double: + case BuiltinTypeSpec.Type.Char: + case BuiltinTypeSpec.Type.Short: + case BuiltinTypeSpec.Type.Decimal: + case BuiltinTypeSpec.Type.Bool: + case BuiltinTypeSpec.Type.SByte: + case BuiltinTypeSpec.Type.Byte: + case BuiltinTypeSpec.Type.UShort: + case BuiltinTypeSpec.Type.Dynamic: + return true; + } + + return false; } } @@ -149,8 +167,34 @@ namespace Mono.CSharp } } + // + // Returns true for instances of Expression + // + public virtual bool IsExpressionTreeType { + get { + return false; + } + set { + state = value ? state | StateFlags.InflatedExpressionType : state & ~StateFlags.InflatedExpressionType; + } + } + public bool IsEnum { - get { return Kind == MemberKind.Enum; } + get { + return Kind == MemberKind.Enum; + } + } + + // + // Returns true for instances of IList, IEnumerable, ICollection + // + public virtual bool IsGenericIterateInterface { + get { + return false; + } + set { + state = value ? state | StateFlags.GenericIterateInterface : state & ~StateFlags.GenericIterateInterface; + } } // TODO: Should probably do @@ -170,7 +214,21 @@ namespace Mono.CSharp } public bool IsGenericParameter { - get { return Kind == MemberKind.TypeParameter; } + get { + return Kind == MemberKind.TypeParameter; + } + } + + // + // Returns true for instances of Nullable + // + public virtual bool IsNullableType { + get { + return false; + } + set { + state = value ? state | StateFlags.InflatedNullableType : state & ~StateFlags.InflatedNullableType; + } } public bool IsNested { @@ -187,6 +245,15 @@ namespace Mono.CSharp get { return (Modifiers & Modifiers.SEALED) != 0; } } + public bool IsSpecialRuntimeType { + get { + return (state & StateFlags.SpecialRuntimeType) != 0; + } + set { + state = value ? state | StateFlags.SpecialRuntimeType : state & ~StateFlags.SpecialRuntimeType; + } + } + public bool IsStruct { get { return Kind == MemberKind.Struct; @@ -309,6 +376,11 @@ namespace Mono.CSharp return s + Name + GetTypeNameSignature (); } + public string GetSignatureForErrorIncludingAssemblyName () + { + return string.Format ("{0} [{1}]", GetSignatureForError (), MemberDefinition.DeclaringAssembly.FullName); + } + protected virtual string GetTypeNameSignature () { if (!IsGeneric) @@ -321,7 +393,7 @@ namespace Mono.CSharp { var t = this; do { - if (t.Interfaces != null) { // TODO: Try t.iface + if (t.Interfaces != null) { foreach (TypeSpec i in t.Interfaces) { if (i == iface || TypeSpecComparer.IsEqual (i, iface)) return true; @@ -331,6 +403,7 @@ namespace Mono.CSharp } } + // TODO: Why is it needed when we do it during import t = t.BaseType; } while (t != null); @@ -339,7 +412,11 @@ namespace Mono.CSharp protected virtual void InitializeMemberCache (bool onlyTypes) { - MemberDefinition.LoadMembers (this, onlyTypes, ref cache); + try { + MemberDefinition.LoadMembers (this, onlyTypes, ref cache); + } catch (Exception e) { + throw new InternalErrorException (e, "Unexpected error when loading type `{0}'", GetSignatureForError ()); + } if (onlyTypes) state |= StateFlags.PendingMemberCacheMembers; @@ -360,10 +437,12 @@ namespace Mono.CSharp // // class B : A {} // + type = type.BaseType; while (type != null) { - type = type.BaseType; if (TypeSpecComparer.IsEqual (type, baseClass)) return true; + + type = type.BaseType; } return false; @@ -387,13 +466,13 @@ namespace Mono.CSharp // because type parameters are same for all nested types // if (DeclaringType == inflator.TypeInstance) { - return MakeGenericType (targs); + return MakeGenericType (inflator.Context, targs); } - return new InflatedTypeSpec (this, inflator.TypeInstance, targs); + return new InflatedTypeSpec (inflator.Context, this, inflator.TypeInstance, targs); } - public InflatedTypeSpec MakeGenericType (TypeSpec[] targs) + public InflatedTypeSpec MakeGenericType (IModuleContext context, TypeSpec[] targs) { if (targs.Length == 0 && !IsNested) throw new ArgumentException ("Empty type arguments for type " + GetSignatureForError ()); @@ -421,7 +500,7 @@ namespace Mono.CSharp throw new InternalErrorException ("`{0}' must be type definition or nested non-inflated type to MakeGenericType", GetSignatureForError ()); - instance = new InflatedTypeSpec (this, declaringType, targs); + instance = new InflatedTypeSpec (context, this, declaringType, targs); inflated_instances.Add (targs, instance); } @@ -483,63 +562,67 @@ namespace Mono.CSharp } } - public sealed class BuildinTypeSpec : TypeSpec + public sealed class BuiltinTypeSpec : TypeSpec { public enum Type { None = 0, - // TODO: Reorder it more carefully so we can do fast compares - Object, - ValueType, - Attribute, - Int, - UInt, - Long, - ULong, - Float, - Double, - Char, - Short, - Decimal, - Bool, - SByte, - Byte, - UShort, - String, - Enum, - Delegate, - MulticastDelegate, - Void, - Array, - Type, + // Ordered carefully for fast compares + FirstPrimitive = 1, + Bool = 1, + Byte = 2, + SByte = 3, + Char = 4, + Short = 5, + UShort = 6, + Int = 7, + UInt = 8, + Long = 9, + ULong = 10, + Float = 11, + Double = 12, + LastPrimitive = 12, + Decimal = 13, + + IntPtr = 14, + UIntPtr = 15, + + Object = 16, + Dynamic = 17, + String = 18, + Type = 19, + + ValueType = 20, + Enum = 21, + Delegate = 22, + MulticastDelegate = 23, + Array = 24, + IEnumerator, IEnumerable, IDisposable, - IntPtr, - UIntPtr, - RuntimeFieldHandle, - RuntimeTypeHandle, Exception, + Attribute, + Other, Null, - Dynamic } readonly Type type; readonly string ns; readonly string name; - public BuildinTypeSpec (MemberKind kind, string ns, string name, Type buildinKind) + public BuiltinTypeSpec (MemberKind kind, string ns, string name, Type builtinKind) : base (kind, null, null, null, Modifiers.PUBLIC) { - this.type = buildinKind; + this.type = builtinKind; this.ns = ns; this.name = name; } - public BuildinTypeSpec (string name, Type buildinKind) - : this (MemberKind.InternalCompilerType, "", name, buildinKind) + public BuiltinTypeSpec (string name, Type builtinKind) + : this (MemberKind.InternalCompilerType, "", name, builtinKind) { // Make all internal types CLS-compliant, non-obsolete, compact state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant; @@ -553,7 +636,7 @@ namespace Mono.CSharp } } - public override BuildinTypeSpec.Type BuildinType { + public override BuiltinTypeSpec.Type BuiltinType { get { return type; } @@ -579,6 +662,16 @@ namespace Mono.CSharp #endregion + public static bool IsPrimitiveType (TypeSpec type) + { + return type.BuiltinType >= Type.FirstPrimitive && type.BuiltinType <= Type.LastPrimitive; + } + + public static bool IsPrimitiveTypeOrDecimal (TypeSpec type) + { + return type.BuiltinType >= Type.FirstPrimitive && type.BuiltinType <= Type.Decimal; + } + public override string GetSignatureForError () { switch (Name) { @@ -606,6 +699,35 @@ namespace Mono.CSharp return FullName; } + // + // Returns the size of type if known, otherwise, 0 + // + public static int GetSize (TypeSpec type) + { + switch (type.BuiltinType) { + case Type.Int: + case Type.UInt: + case Type.Float: + return 4; + case Type.Long: + case Type.ULong: + case Type.Double: + return 8; + case Type.Byte: + case Type.SByte: + case Type.Bool: + return 1; + case Type.Short: + case Type.Char: + case Type.UShort: + return 2; + case Type.Decimal: + return 16; + default: + return 0; + } + } + public void SetDefinition (ITypeDefinition td, MetaType type, Modifiers mod) { this.definition = td; @@ -704,8 +826,8 @@ namespace Mono.CSharp return ac_b != null && ac_a.Rank == ac_b.Rank && IsEqual (ac_a.Element, ac_b.Element); } - if (a == InternalType.Dynamic || b == InternalType.Dynamic) - return b == TypeManager.object_type || a == TypeManager.object_type; + if (a.BuiltinType == BuiltinTypeSpec.Type.Dynamic || b.BuiltinType == BuiltinTypeSpec.Type.Dynamic) + return b.BuiltinType == BuiltinTypeSpec.Type.Object || a.BuiltinType == BuiltinTypeSpec.Type.Object; if (a.MemberDefinition != b.MemberDefinition) return false; @@ -802,9 +924,9 @@ namespace Mono.CSharp } if (v == Variance.Covariant) { - if (!Convert.ImplicitReferenceConversionExists (new EmptyExpression (t1_targs[i]), t2_targs[i])) + if (!Convert.ImplicitReferenceConversionExists (t1_targs[i], t2_targs[i])) return false; - } else if (!Convert.ImplicitReferenceConversionExists (new EmptyExpression (t2_targs[i]), t1_targs[i])) { + } else if (!Convert.ImplicitReferenceConversionExists (t2_targs[i], t1_targs[i])) { return false; } } @@ -948,18 +1070,10 @@ namespace Mono.CSharp { if (a == b) { // This also rejects dynamic == dynamic - return a.Kind != MemberKind.InternalCompilerType || a == InternalType.Dynamic; + return a.Kind != MemberKind.InternalCompilerType || a.BuiltinType == BuiltinTypeSpec.Type.Dynamic; } - // - // object and dynamic are considered equivalent there is an identity conversion - // between object and dynamic, and between constructed types that are the same - // when replacing all occurences of dynamic with object. - // - if (a == InternalType.Dynamic || b == InternalType.Dynamic) - return b == TypeManager.object_type || a == TypeManager.object_type; - - if (a == null) + if (a == null || b == null) return false; if (a.IsArray) { @@ -971,8 +1085,17 @@ namespace Mono.CSharp return IsEqual (a_a.Element, b_a.Element) && a_a.Rank == b_a.Rank; } - if (!a.IsGeneric || b == null || !b.IsGeneric) + if (!a.IsGeneric || !b.IsGeneric) { + // + // object and dynamic are considered equivalent there is an identity conversion + // between object and dynamic, and between constructed types that are the same + // when replacing all occurences of dynamic with object. + // + if (a.BuiltinType == BuiltinTypeSpec.Type.Dynamic || b.BuiltinType == BuiltinTypeSpec.Type.Dynamic) + return b.BuiltinType == BuiltinTypeSpec.Type.Object || a.BuiltinType == BuiltinTypeSpec.Type.Object; + return false; + } if (a.MemberDefinition != b.MemberDefinition) return false; @@ -1007,9 +1130,8 @@ namespace Mono.CSharp { public static readonly InternalType AnonymousMethod = new InternalType ("anonymous method"); public static readonly InternalType Arglist = new InternalType ("__arglist"); - public static BuildinTypeSpec Dynamic; public static readonly InternalType MethodGroup = new InternalType ("method group"); - public static BuildinTypeSpec Null; + public static readonly InternalType NullLiteral = new InternalType ("null"); public static readonly InternalType FakeInternalType = new InternalType (""); readonly string name; @@ -1149,7 +1271,7 @@ namespace Mono.CSharp state &= ~shared_flags; state |= (element.state & shared_flags); - if (element == InternalType.Dynamic) + if (element.BuiltinType == BuiltinTypeSpec.Type.Dynamic) state |= StateFlags.HasDynamicElement; // Has to use its own type definition instead of just element definition to @@ -1274,7 +1396,7 @@ namespace Mono.CSharp public class ArrayContainer : ElementTypeSpec { - struct TypeRankPair : IEquatable + public struct TypeRankPair : IEquatable { TypeSpec ts; int rank; @@ -1301,11 +1423,12 @@ namespace Mono.CSharp } readonly int rank; - static Dictionary instances = new Dictionary (); + readonly ModuleContainer module; - private ArrayContainer (TypeSpec element, int rank) + private ArrayContainer (ModuleContainer module, TypeSpec element, int rank) : base (MemberKind.ArrayType, element, null) { + this.module = module; this.rank = rank; } @@ -1317,11 +1440,11 @@ namespace Mono.CSharp public MethodInfo GetConstructor () { - var mb = RootContext.ToplevelTypes.Builder; + var mb = module.Builder; var arg_types = new MetaType[rank]; for (int i = 0; i < rank; i++) - arg_types[i] = TypeManager.int32_type.GetMetaInfo (); + arg_types[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo (); var ctor = mb.GetArrayMethod ( GetMetaInfo (), Constructor.ConstructorName, @@ -1333,27 +1456,27 @@ namespace Mono.CSharp public MethodInfo GetAddressMethod () { - var mb = RootContext.ToplevelTypes.Builder; + var mb = module.Builder; var arg_types = new MetaType[rank]; for (int i = 0; i < rank; i++) - arg_types[i] = TypeManager.int32_type.GetMetaInfo (); + arg_types[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo (); var address = mb.GetArrayMethod ( GetMetaInfo (), "Address", CallingConventions.HasThis | CallingConventions.Standard, - ReferenceContainer.MakeType (Element).GetMetaInfo (), arg_types); + ReferenceContainer.MakeType (module, Element).GetMetaInfo (), arg_types); return address; } public MethodInfo GetGetMethod () { - var mb = RootContext.ToplevelTypes.Builder; + var mb = module.Builder; var arg_types = new MetaType[rank]; for (int i = 0; i < rank; i++) - arg_types[i] = TypeManager.int32_type.GetMetaInfo (); + arg_types[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo (); var get = mb.GetArrayMethod ( GetMetaInfo (), "Get", @@ -1365,18 +1488,18 @@ namespace Mono.CSharp public MethodInfo GetSetMethod () { - var mb = RootContext.ToplevelTypes.Builder; + var mb = module.Builder; var arg_types = new MetaType[rank + 1]; for (int i = 0; i < rank; i++) - arg_types[i] = TypeManager.int32_type.GetMetaInfo (); + arg_types[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo (); arg_types[rank] = Element.GetMetaInfo (); var set = mb.GetArrayMethod ( GetMetaInfo (), "Set", CallingConventions.HasThis | CallingConventions.Standard, - TypeManager.void_type.GetMetaInfo (), arg_types); + module.Compiler.BuiltinTypes.Void.GetMetaInfo (), arg_types); return set; } @@ -1410,36 +1533,29 @@ namespace Mono.CSharp return sb.ToString (); } - public static ArrayContainer MakeType (TypeSpec element) + public static ArrayContainer MakeType (ModuleContainer module, TypeSpec element) { - return MakeType (element, 1); + return MakeType (module, element, 1); } - public static ArrayContainer MakeType (TypeSpec element, int rank) + public static ArrayContainer MakeType (ModuleContainer module, TypeSpec element, int rank) { ArrayContainer ac; var key = new TypeRankPair (element, rank); - if (!instances.TryGetValue (key, out ac)) { - ac = new ArrayContainer (element, rank) { - BaseType = TypeManager.array_type + if (!module.ArrayTypesCache.TryGetValue (key, out ac)) { + ac = new ArrayContainer (module, element, rank) { + BaseType = module.Compiler.BuiltinTypes.Array }; - instances.Add (key, ac); + module.ArrayTypesCache.Add (key, ac); } return ac; } - - public static void Reset () - { - instances = new Dictionary (); - } } class ReferenceContainer : ElementTypeSpec { - static Dictionary instances = new Dictionary (); - private ReferenceContainer (TypeSpec element) : base (MemberKind.Class, element, null) // TODO: Kind.Class is most likely wrong { @@ -1454,27 +1570,20 @@ namespace Mono.CSharp return info; } - public static ReferenceContainer MakeType (TypeSpec element) + public static ReferenceContainer MakeType (ModuleContainer module, TypeSpec element) { ReferenceContainer pc; - if (!instances.TryGetValue (element, out pc)) { + if (!module.ReferenceTypesCache.TryGetValue (element, out pc)) { pc = new ReferenceContainer (element); - instances.Add (element, pc); + module.ReferenceTypesCache.Add (element, pc); } return pc; } - - public static void Reset () - { - instances = new Dictionary (); - } } class PointerContainer : ElementTypeSpec { - static Dictionary instances = new Dictionary (); - private PointerContainer (TypeSpec element) : base (MemberKind.PointerType, element, null) { @@ -1496,20 +1605,15 @@ namespace Mono.CSharp return "*"; } - public static PointerContainer MakeType (TypeSpec element) + public static PointerContainer MakeType (ModuleContainer module, TypeSpec element) { PointerContainer pc; - if (!instances.TryGetValue (element, out pc)) { + if (!module.PointerTypesCache.TryGetValue (element, out pc)) { pc = new PointerContainer (element); - instances.Add (element, pc); + module.PointerTypesCache.Add (element, pc); } return pc; } - - public static void Reset () - { - instances = new Dictionary (); - } } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/visit.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/visit.cs index 80819ee59..9ec4d2580 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/visit.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Parser/mcs/visit.cs @@ -76,7 +76,11 @@ namespace Mono.CSharp public virtual void Visit (UsingsBag.AliasUsing aliasUsing) { } - + + public virtual void Visit (UsingsBag.ExternAlias externAlias) + { + } + public virtual void Visit (Class c) { VisitTypeContainer (c); @@ -405,7 +409,12 @@ namespace Mono.CSharp { return null; } - + + public virtual object Visit (DefaultParameterValueExpression defaultParameterValueExpression) + { + return null; + } + public virtual object Visit (Binary binaryExpression) { return null; diff --git a/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj index e8fdec0b5..0ac90b2d3 100644 --- a/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj +++ b/NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj @@ -15,7 +15,6 @@ False false 1591,0618 - Client False -Microsoft.Design#CA1026;-Microsoft.Security#CA2104 @@ -41,16 +40,11 @@ False - Full - false 4 true - None - true 4 - false @@ -164,8 +158,6 @@ - - @@ -351,6 +343,16 @@ + + + + + + + + + + @@ -358,8 +360,5 @@ Mono.Cecil - - - \ No newline at end of file diff --git a/NRefactory/NRefactory.sln b/NRefactory/NRefactory.sln index 24aed9f13..15d03f493 100644 --- a/NRefactory/NRefactory.sln +++ b/NRefactory/NRefactory.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.0.1.7096 +# SharpDevelop 4.1.0.7372-alpha Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DC98210E-1646-483B-819A-2BB8272461E4}" ProjectSection(SolutionItems) = postProject README = README @@ -14,7 +14,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Demo", "ICSharpCode.NRefactory.Demo\ICSharpCode.NRefactory.Demo.csproj", "{9C19E629-C93E-4ACB-9A4B-13072B5AEF9D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBDomGenerator", "VBDomGenerator\VBDomGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBAstGenerator", "VBAstGenerator\VBAstGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB", "ICSharpCode.NRefactory.VB\ICSharpCode.NRefactory.VB.csproj", "{7B82B671-419F-45F4-B778-D9286F996EFA}" EndProject diff --git a/NRefactory/README b/NRefactory/README index ea347e6d3..551448567 100644 --- a/NRefactory/README +++ b/NRefactory/README @@ -15,7 +15,7 @@ ICSharpCode.NRefactory.CSharp.Resolver: ICSharpCode.NRefactory.Util: Various helper classes. -ICSharpCode.NRefactory.VB.Dom: (in the separate ICSharpCode.NRefactory.VB assembly) +ICSharpCode.NRefactory.VB.Ast: (in the separate ICSharpCode.NRefactory.VB assembly) Abstract Syntax Tree for VB Dependencies: diff --git a/NRefactory/VBDomGenerator/.gitignore b/NRefactory/VBAstGenerator/.gitignore similarity index 100% rename from NRefactory/VBDomGenerator/.gitignore rename to NRefactory/VBAstGenerator/.gitignore diff --git a/NRefactory/VBDomGenerator/AssemblyInfo.cs b/NRefactory/VBAstGenerator/AssemblyInfo.cs similarity index 93% rename from NRefactory/VBDomGenerator/AssemblyInfo.cs rename to NRefactory/VBAstGenerator/AssemblyInfo.cs index de620a227..8139fe99c 100644 --- a/NRefactory/VBDomGenerator/AssemblyInfo.cs +++ b/NRefactory/VBAstGenerator/AssemblyInfo.cs @@ -10,8 +10,8 @@ using System.Runtime.CompilerServices; // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("VB Dom Generator")] -[assembly: AssemblyDescription("Parser and refactoring library for C# and VB.NET")] +[assembly: AssemblyTitle("VB Ast Generator")] +[assembly: AssemblyDescription("Parser and refactoring library for VB.NET")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("ic#code")] [assembly: AssemblyProduct("SharpDevelop")] diff --git a/NRefactory/VBDomGenerator/Dom/Expressions.cs b/NRefactory/VBAstGenerator/Ast/Expressions.cs similarity index 99% rename from NRefactory/VBDomGenerator/Dom/Expressions.cs rename to NRefactory/VBAstGenerator/Ast/Expressions.cs index 450a355cc..f0a1701d2 100644 --- a/NRefactory/VBDomGenerator/Dom/Expressions.cs +++ b/NRefactory/VBAstGenerator/Ast/Expressions.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace VBDomGenerator.Dom +namespace VBAstGenerator.Ast { [CustomImplementation] abstract class Expression : AbstractNode, INullable {} diff --git a/NRefactory/VBDomGenerator/Dom/GlobalLevel.cs b/NRefactory/VBAstGenerator/Ast/GlobalLevel.cs similarity index 99% rename from NRefactory/VBDomGenerator/Dom/GlobalLevel.cs rename to NRefactory/VBAstGenerator/Ast/GlobalLevel.cs index 428e36b50..64b4ec05c 100644 --- a/NRefactory/VBDomGenerator/Dom/GlobalLevel.cs +++ b/NRefactory/VBAstGenerator/Ast/GlobalLevel.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace VBDomGenerator.Dom +namespace VBAstGenerator.Ast { [CustomImplementation, HasChildren] class CompilationUnit : AbstractNode {} diff --git a/NRefactory/VBDomGenerator/Dom/Node.cs b/NRefactory/VBAstGenerator/Ast/Node.cs similarity index 98% rename from NRefactory/VBDomGenerator/Dom/Node.cs rename to NRefactory/VBAstGenerator/Ast/Node.cs index 4e57449d6..c1cce36dc 100644 --- a/NRefactory/VBDomGenerator/Dom/Node.cs +++ b/NRefactory/VBAstGenerator/Ast/Node.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace VBDomGenerator.Dom +namespace VBAstGenerator.Ast { interface INode {} interface INullable {} diff --git a/NRefactory/VBDomGenerator/Dom/Statements.cs b/NRefactory/VBAstGenerator/Ast/Statements.cs similarity index 99% rename from NRefactory/VBDomGenerator/Dom/Statements.cs rename to NRefactory/VBAstGenerator/Ast/Statements.cs index 9792988ec..482595443 100644 --- a/NRefactory/VBDomGenerator/Dom/Statements.cs +++ b/NRefactory/VBAstGenerator/Ast/Statements.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace VBDomGenerator.Dom +namespace VBAstGenerator.Ast { [CustomImplementation] abstract class Statement : AbstractNode, INullable {} diff --git a/NRefactory/VBDomGenerator/Dom/TypeLevel.cs b/NRefactory/VBAstGenerator/Ast/TypeLevel.cs similarity index 99% rename from NRefactory/VBDomGenerator/Dom/TypeLevel.cs rename to NRefactory/VBAstGenerator/Ast/TypeLevel.cs index a60902c48..47814c293 100644 --- a/NRefactory/VBDomGenerator/Dom/TypeLevel.cs +++ b/NRefactory/VBAstGenerator/Ast/TypeLevel.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace VBDomGenerator.Dom +namespace VBAstGenerator.Ast { class VariableDeclaration : AbstractNode { diff --git a/NRefactory/VBDomGenerator/Attributes.cs b/NRefactory/VBAstGenerator/Attributes.cs similarity index 99% rename from NRefactory/VBDomGenerator/Attributes.cs rename to NRefactory/VBAstGenerator/Attributes.cs index 0159cc006..9a655ccda 100644 --- a/NRefactory/VBDomGenerator/Attributes.cs +++ b/NRefactory/VBAstGenerator/Attributes.cs @@ -6,7 +6,7 @@ using System.CodeDom; using System.Reflection; using ICSharpCode.EasyCodeDom; -namespace VBDomGenerator +namespace VBAstGenerator { public enum NullableImplementation { @@ -146,7 +146,7 @@ namespace VBDomGenerator CodeMemberMethod method = new CodeMemberMethod(); method.Name = "AcceptVisitor"; method.Attributes = MemberAttributes.Public | MemberAttributes.Override; - method.Parameters.Add(new CodeParameterDeclarationExpression("IDomVisitor", "visitor")); + method.Parameters.Add(new CodeParameterDeclarationExpression("IAstVisitor", "visitor")); method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "data")); method.ReturnType = new CodeTypeReference(typeof(object)); method.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); diff --git a/NRefactory/VBDomGenerator/EasyCodeDom.cs b/NRefactory/VBAstGenerator/EasyCodeDom.cs similarity index 100% rename from NRefactory/VBDomGenerator/EasyCodeDom.cs rename to NRefactory/VBAstGenerator/EasyCodeDom.cs diff --git a/NRefactory/VBDomGenerator/KeywordGenerator.cs b/NRefactory/VBAstGenerator/KeywordGenerator.cs similarity index 99% rename from NRefactory/VBDomGenerator/KeywordGenerator.cs rename to NRefactory/VBAstGenerator/KeywordGenerator.cs index 7dbbc363f..f1a0bc576 100644 --- a/NRefactory/VBDomGenerator/KeywordGenerator.cs +++ b/NRefactory/VBAstGenerator/KeywordGenerator.cs @@ -9,7 +9,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; -namespace VBDomGenerator +namespace VBAstGenerator { static class KeywordGenerator { diff --git a/NRefactory/VBDomGenerator/Main.cs b/NRefactory/VBAstGenerator/Main.cs similarity index 90% rename from NRefactory/VBDomGenerator/Main.cs rename to NRefactory/VBAstGenerator/Main.cs index 54ac9dd90..718521129 100644 --- a/NRefactory/VBDomGenerator/Main.cs +++ b/NRefactory/VBAstGenerator/Main.cs @@ -7,10 +7,10 @@ using System.CodeDom; using System.Diagnostics; using System.Reflection; using System.IO; -using VBDomGenerator.Dom; +using VBAstGenerator.Ast; using ICSharpCode.EasyCodeDom; -namespace VBDomGenerator +namespace VBAstGenerator { class MainClass { @@ -20,15 +20,15 @@ namespace VBDomGenerator public static void Main(string[] args) { - string directory = "../../../ICSharpCode.NRefactory.VB/Dom/"; + string directory = "../../../ICSharpCode.NRefactory.VB/Ast/"; string visitorsDir = "../../../ICSharpCode.NRefactory.VB/Visitors/"; - Debug.WriteLine("DOM Generator running..."); + Debug.WriteLine("AST Generator running..."); if (!File.Exists(directory + "INode.cs")) { Debug.WriteLine("did not find output directory"); return; } - if (!File.Exists(visitorsDir + "AbstractDomTransformer.cs")) { + if (!File.Exists(visitorsDir + "AbstractAstTransformer.cs")) { Debug.WriteLine("did not find visitor output directory"); return; } @@ -42,7 +42,7 @@ namespace VBDomGenerator nodeTypes.Sort(delegate(Type a, Type b) { return a.Name.CompareTo(b.Name); }); CodeCompileUnit ccu = new CodeCompileUnit(); - CodeNamespace cns = ccu.AddNamespace("ICSharpCode.NRefactory.VB.Dom"); + CodeNamespace cns = ccu.AddNamespace("ICSharpCode.NRefactory.VB.Ast"); cns.AddImport("System"); cns.AddImport("System.Collections.Generic"); foreach (Type type in nodeTypes) { @@ -65,7 +65,7 @@ namespace VBDomGenerator CodeMemberMethod method = new CodeMemberMethod(); method.Name = "AcceptVisitor"; method.Attributes = MemberAttributes.Public | MemberAttributes.Override; - method.Parameters.Add(new CodeParameterDeclarationExpression("IDomVisitor", "visitor")); + method.Parameters.Add(new CodeParameterDeclarationExpression("IAstVisitor", "visitor")); method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "data")); method.ReturnType = new CodeTypeReference(typeof(object)); CodeExpression ex = new CodeVariableReferenceExpression("visitor"); @@ -97,12 +97,12 @@ namespace VBDomGenerator ccu = new CodeCompileUnit(); cns = ccu.AddNamespace("ICSharpCode.NRefactory.VB"); cns.AddImport("System"); - cns.AddImport("ICSharpCode.NRefactory.VB.Dom"); - cns.Types.Add(CreateDomVisitorInterface(nodeTypes)); + cns.AddImport("ICSharpCode.NRefactory.VB.Ast"); + cns.Types.Add(CreateAstVisitorInterface(nodeTypes)); using (StringWriter writer = new StringWriter()) { new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); - File.WriteAllText(visitorsDir + "../IDomVisitor.cs", NormalizeNewLines(writer)); + File.WriteAllText(visitorsDir + "../IAstVisitor.cs", NormalizeNewLines(writer)); } ccu = new CodeCompileUnit(); @@ -110,12 +110,12 @@ namespace VBDomGenerator cns.AddImport("System"); cns.AddImport("System.Collections.Generic"); cns.AddImport("System.Diagnostics"); - cns.AddImport("ICSharpCode.NRefactory.VB.Dom"); - cns.Types.Add(CreateDomVisitorClass(nodeTypes, false)); + cns.AddImport("ICSharpCode.NRefactory.VB.Ast"); + cns.Types.Add(CreateAstVisitorClass(nodeTypes, false)); using (StringWriter writer = new StringWriter()) { new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); - File.WriteAllText(visitorsDir + "AbstractDomVisitor.cs", NormalizeNewLines(writer)); + File.WriteAllText(visitorsDir + "AbstractAstVisitor.cs", NormalizeNewLines(writer)); } ccu = new CodeCompileUnit(); @@ -123,37 +123,37 @@ namespace VBDomGenerator cns.AddImport("System"); cns.AddImport("System.Collections.Generic"); cns.AddImport("System.Diagnostics"); - cns.AddImport("ICSharpCode.NRefactory.VB.Dom"); - cns.Types.Add(CreateDomVisitorClass(nodeTypes, true)); + cns.AddImport("ICSharpCode.NRefactory.VB.Ast"); + cns.Types.Add(CreateAstVisitorClass(nodeTypes, true)); using (StringWriter writer = new StringWriter()) { new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); - File.WriteAllText(visitorsDir + "AbstractDomTransformer.cs", NormalizeNewLines(writer)); + File.WriteAllText(visitorsDir + "AbstractAstTransformer.cs", NormalizeNewLines(writer)); } ccu = new CodeCompileUnit(); cns = ccu.AddNamespace("ICSharpCode.NRefactory.VB.Visitors"); cns.AddImport("System"); - cns.AddImport("ICSharpCode.NRefactory.VB.Dom"); - cns.Types.Add(CreateNodeTrackingDomVisitorClass(nodeTypes)); + cns.AddImport("ICSharpCode.NRefactory.VB.Ast"); + cns.Types.Add(CreateNodeTrackingAstVisitorClass(nodeTypes)); using (StringWriter writer = new StringWriter()) { new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); // CodeDom cannot output "sealed", so we need to use this hack: - File.WriteAllText(visitorsDir + "NodeTrackingDomVisitor.cs", + File.WriteAllText(visitorsDir + "NodeTrackingAstVisitor.cs", NormalizeNewLines(writer).Replace("public override object", "public sealed override object")); } - //NotImplementedDomVisitor + //NotImplementedAstVisitor ccu = new CodeCompileUnit(); cns = ccu.AddNamespace("ICSharpCode.NRefactory.VB.Visitors"); cns.AddImport("System"); - cns.AddImport("ICSharpCode.NRefactory.VB.Dom"); - cns.Types.Add(CreateNotImplementedDomVisitorClass(nodeTypes)); + cns.AddImport("ICSharpCode.NRefactory.VB.Ast"); + cns.Types.Add(CreateNotImplementedAstVisitorClass(nodeTypes)); using (StringWriter writer = new StringWriter()) { new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); - File.WriteAllText(visitorsDir + "NotImplementedDomVisitor.cs", NormalizeNewLines(writer)); + File.WriteAllText(visitorsDir + "NotImplementedAstVisitor.cs", NormalizeNewLines(writer)); } Debug.WriteLine("DOM Generator done!"); @@ -169,9 +169,9 @@ namespace VBDomGenerator return string.Join(Environment.NewLine, writer.ToString().Split(lineEndings, StringSplitOptions.None)); } - static CodeTypeDeclaration CreateDomVisitorInterface(List nodeTypes) + static CodeTypeDeclaration CreateAstVisitorInterface(List nodeTypes) { - CodeTypeDeclaration td = new CodeTypeDeclaration("IDomVisitor"); + CodeTypeDeclaration td = new CodeTypeDeclaration("IAstVisitor"); td.IsInterface = true; foreach (Type t in nodeTypes) { @@ -184,17 +184,17 @@ namespace VBDomGenerator return td; } - static CodeTypeDeclaration CreateDomVisitorClass(List nodeTypes, bool transformer) + static CodeTypeDeclaration CreateAstVisitorClass(List nodeTypes, bool transformer) { - CodeTypeDeclaration td = new CodeTypeDeclaration(transformer ? "AbstractDomTransformer" : "AbstractDomVisitor"); + CodeTypeDeclaration td = new CodeTypeDeclaration(transformer ? "AbstractAstTransformer" : "AbstractAstVisitor"); td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Abstract; - td.BaseTypes.Add(new CodeTypeReference("IDomVisitor")); + td.BaseTypes.Add(new CodeTypeReference("IAstVisitor")); if (transformer) { string comment = - "The AbstractDomTransformer will iterate through the whole Dom,\n " + - "just like the AbstractDomVisitor. However, the AbstractDomTransformer allows\n " + - "you to modify the Dom at the same time: It does not use 'foreach' internally,\n " + + "The AbstractAstTransformer will iterate through the whole Ast,\n " + + "just like the AbstractAstVisitor. However, the AbstractAstTransformer allows\n " + + "you to modify the Ast at the same time: It does not use 'foreach' internally,\n " + "so you can add members to collections of parents of the current node (but\n " + "you cannot insert or delete items as that will make the index used invalid).\n " + "You can use the methods ReplaceCurrentNode and RemoveCurrentNode to replace\n " + @@ -493,24 +493,24 @@ namespace VBDomGenerator tr.TypeArguments.Add(ConvertType(subType)); } return tr; - } else if (type.FullName.StartsWith("VBDom") || type.FullName.StartsWith("System.Collections")) { + } else if (type.FullName.StartsWith("VBAst") || type.FullName.StartsWith("System.Collections")) { if (type.Name == "Attribute") - return new CodeTypeReference("ICSharpCode.NRefactory.VB.Dom.Attribute"); + return new CodeTypeReference("ICSharpCode.NRefactory.VB.Ast.Attribute"); return new CodeTypeReference(type.Name); } else { return new CodeTypeReference(type); } } - static CodeTypeDeclaration CreateNodeTrackingDomVisitorClass(List nodeTypes) + static CodeTypeDeclaration CreateNodeTrackingAstVisitorClass(List nodeTypes) { - CodeTypeDeclaration td = new CodeTypeDeclaration("NodeTrackingDomVisitor"); + CodeTypeDeclaration td = new CodeTypeDeclaration("NodeTrackingAstVisitor"); td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Abstract; - td.BaseTypes.Add(new CodeTypeReference("AbstractDomVisitor")); + td.BaseTypes.Add(new CodeTypeReference("AbstractAstVisitor")); string comment = "\n " + - "The NodeTrackingDomVisitor will iterate through the whole Dom,\n " + - "just like the AbstractDomVisitor, and calls the virtual methods\n " + + "The NodeTrackingAstVisitor will iterate through the whole Ast,\n " + + "just like the AbstractAstVisitor, and calls the virtual methods\n " + "BeginVisit and EndVisit for each node being visited.\n " + ""; td.Comments.Add(new CodeCommentStatement(comment, true)); @@ -562,14 +562,14 @@ namespace VBDomGenerator return td; } - static CodeTypeDeclaration CreateNotImplementedDomVisitorClass(List nodeTypes) + static CodeTypeDeclaration CreateNotImplementedAstVisitorClass(List nodeTypes) { - CodeTypeDeclaration td = new CodeTypeDeclaration("NotImplementedDomVisitor"); + CodeTypeDeclaration td = new CodeTypeDeclaration("NotImplementedAstVisitor"); td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class; - td.BaseTypes.Add(new CodeTypeReference("IDomVisitor")); + td.BaseTypes.Add(new CodeTypeReference("IAstVisitor")); string comment = "\n " + - "IDomVisitor implementation that always throws NotImplementedExceptions.\n " + + "IAstVisitor implementation that always throws NotImplementedExceptions.\n " + ""; td.Comments.Add(new CodeCommentStatement(comment, true)); diff --git a/NRefactory/VBDomGenerator/VBDomGenerator.csproj b/NRefactory/VBAstGenerator/VBAstGenerator.csproj similarity index 84% rename from NRefactory/VBDomGenerator/VBDomGenerator.csproj rename to NRefactory/VBAstGenerator/VBAstGenerator.csproj index c9e014b1f..cbc0bb47e 100644 --- a/NRefactory/VBDomGenerator/VBDomGenerator.csproj +++ b/NRefactory/VBAstGenerator/VBAstGenerator.csproj @@ -2,8 +2,8 @@ Exe - VBDomGenerator - VBDomGenerator + VBAstGenerator + VBAstGenerator Debug AnyCPU {B22522AA-B5BF-4A58-AC6D-D4B45805521F} @@ -50,15 +50,15 @@ - + - - - - + + + + - + \ No newline at end of file