From a07bea82ea5fa77fe50b76742446c7651a3ea3d5 Mon Sep 17 00:00:00 2001 From: Ronny Klier Date: Mon, 6 Jun 2011 09:54:04 +0200 Subject: [PATCH 01/28] Decompile string resources in .resources TreeNodes and show them in a table. --- ILSpy/Controls/ResourceStringTable.xaml | 20 +++++++++++ ILSpy/Controls/ResourceStringTable.xaml.cs | 36 +++++++++++++++++++ ILSpy/ILSpy.csproj | 6 ++++ .../ResourceNodes/ResourcesFileTreeNode.cs | 25 +++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 ILSpy/Controls/ResourceStringTable.xaml create mode 100644 ILSpy/Controls/ResourceStringTable.xaml.cs diff --git a/ILSpy/Controls/ResourceStringTable.xaml b/ILSpy/Controls/ResourceStringTable.xaml new file mode 100644 index 000000000..47663dc68 --- /dev/null +++ b/ILSpy/Controls/ResourceStringTable.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Controls/ResourceStringTable.xaml.cs b/ILSpy/Controls/ResourceStringTable.xaml.cs new file mode 100644 index 000000000..3c7aa04ff --- /dev/null +++ b/ILSpy/Controls/ResourceStringTable.xaml.cs @@ -0,0 +1,36 @@ +/* + * Created by SharpDevelop. + * User: Ronny Klier + * Date: 31.05.2011 + * Time: 00:13 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; + +namespace ICSharpCode.ILSpy.Controls +{ + /// + /// Interaction logic for ResourceStringTable.xaml + /// + public partial class ResourceStringTable : UserControl + { + public ResourceStringTable(IEnumerable strings) + { + InitializeComponent(); + // set size to fit decompiler window + // TODO: there should be a more transparent way to do this + MaxWidth = MainWindow.Instance.mainPane.ActualWidth-20; + MaxHeight = MainWindow.Instance.mainPane.ActualHeight-100; + resourceListView.ItemsSource = strings; + } + } +} \ No newline at end of file diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 9090a9a0a..64e99b05c 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -68,6 +68,7 @@ 3.5 + 4.0 @@ -101,6 +102,10 @@ + + ResourceStringTable.xaml + Code + DecompilerSettingsPanel.xaml Code @@ -246,6 +251,7 @@ + SearchBox.cs diff --git a/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs b/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs index a99e2a989..1b686c2da 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs @@ -18,10 +18,15 @@ using System; using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel.Composition; using System.IO; using System.Linq; using System.Resources; + +using ICSharpCode.Decompiler; +using ICSharpCode.ILSpy.Controls; using Mono.Cecil; namespace ICSharpCode.ILSpy.TreeNodes @@ -46,6 +51,8 @@ namespace ICSharpCode.ILSpy.TreeNodes sealed class ResourcesFileTreeNode : ResourceTreeNode { + ICollection> filteredEntries = new ObservableCollection>(); + public ResourcesFileTreeNode(EmbeddedResource er) : base(er) { @@ -75,8 +82,26 @@ namespace ICSharpCode.ILSpy.TreeNodes Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), (Stream)entry.Value)); else if (entry.Value is byte[]) Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), new MemoryStream((byte[])entry.Value))); + else if (entry.Value is String) + filteredEntries.Add(new KeyValuePair(entry.Key.ToString(), (string)entry.Value)); } } } + + public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) + { + base.Decompile(language, output, options); + if (null == filteredEntries) + return; + ISmartTextOutput smartOutput = output as ISmartTextOutput; + if (null != smartOutput) { + smartOutput.AddUIElement( + delegate { + return new ResourceStringTable(filteredEntries); + } + ); + } + output.WriteLine(); + } } } From 77c2411b6d8604b9c2c7babc200a534228288fef Mon Sep 17 00:00:00 2001 From: Ronny Klier Date: Wed, 8 Jun 2011 22:01:11 +0200 Subject: [PATCH 02/28] Decompile contents of resource file nodes + non-Stream resources --- .../BamlResourceNodeFactory.cs | 6 +++--- ILSpy.sln | 8 ++++---- .../ResourceNodes/CursorResourceEntryNode.cs | 15 ++++++++++++--- .../ResourceNodes/IResourceNodeFactory.cs | 2 +- .../ResourceNodes/ImageResourceEntryNode.cs | 18 ++++++++++++++++-- .../ResourceNodes/ResourceEntryNode.cs | 4 ++-- .../ResourceNodes/ResourcesFileTreeNode.cs | 10 +++++----- .../ResourceNodes/XamlResourceNode.cs | 6 +++--- .../TreeNodes/ResourceNodes/XmlResourceNode.cs | 10 +++++++--- 9 files changed, 53 insertions(+), 26 deletions(-) diff --git a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs index a1b77fb6b..21ea662a6 100644 --- a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs +++ b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs @@ -18,10 +18,10 @@ namespace ILSpy.BamlDecompiler return null; } - public ILSpyTreeNode CreateNode(string key, Stream data) + public ILSpyTreeNode CreateNode(string key, object data) { - if (key.EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) - return new BamlResourceEntryNode(key, data); + if (key.EndsWith(".baml", StringComparison.OrdinalIgnoreCase) && data is Stream) + return new BamlResourceEntryNode(key, (Stream)data); else return null; } diff --git a/ILSpy.sln b/ILSpy.sln index 3888446b9..b1c88f93c 100644 --- a/ILSpy.sln +++ b/ILSpy.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.1.0.7590-alpha +# SharpDevelop 4.0.1.7126 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{F45DB999-7E72-4000-B5AD-3A7B485A0896}" ProjectSection(SolutionItems) = postProject doc\Command Line.txt = doc\Command Line.txt @@ -11,10 +11,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{89 ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Debugger", "Debugger\ILSpy.Debugger\ILSpy.Debugger.csproj", "{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Debugger", "Debugger\ILSpy.Debugger\ILSpy.Debugger.csproj", "{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}" @@ -146,7 +146,7 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {89C4A682-2706-44A3-ADDC-BC273164C37E} {6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A} = {89C4A682-2706-44A3-ADDC-BC273164C37E} + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {89C4A682-2706-44A3-ADDC-BC273164C37E} EndGlobalSection EndGlobal diff --git a/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs index 3170f0992..956d3bcac 100644 --- a/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs @@ -40,11 +40,13 @@ namespace ICSharpCode.ILSpy.TreeNodes return null; } - public ILSpyTreeNode CreateNode(string key, Stream data) + public ILSpyTreeNode CreateNode(string key, object data) { + if (!(data is Stream)) + return null; foreach (string fileExt in imageFileExtensions) { if (key.EndsWith(fileExt, StringComparison.OrdinalIgnoreCase)) - return new CursorResourceEntryNode(key, data); + return new CursorResourceEntryNode(key, (Stream)data); } return null; } @@ -71,7 +73,14 @@ namespace ICSharpCode.ILSpy.TreeNodes //HACK: windows imaging does not understand that .cur files have the same layout as .ico // so load to data, and modify the ResourceType in the header to make look like an icon... - byte[] curData = ((MemoryStream)Data).ToArray(); + MemoryStream s = Data as MemoryStream; + if (null == s) + { + // data was stored in another stream type (e.g. PinnedBufferedMemoryStream) + s = new MemoryStream(); + Data.CopyTo(s); + } + byte[] curData = s.ToArray(); curData[2] = 1; using (Stream stream = new MemoryStream(curData)) { image.BeginInit(); diff --git a/ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs b/ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs index 49d5f4893..c19cbfeda 100644 --- a/ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs +++ b/ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs @@ -28,6 +28,6 @@ namespace ICSharpCode.ILSpy.TreeNodes public interface IResourceNodeFactory { ILSpyTreeNode CreateNode(Resource resource); - ILSpyTreeNode CreateNode(string key, Stream data); + ILSpyTreeNode CreateNode(string key, object data); } } diff --git a/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs index 94e894961..b2d2d60b9 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs @@ -40,11 +40,25 @@ namespace ICSharpCode.ILSpy.TreeNodes return null; } - public ILSpyTreeNode CreateNode(string key, Stream data) + public ILSpyTreeNode CreateNode(string key, object data) { + if (data is System.Drawing.Icon) + { + MemoryStream s = new MemoryStream(); + ((System.Drawing.Icon)data).Save(s); + return new ImageResourceEntryNode(key, s); + } + else if (data is System.Drawing.Image) + { + MemoryStream s = new MemoryStream(); + ((System.Drawing.Image)data).Save(s, System.Drawing.Imaging.ImageFormat.Bmp); + return new ImageResourceEntryNode(key, s); + } + if (!(data is Stream)) + return null; foreach (string fileExt in imageFileExtensions) { if (key.EndsWith(fileExt, StringComparison.OrdinalIgnoreCase)) - return new ImageResourceEntryNode(key, data); + return new ImageResourceEntryNode(key, (Stream)data); } return null; } diff --git a/ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs index fa2cff797..da58bde8f 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs @@ -62,7 +62,7 @@ namespace ICSharpCode.ILSpy.TreeNodes this.data = data; } - public static ILSpyTreeNode Create(string key, Stream data) + public static ILSpyTreeNode Create(string key, object data) { ILSpyTreeNode result = null; foreach (var factory in App.CompositionContainer.GetExportedValues()) { @@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy.TreeNodes if (result != null) break; } - return result ?? new ResourceEntryNode(key, data); + return result ?? new ResourceEntryNode(key, data as Stream); } public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) diff --git a/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs b/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs index 1b686c2da..ede880e10 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs @@ -43,7 +43,7 @@ namespace ICSharpCode.ILSpy.TreeNodes return null; } - public ILSpyTreeNode CreateNode(string key, Stream data) + public ILSpyTreeNode CreateNode(string key, object data) { return null; } @@ -78,12 +78,12 @@ namespace ICSharpCode.ILSpy.TreeNodes return; } foreach (DictionaryEntry entry in reader.Cast().OrderBy(e => e.Key.ToString())) { - if (entry.Value is Stream) - Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), (Stream)entry.Value)); + if (entry.Value is String) + filteredEntries.Add(new KeyValuePair(entry.Key.ToString(), (string)entry.Value)); else if (entry.Value is byte[]) Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), new MemoryStream((byte[])entry.Value))); - else if (entry.Value is String) - filteredEntries.Add(new KeyValuePair(entry.Key.ToString(), (string)entry.Value)); + else + Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), entry.Value)); } } } diff --git a/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs b/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs index 13912e348..d148d1f4b 100644 --- a/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs @@ -35,10 +35,10 @@ namespace ICSharpCode.ILSpy.Xaml return null; } - public ILSpyTreeNode CreateNode(string key, Stream data) + public ILSpyTreeNode CreateNode(string key, object data) { - if (key.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) - return new XamlResourceEntryNode(key, data); + if (key.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase) && data is Stream) + return new XamlResourceEntryNode(key, (Stream)data); else return null; } diff --git a/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs b/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs index ce2f1e1d4..9aa8d96ea 100644 --- a/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs @@ -41,12 +41,16 @@ namespace ICSharpCode.ILSpy.Xaml return null; } - public ILSpyTreeNode CreateNode(string key, Stream data) + public ILSpyTreeNode CreateNode(string key, object data) { + if (!(data is Stream)) + return null; foreach (string fileExt in xmlFileExtensions) + { if (key.EndsWith(fileExt, StringComparison.OrdinalIgnoreCase)) - return new XmlResourceEntryNode(key, data); - return null; + return new XmlResourceEntryNode(key, (Stream)data); + } + return null; } } From 7d3df0490395aa115ea40afc1d1e8f42d328e136 Mon Sep 17 00:00:00 2001 From: Ronny Klier Date: Wed, 15 Jun 2011 22:23:18 +0200 Subject: [PATCH 03/28] First part to support copy from string table --- ILSpy/Controls/ResourceStringTable.xaml | 5 +++++ ILSpy/Controls/ResourceStringTable.xaml.cs | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ILSpy/Controls/ResourceStringTable.xaml b/ILSpy/Controls/ResourceStringTable.xaml index 47663dc68..925b0367c 100644 --- a/ILSpy/Controls/ResourceStringTable.xaml +++ b/ILSpy/Controls/ResourceStringTable.xaml @@ -1,6 +1,11 @@  + + + diff --git a/ILSpy/Controls/ResourceStringTable.xaml.cs b/ILSpy/Controls/ResourceStringTable.xaml.cs index 3c7aa04ff..347667228 100644 --- a/ILSpy/Controls/ResourceStringTable.xaml.cs +++ b/ILSpy/Controls/ResourceStringTable.xaml.cs @@ -32,5 +32,18 @@ namespace ICSharpCode.ILSpy.Controls MaxHeight = MainWindow.Instance.mainPane.ActualHeight-100; resourceListView.ItemsSource = strings; } + + void ExecuteCopy(object sender, ExecutedRoutedEventArgs args) + { + if (resourceListView.SelectionMode == SelectionMode.Single) + return; + else if (resourceListView.SelectionMode == SelectionMode.Multiple) + return; + } + + void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args) + { + args.CanExecute = true; + } } } \ No newline at end of file From a318ce67bed3482bae7ea13a92ab124c315fe7db Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 17 Jun 2011 20:15:33 +0200 Subject: [PATCH 04/28] Cache assembly lookup results - improves performance (especially for failed lookups) --- ILSpy/AssemblyList.cs | 4 ++++ ILSpy/LoadedAssembly.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ILSpy/AssemblyList.cs b/ILSpy/AssemblyList.cs index 9585d71f0..d49ed3c23 100644 --- a/ILSpy/AssemblyList.cs +++ b/ILSpy/AssemblyList.cs @@ -41,6 +41,8 @@ namespace ICSharpCode.ILSpy /// Dirty flag, used to mark modifications so that the list is saved later bool dirty; + internal readonly ConcurrentDictionary assemblyLookupCache = new ConcurrentDictionary(); + /// /// The assemblies in this list. /// Needs locking for multi-threaded access! @@ -101,6 +103,7 @@ namespace ICSharpCode.ILSpy void Assemblies_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { + assemblyLookupCache.Clear(); // Whenever the assembly list is modified, mark it as dirty // and enqueue a task that saves it once the UI has finished modifying the assembly list. if (!dirty) { @@ -111,6 +114,7 @@ namespace ICSharpCode.ILSpy delegate { dirty = false; AssemblyListManager.SaveList(this); + assemblyLookupCache.Clear(); }) ); } diff --git a/ILSpy/LoadedAssembly.cs b/ILSpy/LoadedAssembly.cs index 147044157..fdfb2636b 100644 --- a/ILSpy/LoadedAssembly.cs +++ b/ILSpy/LoadedAssembly.cs @@ -17,11 +17,11 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Collections.Concurrent; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows.Threading; - using Mono.Cecil; namespace ICSharpCode.ILSpy @@ -133,6 +133,8 @@ namespace ICSharpCode.ILSpy if (!disposed) { disposed = true; assemblyLoadDisableCount--; + // clear the lookup cache since we might have stored the lookups failed due to DisableAssemblyLoad() + MainWindow.Instance.CurrentAssemblyList.assemblyLookupCache.Clear(); } } } @@ -177,6 +179,11 @@ namespace ICSharpCode.ILSpy } public LoadedAssembly LookupReferencedAssembly(string fullName) + { + return assemblyList.assemblyLookupCache.GetOrAdd(fullName, LookupReferencedAssemblyInternal); + } + + LoadedAssembly LookupReferencedAssemblyInternal(string fullName) { foreach (LoadedAssembly asm in assemblyList.GetAssemblies()) { if (asm.AssemblyDefinition != null && fullName.Equals(asm.AssemblyDefinition.FullName, StringComparison.OrdinalIgnoreCase)) From 2783b020079a26e8e82ad503a3d5a6143fb8d55b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 17 Jun 2011 22:24:22 +0200 Subject: [PATCH 05/28] Fix #241: type analysis causes truncation of integer literals when calculating with types smaller than int32. --- .../ILAst/InitializerPeepholeTransforms.cs | 38 +++++++++++++------ ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs | 37 +++++++++++++++++- .../Tests/ICSharpCode.Decompiler.Tests.csproj | 1 + ICSharpCode.Decompiler/Tests/TestRunner.cs | 6 +++ .../Tests/TypeAnalysisTests.cs | 27 +++++++++++++ 5 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs diff --git a/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs b/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs index 1a9ad78cf..bde84e828 100644 --- a/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs +++ b/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs @@ -93,9 +93,9 @@ namespace ICSharpCode.Decompiler.ILAst List ctorArgs; ArrayType arrayType; if (expr.Match(ILCode.Stloc, out v, out newarrExpr) && - newarrExpr.Match(ILCode.Newobj, out ctor, out ctorArgs) && - (arrayType = (ctor.DeclaringType as ArrayType)) != null && - arrayType.Rank == ctorArgs.Count) { + newarrExpr.Match(ILCode.Newobj, out ctor, out ctorArgs) && + (arrayType = (ctor.DeclaringType as ArrayType)) != null && + arrayType.Rank == ctorArgs.Count) { // Clone the type, so we can muck about with the Dimensions arrayType = new ArrayType(arrayType.ElementType, arrayType.Rank); var arrayLengths = new int[arrayType.Rank]; @@ -126,12 +126,12 @@ namespace ICSharpCode.Decompiler.ILAst ILExpression methodArg2; FieldDefinition field; if (body.ElementAtOrDefault(pos).Match(ILCode.Call, out methodRef, out methodArg1, out methodArg2) && - methodRef.DeclaringType.FullName == "System.Runtime.CompilerServices.RuntimeHelpers" && - methodRef.Name == "InitializeArray" && - methodArg1.Match(ILCode.Ldloc, out v2) && - array == v2 && - methodArg2.Match(ILCode.Ldtoken, out field) && - field != null && field.InitialValue != null) { + methodRef.DeclaringType.FullName == "System.Runtime.CompilerServices.RuntimeHelpers" && + methodRef.Name == "InitializeArray" && + methodArg1.Match(ILCode.Ldloc, out v2) && + array == v2 && + methodArg2.Match(ILCode.Ldtoken, out field) && + field != null && field.InitialValue != null) { ILExpression[] newArr = new ILExpression[arrayLength]; if (DecodeArrayInitializer(TypeAnalysis.GetTypeCode(arrayType.GetElementType()), field.InitialValue, newArr)) { values = newArr; @@ -148,7 +148,6 @@ namespace ICSharpCode.Decompiler.ILAst { switch (elementType) { case TypeCode.Boolean: - case TypeCode.SByte: case TypeCode.Byte: if (initialValue.Length == output.Length) { for (int j = 0; j < output.Length; j++) { @@ -157,9 +156,15 @@ namespace ICSharpCode.Decompiler.ILAst return true; } return false; - case TypeCode.Char: + case TypeCode.SByte: + if (initialValue.Length == output.Length) { + for (int j = 0; j < output.Length; j++) { + output[j] = new ILExpression(ILCode.Ldc_I4, (int)unchecked((sbyte)initialValue[j])); + } + return true; + } + return false; case TypeCode.Int16: - case TypeCode.UInt16: if (initialValue.Length == output.Length * 2) { for (int j = 0; j < output.Length; j++) { output[j] = new ILExpression(ILCode.Ldc_I4, (int)BitConverter.ToInt16(initialValue, j * 2)); @@ -167,6 +172,15 @@ namespace ICSharpCode.Decompiler.ILAst return true; } return false; + case TypeCode.Char: + case TypeCode.UInt16: + if (initialValue.Length == output.Length * 2) { + for (int j = 0; j < output.Length; j++) { + output[j] = new ILExpression(ILCode.Ldc_I4, (int)BitConverter.ToUInt16(initialValue, j * 2)); + } + return true; + } + return false; case TypeCode.Int32: case TypeCode.UInt32: if (initialValue.Length == output.Length * 4) { diff --git a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs index 4755ea4c7..d7678dd54 100644 --- a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs +++ b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs @@ -543,9 +543,19 @@ namespace ICSharpCode.Decompiler.ILAst case ILCode.Ldc_I4: if (IsBoolean(expectedType) && ((int)expr.Operand == 0 || (int)expr.Operand == 1)) return typeSystem.Boolean; - return (IsIntegerOrEnum(expectedType) || expectedType is PointerType) ? expectedType : typeSystem.Int32; + if (expectedType is PointerType && (int)expr.Operand == 0) + return expectedType; + if (IsIntegerOrEnum(expectedType) && OperandFitsInType(expectedType, (int)expr.Operand)) + return expectedType; + else + return typeSystem.Int32; case ILCode.Ldc_I8: - return (IsIntegerOrEnum(expectedType) || expectedType is PointerType) ? expectedType : typeSystem.Int64; + if (expectedType is PointerType && (long)expr.Operand == 0) + return expectedType; + if (IsIntegerOrEnum(expectedType) && GetInformationAmount(expectedType) >= NativeInt) + return expectedType; + else + return typeSystem.Int64; case ILCode.Ldc_R4: return typeSystem.Single; case ILCode.Ldc_R8: @@ -1043,6 +1053,29 @@ namespace ICSharpCode.Decompiler.ILAst } } + static bool OperandFitsInType(TypeReference type, int num) + { + TypeDefinition typeDef = type.Resolve() as TypeDefinition; + if (typeDef != null && typeDef.IsEnum) { + type = typeDef.Fields.Single(f => f.IsRuntimeSpecialName && !f.IsStatic).FieldType; + } + switch (type.MetadataType) { + case MetadataType.SByte: + return sbyte.MinValue <= num && num <= sbyte.MaxValue; + case MetadataType.Int16: + return short.MinValue <= num && num <= short.MaxValue; + case MetadataType.Byte: + return byte.MinValue <= num && num <= byte.MaxValue; + case MetadataType.Char: + return char.MinValue <= num && num <= char.MaxValue; + case MetadataType.UInt16: + return ushort.MinValue <= num && num <= ushort.MaxValue; + break; + default: + return true; + } + } + static bool IsArrayPointerOrReference(TypeReference type) { TypeSpecification typeSpec = type as TypeSpecification; diff --git a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj index 13af1018c..a3bcddf9e 100644 --- a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj @@ -63,6 +63,7 @@ + diff --git a/ICSharpCode.Decompiler/Tests/TestRunner.cs b/ICSharpCode.Decompiler/Tests/TestRunner.cs index cdfde87af..f6d21fde1 100644 --- a/ICSharpCode.Decompiler/Tests/TestRunner.cs +++ b/ICSharpCode.Decompiler/Tests/TestRunner.cs @@ -142,6 +142,12 @@ namespace ICSharpCode.Decompiler.Tests TestFile(@"..\..\Tests\YieldReturn.cs"); } + [Test] + public void TypeAnalysis() + { + TestFile(@"..\..\Tests\TypeAnalysisTests.cs"); + } + static void TestFile(string fileName) { string code = File.ReadAllText(fileName); diff --git a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs new file mode 100644 index 000000000..813005933 --- /dev/null +++ b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs @@ -0,0 +1,27 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; + +public class TypeAnalysisTests +{ + public byte SubtractFrom256(byte b) + { + return (byte)(256 - (int)b); + } +} From 891f8a4f627ae8eb2177256235efac51f81933da Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 20 Jun 2011 23:02:26 +0200 Subject: [PATCH 06/28] remove some classes from BAML decompiler, that are no longer needed --- .../ILSpy.BamlDecompiler.csproj | 5 - .../AppDomainTypeResolver.cs | 183 ------------------ .../BamlAssembly.cs | 112 ----------- .../BamlFile.cs | 80 -------- .../DotNetType.cs | 64 ------ .../WpfDependencyPropertyDescriptor.cs | 35 ---- .../XmlBamlReader.cs | 5 - 7 files changed, 484 deletions(-) delete mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/AppDomainTypeResolver.cs delete mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlAssembly.cs delete mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlFile.cs delete mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/DotNetType.cs delete mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/WpfDependencyPropertyDescriptor.cs diff --git a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj index 88aa520f9..8e2f0c90b 100644 --- a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj +++ b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj @@ -80,12 +80,8 @@ - - - - @@ -94,7 +90,6 @@ - diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/AppDomainTypeResolver.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/AppDomainTypeResolver.cs deleted file mode 100644 index b33379323..000000000 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/AppDomainTypeResolver.cs +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) Cristian Civera (cristian@aspitalia.com) -// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using System.Text; -using System.IO; -using System.Linq; -using Microsoft.Win32; -using System.Threading; -using System.Security.Permissions; -using System.Security; - -namespace Ricciolo.StylesExplorer.MarkupReflection -{ - public delegate void AssemblyResolveEventHandler(object s, AssemblyResolveEventArgs e); - - public class AppDomainTypeResolver : MarshalByRefObject, ITypeResolver - { - private readonly AppDomain _domain; - private string baseDir; - - public event AssemblyResolveEventHandler AssemblyResolve; - - public static AppDomainTypeResolver GetIntoNewAppDomain(string baseDir) - { - AppDomainSetup info = new AppDomainSetup(); - info.ApplicationBase = Environment.CurrentDirectory; - AppDomain domain = AppDomain.CreateDomain("AppDomainTypeResolver", null, info, new PermissionSet(PermissionState.Unrestricted)); - AppDomainTypeResolver resolver = (AppDomainTypeResolver)domain.CreateInstanceAndUnwrap(typeof(AppDomainTypeResolver).Assembly.FullName, - typeof(AppDomainTypeResolver).FullName, false, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, new object[] { domain, baseDir }, null, null, null); - - return resolver; - } - - Assembly domain_AssemblyResolve(object sender, ResolveEventArgs args) - { - // Cerco di risolvere automaticamente - AssemblyName name = new AssemblyName(args.Name); - string fileName = Path.Combine(this.baseDir, name.Name + ".exe"); - if (!File.Exists(fileName)) - fileName = Path.Combine(this.baseDir, name.Name + ".dll"); - - // Carico il percorso autocalcolato - if (File.Exists(fileName)) - return Assembly.LoadFile(fileName); - - if (AssemblyResolve != null) - { - AssemblyResolveEventArgs e = new AssemblyResolveEventArgs(args.Name, this.baseDir); - AssemblyResolve(this, e); - if (!String.IsNullOrEmpty(e.Location) && File.Exists(e.Location)) - return Assembly.LoadFile(e.Location); - } - - return null; - } - - public static void DestroyResolver(AppDomainTypeResolver resolver) - { - if (resolver == null) throw new ArgumentNullException("resolver"); - - ThreadPool.QueueUserWorkItem(delegate - { - AppDomain.Unload(resolver.Domain); - }); - } - - protected AppDomainTypeResolver(AppDomain domain, string baseDir) - { - _domain = domain; - this.baseDir = baseDir; - - domain.AssemblyResolve += new ResolveEventHandler(domain_AssemblyResolve); - } - - public BamlAssembly LoadAssembly(AssemblyName asm) - { - //return new BamlAssembly(Assembly.Load(asm)); - return new BamlAssembly(_domain.Load(asm)); - } - - public BamlAssembly LoadAssembly(string location) - { - Assembly asm = Assembly.LoadFile(location); - return new BamlAssembly(asm); - //return _domain.Load(System.IO.File.ReadAllBytes(location)); - //return Assembly.LoadFrom(location); - } - - public BamlAssembly[] GetReferencedAssemblies(BamlAssembly asm) - { - AssemblyName[] list = asm.Assembly.GetReferencedAssemblies(); - - return (from an in list - select this.LoadAssembly(an)).ToArray(); - } - - public AppDomain Domain - { - get { return _domain; } - } - - #region ITypeResolver Members - - public IType GetTypeByAssemblyQualifiedName(string name) - { - return new DotNetType(name); - } - - public IDependencyPropertyDescriptor GetDependencyPropertyDescriptor(string name, IType ownerType, IType targetType) - { - if (name == null) throw new ArgumentNullException("name"); - if (ownerType == null) throw new ArgumentNullException("ownerType"); - if (targetType == null) throw new ArgumentNullException("targetType"); - - Type dOwnerType = ((DotNetType)ownerType).Type; - Type dTargetType = ((DotNetType)targetType).Type; - - try - { - DependencyPropertyDescriptor propertyDescriptor = DependencyPropertyDescriptor.FromName(name, dOwnerType, dTargetType); - if (propertyDescriptor != null) - return new WpfDependencyPropertyDescriptor(propertyDescriptor); - return null; - } - catch (Exception) - { - return null; - } - } - - public bool IsLocalAssembly(string name) - { - return false; - } - - public string RuntimeVersion { - get { - throw new NotImplementedException(); - } - } - - #endregion - - public override object InitializeLifetimeService() - { - return null; - } - } - - public class AssemblyResolveEventArgs : MarshalByRefObject - { - - private string _location; - private string _name; - private string _baseDir; - - public AssemblyResolveEventArgs(string name, string baseDir) - { - _name = name; - _baseDir = baseDir; - } - - public string Location - { - get { return _location; } - set { _location = value; } - } - - public string Name - { - get { return _name; } - } - - public string BaseDir - { - get { return _baseDir; } - } - } -} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlAssembly.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlAssembly.cs deleted file mode 100644 index d9d71860f..000000000 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlAssembly.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) Cristian Civera (cristian@aspitalia.com) -// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Reflection; -using System.Resources; -using System.Text; - -namespace Ricciolo.StylesExplorer.MarkupReflection -{ - public class BamlAssembly : MarshalByRefObject - { - private readonly string _filePath; - private Assembly _assembly; - private BamlFileList _bamlFile; - - public BamlAssembly(Assembly assembly) - { - _assembly = assembly; - _filePath = assembly.CodeBase; - - ReadBaml(); - } - - public BamlAssembly(string filePath) - { - this._filePath = Path.GetFullPath(filePath); - this._assembly = Assembly.LoadFile(this.FilePath); - if (String.Compare(this.Assembly.CodeBase, this.FilePath, true) != 0) - throw new ArgumentException("Cannot load filePath because Assembly is already loaded", "filePath"); - - ReadBaml(); - } - - private void ReadBaml() - { - // Get available names - string[] resources = this.Assembly.GetManifestResourceNames(); - foreach (string res in resources) - { - // Solo le risorse - if (String.Compare(Path.GetExtension(res), ".resources", true) != 0) continue; - - // Get stream - using (Stream stream = this.Assembly.GetManifestResourceStream(res)) - { - try - { - ResourceReader reader = new ResourceReader(stream); - foreach (DictionaryEntry entry in reader) - { - if (String.Compare(Path.GetExtension(entry.Key.ToString()), ".baml", true) == 0 && entry.Value is Stream) - { - BamlFile bm = new BamlFile(GetAssemblyResourceUri(entry.Key.ToString()), (Stream)entry.Value); - this.BamlFiles.Add(bm); - } - } - } - catch (ArgumentException) - {} - } - } - } - - private Uri GetAssemblyResourceUri(string resourceName) - { - AssemblyName asm = this.Assembly.GetName(); - byte[] data = asm.GetPublicKeyToken(); - StringBuilder token = new StringBuilder(data.Length * 2); - for (int x = 0; x < data.Length; x++) - { - token.Append(data[x].ToString("x", System.Globalization.CultureInfo.InvariantCulture)); - } - - return new Uri(String.Format(@"{0};V{1};{2};component\{3}", asm.Name, asm.Version, token, Path.ChangeExtension(resourceName, ".xaml")), UriKind.RelativeOrAbsolute); - } - - public string FilePath - { - get { return _filePath; } - } - - public Assembly Assembly - { - get { return _assembly; } - } - - public BamlFileList BamlFiles - { - get - { - if (_bamlFile == null) - _bamlFile = new BamlFileList(); - return _bamlFile; - } - } - - public override object InitializeLifetimeService() - { - return null; - } - } - - [Serializable()] - public class BamlFileList : Collection - {} - -} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlFile.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlFile.cs deleted file mode 100644 index d4af6bb81..000000000 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlFile.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Cristian Civera (cristian@aspitalia.com) -// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Resources; -using System.Text; -using System.Windows; - -namespace Ricciolo.StylesExplorer.MarkupReflection -{ - /// - /// Rappresenta un singole file Baml all'interno di un assembly - /// - public class BamlFile : Component - { - private Uri _uri; - private readonly Stream _stream; - - public BamlFile(Uri uri, Stream stream) - { - if (uri == null) - new ArgumentNullException("uri"); - if (stream == null) - throw new ArgumentNullException("stream"); - - _uri = uri; - _stream = stream; - } - - /// - /// Carica il Baml attraverso il motore di WPF con Application.LoadComponent - /// - /// - public object LoadContent() - { - try - { - return Application.LoadComponent(this.Uri); - } - catch (Exception e) - { - throw new InvalidOperationException("Invalid baml file.", e); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - this.Stream.Dispose(); - } - - public override object InitializeLifetimeService() - { - return null; - } - - /// - /// Restituisce lo stream originale contenente il Baml - /// - public Stream Stream - { - get { return _stream; } - } - - /// - /// Restituisce l'indirizzo secondo lo schema pack:// - /// - public Uri Uri - { - get { return _uri; } - } - - } -} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/DotNetType.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/DotNetType.cs deleted file mode 100644 index 313863bd0..000000000 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/DotNetType.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Cristian Civera (cristian@aspitalia.com) -// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Ricciolo.StylesExplorer.MarkupReflection -{ - public class DotNetType : MarshalByRefObject, IType - { - private readonly string _assemblyQualifiedName; - private Type _type; - - public DotNetType(string assemblyQualifiedName) - { - if (assemblyQualifiedName == null) throw new ArgumentNullException("assemblyQualifiedName"); - - _assemblyQualifiedName = assemblyQualifiedName; - _type = Type.GetType(assemblyQualifiedName, false, true); - } - - #region IType Members - - public string AssemblyQualifiedName - { - get { return _assemblyQualifiedName; } - } - - public bool IsSubclassOf(IType type) - { - if (type == null) throw new ArgumentNullException("type"); - if (!(type is DotNetType)) throw new ArgumentException("type"); - if (_type == null) return false; - return this._type.IsSubclassOf(((DotNetType)type).Type); - } - - public bool Equals(IType type) - { - if (type == null) throw new ArgumentNullException("type"); - if (!(type is DotNetType)) throw new ArgumentException("type"); - if (_type == null) return false; - return this._type.Equals(((DotNetType)type).Type); - } - - public IType BaseType { - get { - return new DotNetType(this._type.BaseType.AssemblyQualifiedName); - } - } - - #endregion - - public Type Type - { - get { return _type; } - } - - public override object InitializeLifetimeService() - { - return null; - } - } -} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/WpfDependencyPropertyDescriptor.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/WpfDependencyPropertyDescriptor.cs deleted file mode 100644 index 2ac19f1a5..000000000 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/WpfDependencyPropertyDescriptor.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Cristian Civera (cristian@aspitalia.com) -// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; - -namespace Ricciolo.StylesExplorer.MarkupReflection -{ - public class WpfDependencyPropertyDescriptor : MarshalByRefObject, IDependencyPropertyDescriptor - { - private readonly DependencyPropertyDescriptor _propertyDescriptor; - - public WpfDependencyPropertyDescriptor(DependencyPropertyDescriptor propertyDescriptor) - { - if (propertyDescriptor == null) throw new ArgumentNullException("propertyDescriptor"); - _propertyDescriptor = propertyDescriptor; - } - - #region IDependencyPropertyDescriptor Members - - public bool IsAttached - { - get { return _propertyDescriptor.IsAttached; } - } - - #endregion - - public override object InitializeLifetimeService() - { - return null; - } - } -} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index eb5887901..36518286f 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -112,11 +112,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection public const string XWPFNamespace = "http://schemas.microsoft.com/winfx/2006/xaml"; public const string DefaultWPFNamespace = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"; - public XmlBamlReader(Stream stream) : this (stream, AppDomainTypeResolver.GetIntoNewAppDomain(Environment.CurrentDirectory)) - { - - } - public XmlBamlReader(Stream stream, ITypeResolver resolver) { if (stream == null) From 19a8087be02ad2b39c30d6fe67c0ae7388584a92 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 21 Jun 2011 14:03:49 +0200 Subject: [PATCH 07/28] add support for nested classes in type system - fix missing Win32Native.Color --- .../CecilDependencyPropertyDescriptor.cs | 3 + ILSpy.BamlDecompiler/CecilType.cs | 2 + ILSpy.BamlDecompiler/CecilTypeResolver.cs | 2 +- .../KnownInfo.cs | 2 +- .../TypeDeclaration.cs | 80 +++++++------------ .../XmlBamlElement.cs | 19 ++--- .../XmlBamlPropertyElement.cs | 2 +- .../XmlBamlReader.cs | 8 +- 8 files changed, 46 insertions(+), 72 deletions(-) diff --git a/ILSpy.BamlDecompiler/CecilDependencyPropertyDescriptor.cs b/ILSpy.BamlDecompiler/CecilDependencyPropertyDescriptor.cs index 9a0e1e559..21806b21f 100644 --- a/ILSpy.BamlDecompiler/CecilDependencyPropertyDescriptor.cs +++ b/ILSpy.BamlDecompiler/CecilDependencyPropertyDescriptor.cs @@ -2,6 +2,7 @@ // This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) using System; +using System.Diagnostics; using System.Linq; using ICSharpCode.ILSpy; using Mono.Cecil; @@ -16,6 +17,8 @@ namespace ILSpy.BamlDecompiler public CecilDependencyPropertyDescriptor(string member, TypeDefinition type) { + if (type == null) + throw new ArgumentNullException("type"); this.member = member; this.type = type; } diff --git a/ILSpy.BamlDecompiler/CecilType.cs b/ILSpy.BamlDecompiler/CecilType.cs index e84f95938..d41cac4c9 100644 --- a/ILSpy.BamlDecompiler/CecilType.cs +++ b/ILSpy.BamlDecompiler/CecilType.cs @@ -15,6 +15,8 @@ namespace ILSpy.BamlDecompiler public CecilType(TypeDefinition type) { + if (type == null) + throw new ArgumentNullException("type"); this.type = type; } diff --git a/ILSpy.BamlDecompiler/CecilTypeResolver.cs b/ILSpy.BamlDecompiler/CecilTypeResolver.cs index bc42696ea..1bc79ab11 100644 --- a/ILSpy.BamlDecompiler/CecilTypeResolver.cs +++ b/ILSpy.BamlDecompiler/CecilTypeResolver.cs @@ -52,7 +52,7 @@ namespace ILSpy.BamlDecompiler var otherAssembly = resolver.Resolve(assemblyName); if (otherAssembly == null) throw new Exception("could not resolve '" + assemblyName + "'!"); - type = otherAssembly.MainModule.GetType(fullName); + type = otherAssembly.MainModule.GetType(fullName.Replace('+', '/')); } return new CecilType(type); diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs index 81d7bea20..93651741a 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs @@ -127,7 +127,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection KnownTypeTable[0x4e] = new TypeDeclaration(resolver, "CollectionContainer", "System.Windows.Data", 0); KnownTypeTable[0x4f] = new TypeDeclaration(resolver, "CollectionView", "System.Windows.Data", 0); KnownTypeTable[80] = new TypeDeclaration(resolver, "CollectionViewSource", "System.Windows.Data", 0); - KnownTypeTable[0x51] = new TypeDeclaration(resolver, "Color", "Microsoft.Win32", 2); + KnownTypeTable[0x51] = new TypeDeclaration(resolver, "Color", "Win32Native", "Microsoft.Win32", 2); KnownTypeTable[0x52] = new TypeDeclaration(resolver, "ColorAnimation", "System.Windows.Media.Animation", 1); KnownTypeTable[0x53] = new TypeDeclaration(resolver, "ColorAnimationBase", "System.Windows.Media.Animation", 1); KnownTypeTable[0x54] = new TypeDeclaration(resolver, "ColorAnimationUsingKeyFrames", "System.Windows.Media.Animation", 1); diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/TypeDeclaration.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/TypeDeclaration.cs index 2acc523f4..e42dd24ce 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/TypeDeclaration.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/TypeDeclaration.cs @@ -8,11 +8,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection internal class TypeDeclaration { private readonly XmlBamlReader reader; - - private readonly short _assemblyId; - private readonly bool _isKnown; - private readonly string _name; - private readonly string _namespaceName; private readonly bool _isExtension; private IType _type; private bool _typeLoaded; @@ -21,7 +16,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection public TypeDeclaration(ITypeResolver resolver, string name, string namespaceName, short assemblyId) : this(null, resolver, name, namespaceName, assemblyId, true) { + } + public TypeDeclaration(ITypeResolver resolver, string name, string enclosingTypeName, string namespaceName, short assemblyId) + : this(null, resolver, name, namespaceName, assemblyId, true) + { + this.EnclosingTypeName = enclosingTypeName; } public TypeDeclaration(ITypeResolver resolver, string name, string namespaceName, short assemblyId, bool isExtension) @@ -39,10 +39,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection { this.reader = reader; this.resolver = resolver; - this._name = name; - this._namespaceName = namespaceName; - this._assemblyId = assemblyId; - this._isKnown = isKnown; + this.Name = name; + this.Namespace = namespaceName; + this.AssemblyId = assemblyId; + this.IsKnown = isKnown; if (!_isExtension) _isExtension = name.EndsWith("Extension"); @@ -50,8 +50,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection public override string ToString() { - return this._name; + return this.Name; } + + public string EnclosingTypeName { get; private set; } public bool IsExtension { @@ -60,8 +62,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection public string Assembly { - get - { + get { if (reader != null) return this.reader.GetAssembly(this.AssemblyId); else @@ -69,46 +70,19 @@ namespace Ricciolo.StylesExplorer.MarkupReflection } } - public short AssemblyId - { - get { return _assemblyId; } - } + public short AssemblyId { get; private set; } - public string Name - { - get - { - return this._name; - } - } + public string Name { get; private set; } - public bool IsKnown - { - get { return _isKnown; } - } + public bool IsKnown { get; private set; } - //public Type DotNetType - //{ - // get - // { - // if (!_typeLoaded) - // { - // _type = Type.GetType(String.Format("{0}.{1}, {2}", this.Namespace, this.Name, this.Assembly), false, true); - // _typeLoaded = true; - // } - - // return _type; - // } - //} - - public IType Type - { + public IType Type { get { if (!_typeLoaded) { if (this.Name.Length > 0) - _type = resolver.GetTypeByAssemblyQualifiedName(String.Format("{0}.{1}, {2}", this.Namespace, this.Name, this.Assembly)); + _type = resolver.GetTypeByAssemblyQualifiedName(AssemblyQualifiedName); _typeLoaded = true; } @@ -116,26 +90,28 @@ namespace Ricciolo.StylesExplorer.MarkupReflection } } - public string Namespace - { - get - { - return this._namespaceName; - } + public string Namespace { get; private set; } + + public string FullyQualifiedName { + get { return EnclosingTypeName == null ? string.Format("{0}.{1}", Namespace, Name) : string.Format("{0}.{1}+{2}", Namespace, EnclosingTypeName, Name); } + } + + public string AssemblyQualifiedName { + get { return string.Format("{0}, {1}", FullyQualifiedName, Assembly); } } public override bool Equals(object obj) { TypeDeclaration td = obj as TypeDeclaration; if (td != null) - return (this.Name == td.Name && this.Namespace == td.Namespace && this.AssemblyId == td.AssemblyId); + return (this.Name == td.Name && this.EnclosingTypeName == td.EnclosingTypeName && this.Namespace == td.Namespace && this.AssemblyId == td.AssemblyId); else return false; } public override int GetHashCode() { - return this.AssemblyId ^ this.Name.GetHashCode() ^ this.Namespace.GetHashCode(); + return this.AssemblyId ^ this.Name.GetHashCode() ^ this.EnclosingTypeName.GetHashCode() ^ this.Namespace.GetHashCode(); } } diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs index 25d8f466f..fa3e5c971 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs @@ -23,8 +23,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection this.Namespaces.AddRange(parent.Namespaces); } - public XmlNamespaceCollection Namespaces - { + public XmlNamespaceCollection Namespaces { get { return _namespaces; } } @@ -42,11 +41,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection public override string ToString() { - return String.Format("Element: {0}", TypeDeclaration.Name); + return string.Format("Element: {0}", TypeDeclaration.Name); } } - internal class XmlBamlEndElement : XmlBamlElement + class XmlBamlEndElement : XmlBamlElement { public XmlBamlEndElement(XmlBamlElement start) { @@ -54,19 +53,13 @@ namespace Ricciolo.StylesExplorer.MarkupReflection this.Namespaces.AddRange(start.Namespaces); } - public override XmlNodeType NodeType - { - get - { - return XmlNodeType.EndElement; - } + public override XmlNodeType NodeType { + get { return XmlNodeType.EndElement; } } public override string ToString() { - return String.Format("EndElement: {0}", TypeDeclaration.Name); + return string.Format("EndElement: {0}", TypeDeclaration.Name); } } - - } diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs index a6ce053d9..2e428618b 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs @@ -41,7 +41,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection public override string ToString() { - return String.Format("PropertyElement: {0}.{1}", TypeDeclaration.Name, PropertyDeclaration.Name); + return String.Format("PropertyElement: {0}.{1}", TypeDeclaration.Name.Replace('+', '.'), PropertyDeclaration.Name); } } } diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 36518286f..959847552 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -632,9 +632,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection { get { - if (intoAttribute) return String.Empty; + if (intoAttribute) return string.Empty; - String localName = String.Empty; + String localName = string.Empty; XmlBamlNode node = this.CurrentNode; if (node is XmlBamlSimpleProperty) { @@ -1226,7 +1226,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection nodes.Enqueue(element); if (oldDeclaration != null) { - nodes.Enqueue(new XmlBamlSimpleProperty(XWPFNamespace, "Class", string.Format("{0}.{1}", oldDeclaration.Namespace, oldDeclaration.Name))); + nodes.Enqueue(new XmlBamlSimpleProperty(XWPFNamespace, "Class", oldDeclaration.FullyQualifiedName.Replace('+', '.'))); } if (parentElement != null && complexPropertyOpened == 0 && !Current.IsInStaticResource && Current.Previous.IsDeferred) { @@ -1590,7 +1590,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection TypeDeclaration GetKnownTypeDeclarationByName(string name) { foreach (var type in KnownInfo.KnownTypeTable) { - if (name == string.Format("{0}.{1}, {2}", type.Namespace, type.Name, type.Assembly)) + if (name == type.AssemblyQualifiedName) return type; } From c572835c9efad19f5ee3e711293d72baab821e78 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 21 Jun 2011 16:10:16 +0200 Subject: [PATCH 08/28] fixed InvalidCastException when trying to read optimized static resource --- .../XmlBamlReader.cs | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 959847552..875b1d1cf 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -334,7 +334,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection else currentType = (BamlRecordType)type; + if (currentType.ToString().EndsWith("End")) + Debug.Unindent(); Debug.WriteLine(string.Format("{0} (0x{0:x})", currentType)); + if (currentType.ToString().EndsWith("Start")) + Debug.Indent(); } bool SetNextNode() @@ -684,13 +688,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection object GetResourceName(short identifier) { - if (identifier >= 0) - { + if (identifier >= 0) { PropertyDeclaration declaration = this.propertyTable[identifier]; return declaration; - } - else - { + } else { identifier = (short)-identifier; bool isNotKey = (identifier > 0xe8); if (isNotKey) @@ -1404,27 +1405,28 @@ namespace Ricciolo.StylesExplorer.MarkupReflection void ReadOptimizedStaticResource() { - byte num = reader.ReadByte(); + byte flags = reader.ReadByte(); short typeIdentifier = reader.ReadInt16(); - bool isValueType = (num & 1) == 1; - bool isStaticType = (num & 2) == 2; + bool isValueType = (flags & 1) == 1; + bool isStaticType = (flags & 2) == 2; object resource; if (isValueType) - resource = this.GetTypeExtension(typeIdentifier); - else if (isStaticType) - { - ResourceName resourceName = (ResourceName)this.GetResourceName(typeIdentifier); - resource = GetStaticExtension(resourceName.Name); - } - else - { + resource = GetTypeExtension(typeIdentifier); + else if (isStaticType) { + object name = GetResourceName(typeIdentifier); + if (name is ResourceName) + resource = GetStaticExtension(((ResourceName)name).Name); + else if (name is PropertyDeclaration) + resource = GetStaticExtension(FormatPropertyDeclaration(((PropertyDeclaration)name), true, false, false)); + else + throw new InvalidOperationException("Invalid resource: " + name.GetType()); + } else { resource = this.stringTable[typeIdentifier]; } //this.staticResourceTable.Add(resource); isPartialDefKeysClosed = true; - // Aggiungo la risorsa nell'ultimo gruppo LastKey.StaticResources.Add(resource); } From b8fd7b4d995f503045a7fddfcc8e9c60d44bb5d9 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 21 Jun 2011 18:34:04 +0200 Subject: [PATCH 09/28] fixed static resource handling --- .../KeyMapping.cs | 6 +++++ .../XmlBamlReader.cs | 18 ++++++--------- .../Tests/Cases/Dictionary1.xaml | 23 +++++++++++++++++++ .../Tests/ILSpy.BamlDecompiler.Tests.csproj | 1 + ILSpy.BamlDecompiler/Tests/TestRunner.cs | 17 ++++++++++---- 5 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 ILSpy.BamlDecompiler/Tests/Cases/Dictionary1.xaml diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KeyMapping.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KeyMapping.cs index 0b20620fc..abda8e317 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KeyMapping.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KeyMapping.cs @@ -36,5 +36,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection this.staticResources = new List(); this.Position = -1; } + + public override string ToString() + { + return '"' + KeyString + '"'; + } + } } diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 875b1d1cf..4e8a4a693 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -41,9 +41,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection bool intoAttribute = false; bool initialized; bool _eof; - - bool isPartialDefKeysClosed = true; - bool isDefKeysClosed = true; #region Context Stack layer = new Stack(); @@ -994,6 +991,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection bool sharedSet = reader.ReadBoolean(); string text = this.stringTable[stringId]; + Debug.Print("KeyString: " + text); if (text == null) throw new NotSupportedException(); @@ -1425,8 +1423,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection resource = this.stringTable[typeIdentifier]; } - //this.staticResourceTable.Add(resource); - isPartialDefKeysClosed = true; LastKey.StaticResources.Add(resource); } @@ -1508,11 +1504,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection void ReadPropertyWithStaticResourceIdentifier() { - short identifier = reader.ReadInt16(); - short staticIdentifier = reader.ReadInt16(); + short propertyId = reader.ReadInt16(); + short index = reader.ReadInt16(); - PropertyDeclaration pd = this.GetPropertyDeclaration(identifier); - object staticResource = GetStaticResource(staticIdentifier); + PropertyDeclaration pd = this.GetPropertyDeclaration(propertyId); + object staticResource = GetStaticResource(index); string prefix = this.LookupPrefix(XmlPIMapping.PresentationNamespace, false); string value = String.Format("{{{0}{1}StaticResource {2}}}", prefix, (String.IsNullOrEmpty(prefix)) ? String.Empty : ":", staticResource); @@ -1525,8 +1521,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection object GetStaticResource(short identifier) { - if (identifier < LastKey.StaticResources.Count) - return LastKey.StaticResources[(int)identifier]; + if (identifier < keys[currentKey - 1].StaticResources.Count) + return keys[currentKey - 1].StaticResources[(int)identifier]; // return "???" + identifier +"???"; throw new ArgumentException("Cannot find StaticResource", "identifier"); diff --git a/ILSpy.BamlDecompiler/Tests/Cases/Dictionary1.xaml b/ILSpy.BamlDecompiler/Tests/Cases/Dictionary1.xaml new file mode 100644 index 000000000..594de1dad --- /dev/null +++ b/ILSpy.BamlDecompiler/Tests/Cases/Dictionary1.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj b/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj index b7174e31a..3b1d5c14d 100644 --- a/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj +++ b/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj @@ -128,6 +128,7 @@ + \ No newline at end of file diff --git a/ILSpy.BamlDecompiler/Tests/TestRunner.cs b/ILSpy.BamlDecompiler/Tests/TestRunner.cs index 6469bc081..df671eee4 100644 --- a/ILSpy.BamlDecompiler/Tests/TestRunner.cs +++ b/ILSpy.BamlDecompiler/Tests/TestRunner.cs @@ -61,18 +61,27 @@ namespace ILSpy.BamlDecompiler.Tests RunTest("cases/attachedevent"); } + [Test] + public void Dictionary1() + { + RunTest("cases/dictionary1"); + } + #region RunTest void RunTest(string name) { - string asmPath = typeof(TestRunner).Assembly.Location; + RunTest(name, typeof(TestRunner).Assembly.Location, Path.Combine("..\\..\\Tests", name + ".xaml")); + } + + void RunTest(string name, string asmPath, string sourcePath) + { var assembly = AssemblyDefinition.ReadAssembly(asmPath); Resource res = assembly.MainModule.Resources.First(); Stream bamlStream = LoadBaml(res, name + ".baml"); Assert.IsNotNull(bamlStream); XDocument document = BamlResourceEntryNode.LoadIntoDocument(new DefaultAssemblyResolver(), assembly, bamlStream); - string path = Path.Combine("..\\..\\Tests", name + ".xaml"); - - CodeAssert.AreEqual(File.ReadAllText(path), document.ToString()); + + CodeAssert.AreEqual(File.ReadAllText(sourcePath), document.ToString()); } Stream LoadBaml(Resource res, string name) From fa638010a9ec5a556eac1f7305ea83eb6d731fda Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 21 Jun 2011 21:07:42 +0200 Subject: [PATCH 10/28] some minor cleanup --- .../XmlBamlReader.cs | 68 ++++--------------- 1 file changed, 13 insertions(+), 55 deletions(-) diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 4e8a4a693..68ef01a93 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -76,13 +76,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection List keys = new List(); KeyMapping LastKey { - get { - KeyMapping last = keys.LastOrDefault(); - if (last == null) - keys.Add(last = new KeyMapping()); - - return last; - } + get { return keys.LastOrDefault(); } } void LayerPop() @@ -398,6 +392,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection break; case BamlRecordType.DeferableContentStart: Current.IsDeferred = true; + keys = new List(); + currentKey = 0; reader.ReadInt32(); break; case BamlRecordType.DefAttribute: @@ -1033,6 +1029,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection void ReadElementEnd() { CloseElement(); + if (Current.IsDeferred) + keys = null; LayerPop(); } @@ -1600,26 +1598,18 @@ namespace Ricciolo.StylesExplorer.MarkupReflection return this.assemblyTable[identifier]; } - XmlBamlNode CurrentNode - { - get - { - return _currentNode; - } + XmlBamlNode CurrentNode { + get { return _currentNode; } } /// ///When overridden in a derived class, gets the namespace URI (as defined in the W3C Namespace specification) of the node on which the reader is positioned. /// - /// /// ///The namespace URI of the current node; otherwise an empty string. /// - /// - public override string NamespaceURI - { - get - { + public override string NamespaceURI { + get { if (intoAttribute) return String.Empty; TypeDeclaration declaration; @@ -1657,11 +1647,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets the namespace prefix associated with the current node. /// - /// /// ///The namespace prefix associated with the current node. /// - /// public override string Prefix { get @@ -1675,11 +1663,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets a value indicating whether the current node can have a . /// - /// /// ///true if the node on which the reader is currently positioned can have a Value; otherwise, false. If false, the node has a value of String.Empty. /// - /// public override bool HasValue { get { return this.Value != null; } @@ -1696,11 +1682,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets the text value of the current node. /// - /// /// ///The value returned depends on the of the node. The following table lists node types that have a value to return. All other node types return String.Empty.Node type Value AttributeThe value of the attribute. CDATAThe content of the CDATA section. CommentThe content of the comment. DocumentTypeThe internal subset. ProcessingInstructionThe entire content, excluding the target. SignificantWhitespaceThe white space between markup in a mixed content model. TextThe content of the text node. WhitespaceThe white space between markup. XmlDeclarationThe content of the declaration. /// - /// public override string Value { get @@ -1730,11 +1714,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets the depth of the current node in the XML document. /// - /// /// ///The depth of the current node in the XML document. /// - /// public override int Depth { get { return this.readingElements.Count; } @@ -1743,11 +1725,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets the base URI of the current node. /// - /// /// ///The base URI of the current node. /// - /// public override string BaseURI { get { return String.Empty; } @@ -1756,62 +1736,42 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets a value indicating whether the current node is an empty element (for example, <MyElement/>). /// - /// /// ///true if the current node is an element ( equals XmlNodeType.Element) that ends with />; otherwise, false. /// - /// public override bool IsEmptyElement { get { return false; } } - //public override bool IsDefault - //{ - // get - // { - // return this.NamespaceURI == null; - // } - //} - /// ///When overridden in a derived class, gets the number of attributes on the current node. /// - /// /// ///The number of attributes on the current node. /// - /// - public override int AttributeCount - { + public override int AttributeCount { get { throw new NotImplementedException(); } } /// ///When overridden in a derived class, gets a value indicating whether the reader is positioned at the end of the stream. /// - /// /// ///true if the reader is positioned at the end of the stream; otherwise, false. /// - /// - public override bool EOF - { + public override bool EOF { get { return _eof; } } /// ///When overridden in a derived class, gets the state of the reader. /// - /// /// ///One of the values. /// - /// - public override ReadState ReadState - { - get - { + public override ReadState ReadState { + get { if (!initialized) return ReadState.Initial; else if (reader == null) @@ -1831,11 +1791,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection /// ///When overridden in a derived class, gets the associated with this implementation. /// - /// /// ///The XmlNameTable enabling you to get the atomized version of a string within the node. /// - /// public override XmlNameTable NameTable { get { return _nameTable; } From 4b1622e55e600c44cdd64c1ce47e1a8a89e38257 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 24 Jun 2011 00:03:46 +0200 Subject: [PATCH 11/28] fix wrong declaration info in KnownInfo --- .../Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs | 2 +- .../Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs index 93651741a..4cfd70d86 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs @@ -58,7 +58,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection KnownTypeTable[9] = new TypeDeclaration(resolver, "Animatable", "System.Windows.Media.Animaton", 1); KnownTypeTable[10] = new TypeDeclaration(resolver, "AnimationClock", "System.Windows.Media.Animation", 1); KnownTypeTable[11] = new TypeDeclaration(resolver, "AnimationTimeline", "System.Windows.Media.Animation", 1); - KnownTypeTable[12] = new TypeDeclaration(resolver, "Application", "System.Net.Mime", 3); + KnownTypeTable[12] = new TypeDeclaration(resolver, "Application", "System.Windows", 0); KnownTypeTable[13] = new TypeDeclaration(resolver, "ArcSegment", "System.Windows.Media", 1); KnownTypeTable[14] = new TypeDeclaration(resolver, "ArrayExtension", "System.Windows.Markup", 0); KnownTypeTable[15] = new TypeDeclaration(resolver, "AxisAngleRotation3D", "System.Windows.Media.Media3D", 1); diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 68ef01a93..4cf5adcc1 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -1590,7 +1590,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection return type; } - throw new NotSupportedException(); + throw new NotSupportedException("Type '" + name + "' not found!"); } internal string GetAssembly(short identifier) From 0eb3aabc7200db29431083bbd3587ce44c16642c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 24 Jun 2011 17:23:41 +0200 Subject: [PATCH 12/28] use generic enumerator --- .../XmlBamlReader.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index 4cf5adcc1..e2d1e7e25 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -1087,12 +1087,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection // this property could be a markup extension // try to convert it int start = nodes.IndexOf(propertyElement) + 1; - IEnumerator enumerator = nodes.GetEnumerator(); + IEnumerator enumerator = nodes.GetEnumerator(); // move enumerator to the start of this property value for (int i = 0; i < start && enumerator.MoveNext(); i++) ; - if (IsExtension(enumerator)) { + if (IsExtension(enumerator) && start < nodes.Count - 1) { start--; nodes.RemoveAt(start); nodes.RemoveLast(); @@ -1165,11 +1165,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection } } - bool IsExtension(IEnumerator enumerator) + bool IsExtension(IEnumerator enumerator) { while (enumerator.MoveNext()) { - object node = enumerator.Current; - if (node is XmlBamlElement && !(node is XmlBamlEndElement) && !((XmlBamlElement)node).TypeDeclaration.IsExtension) + var node = enumerator.Current; + if (node.NodeType == XmlNodeType.Element && !((XmlBamlElement)node).TypeDeclaration.IsExtension) return false; } From 8beed6aa70ae225f395198251c54b59c64c69c10 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 26 Jun 2011 01:39:45 +0200 Subject: [PATCH 13/28] Fixed type inference for shift operators. Closes #239. --- ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs | 33 +++++++++++++++++-- .../Tests/TypeAnalysisTests.cs | 30 +++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs index d7678dd54..d5d50f352 100644 --- a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs +++ b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs @@ -515,14 +515,20 @@ namespace ICSharpCode.Decompiler.ILAst case ILCode.Rem_Un: return InferArgumentsInBinaryOperator(expr, false, expectedType); case ILCode.Shl: - case ILCode.Shr: if (forceInferChildren) InferTypeForExpression(expr.Arguments[1], typeSystem.Int32); - return InferTypeForExpression(expr.Arguments[0], typeSystem.Int32); + if (expectedType != null && ( + expectedType.MetadataType == MetadataType.Int32 || expectedType.MetadataType == MetadataType.UInt32 || + expectedType.MetadataType == MetadataType.Int64 || expectedType.MetadataType == MetadataType.UInt64) + ) + return NumericPromotion(InferTypeForExpression(expr.Arguments[0], expectedType)); + else + return NumericPromotion(InferTypeForExpression(expr.Arguments[0], null)); + case ILCode.Shr: case ILCode.Shr_Un: if (forceInferChildren) InferTypeForExpression(expr.Arguments[1], typeSystem.Int32); - return InferTypeForExpression(expr.Arguments[0], typeSystem.UInt32); + return NumericPromotion(InferTypeForExpression(expr.Arguments[0], null)); case ILCode.CompoundAssignment: { TypeReference varType = InferTypeForExpression(expr.Arguments[0].Arguments[0], null); @@ -763,6 +769,27 @@ namespace ICSharpCode.Decompiler.ILAst } } + /// + /// Promotes primitive types smaller than int32 to int32. + /// + /// + /// Always promotes to signed int32. + /// + TypeReference NumericPromotion(TypeReference type) + { + if (type == null) + return null; + switch (type.MetadataType) { + case MetadataType.SByte: + case MetadataType.Int16: + case MetadataType.Byte: + case MetadataType.UInt16: + return typeSystem.Int32; + default: + return type; + } + } + TypeReference HandleConversion(int targetBitSize, bool targetSigned, ILExpression arg, TypeReference expectedType, TypeReference targetType) { if (targetBitSize >= NativeInt && expectedType is PointerType) { diff --git a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs index 813005933..034d0c8bf 100644 --- a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs +++ b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs @@ -24,4 +24,34 @@ public class TypeAnalysisTests { return (byte)(256 - (int)b); } + + public int GetHashCode(long num) + { + return (int)num ^ (int)(num >> 32); + } + + public int ShiftByte(byte num) + { + return (int)num << 8; + } + + public int RShiftByte(byte num) + { + return num >> 8; + } + + public int RShiftByteWithSignExtension(byte num) + { + return (sbyte)num >> 8; + } + + public int RShiftSByte(sbyte num) + { + return num >> 8; + } + + public int RShiftSByteWithZeroExtension(sbyte num) + { + return (byte)num >> 8; + } } From f4504ab36e459e40d4dff028a8f2448fb3ad21f3 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 24 Jun 2011 17:50:16 +0200 Subject: [PATCH 14/28] move NodesCollection to a separate file --- .../ILSpy.BamlDecompiler.csproj | 1 + .../NodesCollection.cs | 68 +++++++++++++++++++ .../XmlBamlReader.cs | 63 +---------------- 3 files changed, 71 insertions(+), 61 deletions(-) create mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs diff --git a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj index 8e2f0c90b..26b25f1d3 100644 --- a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj +++ b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj @@ -87,6 +87,7 @@ + diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs new file mode 100644 index 000000000..c2170b71c --- /dev/null +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs @@ -0,0 +1,68 @@ +// Copyright (c) Cristian Civera (cristian@aspitalia.com) +// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Xml; +using System.Windows.Media; + +namespace Ricciolo.StylesExplorer.MarkupReflection +{ + class NodesCollection : List + { + public XmlBamlNode Last + { + get + { + if (this.Count > 0) + { + int i = this.Count - 1; + return this[i]; + } + return null; + } + } + + public void RemoveLast() + { + if (this.Count > 0) + this.Remove(this.Last); + } + + public XmlBamlNode Dequeue() + { + return DequeueInternal(true); + } + + public XmlBamlNode Peek() + { + return DequeueInternal(false); + } + + XmlBamlNode DequeueInternal(bool remove) + { + if (this.Count > 0) + { + XmlBamlNode node = this[0]; + if (remove) + this.RemoveAt(0); + return node; + } + else + return null; + } + + public void Enqueue(XmlBamlNode node) + { + this.Add(node); + } + } +} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index e2d1e7e25..0c1ec8712 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -1334,9 +1334,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection CloseElement(); complexPropertyOpened--; - if (complexPropertyOpened == 0) - { - + if (complexPropertyOpened == 0) { int start = nodes.IndexOf(propertyElement); StringBuilder sb = new StringBuilder(); @@ -1465,8 +1463,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection return String.Format("{0}:{1}", prefix, name); } - - string FormatPropertyDeclaration(PropertyDeclaration propertyDeclaration, bool withPrefix, bool useReading, bool checkType) { StringBuilder sb = new StringBuilder(); @@ -1522,7 +1518,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection if (identifier < keys[currentKey - 1].StaticResources.Count) return keys[currentKey - 1].StaticResources[(int)identifier]; -// return "???" + identifier +"???"; +// return "???" + identifier + "???"; throw new ArgumentException("Cannot find StaticResource", "identifier"); } @@ -1889,60 +1885,5 @@ namespace Ricciolo.StylesExplorer.MarkupReflection } #endregion - - #region NodesCollection - - internal class NodesCollection : List - { - public XmlBamlNode Last - { - get - { - if (this.Count > 0) - { - int i = this.Count - 1; - return this[i]; - } - return null; - } - } - - public void RemoveLast() - { - if (this.Count > 0) - this.Remove(this.Last); - } - - public XmlBamlNode Dequeue() - { - return DequeueInternal(true); - } - - public XmlBamlNode Peek() - { - return DequeueInternal(false); - } - - XmlBamlNode DequeueInternal(bool remove) - { - if (this.Count > 0) - { - XmlBamlNode node = this[0]; - if (remove) - this.RemoveAt(0); - return node; - } - else - return null; - } - - - public void Enqueue(XmlBamlNode node) - { - this.Add(node); - } - } - - #endregion } } \ No newline at end of file From 80ed40e6a76f75ac88e223f5af8f3e54c22e8029 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 26 Jun 2011 14:02:13 +0200 Subject: [PATCH 15/28] move the focus to the previous node after deletion --- SharpTreeView/SharpTreeView.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SharpTreeView/SharpTreeView.cs b/SharpTreeView/SharpTreeView.cs index 683105f53..7d44e0744 100644 --- a/SharpTreeView/SharpTreeView.cs +++ b/SharpTreeView/SharpTreeView.cs @@ -152,6 +152,10 @@ namespace ICSharpCode.TreeView var list = SelectedItems.Cast().Except(selectedOldItems).ToList(); SetSelectedItems(list); } + // reset the focus to the previous node + SelectedIndex = Math.Max(0, e.OldStartingIndex - 1); + if (SelectedItem != null) + FocusNode((SharpTreeNode)SelectedItem); } } From fe7fdec28b7df0d660ed47c4ada6c8ef606bab9f Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 26 Jun 2011 14:55:31 +0200 Subject: [PATCH 16/28] display a message if navigation is not possible; fixes #237 --- ILSpy/MainWindow.xaml.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index 4425555af..5efcd8616 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -382,9 +382,16 @@ namespace ICSharpCode.ILSpy internal void SelectNode(SharpTreeNode obj) { if (obj != null) { - // Set both the selection and focus to ensure that keyboard navigation works as expected. - treeView.FocusNode(obj); - treeView.SelectedItem = obj; + if (!obj.AncestorsAndSelf().Any(node => node.IsHidden)) { + // Set both the selection and focus to ensure that keyboard navigation works as expected. + treeView.FocusNode(obj); + treeView.SelectedItem = obj; + } else { + MessageBox.Show("Navigation failed because the target is hidden or a compiler-generated class.\n" + + "Please disable all filters that might hide the item (i.e. activate " + + "\"View > Show internal types and members\") and try again.", + "ILSpy", MessageBoxButton.OK, MessageBoxImage.Exclamation); + } } } From 443a312901521f0a31ffcb96aa503b10db110fb3 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 26 Jun 2011 16:03:43 +0200 Subject: [PATCH 17/28] fix #227 and #229 --- ILSpy/XmlDoc/XmlDocKeyProvider.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ILSpy/XmlDoc/XmlDocKeyProvider.cs b/ILSpy/XmlDoc/XmlDocKeyProvider.cs index d4f1e646c..4e3673f26 100644 --- a/ILSpy/XmlDoc/XmlDocKeyProvider.cs +++ b/ILSpy/XmlDoc/XmlDocKeyProvider.cs @@ -169,6 +169,7 @@ namespace ICSharpCode.ILSpy.XmlDoc } else { dotPos = key.LastIndexOf('.'); } + if (dotPos < 0) return null; TypeDefinition type = FindType(module, key.Substring(2, dotPos - 2)); if (type == null) return null; @@ -192,6 +193,7 @@ namespace ICSharpCode.ILSpy.XmlDoc } else { ns = string.Empty; } + if (string.IsNullOrEmpty(name)) return null; TypeDefinition type = module.GetType(ns, name); if (type == null && ns.Length > 0) { // try if this is a nested type From 3fdfe1585a597686d9d6d864e06b0519a3583cd9 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 26 Jun 2011 16:40:20 +0200 Subject: [PATCH 18/28] fix #231 --- ILSpy/MainWindow.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index 5efcd8616..a1f5da3fc 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -198,6 +198,8 @@ namespace ICSharpCode.ILSpy } var args = new CommandLineArguments(lines); if (HandleCommandLineArguments(args)) { + if (!args.NoActivate && WindowState == WindowState.Minimized) + WindowState = WindowState.Normal; HandleCommandLineArgumentsAfterShowList(args); handled = true; return (IntPtr)1; From e63cbb6175ce5e719a3d8bcbf40f53df58abc19e Mon Sep 17 00:00:00 2001 From: Ronny Klier Date: Sun, 26 Jun 2011 23:57:03 +0200 Subject: [PATCH 19/28] Support copy entries from resource string table --- ILSpy/Controls/ResourceStringTable.xaml | 5 +++-- ILSpy/Controls/ResourceStringTable.xaml.cs | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ILSpy/Controls/ResourceStringTable.xaml b/ILSpy/Controls/ResourceStringTable.xaml index 925b0367c..e5782a33b 100644 --- a/ILSpy/Controls/ResourceStringTable.xaml +++ b/ILSpy/Controls/ResourceStringTable.xaml @@ -1,13 +1,14 @@  + x:Class="ICSharpCode.ILSpy.Controls.ResourceStringTable" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + Name="resourceListView" + SelectionMode="Extended"> diff --git a/ILSpy/Controls/ResourceStringTable.xaml.cs b/ILSpy/Controls/ResourceStringTable.xaml.cs index 347667228..b3aab0049 100644 --- a/ILSpy/Controls/ResourceStringTable.xaml.cs +++ b/ILSpy/Controls/ResourceStringTable.xaml.cs @@ -35,10 +35,12 @@ namespace ICSharpCode.ILSpy.Controls void ExecuteCopy(object sender, ExecutedRoutedEventArgs args) { - if (resourceListView.SelectionMode == SelectionMode.Single) - return; - else if (resourceListView.SelectionMode == SelectionMode.Multiple) - return; + StringBuilder sb = new StringBuilder(); + foreach (var item in resourceListView.SelectedItems) + { + sb.AppendLine(item.ToString()); + } + Clipboard.SetText(sb.ToString()); } void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args) From b9109469af002ac431ac7088a5a53603bfe478b6 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 28 Jun 2011 21:21:34 +0200 Subject: [PATCH 20/28] Fixed bug that could cause variable names to be used twice, resulting in a crash in DeclareVariable step. Closes #222. --- ICSharpCode.Decompiler/Ast/NameVariables.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/Ast/NameVariables.cs b/ICSharpCode.Decompiler/Ast/NameVariables.cs index 9b3632119..796897fee 100644 --- a/ICSharpCode.Decompiler/Ast/NameVariables.cs +++ b/ICSharpCode.Decompiler/Ast/NameVariables.cs @@ -139,7 +139,7 @@ namespace ICSharpCode.Decompiler.Ast typeNames.Add(nameWithoutDigits, number - 1); } int count = ++typeNames[nameWithoutDigits]; - if (count > 1) { + if (count != 1) { return nameWithoutDigits + count.ToString(); } else { return nameWithoutDigits; From 43b4339bead51caa042a2a687040b65f8b7cd1c1 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 28 Jun 2011 22:07:11 +0200 Subject: [PATCH 21/28] Simplify shift operators (<< and >>). Based on patch by Pent Ploompuu. --- .../ILAst/ILAstOptimizer.cs | 6 +++- .../ILAst/PeepholeTransform.cs | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs index 42c2893e5..60da4cbea 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs @@ -42,6 +42,7 @@ namespace ICSharpCode.Decompiler.ILAst SimplifyTernaryOperator, SimplifyNullCoalescing, JoinBasicBlocks, + SimplifyShiftOperators, TransformDecimalCtorToConstant, SimplifyLdObjAndStObj, SimplifyCustomShortCircuit, @@ -131,7 +132,10 @@ namespace ICSharpCode.Decompiler.ILAst if (abortBeforeStep == ILAstOptimizationStep.JoinBasicBlocks) return; modified |= block.RunOptimization(new SimpleControlFlow(context, method).JoinBasicBlocks); - + + if (abortBeforeStep == ILAstOptimizationStep.SimplifyShiftOperators) return; + modified |= block.RunOptimization(SimplifyShiftOperators); + if (abortBeforeStep == ILAstOptimizationStep.TransformDecimalCtorToConstant) return; modified |= block.RunOptimization(TransformDecimalCtorToConstant); modified |= block.RunOptimization(SimplifyLdcI4ConvI8); diff --git a/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs b/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs index 88900a73b..b8110651b 100644 --- a/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs +++ b/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs @@ -868,5 +868,40 @@ namespace ICSharpCode.Decompiler.ILAst return false; } #endregion + + #region SimplifyShiftOperators + static bool SimplifyShiftOperators(List body, ILExpression expr, int pos) + { + // C# compiles "a << b" to "a << (b & 31)", so we will remove the "& 31" if possible. + bool modified = false; + SimplifyShiftOperators(expr, ref modified); + return modified; + } + + static void SimplifyShiftOperators(ILExpression expr, ref bool modified) + { + for (int i = 0; i < expr.Arguments.Count; i++) + SimplifyShiftOperators(expr.Arguments[i], ref modified); + if (expr.Code != ILCode.Shl && expr.Code != ILCode.Shr && expr.Code != ILCode.Shr_Un) + return; + var a = expr.Arguments[1]; + if (a.Code != ILCode.And || a.Arguments[1].Code != ILCode.Ldc_I4 || expr.InferredType == null) + return; + int mask; + switch (expr.InferredType.MetadataType) { + case MetadataType.Int32: + case MetadataType.UInt32: mask = 31; break; + case MetadataType.Int64: + case MetadataType.UInt64: mask = 63; break; + default: return; + } + if ((int)a.Arguments[1].Operand != mask) return; + var res = a.Arguments[0]; + res.ILRanges.AddRange(a.ILRanges); + res.ILRanges.AddRange(a.Arguments[1].ILRanges); + expr.Arguments[1] = res; + modified = true; + } + #endregion } } From 3020bc9ce88a69400087af6cf0189bef25cc9fdf Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 28 Jun 2011 22:29:34 +0200 Subject: [PATCH 22/28] Fixed type analysis for right shift operator. --- ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs | 34 +++++++++-- .../Tests/TypeAnalysisTests.cs | 60 +++++++++++++++++-- 2 files changed, 86 insertions(+), 8 deletions(-) diff --git a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs index d5d50f352..17d65530e 100644 --- a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs +++ b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs @@ -526,9 +526,36 @@ namespace ICSharpCode.Decompiler.ILAst return NumericPromotion(InferTypeForExpression(expr.Arguments[0], null)); case ILCode.Shr: case ILCode.Shr_Un: - if (forceInferChildren) - InferTypeForExpression(expr.Arguments[1], typeSystem.Int32); - return NumericPromotion(InferTypeForExpression(expr.Arguments[0], null)); + { + if (forceInferChildren) + InferTypeForExpression(expr.Arguments[1], typeSystem.Int32); + TypeReference type = NumericPromotion(InferTypeForExpression(expr.Arguments[0], null)); + TypeReference expectedInputType = null; + switch (type.MetadataType) { + case MetadataType.Int32: + if (expr.Code == ILCode.Shr_Un) + expectedInputType = typeSystem.UInt32; + break; + case MetadataType.UInt32: + if (expr.Code == ILCode.Shr) + expectedInputType = typeSystem.Int32; + break; + case MetadataType.Int64: + if (expr.Code == ILCode.Shr_Un) + expectedInputType = typeSystem.UInt64; + break; + case MetadataType.UInt64: + if (expr.Code == ILCode.Shr) + expectedInputType = typeSystem.UInt64; + break; + } + if (expectedInputType != null) { + InferTypeForExpression(expr.Arguments[0], expectedInputType); + return expectedInputType; + } else { + return type; + } + } case ILCode.CompoundAssignment: { TypeReference varType = InferTypeForExpression(expr.Arguments[0].Arguments[0], null); @@ -1097,7 +1124,6 @@ namespace ICSharpCode.Decompiler.ILAst return char.MinValue <= num && num <= char.MaxValue; case MetadataType.UInt16: return ushort.MinValue <= num && num <= ushort.MaxValue; - break; default: return true; } diff --git a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs index 034d0c8bf..3224debdd 100644 --- a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs +++ b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs @@ -25,9 +25,45 @@ public class TypeAnalysisTests return (byte)(256 - (int)b); } - public int GetHashCode(long num) + #region Shift + public int LShiftInteger(int num1, int num2) { - return (int)num ^ (int)(num >> 32); + return num1 << num2; + } + + public uint LShiftUnsignedInteger(uint num1, uint num2) + { + return num1 << (int)num2; + } + + public long LShiftLong(long num1, long num2) + { + return num1 << (int)num2; + } + + public ulong LShiftUnsignedLong(ulong num1, ulong num2) + { + return num1 << (int)num2; + } + + public int RShiftInteger(int num1, int num2) + { + return num1 >> num2; + } + + public uint RShiftUnsignedInteger(uint num1, int num2) + { + return num1 >> num2; + } + + public long RShiftLong(long num1, long num2) + { + return num1 >> (int)num2; + } + + public ulong RShiftUnsignedLong(ulong num1, ulong num2) + { + return num1 >> (int)num2; } public int ShiftByte(byte num) @@ -40,7 +76,12 @@ public class TypeAnalysisTests return num >> 8; } - public int RShiftByteWithSignExtension(byte num) + public uint RShiftByteWithZeroExtension(byte num) + { + return (uint)num >> 8; + } + + public int RShiftByteAsSByte(byte num) { return (sbyte)num >> 8; } @@ -50,8 +91,19 @@ public class TypeAnalysisTests return num >> 8; } - public int RShiftSByteWithZeroExtension(sbyte num) + public uint RShiftSByteWithZeroExtension(sbyte num) + { + return (uint)num >> 8; + } + + public int RShiftSByteAsByte(sbyte num) { return (byte)num >> 8; } + #endregion + + public int GetHashCode(long num) + { + return (int)num ^ (int)(num >> 32); + } } From 822e473df3db428f42b8e010a896f0e1c4b325e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Tue, 28 Jun 2011 23:16:28 +0100 Subject: [PATCH 23/28] Replace endfinally with jump. Closes #232 --- .../ILAst/ILAstOptimizer.cs | 29 +++++++++++++++++++ ICSharpCode.Decompiler/ILAst/ILAstTypes.cs | 1 + 2 files changed, 30 insertions(+) diff --git a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs index 60da4cbea..aebda33e8 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs @@ -55,6 +55,7 @@ namespace ICSharpCode.Decompiler.ILAst FindLoops, FindConditions, FlattenNestedMovableBlocks, + RemoveEndFinally, RemoveRedundantCode2, GotoRemoval, DuplicateReturns, @@ -182,6 +183,9 @@ namespace ICSharpCode.Decompiler.ILAst if (abortBeforeStep == ILAstOptimizationStep.FlattenNestedMovableBlocks) return; FlattenBasicBlocks(method); + if (abortBeforeStep == ILAstOptimizationStep.RemoveEndFinally) return; + RemoveEndFinally(method); + if (abortBeforeStep == ILAstOptimizationStep.RemoveRedundantCode2) return; RemoveRedundantCode(method); @@ -538,6 +542,25 @@ namespace ICSharpCode.Decompiler.ILAst } } + /// + /// Replace endfinally with jump to the end of the finally block + /// + void RemoveEndFinally(ILBlock method) + { + // Go thought the list in reverse so that we do the nested blocks first + foreach(var tryCatch in method.GetSelfAndChildrenRecursive(tc => tc.FinallyBlock != null).Reverse()) { + ILLabel label = new ILLabel() { Name = "EndFinally_" + nextLabelIndex++ }; + tryCatch.FinallyBlock.Body.Add(label); + foreach(var block in tryCatch.FinallyBlock.GetSelfAndChildrenRecursive()) { + for (int i = 0; i < block.Body.Count; i++) { + if (block.Body[i].Match(ILCode.Endfinally)) { + block.Body[i] = new ILExpression(ILCode.Br, label).WithILRanges(((ILExpression)block.Body[i]).ILRanges); + } + } + } + } + } + /// /// Reduce the nesting of conditions. /// It should be done on flat data that already had most gotos removed @@ -770,6 +793,12 @@ namespace ICSharpCode.Decompiler.ILAst } } + public static ILExpression WithILRanges(this ILExpression expr, IEnumerable ilranges) + { + expr.ILRanges.AddRange(ilranges); + return expr; + } + public static void RemoveTail(this List body, params ILCode[] codes) { for (int i = 0; i < codes.Length; i++) { diff --git a/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs b/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs index f86225fb8..4f3930fcd 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs @@ -43,6 +43,7 @@ namespace ICSharpCode.Decompiler.ILAst void AccumulateSelfAndChildrenRecursive(List list, Func predicate) where T:ILNode { + // Note: RemoveEndFinally depends on self coming before children T thisAsT = this as T; if (thisAsT != null && (predicate == null || predicate(thisAsT))) list.Add(thisAsT); From 5c2f3633a087a0f001c237ad054eed636f6a7203 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 29 Jun 2011 21:17:19 +0200 Subject: [PATCH 24/28] Don't use variable name from .pdb file if it isn't a valid C# identifier. --- ICSharpCode.Decompiler/Ast/NameVariables.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/Ast/NameVariables.cs b/ICSharpCode.Decompiler/Ast/NameVariables.cs index 796897fee..f0a862f44 100644 --- a/ICSharpCode.Decompiler/Ast/NameVariables.cs +++ b/ICSharpCode.Decompiler/Ast/NameVariables.cs @@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.Ast nv.AddExistingName(v.Name); } else if (v.OriginalVariable != null && context.Settings.UseDebugSymbols) { string varName = v.OriginalVariable.Name; - if (string.IsNullOrEmpty(varName) || varName.StartsWith("V_", StringComparison.Ordinal) || varName.StartsWith("CS$", StringComparison.Ordinal)) + if (string.IsNullOrEmpty(varName) || varName.StartsWith("V_", StringComparison.Ordinal) || !IsValidName(varName)) { // don't use the name from the debug symbols if it looks like a generated name v.Name = null; @@ -86,6 +86,19 @@ namespace ICSharpCode.Decompiler.Ast } } + static bool IsValidName(string varName) + { + if (string.IsNullOrEmpty(varName)) + return false; + if (!(char.IsLetter(varName[0]) || varName[0] == '_')) + return false; + for (int i = 1; i < varName.Length; i++) { + if (!(char.IsLetterOrDigit(varName[i]) || varName[i] == '_')) + return false; + } + return true; + } + DecompilerContext context; List fieldNamesInCurrentType; Dictionary typeNames = new Dictionary(); From 3fad5cb76b14d1b5ed8290c619c851d298ddd5fb Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 6 Jul 2011 12:13:27 +0200 Subject: [PATCH 25/28] Fix #249: Object Initializer not detected for value types --- .../Ast/AstMethodBodyBuilder.cs | 6 ++ ICSharpCode.Decompiler/ILAst/ILCodes.cs | 4 +- .../ILAst/InitializerPeepholeTransforms.cs | 90 +++++++++++++++---- ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs | 33 ++++--- .../Tests/InitializerTests.cs | 79 +++++++++++++++- 5 files changed, 179 insertions(+), 33 deletions(-) diff --git a/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs b/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs index dfeff794e..cab334432 100644 --- a/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs @@ -782,9 +782,15 @@ namespace ICSharpCode.Decompiler.Ast } } ObjectCreateExpression oce = arg1 as ObjectCreateExpression; + DefaultValueExpression dve = arg1 as DefaultValueExpression; if (oce != null) { oce.Initializer = initializer; return oce; + } else if (dve != null) { + oce = new ObjectCreateExpression(dve.Type.Detach()); + oce.CopyAnnotationsFrom(dve); + oce.Initializer = initializer; + return oce; } else { return new AssignmentExpression(arg1, initializer); } diff --git a/ICSharpCode.Decompiler/ILAst/ILCodes.cs b/ICSharpCode.Decompiler/ILAst/ILCodes.cs index 36bc56d52..e7322a770 100644 --- a/ICSharpCode.Decompiler/ILAst/ILCodes.cs +++ b/ICSharpCode.Decompiler/ILAst/ILCodes.cs @@ -261,8 +261,8 @@ namespace ICSharpCode.Decompiler.ILAst // InitCollection(CallGetter(Collection, InitializedObject))), // Call(Add, InitializedObject, 2, 3), // Call(Add, InitializedObject, 4, 5))) - InitObject, // Object initializer: first arg is newobj, remaining args are the initializing statements - InitCollection, // Collection initializer: first arg is newobj, remaining args are the initializing statements + InitObject, // Object initializer: first arg is newobj/defaultvalue, remaining args are the initializing statements + InitCollection, // Collection initializer: first arg is newobj/defaultvalue, remaining args are the initializing statements InitializedObject, // Refers the the object being initialized (refers to first arg in parent InitObject or InitCollection instruction) TernaryOp, // ?: diff --git a/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs b/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs index bde84e828..4c934b866 100644 --- a/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs +++ b/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs @@ -232,18 +232,45 @@ namespace ICSharpCode.Decompiler.ILAst Debug.Assert(body[pos] == expr); // should be called for top-level expressions only ILVariable v; ILExpression newObjExpr; + TypeReference newObjType; + bool isValueType; MethodReference ctor; List ctorArgs; - // v = newObj(ctor, ctorArgs) - if (!(expr.Match(ILCode.Stloc, out v, out newObjExpr) && newObjExpr.Match(ILCode.Newobj, out ctor, out ctorArgs))) + if (expr.Match(ILCode.Stloc, out v, out newObjExpr)) { + if (newObjExpr.Match(ILCode.Newobj, out ctor, out ctorArgs)) { + // v = newObj(ctor, ctorArgs) + newObjType = ctor.DeclaringType; + isValueType = false; + } else if (newObjExpr.Match(ILCode.DefaultValue, out newObjType)) { + // v = defaultvalue(type) + isValueType = true; + } else { + return false; + } + } else if (expr.Match(ILCode.Call, out ctor, out ctorArgs)) { + // call(SomeStruct::.ctor, ldloca(v), remainingArgs) + if (ctorArgs.Count > 0 && ctorArgs[0].Match(ILCode.Ldloca, out v)) { + isValueType = true; + newObjType = ctor.DeclaringType; + ctorArgs = new List(ctorArgs); + ctorArgs.RemoveAt(0); + newObjExpr = new ILExpression(ILCode.Newobj, ctor, ctorArgs); + } else { + return false; + } + } else { return false; + } + if (newObjType.IsValueType != isValueType) + return false; + int originalPos = pos; // don't use object initializer syntax for closures - if (Ast.Transforms.DelegateConstruction.IsPotentialClosure(context, ctor.DeclaringType.ResolveWithinSameModule())) + if (Ast.Transforms.DelegateConstruction.IsPotentialClosure(context, newObjType.ResolveWithinSameModule())) return false; - ILExpression initializer = ParseObjectInitializer(body, ref pos, v, newObjExpr, IsCollectionType(ctor.DeclaringType)); + ILExpression initializer = ParseObjectInitializer(body, ref pos, v, newObjExpr, IsCollectionType(newObjType), isValueType); if (initializer.Arguments.Count == 1) // only newobj argument, no initializer elements return false; @@ -256,16 +283,36 @@ namespace ICSharpCode.Decompiler.ILAst return false; // reached end of block, but there should be another instruction which consumes the initialized object ILInlining inlining = new ILInlining(method); - // one ldloc for each initializer argument, and another ldloc for the use of the initialized object - if (inlining.numLdloc.GetOrDefault(v) != totalElementCount + 1) - return false; - if (!(inlining.numStloc.GetOrDefault(v) == 1 && inlining.numLdloca.GetOrDefault(v) == 0)) - return false; + if (isValueType) { + // one ldloc for the use of the initialized object + if (inlining.numLdloc.GetOrDefault(v) != 1) + return false; + // one ldloca for each initializer argument, and also for the ctor call (if it exists) + if (inlining.numLdloca.GetOrDefault(v) != totalElementCount + (expr.Code == ILCode.Call ? 1 : 0)) + return false; + // one stloc for the initial store (if no ctor call was used) + if (inlining.numStloc.GetOrDefault(v) != (expr.Code == ILCode.Call ? 0 : 1)) + return false; + } else { + // one ldloc for each initializer argument, and another ldloc for the use of the initialized object + if (inlining.numLdloc.GetOrDefault(v) != totalElementCount + 1) + return false; + if (!(inlining.numStloc.GetOrDefault(v) == 1 && inlining.numLdloca.GetOrDefault(v) == 0)) + return false; + } ILExpression nextExpr = body[pos] as ILExpression; if (!inlining.CanInlineInto(nextExpr, v, initializer)) return false; - expr.Arguments[0] = initializer; + if (expr.Code == ILCode.Stloc) { + expr.Arguments[0] = initializer; + } else { + Debug.Assert(expr.Code == ILCode.Call); + expr.Code = ILCode.Stloc; + expr.Operand = v; + expr.Arguments.Clear(); + expr.Arguments.Add(initializer); + } // remove all the instructions that were pulled into the initializer body.RemoveRange(originalPos + 1, pos - originalPos - 1); @@ -302,7 +349,7 @@ namespace ICSharpCode.Decompiler.ILAst { if (expr == null) return false; - if (expr.Code == ILCode.CallvirtSetter || expr.Code == ILCode.Stfld) { + if (expr.Code == ILCode.CallvirtSetter || expr.Code == ILCode.CallSetter || expr.Code == ILCode.Stfld) { return expr.Arguments.Count == 2; } return false; @@ -334,9 +381,8 @@ namespace ICSharpCode.Decompiler.ILAst /// The variable that holds the object being initialized /// The newobj instruction /// InitObject instruction - ILExpression ParseObjectInitializer(List body, ref int pos, ILVariable v, ILExpression newObjExpr, bool isCollection) + ILExpression ParseObjectInitializer(List body, ref int pos, ILVariable v, ILExpression newObjExpr, bool isCollection, bool isValueType) { - Debug.Assert(((ILExpression)body[pos]).Code == ILCode.Stloc); // Take care not to modify any existing ILExpressions in here. // We just construct new ones around the old ones, any modifications must wait until the whole // object/collection initializer was analyzed. @@ -346,13 +392,13 @@ namespace ICSharpCode.Decompiler.ILAst while (++pos < body.Count) { ILExpression nextExpr = body[pos] as ILExpression; if (IsSetterInObjectInitializer(nextExpr)) { - if (!AdjustInitializerStack(initializerStack, nextExpr.Arguments[0], v, false)) { + if (!AdjustInitializerStack(initializerStack, nextExpr.Arguments[0], v, false, isValueType)) { CleanupInitializerStackAfterFailedAdjustment(initializerStack); break; } initializerStack[initializerStack.Count - 1].Arguments.Add(nextExpr); } else if (IsAddMethodCall(nextExpr)) { - if (!AdjustInitializerStack(initializerStack, nextExpr.Arguments[0], v, true)) { + if (!AdjustInitializerStack(initializerStack, nextExpr.Arguments[0], v, true, isValueType)) { CleanupInitializerStackAfterFailedAdjustment(initializerStack); break; } @@ -365,20 +411,26 @@ namespace ICSharpCode.Decompiler.ILAst return objectInitializer; } - static bool AdjustInitializerStack(List initializerStack, ILExpression argument, ILVariable v, bool isCollection) + static bool AdjustInitializerStack(List initializerStack, ILExpression argument, ILVariable v, bool isCollection, bool isValueType) { // Argument is of the form 'getter(getter(...(v)))' // Unpack it into a list of getters: List getters = new List(); - while (argument.Code == ILCode.CallvirtGetter || argument.Code == ILCode.Ldfld) { + while (argument.Code == ILCode.CallvirtGetter || argument.Code == ILCode.CallGetter || argument.Code == ILCode.Ldfld) { getters.Add(argument); if (argument.Arguments.Count != 1) return false; argument = argument.Arguments[0]; } // Ensure that the final argument is 'v' - if (!argument.MatchLdloc(v)) - return false; + if (isValueType) { + ILVariable loadedVar; + if (!(argument.Match(ILCode.Ldloca, out loadedVar) && loadedVar == v)) + return false; + } else { + if (!argument.MatchLdloc(v)) + return false; + } // Now compare the getters with those that are currently active on the initializer stack: int i; for (i = 1; i <= Math.Min(getters.Count, initializerStack.Count - 1); i++) { diff --git a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs index 17d65530e..0891f82f1 100644 --- a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs +++ b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs @@ -323,13 +323,7 @@ namespace ICSharpCode.Decompiler.ILAst if (forceInferChildren) { for (int i = 0; i < expr.Arguments.Count; i++) { if (i == 0 && method.HasThis) { - ILExpressionPrefix constraint = expr.GetPrefix(ILCode.Constrained); - if (constraint != null) - InferTypeForExpression(expr.Arguments[i], new ByReferenceType((TypeReference)constraint.Operand)); - else if (method.DeclaringType.IsValueType) - InferTypeForExpression(expr.Arguments[i], new ByReferenceType(method.DeclaringType)); - else - InferTypeForExpression(expr.Arguments[i], method.DeclaringType); + InferTypeForExpression(expr.Arguments[0], MakeRefIfValueType(method.DeclaringType, expr.GetPrefix(ILCode.Constrained))); } else { InferTypeForExpression(expr.Arguments[i], SubstituteTypeArgs(method.Parameters[method.HasThis ? i - 1 : i].ParameterType, method)); } @@ -361,17 +355,22 @@ namespace ICSharpCode.Decompiler.ILAst #endregion #region Load/Store Fields case ILCode.Ldfld: - if (forceInferChildren) - InferTypeForExpression(expr.Arguments[0], ((FieldReference)expr.Operand).DeclaringType); + if (forceInferChildren) { + InferTypeForExpression(expr.Arguments[0], MakeRefIfValueType(((FieldReference)expr.Operand).DeclaringType, expr.GetPrefix(ILCode.Constrained))); + } return GetFieldType((FieldReference)expr.Operand); case ILCode.Ldsfld: return GetFieldType((FieldReference)expr.Operand); case ILCode.Ldflda: + if (forceInferChildren) { + InferTypeForExpression(expr.Arguments[0], MakeRefIfValueType(((FieldReference)expr.Operand).DeclaringType, expr.GetPrefix(ILCode.Constrained))); + } + return new ByReferenceType(GetFieldType((FieldReference)expr.Operand)); case ILCode.Ldsflda: return new ByReferenceType(GetFieldType((FieldReference)expr.Operand)); case ILCode.Stfld: if (forceInferChildren) { - InferTypeForExpression(expr.Arguments[0], ((FieldReference)expr.Operand).DeclaringType); + InferTypeForExpression(expr.Arguments[0], MakeRefIfValueType(((FieldReference)expr.Operand).DeclaringType, expr.GetPrefix(ILCode.Constrained))); InferTypeForExpression(expr.Arguments[1], GetFieldType((FieldReference)expr.Operand)); } return GetFieldType((FieldReference)expr.Operand); @@ -796,6 +795,20 @@ namespace ICSharpCode.Decompiler.ILAst } } + /// + /// Wraps 'type' in a ByReferenceType if it is a value type. If a constrained prefix is specified, + /// returns the constrained type wrapped in a ByReferenceType. + /// + TypeReference MakeRefIfValueType(TypeReference type, ILExpressionPrefix constrainedPrefix) + { + if (constrainedPrefix != null) + return new ByReferenceType((TypeReference)constrainedPrefix.Operand); + if (type.IsValueType) + return new ByReferenceType(type); + else + return type; + } + /// /// Promotes primitive types smaller than int32 to int32. /// diff --git a/ICSharpCode.Decompiler/Tests/InitializerTests.cs b/ICSharpCode.Decompiler/Tests/InitializerTests.cs index 80fbe7478..a4ab57fbf 100644 --- a/ICSharpCode.Decompiler/Tests/InitializerTests.cs +++ b/ICSharpCode.Decompiler/Tests/InitializerTests.cs @@ -52,8 +52,37 @@ public class InitializerTests get; set; } + + public InitializerTests.StructData NestedStruct + { + get; + set; + } } - + + private struct StructData + { + public int Field; + public int Property + { + get; + set; + } + + public InitializerTests.Data MoreData + { + get; + set; + } + + public StructData(int initialValue) + { + this = default(InitializerTests.StructData); + this.Field = initialValue; + this.Property = initialValue; + } + } + // Helper methods used to ensure initializers used within expressions work correctly private static void X(object a, object b) { @@ -456,7 +485,53 @@ public class InitializerTests } }); } - + + public static void StructInitializer_DefaultConstructor() + { + InitializerTests.X(InitializerTests.Y(), new InitializerTests.StructData + { + Field = 1, + Property = 2 + }); + } + + public static void StructInitializer_ExplicitConstructor() + { + InitializerTests.X(InitializerTests.Y(), new InitializerTests.StructData(0) + { + Field = 1, + Property = 2 + }); + } + + public static void StructInitializerWithInitializationOfNestedObjects() + { + InitializerTests.X(InitializerTests.Y(), new InitializerTests.StructData + { + MoreData = + { + a = InitializerTests.MyEnum.a, + FieldList = + { + InitializerTests.MyEnum2.c, + InitializerTests.MyEnum2.d + } + } + }); + } + + public static void StructInitializerWithinObjectInitializer() + { + InitializerTests.X(InitializerTests.Y(), new InitializerTests.Data + { + NestedStruct = new InitializerTests.StructData(2) + { + Field = 1, + Property = 2 + } + }); + } + public void MultidimensionalInit() { int[,] expr_09 = new int[, ] From 17a75ded4ea9d479eb7ae43897f270f3b0c5a498 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 6 Jul 2011 12:26:48 +0200 Subject: [PATCH 26/28] Fix #211 InvalidCastException in ILAstOptimizer.TransformArrayInitializers --- .../ILAst/InitializerPeepholeTransforms.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs b/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs index 4c934b866..5b194b738 100644 --- a/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs +++ b/ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs @@ -124,19 +124,24 @@ namespace ICSharpCode.Decompiler.ILAst MethodReference methodRef; ILExpression methodArg1; ILExpression methodArg2; - FieldDefinition field; + FieldReference fieldRef; if (body.ElementAtOrDefault(pos).Match(ILCode.Call, out methodRef, out methodArg1, out methodArg2) && methodRef.DeclaringType.FullName == "System.Runtime.CompilerServices.RuntimeHelpers" && methodRef.Name == "InitializeArray" && methodArg1.Match(ILCode.Ldloc, out v2) && array == v2 && - methodArg2.Match(ILCode.Ldtoken, out field) && - field != null && field.InitialValue != null) { - ILExpression[] newArr = new ILExpression[arrayLength]; - if (DecodeArrayInitializer(TypeAnalysis.GetTypeCode(arrayType.GetElementType()), field.InitialValue, newArr)) { - values = newArr; - foundPos = pos; - return true; + methodArg2.Match(ILCode.Ldtoken, out fieldRef)) + { + FieldDefinition fieldDef = fieldRef.ResolveWithinSameModule(); + if (fieldDef != null && fieldDef.InitialValue != null) { + ILExpression[] newArr = new ILExpression[arrayLength]; + if (DecodeArrayInitializer(TypeAnalysis.GetTypeCode(arrayType.GetElementType()), + fieldDef.InitialValue, newArr)) + { + values = newArr; + foundPos = pos; + return true; + } } } values = null; From 1c1420a8d2eb1e42203ea6e167fa26a677599bb6 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 6 Jul 2011 14:37:07 +0200 Subject: [PATCH 27/28] Squashed 'NRefactory/' changes from 1e4a1d9..9675caf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 9675caf ReadOnlyDocument: rename textBuffer->textSource 97d0964 Fixed GetDelegateInvokeMethod() for parameterized types. Fixed copy constructor of DefaultMethod. Fixed handling of "class" constraint in CecilLoader. 42d4d7d fixed some bugs in use explicit type context action. 79b9582 Fixed failing attribute unit tests. 6fb0a90 Added error indicators for missing closing brackets. a11458e Worked on attribute resolving. Some tests fail because of wrongly loaded classes in my system. Daniel: Can you check the constructor attribute cases. I think something doesn't work in the Cecil loader on my system. I only get 1 empty constructor for LoaderOptimization & the name on my system is .ctor instead of #ctor. cf8a412 Use equals. 5c398f2 fixed return types of anonymous type properties. Re-used the var type reference for that. c458e06 Implemented anonymous types. 19653fa Added identifier token property. 96d1b7f fixed check. 1af72c9 GetResolveableNodeAt is now more selective. b74fe93 Set compiler errors to parsed file. b411a2a fixed possible null ref. 7e708a6 Worked on ast formatter tests. fa55d14 Fix adding assembly attributes to SimpleProjectContent. Fixed MemberLookup.IsInvocable(). Add (ignored) unit tests for user-defined binary operators. b368465 fixed bug. 99b60b8 Parser change: Interface members are now Accessibiliy.Public. This is a proposal to solve the .. ... lookup. dd4f73b Fixed bug in inner type result. 2c2f30d Fixed some issues in the context actions. b01c263 Implemented brace style formatting. aceae1f implemented type parameter getmember methods. 2b726d2 Fixed System.Void output. 67fff9f fixed bug in using statement parsing. ef0d911 Revert "Implemented user defined operator candidates." 9165dfe Implemented user defined operator candidates. 6199ee3 checked outer classes for aceessibility private check. 5fad5f9 Added time stamp to parsed files. 37dbafd fixed mcs bug. 0e1ad6e Started to implement a 'skip bodies' mode for parsing. 62d61ec Implemented GetResolveableNodeAt function. 26946f0 Added DeclarationRegion property to IVariable. 694f373 fix infinite loop. daf0f21 Fixed some bugs related to conversions of type parameters. 5ae4d60 Conversions: add support for user-defined implicit conversions. 7615720 ResolveVisitor: Handle type arguments on IdentifierExpression and MemberReferenceExpression. Add support for PointerReferenceExpression. 3435eec Add ResolveVisitor.GetResolverStateBefore(AstNode). 5b92717 Add GetMembers() to IType; add ParsedFiles to IProjectContent. c923833 Fix build errors. 1037d56 fixed some errors. 7fb7783 Make AbstractAnnotatable implement IAnnotatable. c9d4a5d Rename ITypeResolveContext extension methods to be consistent with the new names of the ITypeResolveContext methods. 350ebaa Fixed NullReferenceException in type inference when passing a "string[]" for a parameter of type "IEnumerable". 823471e Make the end offset of SegmentExtensions.Contains inclusive. b40610d Simplify nested synchronization of CompositeTypeResolveContext. 991bea4 Added IsVerbatim property again. 484c586 Added easy accessible acceess members. a883a3d Added constructors that take an error location/added file header. 77d54ee added some constructors. e8153e0 reduced comment insertion time from O(m log n) to O (m). 44e796a Reduced the memory consumption of identifiers a bit by saving the 'isverbatim' bool. Note: Don't introduce that as virtual property, otherwise the memory saving is lost. 0afc1c6 Updated mcs / included code completion expression lookup. 33d588b Added the ability to specify parser arguments & provided a compiler callback (for getting pre processor directives etc). TODO: Move pre processor directives in the AST. 93b3ebf Implemented type system -> cecil object table. 6a85f0c Renamed GetClass-> GetTypeDefinition; abec118 fix build. c6aa05d Addded GetSubTypeDefinitions method. That's like a routine we had in the old MD dom - it's used for example for finding all exceptions in an assembly. b7fc89c added header. 0cb2388 Separated the annotations from the ast node & added annotations to the project content. af5e2c6 Added extension method GetMembers on IType. 7e29f61 Fix build (however formatting tests will fail). 9d21d1c Renamed GetClasses -> GetTypes. (GetClasess can give enums, structs & delegates too). 51f924f Renamed ITypeDefinition.InnerClasses -> NestedTypes (for more consistency with IType.GetNestedTypes 224f973 Revert "Moved class type to IType / added type parameter class type for type" ba335ed Moved class type to IType / added type parameter class type for type parameters. aa42b1b Added error storage to IParsedFile. bae8765 Added AstLocation Begin/End properties. 9bc76cf Added naive remove type definition. This won't work for partial types. bd4fb10 Added cenecllationtoken work around. Mono crashes on default cancellation token. 40147bc Changed CreateShortType implementation a bit. 1ae1b17 Added gettype/member extension methods that are working on a line/column pair. c744d2f Worked on the way nrefactory contexct actions use the resolver. 1836aa8 Merge branch 'master' of github.com:icsharpcode/NRefactory 1b7906a Worked on context actions. 94b4130 Add IParsedFile to type system. be5139a Added more context actions. 62988d6 Add TypeSystemAstBuilder: IType --> AstType conversion. 530cb0b mhutch: [NRefactory] Fix const modifier on fields 2b5569d use faster string comparer. 0f5f474 worked on context actions. c337048 added missing file. 6e1eaf1 Added monodevelop context actions. 3eb2e5d Added patch from mhutch: [NRefactory] Add some name token accessors 7070e47 corrected output of primitive expressions. Primitive expressions contain a literal value which should be preferred ("0x10" vs "16"). 13acde3 fix build. 8b606d1 Updated mcs/fixed unit test. string literal constants now contain the real 'literal'. b2d2678 Rename ITextBuffer -> ITextSource 3048d66 Added some proposals. 21fcd82 Add ISegment and ITextEditor interfaces. b4bcc80 Add ICSharpCode.Editor assembly. 0afdacd changed to HasModifier. 878dbbf Fixed some issues in resolver; enable resolver unit tests. d36805c fixed assembly attribute csharp test. 67d9bb5 Fixed attribute on method parameter tests. 3685f49 Fixed TypeSystemConvertVisitor for read-only properties. Added some attribute parser tests. 26986f9 Make sure NamespaceEntry.ClassCount stays consistent with the ordinal typeDict at all times, even when there are name clashes in one of the non-ordinal dictionaries. ddc55ad fixed variable declaration statement inside for loops wrong semicolon position. fca4dd0 Added GetTypes method in compilation unit. 0398fd6 Fixed 'GlobalAttributeCSharp' test. 9bcf087 Fixed EnumWithBaseType unit test. 390ed3a Fixed NestedArrays unit test. 1c51b3a Type storage: Fixed handling of namespaces that have sub-namespaces but do not directly contain classes. 07e2896 Make InsertParenthesesVisitorTests independent from indentation of the output. 73a9d8d Merge NRefactory changes from ILSpy. fb57f7d Fixed several issues in the type system convert visitor. a697f19 fixed unboundtypeofexpression test. 93117a1 Added MemberNameToken property. 7cd4526 Added some properties to allow easier access for modifiers. 014ecea Pass the parameter to the event handlers. 42717c9 fix missing method. 6144698 removed exception (shouldn't be in production code). 1365588 passed type parameters to the observable ast visitor. 7a5c7f3 fixed possible null reference exception. 6894e6a Primitive expressions now contain the literal value + updated mcs. 790585c Implemented invert condition function. 7f16970 Added token atrribute. 0648470 Fixed membertpe location. ba4a272 Implemented specific GetNodeAt method. 1feb0fc Added contains method. d4d9ffd Added observer visitor. f761813 Fixing switch section output + it's now possible to track node output in the output visitor. 79f1798 Put embedded statments onto next line. 478faf7 added name token property. d561ccf Merged some changes from monodevelop. 280b79b Fixed return type tokens 8578bad Added easy name token access. dfea089 added bounds check. 2fa40d8 Fixed special constraint expression parsing. eb6f6c1 Make ConvertChar and ConvertString public. b07228e Fixed issues with detection of using statements. a238bf1 When decompiling a field, also decompile constructors to check whether there's an initializer on the field. When decompiling a constructor, display field initializers outside of the constructor. Closes #3. 3974a80 remove isLastLine from interface - use stack instead; fix null reference if resolve of TypeDefinition fails 7738421 Fixed position of XML comments on nested types. 9a35ee4 Applied some of the optimizations suggested by Kris Vandermotten. #150 5997f81 add foldings to documentation comments; closes #165 fc86a67 Fixed relocation bug. 8fc4139 Fixed relocatable bug/removed some debug messages. 8237448 Renamed interface. 99b4726 fix https://github.com/icsharpcode/ILSpy/issues/177 450be5a Corrected locations for parset expressions/statments/type members. cb114b8 Fixed blank line formatting bug. e187185 Merge NRefactory subtree from commit '1e4a1d911cb430db2a4199695ee73dfd89bcc543' 4db670a Merge NRefactory b8330be into ILSpy f70f6a8 Add SaveIndex/LoadFromIndex methods to XmlDocumentationProvider. 4995f48 New XmlDocumentationProvider implementation: f3b9d11 When the last statement in a block is a label, add an EmptyStatement so that the generated code is valid. e68833d Add TestPlugin. b22b3ec C# OutputVisitor: improve indentation of query expressions 2ca7ec2 Fixed output of NamedArgumentExpression within object initializers. 43e33f8 Fixed InsertParenthesesVisitor for casts of negative primitive expressions. f3c52a0 Add OperatorDeclaration.GetOperatorType() helper method. 7cbab5e Merge NRefactory a92606c..56fde51 git-subtree-dir: NRefactory git-subtree-split: 9675caf1e9276391f17536b488148cb668a6cc44 --- ICSharpCode.Editor/ICSharpCode.Editor.csproj | 72 + ICSharpCode.Editor/IDocument.cs | 141 + ICSharpCode.Editor/IDocumentLine.cs | 30 + ICSharpCode.Editor/ISegment.cs | 55 + ICSharpCode.Editor/ITextAnchor.cs | 102 + ICSharpCode.Editor/ITextEditor.cs | 100 + ICSharpCode.Editor/ITextSource.cs | 147 + ICSharpCode.Editor/LinkedElement.cs | 68 + ICSharpCode.Editor/Properties/AssemblyInfo.cs | 31 + ICSharpCode.Editor/ReadOnlyDocument.cs | 321 + ICSharpCode.Editor/StringTextSource.cs | 91 + ICSharpCode.Editor/TextChangeEventArgs.cs | 64 + ICSharpCode.Editor/TextLocation.cs | 173 + ICSharpCode.NRefactory.Demo/CSDemo.cs | 2 +- .../CSharp/InsertParenthesesVisitorTests.cs | 53 +- .../Expression/TypeOfExpressionTests.cs | 17 +- .../GeneralScope/AttributeSectionTests.cs | 69 +- .../GeneralScope/TypeDeclarationTests.cs | 8 + .../Parser/TypeSystemConvertVisitorTests.cs | 4 +- .../CSharp/Resolver/AttributeTests.cs | 8 +- .../CSharp/Resolver/BinaryOperatorTests.cs | 57 + .../CSharp/Resolver/ConversionsTest.cs | 115 +- .../CSharp/Resolver/ExtensionMethodTests.cs | 2 +- .../CSharp/Resolver/InvocationTests.cs | 12 +- .../CSharp/Resolver/LambdaTests.cs | 2 +- .../CSharp/Resolver/NameLookupTests.cs | 88 +- .../CSharp/Resolver/ObjectCreationTests.cs | 2 +- .../CSharp/Resolver/ResolverTestBase.cs | 2 +- .../CSharp/Resolver/TypeInferenceTests.cs | 47 +- .../CSharp/Resolver/UnsafeCodeTests.cs | 2 +- .../TestBlankLineFormatting.cs | 1 + .../FormattingTests/TestBraceStlye.cs | 3 + .../FormattingTests/TestFormattingBugs.cs | 1 + .../FormattingTests/TestSpacingVisitor.cs | 19 + .../TestStatementIndentation.cs | 3 + .../TestTypeLevelIndentation.cs | 7 +- .../FormattingTests/TextEditorTestAdapter.cs | 70 +- .../TypeSystem/CecilLoaderTests.cs | 40 +- .../TypeSystem/GetAllBaseTypesTest.cs | 30 +- .../TypeSystem/ReflectionHelperTests.cs | 6 +- .../TypeSystem/TestInterningProvider.cs | 4 +- .../TypeSystem/TypeSystemTests.TestCase.cs | 2 + .../TypeSystem/TypeSystemTests.cs | 82 +- .../GlobalScope/ImportsStatementTests.cs | 2 +- ICSharpCode.NRefactory.VB/Ast/AstNode.cs | 150 +- .../Ast/General/TypeParameterDeclaration.cs | 2 +- .../Ast/GlobalScope/NamespaceDeclaration.cs | 2 +- .../Ast/GlobalScope/TypeDeclaration.cs | 10 +- .../Ast/TypeName/QualifiedType.cs | 2 +- .../Ast/TypeName/SimpleType.cs | 4 +- ICSharpCode.NRefactory.VB/Parser/Parser.cs | 6 +- .../CSharp/Analysis/ControlFlow.cs | 7 +- .../Analysis/DefiniteAssignmentAnalysis.cs | 26 +- .../CSharp/Analysis/MinimalResolveContext.cs | 21 +- ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs | 531 +- .../CSharp/Ast/CSharpTokenNode.cs | 11 +- .../CSharp/Ast/CSharpUtil.cs | 95 + .../CSharp/Ast/CompilationUnit.cs | 78 +- .../CSharp/Ast/ComposedType.cs | 4 +- .../CSharp/Ast/ErrorNode.cs | 79 + .../CSharp/Ast/Expressions/EmptyExpression.cs | 13 +- .../Ast/Expressions/IdentifierExpression.cs | 4 +- .../Expressions/MemberReferenceExpression.cs | 13 +- .../Expressions/NamedArgumentExpression.cs | 11 +- .../Expressions/PointerReferenceExpression.cs | 4 +- .../Ast/Expressions/PrimitiveExpression.cs | 31 +- .../CSharp/Ast/Expressions/QueryExpression.cs | 10 +- .../CSharp/Ast/GeneralScope/Attribute.cs | 21 +- .../CSharp/Ast/GeneralScope/Comment.cs | 13 +- .../CSharp/Ast/GeneralScope/Constraint.cs | 4 +- .../Ast/GeneralScope/DelegateDeclaration.cs | 13 +- .../GeneralScope/ExternAliasDeclaration.cs | 2 +- .../Ast/GeneralScope/NamespaceDeclaration.cs | 4 +- .../Ast/GeneralScope/TypeDeclaration.cs | 13 +- .../GeneralScope/TypeParameterDeclaration.cs | 11 +- .../Ast/GeneralScope/UsingAliasDeclaration.cs | 8 +- .../Change.cs => Ast/IRelocatable.cs} | 45 +- .../CSharp/Ast/Identifier.cs | 82 +- .../CSharp/Ast/MemberType.cs | 36 +- .../CSharp/Ast/ObservableAstVisitor.cs | 1141 ++ .../CSharp/Ast/PrimitiveType.cs | 10 +- .../CSharp/Ast/SimpleType.cs | 27 +- .../CSharp/Ast/Statements/EmptyStatement.cs | 11 +- .../CSharp/Ast/Statements/ForeachStatement.cs | 13 +- .../CSharp/Ast/Statements/GotoStatement.cs | 4 +- .../CSharp/Ast/Statements/LabelStatement.cs | 4 +- .../CSharp/Ast/Statements/SwitchStatement.cs | 9 + .../Ast/Statements/TryCatchStatement.cs | 13 +- .../VariableDeclarationStatement.cs | 5 + .../CSharp/Ast/TypeMembers/AttributedNode.cs | 9 +- .../Ast/TypeMembers/ConstructorDeclaration.cs | 5 + .../Ast/TypeMembers/DestructorDeclaration.cs | 5 + .../Ast/TypeMembers/EnumMemberDeclaration.cs | 13 +- .../TypeMembers/FixedVariableInitializer.cs | 15 +- .../Ast/TypeMembers/MemberDeclaration.cs | 13 +- .../Ast/TypeMembers/OperatorDeclaration.cs | 95 +- .../Ast/TypeMembers/ParameterDeclaration.cs | 13 +- .../Ast/TypeMembers/VariableInitializer.cs | 13 +- .../CSharp/Formatter/AstFormattingVisitor.cs | 56 +- .../CSharp/Formatter/ITextEditorAdapter.cs | 35 +- .../OutputVisitor/InsertParenthesesVisitor.cs | 35 + .../CSharp/OutputVisitor/OutputVisitor.cs | 2656 ++--- .../TextWriterOutputFormatter.cs | 76 +- .../CSharp/Parser/CSharpParser.cs | 1489 +-- .../CSharp/Parser/ParsedFile.cs | 53 +- .../CSharp/Parser/TypeSystemConvertVisitor.cs | 78 +- .../CSharp/Parser/mcs/anonymous.cs | 72 +- .../CSharp/Parser/mcs/argument.cs | 72 +- .../CSharp/Parser/mcs/async.cs | 614 ++ .../CSharp/Parser/mcs/attribute.cs | 17 +- .../CSharp/Parser/mcs/context.cs | 4 +- .../CSharp/Parser/mcs/convert.cs | 10 +- .../CSharp/Parser/mcs/cs-parser.cs | 9607 +++++++++-------- .../CSharp/Parser/mcs/cs-parser.jay | 159 +- .../CSharp/Parser/mcs/cs-tokenizer.cs | 145 +- .../CSharp/Parser/mcs/decl.cs | 15 +- .../CSharp/Parser/mcs/doc.cs | 53 + .../CSharp/Parser/mcs/driver.cs | 11 +- .../CSharp/Parser/mcs/ecore.cs | 74 +- .../CSharp/Parser/mcs/eval.cs | 22 +- .../CSharp/Parser/mcs/expression.cs | 70 +- .../CSharp/Parser/mcs/flowanalysis.cs | 5 +- .../CSharp/Parser/mcs/generic.cs | 14 +- .../CSharp/Parser/mcs/import.cs | 2 +- .../CSharp/Parser/mcs/iterators.cs | 573 +- .../CSharp/Parser/mcs/lambda.cs | 7 +- .../CSharp/Parser/mcs/literal.cs | 79 +- .../CSharp/Parser/mcs/location.cs | 9 +- .../CSharp/Parser/mcs/method.cs | 33 +- .../CSharp/Parser/mcs/modifiers.cs | 8 +- .../CSharp/Parser/mcs/parameter.cs | 19 + .../CSharp/Parser/mcs/property.cs | 9 - .../CSharp/Parser/mcs/report.cs | 3 +- .../CSharp/Parser/mcs/roottypes.cs | 21 +- .../CSharp/Parser/mcs/statement.cs | 190 +- .../CSharp/Parser/mcs/support.cs | 12 + .../CSharp/Parser/mcs/typemanager.cs | 70 +- .../CSharp/Parser/mcs/typespec.cs | 48 +- .../CSharp/Refactoring/Action.cs | 55 + .../ContextAction/AddAnotherAccessor.cs | 89 + .../ContextAction/CheckIfParameterIsNull.cs | 112 + .../ContextAction/ConvertDecToHex.cs | 52 + .../ContextAction/ConvertForeachToFor.cs | 95 + .../ContextAction/ConvertHexToDec.cs | 52 + .../ContextAction/CreateBackingStore.cs | 73 + .../ContextAction/CreateEventInvocator.cs | 109 + .../Refactoring/ContextAction/CreateField.cs | 77 + .../ContextAction/CreateLocalVariable.cs | 129 + .../ContextAction/CreateProperty.cs | 66 + .../ContextAction/FlipOperatorArguments.cs | 59 + .../ContextAction/GenerateGetter.cs | 95 + .../ContextAction/GenerateSwitchLabels.cs | 88 + .../InsertAnonymousMethodSignature.cs | 94 + .../ContextAction/IntroduceFormatItem.cs | 100 + .../Refactoring/ContextAction/InvertIf.cs | 61 + .../ContextAction/RemoveBackingStore.cs | 123 + .../Refactoring/ContextAction/RemoveBraces.cs | 61 + .../ContextAction/ReplaceEmptyString.cs | 53 + .../SplitDeclarationAndAssignment.cs | 74 + .../Refactoring/ContextAction/SplitString.cs | 55 + .../ContextAction/UseExplicitType.cs | 67 + .../ContextAction/UseVarKeyword.cs | 56 + .../CSharp/Refactoring/CreateLinkAction.cs | 44 + .../CSharp/Refactoring/FormatTextAction.cs | 39 + .../CSharp/Refactoring/IActionFactory.cs | 75 + .../CSharp/Refactoring/IContextAction.cs | 36 + .../CSharp/Refactoring/NodeOutputAction.cs | 136 + .../CSharp/Refactoring/NodeSelectionAction.cs | 40 + .../CSharp/Refactoring/RefactoringContext.cs | 141 + .../CSharp/Refactoring/Script.cs | 180 + .../StringBuilderOutputFormatter.cs | 158 + .../CSharp/Refactoring/TextReplaceAction.cs | 134 + .../Refactoring/TypeSystemAstBuilder.cs | 218 + .../CSharp/Resolver/CSharpAttribute.cs | 12 +- .../CSharp/Resolver/CSharpResolver.cs | 96 +- .../CSharp/Resolver/ConstantValues.cs | 56 + .../CSharp/Resolver/Conversions.cs | 100 +- .../CSharp/Resolver/MapTypeIntoNewContext.cs | 4 +- .../CSharp/Resolver/MemberLookup.cs | 25 +- .../CSharp/Resolver/OverloadResolution.cs | 4 +- .../CSharp/Resolver/ResolveVisitor.cs | 427 +- .../CSharp/Resolver/TypeInference.cs | 25 +- .../BinaryDocumentationProvider.cs | 231 - .../Documentation/XmlDocumentationProvider.cs | 275 +- .../ICSharpCode.NRefactory.csproj | 51 +- .../TypeSystem/ArrayType.cs | 5 +- .../TypeSystem/ByReferenceType.cs | 5 +- .../TypeSystem/CecilLoader.cs | 118 +- .../TypeSystem/DomRegion.cs | 50 +- ICSharpCode.NRefactory/TypeSystem/Error.cs | 135 + .../TypeSystem/ExtensionMethods.cs | 59 +- .../TypeSystem/IAnnotatable.cs | 216 + ICSharpCode.NRefactory/TypeSystem/IEntity.cs | 48 + .../TypeSystem/IParsedFile.cs | 63 + .../TypeSystem/IProjectContent.cs | 21 +- ICSharpCode.NRefactory/TypeSystem/IType.cs | 37 +- .../TypeSystem/ITypeDefinition.cs | 2 +- .../TypeSystem/ITypeResolveContext.cs | 28 +- .../TypeSystem/IVariable.cs | 5 + .../Implementation/AbstractFreezable.cs | 12 +- .../Implementation/AbstractMember.cs | 24 + .../TypeSystem/Implementation/AbstractType.cs | 11 +- .../CompositeTypeResolveContext.cs | 34 +- .../TypeSystem/Implementation/DefaultField.cs | 6 + .../Implementation/DefaultMethod.cs | 6 +- .../Implementation/DefaultParameter.cs | 6 + .../Implementation/DefaultTypeDefinition.cs | 102 +- .../Implementation/DefaultTypeParameter.cs | 134 +- .../Implementation/GetClassTypeReference.cs | 2 +- .../Implementation/NestedTypeReference.cs | 2 +- .../Implementation/ProxyTypeResolveContext.cs | 16 +- .../Implementation/SimpleProjectContent.cs | 75 +- .../Implementation/SpecializedMethod.cs | 9 +- .../Implementation/SpecializedProperty.cs | 6 +- .../SubstitutionTypeReference.cs | 31 + .../TypeSystem/Implementation/TypeStorage.cs | 93 +- .../TypeSystem/IntersectionType.cs | 10 +- .../TypeSystem/NullableType.cs | 2 +- .../TypeSystem/ParameterizedType.cs | 69 +- .../TypeSystem/PointerType.cs | 5 +- .../TypeSystem/ReflectionHelper.cs | 22 +- .../TypeSystem/SharedTypes.cs | 15 +- ICSharpCode.NRefactory/Utils/Platform.cs | 25 + NRefactory.sln | 12 +- README | 17 +- 225 files changed, 18537 insertions(+), 8867 deletions(-) create mode 100644 ICSharpCode.Editor/ICSharpCode.Editor.csproj create mode 100644 ICSharpCode.Editor/IDocument.cs create mode 100644 ICSharpCode.Editor/IDocumentLine.cs create mode 100644 ICSharpCode.Editor/ISegment.cs create mode 100644 ICSharpCode.Editor/ITextAnchor.cs create mode 100644 ICSharpCode.Editor/ITextEditor.cs create mode 100644 ICSharpCode.Editor/ITextSource.cs create mode 100644 ICSharpCode.Editor/LinkedElement.cs create mode 100644 ICSharpCode.Editor/Properties/AssemblyInfo.cs create mode 100644 ICSharpCode.Editor/ReadOnlyDocument.cs create mode 100644 ICSharpCode.Editor/StringTextSource.cs create mode 100644 ICSharpCode.Editor/TextChangeEventArgs.cs create mode 100644 ICSharpCode.Editor/TextLocation.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Ast/CSharpUtil.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Ast/ErrorNode.cs rename ICSharpCode.NRefactory/CSharp/{Formatter/Change.cs => Ast/IRelocatable.cs} (56%) create mode 100644 ICSharpCode.NRefactory/CSharp/Ast/ObservableAstVisitor.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Parser/mcs/async.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/Action.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/AddAnotherAccessor.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CheckIfParameterIsNull.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertDecToHex.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertForeachToFor.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertHexToDec.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateBackingStore.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateEventInvocator.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateField.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateLocalVariable.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateProperty.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/FlipOperatorArguments.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateGetter.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateSwitchLabels.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InsertAnonymousMethodSignature.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/IntroduceFormatItem.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InvertIf.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBackingStore.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBraces.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ReplaceEmptyString.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitDeclarationAndAssignment.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitString.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseExplicitType.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseVarKeyword.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/CreateLinkAction.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/FormatTextAction.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/IActionFactory.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/IContextAction.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/NodeOutputAction.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/NodeSelectionAction.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/RefactoringContext.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/Script.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/StringBuilderOutputFormatter.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/TextReplaceAction.cs create mode 100644 ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs delete mode 100644 ICSharpCode.NRefactory/Documentation/BinaryDocumentationProvider.cs create mode 100644 ICSharpCode.NRefactory/TypeSystem/Error.cs create mode 100644 ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs create mode 100644 ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs create mode 100644 ICSharpCode.NRefactory/TypeSystem/Implementation/SubstitutionTypeReference.cs create mode 100644 ICSharpCode.NRefactory/Utils/Platform.cs diff --git a/ICSharpCode.Editor/ICSharpCode.Editor.csproj b/ICSharpCode.Editor/ICSharpCode.Editor.csproj new file mode 100644 index 000000000..f3baf10f7 --- /dev/null +++ b/ICSharpCode.Editor/ICSharpCode.Editor.csproj @@ -0,0 +1,72 @@ + + + + {F054A788-B591-4561-A8BA-AE745BBEB817} + Debug + x86 + Library + ICSharpCode.Editor + ICSharpCode.Editor + v4.0 + Client + Properties + False + False + OnBuildSuccess + bin\Debug\ICSharpCode.Editor.xml + False + False + 4 + false + False + + + x86 + False + Auto + 4194304 + 4096 + + + bin\Debug\ + true + Full + False + True + DEBUG;TRACE + Project + + + bin\Release\ + False + None + True + False + TRACE + + + + + 3.5 + + + + 3.5 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ICSharpCode.Editor/IDocument.cs b/ICSharpCode.Editor/IDocument.cs new file mode 100644 index 000000000..925eaee66 --- /dev/null +++ b/ICSharpCode.Editor/IDocument.cs @@ -0,0 +1,141 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.Editor +{ + /// + /// A document representing a source code file for refactoring. + /// Line and column counting starts at 1. + /// Offset counting starts at 0. + /// + public interface IDocument : ITextSource, IServiceProvider + { + /// + /// Gets/Sets the text of the whole document.. + /// + new string Text { get; set; } // hides TextBuffer.Text to add the setter + + /// + /// Is raised when the Text property changes. + /// + event EventHandler TextChanged; + + /// + /// Gets the total number of lines in the document. + /// + int TotalNumberOfLines { get; } + + /// + /// Gets the document line with the specified number. + /// + /// The number of the line to retrieve. The first line has number 1. + IDocumentLine GetLine(int lineNumber); + + /// + /// Gets the document line that contains the specified offset. + /// + IDocumentLine GetLineByOffset(int offset); + + /// + /// Gets the offset from a text location. + /// + /// + int GetOffset(int line, int column); + + /// + /// Gets the offset from a text location. + /// + /// + int GetOffset(TextLocation location); + + /// + /// Gets the location from an offset. + /// + /// + TextLocation GetLocation(int offset); + + /// + /// Inserts text. + /// + /// The offset at which the text is inserted. + /// The new text. + /// + /// Anchors positioned exactly at the insertion offset will move according to their movement type. + /// For AnchorMovementType.Default, they will move behind the inserted text. + /// The caret will also move behind the inserted text. + /// + void Insert(int offset, string text); + + /// + /// Inserts text. + /// + /// The offset at which the text is inserted. + /// The new text. + /// + /// Anchors positioned exactly at the insertion offset will move according to the anchor's movement type. + /// For AnchorMovementType.Default, they will move according to the movement type specified by this parameter. + /// The caret will also move according to the parameter. + /// + void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType); + + /// + /// Removes text. + /// + /// Starting offset of the text to be removed. + /// Length of the text to be removed. + void Remove(int offset, int length); + + /// + /// Replaces text. + /// + /// The starting offset of the text to be replaced. + /// The length of the text to be replaced. + /// The new text. + void Replace(int offset, int length, string newText); + + /// + /// Make the document combine the following actions into a single + /// action for undo purposes. + /// + void StartUndoableAction(); + + /// + /// Ends the undoable action started with . + /// + void EndUndoableAction(); + + /// + /// Creates an undo group. Dispose the returned value to close the undo group. + /// + /// An object that closes the undo group when Dispose() is called. + IDisposable OpenUndoGroup(); + + /// + /// Creates a new at the specified offset. + /// + /// + ITextAnchor CreateAnchor(int offset); + + /// + /// This event is called directly before a change is applied to the document. + /// + /// + /// It is invalid to modify the document within this event handler. + /// Aborting the change (by throwing an exception) is likely to cause corruption of data structures + /// that listen to the Changing and Changed events. + /// + event EventHandler Changing; + + /// + /// This event is called directly after a change is applied to the document. + /// + /// + /// It is invalid to modify the document within this event handler. + /// Aborting the event handler (by throwing an exception) is likely to cause corruption of data structures + /// that listen to the Changing and Changed events. + /// + event EventHandler Changed; + } +} diff --git a/ICSharpCode.Editor/IDocumentLine.cs b/ICSharpCode.Editor/IDocumentLine.cs new file mode 100644 index 000000000..982a8cd2b --- /dev/null +++ b/ICSharpCode.Editor/IDocumentLine.cs @@ -0,0 +1,30 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.Editor +{ + /// + /// A line inside a . + /// + public interface IDocumentLine : ISegment + { + /// + /// Gets the length of this line, including the line delimiter. + /// + int TotalLength { get; } + + /// + /// Gets the length of the line terminator. + /// Returns 1 or 2; or 0 at the end of the document. + /// + int DelimiterLength { get; } + + /// + /// Gets the number of this line. + /// The first line has the number 1. + /// + int LineNumber { get; } + } +} diff --git a/ICSharpCode.Editor/ISegment.cs b/ICSharpCode.Editor/ISegment.cs new file mode 100644 index 000000000..bf8ac3c08 --- /dev/null +++ b/ICSharpCode.Editor/ISegment.cs @@ -0,0 +1,55 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.Editor +{ + /// + /// An (Offset,Length)-pair. + /// + public interface ISegment + { + /// + /// Gets the start offset of the segment. + /// + int Offset { get; } + + /// + /// Gets the length of the segment. + /// + /// Must not be negative. + int Length { get; } + + /// + /// Gets the end offset of the segment. + /// + /// EndOffset = Offset + Length; + int EndOffset { get; } + } + + /// + /// Extension methods for . + /// + public static class ISegmentExtensions + { + /// + /// Gets whether the segment contains the offset. + /// + /// + /// True, if offset is between segment.Start and segment.End (inclusive); otherwise, false. + /// + public static bool Contains (this ISegment segment, int offset) + { + return segment.Offset <= offset && offset <= segment.EndOffset; + } + + /// + /// True, if the segment contains the specified segment, false otherwise. + /// + public static bool Contains (this ISegment thisSegment, ISegment segment) + { + return segment != null && thisSegment.Offset <= segment.Offset && segment.EndOffset <= thisSegment.EndOffset; + } + } +} diff --git a/ICSharpCode.Editor/ITextAnchor.cs b/ICSharpCode.Editor/ITextAnchor.cs new file mode 100644 index 000000000..dfc95c9e7 --- /dev/null +++ b/ICSharpCode.Editor/ITextAnchor.cs @@ -0,0 +1,102 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.Editor +{ + /// + /// The TextAnchor class references an offset (a position between two characters). + /// It automatically updates the offset when text is inserted/removed in front of the anchor. + /// + /// + /// Use the property to get the offset from a text anchor. + /// Use the method to create an anchor from an offset. + /// + /// + /// The document will automatically update all text anchors; and because it uses weak references to do so, + /// the garbage collector can simply collect the anchor object when you don't need it anymore. + /// + /// Moreover, the document is able to efficiently update a large number of anchors without having to look + /// at each anchor object individually. Updating the offsets of all anchors usually only takes time logarithmic + /// to the number of anchors. Retrieving the property also runs in O(lg N). + /// + /// + /// Usage: + /// TextAnchor anchor = document.CreateAnchor(offset); + /// ChangeMyDocument(); + /// int newOffset = anchor.Offset; + /// + /// + public interface ITextAnchor + { + /// + /// Gets the text location of this anchor. + /// + /// Thrown when trying to get the Offset from a deleted anchor. + TextLocation Location { get; } + + /// + /// Gets the offset of the text anchor. + /// + /// Thrown when trying to get the Offset from a deleted anchor. + int Offset { get; } + + /// + /// Controls how the anchor moves. + /// + AnchorMovementType MovementType { get; set; } + + /// + /// Specifies whether the anchor survives deletion of the text containing it. + /// false: The anchor is deleted when the a selection that includes the anchor is deleted. + /// true: The anchor is not deleted. + /// + bool SurviveDeletion { get; set; } + + /// + /// Gets whether the anchor was deleted. + /// + bool IsDeleted { get; } + + /// + /// Occurs after the anchor was deleted. + /// + event EventHandler Deleted; + + /// + /// Gets the line number of the anchor. + /// + /// Thrown when trying to get the Offset from a deleted anchor. + int Line { get; } + + /// + /// Gets the column number of this anchor. + /// + /// Thrown when trying to get the Offset from a deleted anchor. + int Column { get; } + } + + /// + /// Defines how a text anchor moves. + /// + public enum AnchorMovementType + { + /// + /// When text is inserted at the anchor position, the type of the insertion + /// determines where the caret moves to. For normal insertions, the anchor will stay + /// behind the inserted text. + /// + Default, + /// + /// Behaves like a start marker - when text is inserted at the anchor position, the anchor will stay + /// before the inserted text. + /// + BeforeInsertion, + /// + /// Behave like an end marker - when text is insered at the anchor position, the anchor will move + /// after the inserted text. + /// + AfterInsertion + } +} diff --git a/ICSharpCode.Editor/ITextEditor.cs b/ICSharpCode.Editor/ITextEditor.cs new file mode 100644 index 000000000..6d15eb769 --- /dev/null +++ b/ICSharpCode.Editor/ITextEditor.cs @@ -0,0 +1,100 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace ICSharpCode.Editor +{ + /// + /// Interface for text editors. + /// + public interface ITextEditor : IServiceProvider + { + /// + /// Gets the document that is being edited. + /// + IDocument Document { get; } + + /// + /// Gets an object that represents the caret inside this text editor. + /// + ITextEditorCaret Caret { get; } + + /// + /// Sets the caret to the specified line/column and brings the caret into view. + /// + void JumpTo(int line, int column); + + /// + /// Gets the start offset of the selection. + /// + int SelectionStart { get; } + + /// + /// Gets the length of the selection. + /// + int SelectionLength { get; } + + /// + /// Gets/Sets the selected text. + /// + string SelectedText { get; set; } + + /// + /// Sets the selection. + /// + /// Start offset of the selection + /// Length of the selection + void Select(int selectionStart, int selectionLength); + + /// + /// Shows the specified linked elements, and allows the user to edit them. + /// + /// + /// Returns true when the user has finished editing the elements and pressed Return; + /// or false when editing is aborted for any reason. + /// + /// + /// The user can also edit other parts of the document (or other documents) while in link mode. + /// In case of success (true return value), this method will update the offsets of the linked elements + /// to reflect the changes done by the user. + /// If the text editor does not support link mode, it will immediately return false. + /// +// Task ShowLinkedElements(IEnumerable linkedElements); + } + + /// + /// Represents the caret in a text editor. + /// + public interface ITextEditorCaret + { + /// + /// Gets/Sets the caret offset; + /// + int Offset { get; set; } + + /// + /// Gets/Sets the caret line number. + /// Line numbers are counted starting from 1. + /// + int Line { get; set; } + + /// + /// Gets/Sets the caret column number. + /// Column numbers are counted starting from 1. + /// + int Column { get; set; } + + /// + /// Gets/sets the caret location. + /// + TextLocation Location { get; set; } + + /// + /// Is raised whenever the location of the caret has changed. + /// + event EventHandler LocationChanged; + } +} diff --git a/ICSharpCode.Editor/ITextSource.cs b/ICSharpCode.Editor/ITextSource.cs new file mode 100644 index 000000000..d5c6f9e9f --- /dev/null +++ b/ICSharpCode.Editor/ITextSource.cs @@ -0,0 +1,147 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.IO; + +namespace ICSharpCode.Editor +{ + /// + /// A read-only view on a (potentially mutable) text source. + /// The IDocument interfaces derives from this interface. + /// + public interface ITextSource + { + /// + /// Gets a version identifier for this text source. + /// Returns null for unversioned text sources. + /// + ITextSourceVersion Version { get; } + + /// + /// Creates an immutable snapshot of this text source. + /// Unlike all other methods in this interface, this method is thread-safe. + /// + ITextSource CreateSnapshot(); + + /// + /// Creates an immutable snapshot of a part of this text source. + /// Unlike all other methods in this interface, this method is thread-safe. + /// + ITextSource CreateSnapshot(int offset, int length); + + /// + /// Creates a new TextReader to read from this text source. + /// + TextReader CreateReader(); + + /// + /// Creates a new TextReader to read from this text source. + /// + TextReader CreateReader(int offset, int length); + + /// + /// Gets the total text length. + /// + /// The length of the text, in characters. + /// This is the same as Text.Length, but is more efficient because + /// it doesn't require creating a String object. + int TextLength { get; } + + /// + /// Gets the whole text as string. + /// + string Text { get; } + + /// + /// Gets a character at the specified position in the document. + /// + /// The index of the character to get. + /// Offset is outside the valid range (0 to TextLength-1). + /// The character at the specified position. + /// This is the same as Text[offset], but is more efficient because + /// it doesn't require creating a String object. + char GetCharAt(int offset); + + /// + /// Retrieves the text for a portion of the document. + /// + /// offset or length is outside the valid range. + /// This is the same as Text.Substring, but is more efficient because + /// it doesn't require creating a String object for the whole document. + string GetText(int offset, int length); + + /// + /// Retrieves the text for a portion of the document. + /// + /// offset or length is outside the valid range. + string GetText(ISegment segment); + + /// + /// Gets the index of the first occurrence of any character in the specified array. + /// + /// Characters to search for + /// Start index of the search. + /// Length of the area to search. + /// The first index where any character was found; or -1 if no occurrence was found. + int IndexOfAny(char[] anyOf, int startIndex, int count); + + /* What about: + void Insert (int offset, string value); + void Remove (int offset, int count); + void Remove (ISegment segment); + + void Replace (int offset, int count, string value); + + Or more search operations: + + IEnumerable SearchForward (string pattern, int startIndex); + IEnumerable SearchForwardIgnoreCase (string pattern, int startIndex); + + IEnumerable SearchBackward (string pattern, int startIndex); + IEnumerable SearchBackwardIgnoreCase (string pattern, int startIndex); + */ + } + + /// + /// Represents a version identifier for a text source. + /// + /// + /// Verions can be used to efficiently detect whether a document has changed and needs reparsing; + /// or even to implement incremental parsers. + /// It is a separate class from ITextBuffer to allow the GC to collect the text buffer while + /// the version checkpoint is still in use. + /// + public interface ITextSourceVersion + { + /// + /// Gets whether this checkpoint belongs to the same document as the other checkpoint. + /// + bool BelongsToSameDocumentAs(ITextSourceVersion other); + + /// + /// Compares the age of this checkpoint to the other checkpoint. + /// + /// This method is thread-safe. + /// Raised if 'other' belongs to a different document than this version. + /// -1 if this version is older than . + /// 0 if this version instance represents the same version as . + /// 1 if this version is newer than . + int CompareAge(ITextSourceVersion other); + + /// + /// Gets the changes from this checkpoint to the other checkpoint. + /// If 'other' is older than this checkpoint, reverse changes are calculated. + /// + /// This method is thread-safe. + /// Raised if 'other' belongs to a different document than this checkpoint. + IEnumerable GetChangesTo(ITextSourceVersion other); + + /// + /// Calculates where the offset has moved in the other buffer version. + /// + /// Raised if 'other' belongs to a different document than this checkpoint. + int MoveOffsetTo(ITextSourceVersion other, int oldOffset, AnchorMovementType movement); + } +} diff --git a/ICSharpCode.Editor/LinkedElement.cs b/ICSharpCode.Editor/LinkedElement.cs new file mode 100644 index 000000000..104e53e8a --- /dev/null +++ b/ICSharpCode.Editor/LinkedElement.cs @@ -0,0 +1,68 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.Editor +{ +// I'm not sure if we need this. +// How about a method in the context - this method could wrap the internal representation. +// public void StartTextLinkMode (int linkLength, IEnumerable offsets) +// and maybe then variations taking more than one link element ? + +// /// +// /// Represents an element in the text editor that is either editable, or bound to another editable element. +// /// Used with +// /// +// public class LinkedElement +// { +// LinkedElement boundTo; +// +// /// +// /// Gets/Sets the start offset of this linked element. +// /// +// public int StartOffset { get; set; } +// +// /// +// /// Gets/Sets the end offset of this linked element. +// /// +// public int EndOffset { get; set; } +// +// /// +// /// Gets the linked element to which this element is bound. +// /// +// public LinkedElement BoundTo { +// get { return boundTo; } +// } +// +// /// +// /// Gets whether this element is editable. Returns true if this element is not bound. +// /// +// public bool IsEditable { +// get { return boundTo == null; } +// } +// +// /// +// /// Creates a new editable element. +// /// +// public LinkedElement(int startOffset, int endOffset) +// { +// this.StartOffset = startOffset; +// this.EndOffset = endOffset; +// } +// +// /// +// /// Creates a new element that is bound to . +// /// +// public LinkedElement(int startOffset, int endOffset, LinkedElement boundTo) +// { +// if (boundTo == null) +// throw new ArgumentNullException("boundTo"); +// this.StartOffset = startOffset; +// this.EndOffset = endOffset; +// while (boundTo.boundTo != null) +// boundTo = boundTo.boundTo; +// this.boundTo = boundTo; +// } +// } +} diff --git a/ICSharpCode.Editor/Properties/AssemblyInfo.cs b/ICSharpCode.Editor/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..7d06f8744 --- /dev/null +++ b/ICSharpCode.Editor/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ICSharpCode.Editor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ICSharpCode.Editor")] +[assembly: AssemblyCopyright("Copyright 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/ICSharpCode.Editor/ReadOnlyDocument.cs b/ICSharpCode.Editor/ReadOnlyDocument.cs new file mode 100644 index 000000000..d175cea82 --- /dev/null +++ b/ICSharpCode.Editor/ReadOnlyDocument.cs @@ -0,0 +1,321 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.Editor +{ + /// + /// Read-only implementation of . + /// + public sealed class ReadOnlyDocument : IDocument + { + readonly ITextSource textSource; + int[] lines; + + static readonly char[] newline = { '\r', '\n' }; + + /// + /// Creates a new ReadOnlyDocument from the given text source. + /// + public ReadOnlyDocument(ITextSource textSource) + { + if (textSource == null) + throw new ArgumentNullException("textSource"); + // ensure that underlying buffer is immutable + this.textSource = textSource.CreateSnapshot(); + List lines = new List(); + lines.Add(0); + int offset = 0; + int textLength = textSource.TextLength; + while ((offset = textSource.IndexOfAny(newline, offset, textLength - offset)) >= 0) { + offset++; + if (textSource.GetCharAt(offset - 1) == '\r' && offset < textLength && textSource.GetCharAt(offset) == '\n') { + offset++; + } + lines.Add(offset); + } + this.lines = lines.ToArray(); + } + + /// + /// Creates a new ReadOnlyDocument from the given string. + /// + public ReadOnlyDocument(string text) + : this(new StringTextSource(text)) + { + } + + /// + public IDocumentLine GetLine(int lineNumber) + { + if (lineNumber < 1 || lineNumber > lines.Length) + throw new ArgumentOutOfRangeException("lineNumber", lineNumber, "Value must be between 1 and " + lines.Length); + return new ReadOnlyDocumentLine(this, lineNumber); + } + + sealed class ReadOnlyDocumentLine : IDocumentLine + { + readonly ReadOnlyDocument doc; + readonly int lineNumber; + readonly int offset, endOffset; + + public ReadOnlyDocumentLine(ReadOnlyDocument doc, int lineNumber) + { + this.doc = doc; + this.lineNumber = lineNumber; + this.offset = doc.GetStartOffset(lineNumber); + this.endOffset = doc.GetEndOffset(lineNumber); + } + + public int Offset { + get { return offset; } + } + + public int Length { + get { return endOffset - offset; } + } + + public int EndOffset { + get { return endOffset; } + } + + public int TotalLength { + get { + return doc.GetTotalEndOffset(lineNumber) - offset; + } + } + + public int DelimiterLength { + get { + return doc.GetTotalEndOffset(lineNumber) - endOffset; + } + } + + public int LineNumber { + get { return lineNumber; } + } + } + + int GetStartOffset(int lineNumber) + { + return lines[lineNumber-1]; + } + + int GetTotalEndOffset(int lineNumber) + { + return lineNumber < lines.Length ? lines[lineNumber] : textSource.TextLength; + } + + int GetEndOffset(int lineNumber) + { + if (lineNumber == lines.Length) + return textSource.TextLength; + int off = lines[lineNumber] - 1; + if (off > 0 && textSource.GetCharAt(off - 1) == '\r' && textSource.GetCharAt(off) == '\n') + off--; + return off; + } + + /// + public IDocumentLine GetLineByOffset(int offset) + { + return GetLine(GetLineNumberForOffset(offset)); + } + + int GetLineNumberForOffset(int offset) + { + int r = Array.BinarySearch(lines, offset); + return r < 0 ? ~r : r + 1; + } + + /// + public int GetOffset(int line, int column) + { + if (line < 1 || line > lines.Length) + throw new ArgumentOutOfRangeException("line", line, "Value must be between 1 and " + lines.Length); + int lineStart = GetStartOffset(line); + if (column <= 0) + return lineStart; + int lineEnd = GetEndOffset(line); + if (column >= lineEnd - lineStart) + return lineEnd; + return lineStart + column - 1; + } + + /// + public int GetOffset(TextLocation location) + { + return GetOffset(location.Line, location.Column); + } + + /// + public TextLocation GetLocation(int offset) + { + if (offset < 0 || offset > textSource.TextLength) + throw new ArgumentOutOfRangeException("offset", offset, "Value must be between 0 and " + textSource.TextLength); + int line = GetLineNumberForOffset(offset); + return new TextLocation(offset-GetStartOffset(line)+1, line); + } + + /// + public string Text { + get { return textSource.Text; } + set { + throw new NotSupportedException(); + } + } + + /// + public int TotalNumberOfLines { + get { return lines.Length; } + } + + ITextSourceVersion ITextSource.Version { + get { return null; } + } + + /// + public int TextLength { + get { return textSource.TextLength; } + } + + event EventHandler IDocument.Changing { add {} remove {} } + + event EventHandler IDocument.Changed { add {} remove {} } + + event EventHandler IDocument.TextChanged { add {} remove {} } + + void IDocument.Insert(int offset, string text) + { + throw new NotSupportedException(); + } + + void IDocument.Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType) + { + throw new NotSupportedException(); + } + + void IDocument.Remove(int offset, int length) + { + throw new NotSupportedException(); + } + + void IDocument.Replace(int offset, int length, string newText) + { + throw new NotSupportedException(); + } + + void IDocument.StartUndoableAction() + { + } + + void IDocument.EndUndoableAction() + { + } + + IDisposable IDocument.OpenUndoGroup() + { + return null; + } + + /// + public ITextAnchor CreateAnchor(int offset) + { + return new ReadOnlyDocumentTextAnchor(GetLocation(offset), offset); + } + + sealed class ReadOnlyDocumentTextAnchor : ITextAnchor + { + readonly TextLocation location; + readonly int offset; + + public ReadOnlyDocumentTextAnchor(TextLocation location, int offset) + { + this.location = location; + this.offset = offset; + } + + public event EventHandler Deleted { add {} remove {} } + + public TextLocation Location { + get { return location; } + } + + public int Offset { + get { return offset; } + } + + public AnchorMovementType MovementType { get; set; } + + public bool SurviveDeletion { get; set; } + + public bool IsDeleted { + get { return false; } + } + + public int Line { + get { return location.Line; } + } + + public int Column { + get { return location.Column; } + } + } + + /// + public ITextSource CreateSnapshot() + { + return textSource; // textBuffer is immutable + } + + /// + public ITextSource CreateSnapshot(int offset, int length) + { + return textSource.CreateSnapshot(offset, length); + } + + /// + public System.IO.TextReader CreateReader() + { + return textSource.CreateReader(); + } + + /// + public System.IO.TextReader CreateReader(int offset, int length) + { + return textSource.CreateReader(offset, length); + } + + /// + public char GetCharAt(int offset) + { + return textSource.GetCharAt(offset); + } + + /// + public string GetText(int offset, int length) + { + return textSource.GetText(offset, length); + } + + /// + public string GetText(ISegment segment) + { + return textSource.GetText(segment); + } + + /// + public int IndexOfAny(char[] anyOf, int startIndex, int count) + { + return textSource.IndexOfAny(anyOf, startIndex, count); + } + + /// + public object GetService(Type serviceType) + { + return null; + } + } +} diff --git a/ICSharpCode.Editor/StringTextSource.cs b/ICSharpCode.Editor/StringTextSource.cs new file mode 100644 index 000000000..1d5d3386f --- /dev/null +++ b/ICSharpCode.Editor/StringTextSource.cs @@ -0,0 +1,91 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.IO; + +namespace ICSharpCode.Editor +{ + /// + /// Implements the ITextSource interface using a string. + /// + [Serializable] + public class StringTextSource : ITextSource + { + readonly string text; + + /// + /// Creates a new StringTextSource with the given text. + /// + public StringTextSource(string text) + { + if (text == null) + throw new ArgumentNullException("text"); + this.text = text; + } + + ITextSourceVersion ITextSource.Version { + get { return null; } + } + + /// + public int TextLength { + get { return text.Length; } + } + + /// + public string Text { + get { return text; } + } + + /// + public ITextSource CreateSnapshot() + { + return this; // StringTextBuffer is immutable + } + + /// + public ITextSource CreateSnapshot(int offset, int length) + { + return new StringTextSource(text.Substring(offset, length)); + } + + /// + public TextReader CreateReader() + { + return new StringReader(text); + } + + /// + public TextReader CreateReader(int offset, int length) + { + return new StringReader(text.Substring(offset, length)); + } + + /// + public char GetCharAt(int offset) + { + return text[offset]; + } + + /// + public string GetText(int offset, int length) + { + return text.Substring(offset, length); + } + + /// + public string GetText(ISegment segment) + { + if (segment == null) + throw new ArgumentNullException("segment"); + return text.Substring(segment.Offset, segment.Length); + } + + /// + public int IndexOfAny(char[] anyOf, int startIndex, int count) + { + return text.IndexOfAny(anyOf, startIndex, count); + } + } +} diff --git a/ICSharpCode.Editor/TextChangeEventArgs.cs b/ICSharpCode.Editor/TextChangeEventArgs.cs new file mode 100644 index 000000000..385f5104a --- /dev/null +++ b/ICSharpCode.Editor/TextChangeEventArgs.cs @@ -0,0 +1,64 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.Editor +{ + /// + /// Describes a change of the document text. + /// This class is thread-safe. + /// + [Serializable] + public class TextChangeEventArgs : EventArgs + { + readonly int offset; + readonly string removedText; + readonly string insertedText; + + /// + /// The offset at which the change occurs. + /// + public int Offset { + get { return offset; } + } + + /// + /// The text that was inserted. + /// + public string RemovedText { + get { return removedText; } + } + + /// + /// The number of characters removed. + /// + public int RemovalLength { + get { return removedText.Length; } + } + + /// + /// The text that was inserted. + /// + public string InsertedText { + get { return insertedText; } + } + + /// + /// The number of characters inserted. + /// + public int InsertionLength { + get { return insertedText.Length; } + } + + /// + /// Creates a new TextChangeEventArgs object. + /// + public TextChangeEventArgs(int offset, string removedText, string insertedText) + { + this.offset = offset; + this.removedText = removedText ?? string.Empty; + this.insertedText = insertedText ?? string.Empty; + } + } +} diff --git a/ICSharpCode.Editor/TextLocation.cs b/ICSharpCode.Editor/TextLocation.cs new file mode 100644 index 000000000..12bfe354e --- /dev/null +++ b/ICSharpCode.Editor/TextLocation.cs @@ -0,0 +1,173 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.Globalization; + +namespace ICSharpCode.Editor +{ + /// + /// A line/column position. + /// Text editor lines/columns are counted started from one. + /// + /// + /// The document provides the methods and + /// to convert between offsets and TextLocations. + /// + [Serializable] + public struct TextLocation : IComparable, IEquatable + { + /// + /// Represents no text location (0, 0). + /// + public static readonly TextLocation Empty = new TextLocation(0, 0); + + /// + /// Constant of the minimum line. + /// + public const int MinLine = 1; + + /// + /// Constant of the minimum column. + /// + public const int MinColumn = 1; + + /// + /// Creates a TextLocation instance. + /// + public TextLocation(int line, int column) + { + this.line = line; + this.column = column; + } + + int column, line; + + /// + /// Gets the line number. + /// + public int Line { + get { return line; } + } + + /// + /// Gets the column number. + /// + public int Column { + get { return column; } + } + + /// + /// Gets whether the TextLocation instance is empty. + /// + public bool IsEmpty { + get { + return column < MinLine && line < MinColumn; + } + } + + /// + /// Gets a string representation for debugging purposes. + /// + public override string ToString() + { + return string.Format(CultureInfo.InvariantCulture, "(Line {1}, Col {0})", this.column, this.line); + } + + /// + /// Gets a hash code. + /// + public override int GetHashCode() + { + return unchecked (191 * column.GetHashCode() ^ line.GetHashCode()); + } + + /// + /// Equality test. + /// + public override bool Equals(object obj) + { + if (!(obj is TextLocation)) return false; + return (TextLocation)obj == this; + } + + /// + /// Equality test. + /// + public bool Equals(TextLocation other) + { + return this == other; + } + + /// + /// Equality test. + /// + public static bool operator ==(TextLocation left, TextLocation right) + { + return left.column == right.column && left.line == right.line; + } + + /// + /// Inequality test. + /// + public static bool operator !=(TextLocation left, TextLocation right) + { + return left.column != right.column || left.line != right.line; + } + + /// + /// Compares two text locations. + /// + public static bool operator <(TextLocation left, TextLocation right) + { + if (left.line < right.line) + return true; + else if (left.line == right.line) + return left.column < right.column; + else + return false; + } + + /// + /// Compares two text locations. + /// + public static bool operator >(TextLocation left, TextLocation right) + { + if (left.line > right.line) + return true; + else if (left.line == right.line) + return left.column > right.column; + else + return false; + } + + /// + /// Compares two text locations. + /// + public static bool operator <=(TextLocation left, TextLocation right) + { + return !(left > right); + } + + /// + /// Compares two text locations. + /// + public static bool operator >=(TextLocation left, TextLocation right) + { + return !(left < right); + } + + /// + /// Compares two text locations. + /// + public int CompareTo(TextLocation other) + { + if (this == other) + return 0; + if (this < other) + return -1; + else + return 1; + } + } +} diff --git a/ICSharpCode.NRefactory.Demo/CSDemo.cs b/ICSharpCode.NRefactory.Demo/CSDemo.cs index d667596de..f589e3325 100644 --- a/ICSharpCode.NRefactory.Demo/CSDemo.cs +++ b/ICSharpCode.NRefactory.Demo/CSDemo.cs @@ -180,7 +180,7 @@ namespace ICSharpCode.NRefactory.Demo SimpleProjectContent project = new SimpleProjectContent(); TypeSystemConvertVisitor convertVisitor = new TypeSystemConvertVisitor(project, "dummy.cs"); compilationUnit.AcceptVisitor(convertVisitor, null); - project.UpdateProjectContent(null, convertVisitor.ParsedFile.TopLevelTypeDefinitions, null, null); + project.UpdateProjectContent(null, convertVisitor.ParsedFile); List projects = new List(); projects.Add(project); diff --git a/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs index 701aa4b35..b7f6328f3 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs @@ -23,7 +23,8 @@ namespace ICSharpCode.NRefactory.CSharp expr = expr.Clone(); expr.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }, null); StringWriter w = new StringWriter(); - expr.AcceptVisitor(new OutputVisitor(w, policy), null); + w.NewLine = " "; + expr.AcceptVisitor(new OutputVisitor(new TextWriterOutputFormatter(w) { IndentationString = "" }, policy), null); return w.ToString(); } @@ -32,7 +33,8 @@ namespace ICSharpCode.NRefactory.CSharp expr = expr.Clone(); expr.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = false }, null); StringWriter w = new StringWriter(); - expr.AcceptVisitor(new OutputVisitor(w, policy), null); + w.NewLine = " "; + expr.AcceptVisitor(new OutputVisitor(new TextWriterOutputFormatter(w) { IndentationString = "" }, policy), null); return w.ToString(); } @@ -85,6 +87,33 @@ namespace ICSharpCode.NRefactory.CSharp Assert.AreEqual("(MyType)(!a)", InsertReadable(expr)); } + [Test] + public void TrickyCast4() + { + Expression expr = new PrimitiveExpression(int.MinValue).CastTo(new SimpleType("MyType")); + + Assert.AreEqual("(MyType)(-2147483648)", InsertRequired(expr)); + Assert.AreEqual("(MyType)(-2147483648)", InsertReadable(expr)); + } + + [Test] + public void TrickyCast5() + { + Expression expr = new PrimitiveExpression(-1.0).CastTo(new SimpleType("MyType")); + + Assert.AreEqual("(MyType)(-1.0)", InsertRequired(expr)); + Assert.AreEqual("(MyType)(-1.0)", InsertReadable(expr)); + } + + [Test] + public void TrickyCast6() + { + Expression expr = new PrimitiveExpression(int.MinValue).CastTo(new PrimitiveType("double")); + + Assert.AreEqual("(double)-2147483648", InsertRequired(expr)); + Assert.AreEqual("(double)-2147483648", InsertReadable(expr)); + } + [Test] public void CastAndInvoke() { @@ -170,8 +199,8 @@ namespace ICSharpCode.NRefactory.CSharp } }.Invoke("ToArray"); - Assert.AreEqual("(from a in b" + Environment.NewLine + "select a.c ()).ToArray ()", InsertRequired(expr)); - Assert.AreEqual("(from a in b" + Environment.NewLine + "select a.c ()).ToArray ()", InsertReadable(expr)); + Assert.AreEqual("( from a in b select a.c ()).ToArray ()", InsertRequired(expr)); + Assert.AreEqual("( from a in b select a.c ()).ToArray ()", InsertReadable(expr)); } [Test] @@ -194,12 +223,10 @@ namespace ICSharpCode.NRefactory.CSharp query.Clone() ); - Assert.AreEqual("(from a in b" + Environment.NewLine + - "select a) + from a in b" + Environment.NewLine + - "select a", InsertRequired(expr)); - Assert.AreEqual("(from a in b" + Environment.NewLine + - "select a) + (from a in b" + Environment.NewLine + - "select a)", InsertReadable(expr)); + Assert.AreEqual("( from a in b select a) + " + + " from a in b select a", InsertRequired(expr)); + Assert.AreEqual("( from a in b select a) + " + + "( from a in b select a)", InsertReadable(expr)); } [Test] @@ -217,10 +244,8 @@ namespace ICSharpCode.NRefactory.CSharp } }.IsType(new PrimitiveType("int")); - Assert.AreEqual("(from a in b" + Environment.NewLine + - "select a) is int", InsertRequired(expr)); - Assert.AreEqual("(from a in b" + Environment.NewLine + - "select a) is int", InsertReadable(expr)); + Assert.AreEqual("( from a in b select a) is int", InsertRequired(expr)); + Assert.AreEqual("( from a in b select a) is int", InsertReadable(expr)); } [Test] diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeOfExpressionTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeOfExpressionTests.cs index 65fca770a..847b70567 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeOfExpressionTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeOfExpressionTests.cs @@ -118,7 +118,22 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression "typeof(MyType<,>)", new TypeOfExpression { Type = type - }); + }); + } + + [Test] + public void NestedArraysTest() + { + ParseUtilCSharp.AssertExpression( + "typeof(int[,][])", + new TypeOfExpression { + Type = new ComposedType { + BaseType = new PrimitiveType("int"), + ArraySpecifiers = { + new ArraySpecifier(2), + new ArraySpecifier(1) + } + }}); } } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs index 11450dd97..15707c51b 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs @@ -4,7 +4,9 @@ using System; using System.Linq; using System.Text.RegularExpressions; + using ICSharpCode.NRefactory.PatternMatching; +using ICSharpCode.NRefactory.TypeSystem; using NUnit.Framework; namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -12,7 +14,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope [TestFixture] public class AttributeSectionTests { - [Test, Ignore("Parser crash")] + [Test] public void GlobalAttributeCSharp() { string program = @"[global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] @@ -27,7 +29,7 @@ public class Form1 { Assert.AreEqual("someprefix::DesignerGenerated", decl.Attributes.Last().Attributes.Single().Type.ToString()); } - [Test, Ignore("assembly/module attributes are broken")] + [Test] public void AssemblyAttributeCSharp() { string program = @"[assembly: System.Attribute()]"; @@ -80,20 +82,59 @@ public class Form1 { [Test, Ignore("Parser doesn't support attributes on type parameters")] public void AttributesOnTypeParameter() { - string program = @"class Test<[A,B]C> {}"; - TypeDeclaration type = ParseUtilCSharp.ParseGlobal(program); - Assert.IsTrue( - new TypeParameterDeclaration { - Attributes = { - new AttributeSection { + ParseUtilCSharp.AssertGlobal( + "class Test<[A,B]C> {}", + new TypeDeclaration { + ClassType = ClassType.Class, + Name = "Test", + TypeParameters = { + new TypeParameterDeclaration { Attributes = { - new Attribute { Type = new SimpleType("A") }, - new Attribute { Type = new SimpleType("B") } - } + new AttributeSection { + Attributes = { + new Attribute { Type = new SimpleType("A") }, + new Attribute { Type = new SimpleType("B") } + } + } + }, + Name = "C" + } + }}); + } + + [Test] + public void AttributeOnMethodParameter() + { + ParseUtilCSharp.AssertTypeMember( + "void M([In] int p);", + new MethodDeclaration { + ReturnType = new PrimitiveType("void"), + Name = "M", + Parameters = { + new ParameterDeclaration { + Attributes = { new AttributeSection(new Attribute { Type = new SimpleType("In") }) }, + Type = new PrimitiveType("int"), + Name = "p" } - }, - Name = "C" - }.IsMatch(type.TypeParameters.Single())); + }}); + } + + [Test] + public void AttributeOnSetterValue() + { + ParseUtilCSharp.AssertTypeMember( + "int P { get; [param: In] set; }", + new PropertyDeclaration { + ReturnType = new PrimitiveType("int"), + Name = "P", + Getter = new Accessor(), + Setter = new Accessor { + Attributes = { + new AttributeSection { + AttributeTarget = "param", + Attributes = { new Attribute { Type = new SimpleType("In") } }, + } }, + }}); } // TODO: Tests for other contexts where attributes can appear diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs index 4a0b5fad0..2c123a5dd 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs @@ -280,5 +280,13 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 Assert.AreEqual("Val1", member.Name); Assert.AreEqual(10, ((PrimitiveExpression)member.Initializer).Value); } + + [Test] + public void EnumWithBaseType() + { + TypeDeclaration td = ParseUtilCSharp.ParseGlobal("enum MyEnum : short { }"); + Assert.AreEqual("MyEnum", td.Name); + Assert.AreEqual("short", ((PrimitiveType)td.BaseTypes.Single()).Keyword); + } } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs index 6b52a8dc9..9606e3247 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeSystemConvertVisitorTests.cs @@ -10,7 +10,7 @@ using NUnit.Framework; namespace ICSharpCode.NRefactory.CSharp.Parser { - [TestFixture, Ignore("TypeSystemConvertVisitor is not complete yet")] + [TestFixture] public class TypeSystemConvertVisitorTests : TypeSystemTests { ITypeResolveContext ctx = CecilLoaderTests.Mscorlib; @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser TypeSystemConvertVisitor visitor = new TypeSystemConvertVisitor(testCasePC, fileName); cu.AcceptVisitor(visitor, null); ParsedFile parsedFile = visitor.ParsedFile; - ((SimpleProjectContent)testCasePC).UpdateProjectContent(null, parsedFile.TopLevelTypeDefinitions, null, null); + ((SimpleProjectContent)testCasePC).UpdateProjectContent(null, parsedFile); } } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/AttributeTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/AttributeTests.cs index dc5768803..bca436254 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/AttributeTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/AttributeTests.cs @@ -7,7 +7,7 @@ using NUnit.Framework; namespace ICSharpCode.NRefactory.CSharp.Resolver { - [TestFixture, Ignore("DOM for attributes is incomplete")] + [TestFixture] public class AttributeTests : ResolverTestBase { [Test] @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { string program = "using System; [$LoaderOptimization(3)$] class Test { }"; var mrr = Resolve(program); - Assert.AreEqual("System.LoaderOptimization.#ctor", mrr.Member.FullName); + Assert.AreEqual("System.LoaderOptimizationAttribute..ctor", mrr.Member.FullName); Assert.AreEqual("System.Byte", (mrr.Member as IMethod).Parameters[0].Type.Resolve(context).FullName); } @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { string program = "using System; [$LoaderOptimization(LoaderOptimization.NotSpecified)$] class Test { }"; var mrr = Resolve(program); - Assert.AreEqual("System.LoaderOptimization.#ctor", mrr.Member.FullName); + Assert.AreEqual("System.LoaderOptimizationAttribute..ctor", mrr.Member.FullName); Assert.AreEqual("System.LoaderOptimization", (mrr.Member as IMethod).Parameters[0].Type.Resolve(context).FullName); } @@ -78,7 +78,7 @@ enum E { A, B } Assert.AreEqual("MyNamespace.E.A", result.Member.FullName); } - [Test] + [Test, Ignore("Not implemented in type system.")] public void SD_1384() { string program = @"using System; diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/BinaryOperatorTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/BinaryOperatorTests.cs index 1b141ecb0..250c2619e 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/BinaryOperatorTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/BinaryOperatorTests.cs @@ -388,5 +388,62 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver AssertType(typeof(dynamic), resolver.ResolveBinaryOperator( BinaryOperatorType.NullCoalescing, MakeResult(typeof(string)), MakeResult(typeof(dynamic)))); } + + [Test, Ignore("user-defined operators not yet implemented")] + public void LiftedUserDefined() + { + AssertType(typeof(TimeSpan), resolver.ResolveBinaryOperator( + BinaryOperatorType.Subtract, MakeResult(typeof(DateTime)), MakeResult(typeof(DateTime)))); + AssertType(typeof(TimeSpan?), resolver.ResolveBinaryOperator( + BinaryOperatorType.Subtract, MakeResult(typeof(DateTime?)), MakeResult(typeof(DateTime)))); + AssertType(typeof(TimeSpan?), resolver.ResolveBinaryOperator( + BinaryOperatorType.Subtract, MakeResult(typeof(DateTime)), MakeResult(typeof(DateTime?)))); + AssertType(typeof(TimeSpan?), resolver.ResolveBinaryOperator( + BinaryOperatorType.Subtract, MakeResult(typeof(DateTime?)), MakeResult(typeof(DateTime?)))); + } + + [Test, Ignore("user-defined operators not yet implemented")] + public void UserDefinedNeedsLiftingDueToImplicitConversion() + { + string program = @"struct S {} +struct A { + public static implicit operator S?(A a) { return null; } + + public static S operator +(A a, S s) { return s; } +} +class Test { + void M(A a) { + var s = $a + a$; + } +} +"; + MemberResolveResult trr = Resolve(program); + Assert.IsFalse(trr.IsError); + Assert.AreEqual("A.op_Addition", trr.Member.FullName); + // even though we're calling the lifted operator, trr.Member should be the original operator method + Assert.AreEqual("S", trr.Member.ReturnType.Resolve(context).ReflectionName); + Assert.AreEqual("System.Nullable`1[[S]]", trr.Type.ReflectionName); + } + + [Test, Ignore("user-defined operators not yet implemented")] + public void ThereIsNoLiftedOperatorsForClasses() + { + string program = @"struct S {} +class A { + public static implicit operator S?(A a) { return null; } + + public static S operator +(A a, S s) { return s; } +} +class Test { + void M(A a) { + var s = $a + a$; + } +} +"; + MemberResolveResult trr = Resolve(program); + Assert.IsTrue(trr.IsError); // cannot convert from A to S + Assert.AreEqual("A.op_Addition", trr.Member.FullName); + Assert.AreEqual("S", trr.Type.ReflectionName); + } } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ConversionsTest.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ConversionsTest.cs index a63ba562c..f1d270398 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ConversionsTest.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ConversionsTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.Collections.Generic; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; using NUnit.Framework; namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -16,13 +17,13 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver [TestFixture] public unsafe class ConversionsTest { - IProjectContent mscorlib = CecilLoaderTests.Mscorlib; + ITypeResolveContext ctx = CecilLoaderTests.Mscorlib; Conversions conversions = new Conversions(CecilLoaderTests.Mscorlib); bool ImplicitConversion(Type from, Type to) { - IType from2 = from.ToTypeReference().Resolve(mscorlib); - IType to2 = to.ToTypeReference().Resolve(mscorlib); + IType from2 = from.ToTypeReference().Resolve(ctx); + IType to2 = to.ToTypeReference().Resolve(ctx); return conversions.ImplicitConversion(from2, to2); } @@ -194,18 +195,102 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver Assert.IsFalse(ImplicitConversion(typeof(int*), typeof(dynamic))); } - [Test, Ignore] - public void TypeParameterConversions() + [Test] + public void UnconstrainedTypeParameter() + { + DefaultTypeParameter t = new DefaultTypeParameter(EntityType.TypeDefinition, 0, "T"); + DefaultTypeParameter t2 = new DefaultTypeParameter(EntityType.TypeDefinition, 1, "T2"); + DefaultTypeParameter tm = new DefaultTypeParameter(EntityType.Method, 0, "TM"); + + Assert.IsFalse(conversions.ImplicitConversion(SharedTypes.Null, t)); + Assert.IsTrue(conversions.ImplicitConversion(t, KnownTypeReference.Object.Resolve(ctx))); + Assert.IsTrue(conversions.ImplicitConversion(t, SharedTypes.Dynamic)); + Assert.IsFalse(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(ValueType)))); + + Assert.IsTrue(conversions.ImplicitConversion(t, t)); + Assert.IsFalse(conversions.ImplicitConversion(t2, t)); + Assert.IsFalse(conversions.ImplicitConversion(t, t2)); + Assert.IsFalse(conversions.ImplicitConversion(t, tm)); + Assert.IsFalse(conversions.ImplicitConversion(tm, t)); + } + + [Test] + public void TypeParameterWithReferenceTypeConstraint() + { + DefaultTypeParameter t = new DefaultTypeParameter(EntityType.TypeDefinition, 0, "T"); + t.HasReferenceTypeConstraint = true; + + Assert.IsTrue(conversions.ImplicitConversion(SharedTypes.Null, t)); + Assert.IsTrue(conversions.ImplicitConversion(t, KnownTypeReference.Object.Resolve(ctx))); + Assert.IsTrue(conversions.ImplicitConversion(t, SharedTypes.Dynamic)); + Assert.IsFalse(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(ValueType)))); + } + + [Test] + public void TypeParameterWithValueTypeConstraint() + { + DefaultTypeParameter t = new DefaultTypeParameter(EntityType.TypeDefinition, 0, "T"); + t.HasValueTypeConstraint = true; + + Assert.IsFalse(conversions.ImplicitConversion(SharedTypes.Null, t)); + Assert.IsTrue(conversions.ImplicitConversion(t, KnownTypeReference.Object.Resolve(ctx))); + Assert.IsTrue(conversions.ImplicitConversion(t, SharedTypes.Dynamic)); + Assert.IsTrue(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(ValueType)))); + } + + [Test] + public void TypeParameterWithClassConstraint() + { + DefaultTypeParameter t = new DefaultTypeParameter(EntityType.TypeDefinition, 0, "T"); + t.Constraints.Add(ctx.GetTypeDefinition(typeof(StringComparer))); + + Assert.IsTrue(conversions.ImplicitConversion(SharedTypes.Null, t)); + Assert.IsTrue(conversions.ImplicitConversion(t, KnownTypeReference.Object.Resolve(ctx))); + Assert.IsTrue(conversions.ImplicitConversion(t, SharedTypes.Dynamic)); + Assert.IsFalse(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(ValueType)))); + Assert.IsTrue(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(StringComparer)))); + Assert.IsTrue(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(IComparer)))); + Assert.IsFalse(conversions.ImplicitConversion(t, typeof(IComparer).ToTypeReference().Resolve(ctx))); + Assert.IsTrue(conversions.ImplicitConversion(t, typeof(IComparer).ToTypeReference().Resolve(ctx))); + } + + [Test] + public void TypeParameterWithInterfaceConstraint() + { + DefaultTypeParameter t = new DefaultTypeParameter(EntityType.TypeDefinition, 0, "T"); + t.Constraints.Add(ctx.GetTypeDefinition(typeof(IList))); + + Assert.IsFalse(conversions.ImplicitConversion(SharedTypes.Null, t)); + Assert.IsTrue(conversions.ImplicitConversion(t, KnownTypeReference.Object.Resolve(ctx))); + Assert.IsTrue(conversions.ImplicitConversion(t, SharedTypes.Dynamic)); + Assert.IsFalse(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(ValueType)))); + Assert.IsTrue(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(IList)))); + Assert.IsTrue(conversions.ImplicitConversion(t, ctx.GetTypeDefinition(typeof(IEnumerable)))); + } + + [Test] + public void UserDefinedImplicitConversion() + { + Assert.IsTrue(ImplicitConversion(typeof(DateTime), typeof(DateTimeOffset))); + Assert.IsFalse(ImplicitConversion(typeof(DateTimeOffset), typeof(DateTime))); + } + + [Test] + public void UserDefinedImplicitNullableConversion() { - // TODO: write tests for conversions of type parameters - throw new NotImplementedException(); + // User-defined conversion followed by nullable conversion + Assert.IsTrue(ImplicitConversion(typeof(DateTime), typeof(DateTimeOffset?))); + // Lifted user-defined conversion + Assert.IsTrue(ImplicitConversion(typeof(DateTime?), typeof(DateTimeOffset?))); + // User-defined conversion doesn't drop the nullability + Assert.IsFalse(ImplicitConversion(typeof(DateTime?), typeof(DateTimeOffset))); } bool IntegerLiteralConversion(object value, Type to) { - IType fromType = value.GetType().ToTypeReference().Resolve(mscorlib); + IType fromType = value.GetType().ToTypeReference().Resolve(ctx); ConstantResolveResult crr = new ConstantResolveResult(fromType, value); - IType to2 = to.ToTypeReference().Resolve(mscorlib); + IType to2 = to.ToTypeReference().Resolve(ctx); return conversions.ImplicitConversion(crr, to2); } @@ -280,18 +365,18 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver int BetterConversion(Type s, Type t1, Type t2) { - IType sType = s.ToTypeReference().Resolve(mscorlib); - IType t1Type = t1.ToTypeReference().Resolve(mscorlib); - IType t2Type = t2.ToTypeReference().Resolve(mscorlib); + IType sType = s.ToTypeReference().Resolve(ctx); + IType t1Type = t1.ToTypeReference().Resolve(ctx); + IType t2Type = t2.ToTypeReference().Resolve(ctx); return conversions.BetterConversion(sType, t1Type, t2Type); } int BetterConversion(object value, Type t1, Type t2) { - IType fromType = value.GetType().ToTypeReference().Resolve(mscorlib); + IType fromType = value.GetType().ToTypeReference().Resolve(ctx); ConstantResolveResult crr = new ConstantResolveResult(fromType, value); - IType t1Type = t1.ToTypeReference().Resolve(mscorlib); - IType t2Type = t2.ToTypeReference().Resolve(mscorlib); + IType t1Type = t1.ToTypeReference().Resolve(ctx); + IType t2Type = t2.ToTypeReference().Resolve(ctx); return conversions.BetterConversion(crr, t1Type, t2Type); } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ExtensionMethodTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ExtensionMethodTests.cs index 00e531387..3a9f0a739 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ExtensionMethodTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ExtensionMethodTests.cs @@ -57,7 +57,7 @@ namespace XN { Assert.AreEqual("C.F", mrr.Member.FullName); } - [Test, Ignore("Test fails due to parser returning incorrect position")] + [Test, Ignore("Anonymous methods not yet implemented")] public void ExtensionMethodsTest2() { string program = @"using System; using System.Collections.Generic; diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/InvocationTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/InvocationTests.cs index 2f84aa28c..b59b2941e 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/InvocationTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/InvocationTests.cs @@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver Assert.AreSame(SharedTypes.UnknownType, result.Type); } - [Test, Ignore("Inheritance not supported in parser")] + [Test, Ignore("Resolver returns the member from the base class, which is correct according to C# spec, but not what we want to show in tooltips")] public void OverriddenMethodCall() { string program = @"class A { @@ -70,7 +70,7 @@ class B : A { Assert.AreEqual("B.GetRandomNumber", result.Member.FullName); } - [Test, Ignore("Inheritance not supported in parser")] + [Test, Ignore("Resolver returns the member from the base class, which is correct according to C# spec, but not what we want to show in tooltips")] public void OverriddenMethodCall2() { string program = @"class A { @@ -122,7 +122,7 @@ class A { Assert.AreEqual("System.Void", Resolve(program).Type.ReflectionName); } - [Test, Ignore("parser is broken for events")] + [Test] public void EventCallTest() { string program = @"using System; @@ -209,7 +209,7 @@ class Program { Assert.IsTrue(((IMethod)mrr.Member).Parameters[0].IsRef); } - [Test, Ignore("Inheritance not supported in parser")] + [Test, Ignore("Grouping by declaring type not yet implemented")] public void AddedOverload() { string program = @"class BaseClass { @@ -225,7 +225,7 @@ class DerivedClass : BaseClass { Assert.AreEqual("DerivedClass.Test", mrr.Member.FullName); } - [Test, Ignore("Inheritance not supported in parser")] + [Test] public void AddedNonApplicableOverload() { string program = @"class BaseClass { @@ -244,7 +244,7 @@ class DerivedClass : BaseClass { Assert.AreEqual("DerivedClass.Test", mrr.Member.FullName); } - [Test, Ignore("Inheritance not supported in parser")] + [Test, Ignore("Grouping by declaring type not yet implemented")] public void OverrideShadowed() { string program = @"using System; diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs index 9df45f3d9..4a2106704 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs @@ -6,7 +6,7 @@ using NUnit.Framework; namespace ICSharpCode.NRefactory.CSharp.Resolver { - [TestFixture, Ignore("Expression Lambdas not supported by parser")] + [TestFixture, Ignore("Lambdas not supported by resolver")] public class LambdaTests : ResolverTestBase { [Test] diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/NameLookupTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/NameLookupTests.cs index 40cd75b3b..f3836eaaf 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/NameLookupTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/NameLookupTests.cs @@ -134,7 +134,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public void FindTypeParameters() { resolver.UsingScope = MakeUsingScope("System.Collections.Generic"); - resolver.CurrentTypeDefinition = context.GetClass(typeof(List<>)); + resolver.CurrentTypeDefinition = context.GetTypeDefinition(typeof(List<>)); resolver.CurrentMember = resolver.CurrentTypeDefinition.Methods.Single(m => m.Name == "ConvertAll"); TypeResolveResult trr; @@ -191,7 +191,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver Assert.AreSame(SharedTypes.UnknownType, result.Type); } - [Test, Ignore("not yet implemented (depends on distuishing types and expressions in the DOM)")] + [Test] public void PropertyNameAmbiguousWithTypeName() { string program = @"class A { @@ -230,7 +230,7 @@ class Color { public static readonly Color Empty = null; } Assert.AreEqual("value", result.Variable.Name); } - [Test, Ignore("type references not supported")] + [Test] public void ValueInsideEventTest() { string program = @"using System; class A { @@ -263,7 +263,7 @@ class Color { public static readonly Color Empty = null; } Assert.AreEqual("value", result.Variable.Name); } - [Test, Ignore("Anonymous method parameters not supported by parser")] + [Test, Ignore("Anonymous methods not supported in resolver")] public void AnonymousMethodParameters() { string program = @"using System; @@ -350,7 +350,7 @@ namespace Root.Child { Assert.AreEqual("Root.Alpha", result.Type.FullName); } - [Test, Ignore("type references not implemented")] + [Test] public void ImportAliasTest() { string program = @"using COL = System.Collections; @@ -366,7 +366,7 @@ class TestClass { Assert.AreEqual("System.Collections.ArrayList", member.Type.FullName, "the full type should be resolved"); } - [Test, Ignore("Parser position bug")] + [Test] public void ImportAliasNamespaceResolveTest() { NamespaceResolveResult ns; @@ -377,7 +377,7 @@ class TestClass { Assert.AreEqual("System.Collections.Generic", ns.NamespaceName, "COL.Generic"); } - [Test, Ignore("Cannot resolve type references")] + [Test] public void ImportAliasClassResolveTest() { string program = @"using COL = System.Collections.ArrayList; @@ -394,7 +394,36 @@ class TestClass { Assert.AreEqual("System.Collections.ArrayList", rr.Type.FullName, "a"); } - [Test, Ignore("Parser position bug")] + [Test] + public void ImportSubnamespaceWithAliasTest() + { + string program = @"namespace PC +{ + // Define an alias for the nested namespace. + using Project = PC.MyCompany.Project; + class A + { + Project.MyClass M() + { + // Use the alias + $Project.MyClass$ mc = new Project.MyClass(); + return mc; + } + } + namespace MyCompany + { + namespace Project + { + public class MyClass { } + } + } +} +"; + var mrr = Resolve(program); + Assert.AreEqual("PC.MyCompany.Project.MyClass", mrr.Type.FullName); + } + + [Test] public void ResolveNamespaceSD_863() { string program = @"using System; @@ -414,7 +443,7 @@ namespace A.B { Assert.AreEqual("A.B.C.D", trr.Type.FullName); } - [Test, Ignore("Broken due to parser returning incorrect positions")] + [Test] public void ResolveTypeSD_863() { string program = @"using System; @@ -432,6 +461,31 @@ namespace A.B { Assert.AreEqual("A.B.C", trr.Type.FullName); } + + [Test] + public void InnerTypeResolve () + { + string program = @"public class C { public class Inner { } } +class TestClass { + void Test() { + $C.Inner$ a; + } +} +"; + TypeResolveResult trr = Resolve(program); + Assert.AreEqual("C.Inner", trr.Type.FullName); + + program = @"public class C { public class D { public class Inner { } }} +class TestClass { + void Test() { + $C.D.Inner$ a; + } +} +"; + trr = Resolve(program); + Assert.AreEqual("C.D.Inner", trr.Type.FullName); + } + [Test, Ignore("parser is broken and produces IdentifierExpression instead of PrimitiveType")] public void ShortMaxValueTest() { @@ -446,7 +500,7 @@ class TestClass { Assert.AreEqual(short.MaxValue, rr.ConstantValue); } - [Test, Ignore("Parser produces incorrect positions for :: operator")] + [Test] public void ClassWithSameNameAsNamespace() { string program = @"using System; namespace XX { @@ -471,7 +525,7 @@ class TestClass { Assert.AreEqual("XX.XX.Test", mrr.Member.FullName); } - [Test, Ignore("Parser position bug")] + [Test] public void ClassNameLookup1() { string program = @"namespace MainNamespace { @@ -490,7 +544,7 @@ namespace Test.Subnamespace { Assert.AreEqual("Test.Subnamespace.Test.TheClass", trr.Type.FullName); } - [Test, Ignore("Parser position bug")] + [Test] public void ClassNameLookup2() { string program = @"using Test.Subnamespace; @@ -566,7 +620,7 @@ namespace A { Assert.AreEqual("MainNamespace.Test", nrr.NamespaceName); } - [Test, Ignore("Fails because parser does not support base type references")] + [Test] public void InvocableRule() { string program = @"using System; @@ -593,7 +647,7 @@ namespace A { Assert.AreEqual("BaseClass.Test", mrr.Member.FullName); } - [Test, Ignore("Fails because parser does not support base type references")] + [Test] public void InvocableRule2() { string program = @"using System; @@ -621,7 +675,7 @@ namespace A { Assert.AreEqual("BaseClass.Test", mrr.Member.FullName); } - [Test, Ignore("Fails because parser does not support base type references")] + [Test] public void AccessibleRule() { string program = @"using System; @@ -676,7 +730,7 @@ namespace A { Assert.AreEqual("DerivedClass.Test", mrr.Member.FullName); } - [Test, Ignore("Parser doesn't support inheritance")] + [Test, Ignore("Resolver Bug")] public void SD_1487() { string program = @"using System; @@ -713,7 +767,7 @@ class Test { Assert.AreEqual("System.Int32", rr.Member.ReturnType.Resolve(context).FullName); } - [Test, Ignore("Parser doesn't support inheritance")] + [Test, Ignore("Resolver bug")] public void MethodHidesEvent() { // see SD-1542 diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ObjectCreationTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ObjectCreationTests.cs index 4fa54b288..d3a130212 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ObjectCreationTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ObjectCreationTests.cs @@ -100,7 +100,7 @@ class A { Assert.AreEqual(0, m.Parameters.Count); } - [Test, Ignore("parser doesn't produce any nodes for base constructor calls")] + [Test, Ignore("Not implemented")] public void ChainedConstructorCall() { string program = @"using System; diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs index f81a7f2d9..e93bcce1b 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolverTestBase.cs @@ -151,7 +151,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ParsedFile parsedFile = new ParsedFile("test.cs", rootUsingScope); TypeSystemConvertVisitor convertVisitor = new TypeSystemConvertVisitor(parsedFile, resolver.UsingScope, null); cu.AcceptVisitor(convertVisitor, null); - project.UpdateProjectContent(null, convertVisitor.ParsedFile.TopLevelTypeDefinitions, null, null); + project.UpdateProjectContent(null, convertVisitor.ParsedFile); FindNodeVisitor fnv = new FindNodeVisitor(dollars[0], dollars[1]); cu.AcceptVisitor(fnv, null); diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/TypeInferenceTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/TypeInferenceTests.cs index 8391d40a3..21911d656 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/TypeInferenceTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/TypeInferenceTests.cs @@ -6,8 +6,8 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; - using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; using NUnit.Framework; namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -15,14 +15,16 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver [TestFixture] public class TypeInferenceTests { + readonly ITypeResolveContext ctx = CecilLoaderTests.Mscorlib; TypeInference ti; [SetUp] public void Setup() { - ti = new TypeInference(CecilLoaderTests.Mscorlib); + ti = new TypeInference(ctx); } + #region Type Inference IType[] Resolve(params Type[] types) { IType[] r = new IType[types.Length]; @@ -34,6 +36,46 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver return r; } + [Test] + public void ArrayToEnumerable() + { + ITypeParameter tp = new DefaultTypeParameter(EntityType.Method, 0, "T"); + IType stringType = KnownTypeReference.String.Resolve(ctx); + ITypeDefinition enumerableType = ctx.GetTypeDefinition(typeof(IEnumerable<>)); + + bool success; + Assert.AreEqual( + new [] { stringType }, + ti.InferTypeArguments(new [] { tp }, + new [] { new ResolveResult(new ArrayType(stringType)) }, + new [] { new ParameterizedType(enumerableType, new [] { tp }) }, + out success)); + Assert.IsTrue(success); + } + + [Test] + public void EnumerableToArrayInContravariantType() + { + ITypeParameter tp = new DefaultTypeParameter(EntityType.Method, 0, "T"); + IType stringType = KnownTypeReference.String.Resolve(ctx); + ITypeDefinition enumerableType = ctx.GetTypeDefinition(typeof(IEnumerable<>)); + ITypeDefinition comparerType = ctx.GetTypeDefinition(typeof(IComparer<>)); + + var comparerOfIEnumerableOfString = new ParameterizedType(comparerType, new [] { new ParameterizedType(enumerableType, new [] { stringType} ) }); + var comparerOfTpArray = new ParameterizedType(comparerType, new [] { new ArrayType(tp) }); + + bool success; + Assert.AreEqual( + new [] { stringType }, + ti.InferTypeArguments(new [] { tp }, + new [] { new ResolveResult(comparerOfIEnumerableOfString) }, + new [] { comparerOfTpArray }, + out success)); + Assert.IsTrue(success); + } + #endregion + + #region FindTypeInBounds IType[] FindAllTypesInBounds(IList lowerBounds, IList upperBounds = null) { ti.Algorithm = TypeInferenceAlgorithm.ImprovedReturnAllResults; @@ -154,5 +196,6 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver Resolve(typeof(List), typeof(List), typeof(Collection), typeof(Collection), typeof(ReadOnlyCollection), typeof(ReadOnlyCollection)), FindAllTypesInBounds(Resolve(), Resolve(typeof(IEnumerable), typeof(IEnumerable), typeof(IList)))); } + #endregion } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/UnsafeCodeTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/UnsafeCodeTests.cs index f5ef169b6..a336cd23c 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Resolver/UnsafeCodeTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Resolver/UnsafeCodeTests.cs @@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver [TestFixture] public class UnsafeCodeTests : ResolverTestBase { - [Test, Ignore("fixed statement not implemented in parser")] + [Test, Ignore("Parser returns incorrect positions")] public void FixedStatement() { string program = @"using System; diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs index d231327f1..7557859e6 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs @@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.CSharp; namespace ICSharpCode.NRefactory.FormattingTests { + [Ignore ("TODO")] [TestFixture()] public class TestBlankLineFormatting : TestBase { diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs index 033bf1924..3746b3b0f 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs @@ -34,6 +34,7 @@ namespace ICSharpCode.NRefactory.FormattingTests [TestFixture()] public class TestBraceStyle : TestBase { + [Ignore ("TODO")] [Test()] public void TestNamespaceBraceStyle () { @@ -221,6 +222,7 @@ namespace B { }"); } + [Ignore ("TODO")] [Test()] public void TestAllowPropertyGetBlockInline () { @@ -262,6 +264,7 @@ namespace B { }"); } + [Ignore ("TODO")] [Test()] public void TestAllowPropertySetBlockInline () { diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs index 025ea8f0a..8e667542e 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs @@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.CSharp; namespace ICSharpCode.NRefactory.FormattingTests { + [Ignore()] [TestFixture()] public class TestFormattingBugs : TestBase { diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs index a3ca7666c..87d61ee51 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs @@ -1065,6 +1065,25 @@ return (Test)null; i2 = result.Text.IndexOf (";") + ";".Length; Assert.AreEqual (@"int a = 5,b = 6,c;", result.GetTextAt (i1, i2 - i1)); } + + [Test()] + public void TestLocalVariableWithGenerics () + { + CSharpFormattingOptions policy = new CSharpFormattingOptions (); + policy.SpaceBeforeLocalVariableDeclarationComma = true; + policy.SpaceAfterLocalVariableDeclarationComma = true; + + var result = GetResult (policy, @"class Test { + void TestMe () + { + List a; + } +}"); + int i1 = result.Text.IndexOf ("List"); + int i2 = result.Text.IndexOf (";") + ";".Length; + Assert.AreEqual (@"List a;", result.GetTextAt (i1, i2 - i1)); + + } #region Constructors diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs index e0bf27ad9..96d06c1c2 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs @@ -55,6 +55,7 @@ this.TestMethod (); }"); } + [Ignore ("TODO")] [Test()] public void TestIndentBlocks () { @@ -498,6 +499,7 @@ using (var o = new MyObj()) { }"); } + [Ignore ("TODO")] [Test()] public void TestUsingAlignment () { @@ -944,6 +946,7 @@ do { }"); } + [Ignore ("TODO")] [Test()] public void TestIfAlignment () { diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs index 2d31322a4..1ba5ef5f5 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs @@ -249,6 +249,7 @@ A }"); } + [Ignore ("TODO")] [Test()] public void TestIndentMethodBodyOperatorCase () { @@ -283,6 +284,7 @@ A }"); } + [Ignore ("TODO")] [Test()] public void TestIndentPropertyBody () { @@ -354,6 +356,7 @@ set; }"); } + [Ignore ("TODO")] [Test()] public void TestIndentPropertyBodyIndexerCase () { @@ -398,7 +401,7 @@ set { }"); } - + [Ignore ("TODO")] [Test()] public void TestPropertyAlignment () { @@ -432,6 +435,7 @@ set { } + [Ignore ("TODO")] [Test()] public void TestIndentNamespaceBody () { @@ -511,6 +515,7 @@ set; } + [Ignore ("TODO")] [Test()] public void TestIndentEventBody () { diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs index 4b2ca1b52..a9cef844f 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using ICSharpCode.NRefactory.CSharp; using System.IO; using NUnit.Framework; +using ICSharpCode.NRefactory.CSharp.Refactoring; namespace ICSharpCode.NRefactory.FormattingTests { @@ -41,7 +42,10 @@ namespace ICSharpCode.NRefactory.FormattingTests return string.Format ("[Delimiter: Offset={0}, Length={1}]", Offset, Length); } } - + public void Replace (int offset, int count, string value) + { + this.text = this.text.Substring (0, offset) + value + this.text.Substring (offset + count); + } static IEnumerable FindDelimiter (string text) { for (int i = 0; i < text.Length; i++) { @@ -104,16 +108,6 @@ namespace ICSharpCode.NRefactory.FormattingTests 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) { @@ -221,14 +215,50 @@ namespace ICSharpCode.NRefactory.FormattingTests public abstract class TestBase { + static IActionFactory factory = new TestFactory (); + + class TestTextReplaceAction : TextReplaceAction + { + public TestTextReplaceAction (int offset, int removedChars, string insertedText) : base (offset, removedChars, insertedText) + { + } + + public override void Perform (Script script) + { + } + } + + class TestFactory : AbstractActionFactory + { + public override TextReplaceAction CreateTextReplaceAction (int offset, int removedChars, string insertedText) + { + return new TestTextReplaceAction (offset, removedChars, insertedText); + } + } + + static void ApplyChanges (TextEditorTestAdapter adapter, List changes) + { + changes.Sort ((x, y) => y.Offset.CompareTo (x.Offset)); + foreach (var change in changes) { +// Console.WriteLine ("---- apply:" + change); +// Console.WriteLine (adapter.Text); + if (change.Offset > adapter.Length) + continue; + adapter.Replace (change.Offset, change.RemovedChars, change.InsertedText); + } +// Console.WriteLine ("---result:"); +// Console.WriteLine (adapter.Text); + } + protected static ITextEditorAdapter GetResult (CSharpFormattingOptions policy, string input) { var adapter = new TextEditorTestAdapter (input); - var visitior = new AstFormattingVisitor (policy, adapter); + var visitior = new AstFormattingVisitor (policy, adapter, factory); var compilationUnit = new CSharpParser ().Parse (new StringReader (adapter.Text)); compilationUnit.AcceptVisitor (visitior, null); - adapter.ApplyChanges (visitior.Changes); + + ApplyChanges (adapter, visitior.Changes); return adapter; } @@ -236,22 +266,28 @@ namespace ICSharpCode.NRefactory.FormattingTests protected static ITextEditorAdapter Test (CSharpFormattingOptions policy, string input, string expectedOutput) { var adapter = new TextEditorTestAdapter (input); - var visitior = new AstFormattingVisitor (policy, adapter); + var visitior = new AstFormattingVisitor (policy, adapter, factory); var compilationUnit = new CSharpParser ().Parse (new StringReader (adapter.Text)); compilationUnit.AcceptVisitor (visitior, null); - adapter.ApplyChanges (visitior.Changes); + ApplyChanges (adapter, visitior.Changes); + if (expectedOutput != adapter.Text) { + Console.WriteLine (adapter.Text); + } Assert.AreEqual (expectedOutput, adapter.Text); return adapter; } protected static void Continue (CSharpFormattingOptions policy, ITextEditorAdapter adapter, string expectedOutput) { - var visitior = new AstFormattingVisitor (policy, adapter); + var visitior = new AstFormattingVisitor (policy, adapter, factory); var compilationUnit = new CSharpParser ().Parse (new StringReader (adapter.Text)); compilationUnit.AcceptVisitor (visitior, null); - ((TextEditorTestAdapter)adapter).ApplyChanges (visitior.Changes); + ApplyChanges (((TextEditorTestAdapter)adapter), visitior.Changes); + if (expectedOutput != adapter.Text) { + Console.WriteLine (adapter.Text); + } Assert.AreEqual (expectedOutput, adapter.Text); } diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/CecilLoaderTests.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/CecilLoaderTests.cs index 408e2b855..e64e1f753 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/CecilLoaderTests.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/CecilLoaderTests.cs @@ -27,8 +27,8 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void InheritanceTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(SystemException)); - ITypeDefinition c2 = Mscorlib.GetClass(typeof(Exception)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(SystemException)); + ITypeDefinition c2 = Mscorlib.GetTypeDefinition(typeof(Exception)); Assert.IsNotNull(c, "c is null"); Assert.IsNotNull(c2, "c2 is null"); //Assert.AreEqual(3, c.BaseTypes.Count); // Inherited interfaces are not reported by Cecil @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void GenericPropertyTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(Comparer<>)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(Comparer<>)); IProperty def = c.Properties.Single(p => p.Name == "Default"); ParameterizedType pt = (ParameterizedType)def.ReturnType.Resolve(ctx); Assert.AreEqual("System.Collections.Generic.Comparer", pt.FullName); @@ -56,7 +56,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void PointerTypeTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(IntPtr)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(IntPtr)); IMethod toPointer = c.Methods.Single(p => p.Name == "ToPointer"); Assert.AreEqual("System.Void*", toPointer.ReturnType.Resolve(ctx).ReflectionName); Assert.IsTrue (toPointer.ReturnType.Resolve(ctx) is PointerType); @@ -66,7 +66,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void DateTimeDefaultConstructor() { - ITypeDefinition c = Mscorlib.GetClass(typeof(DateTime)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(DateTime)); Assert.IsFalse(c.Methods.Any(m => m.IsConstructor && m.Parameters.Count == 0)); // struct ctor isn't declared // but it is implicit: Assert.IsTrue(c.GetConstructors(ctx).Any(m => m.Parameters.Count == 0)); @@ -75,7 +75,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void NoEncodingInfoDefaultConstructor() { - ITypeDefinition c = Mscorlib.GetClass(typeof(EncodingInfo)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(EncodingInfo)); // EncodingInfo only has an internal constructor Assert.IsFalse(c.Methods.Any(m => m.IsConstructor)); // and no implicit ctor should be added: @@ -85,7 +85,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void StaticModifierTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(Environment)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(Environment)); Assert.IsNotNull(c, "System.Environment not found"); Assert.IsTrue(c.IsAbstract, "class should be abstract"); Assert.IsTrue(c.IsSealed, "class should be sealed"); @@ -95,16 +95,16 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void InnerClassReferenceTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(Environment)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(Environment)); Assert.IsNotNull(c, "System.Environment not found"); ITypeReference rt = c.Methods.First(m => m.Name == "GetFolderPath").Parameters[0].Type; - Assert.AreSame(c.InnerClasses.Single(ic => ic.Name == "SpecialFolder"), rt.Resolve(ctx)); + Assert.AreSame(c.NestedTypes.Single(ic => ic.Name == "SpecialFolder"), rt.Resolve(ctx)); } [Test] - public void InnerClassesTest() + public void NestedTypesTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(Environment.SpecialFolder)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(Environment.SpecialFolder)); Assert.IsNotNull(c, "c is null"); Assert.AreEqual("System.Environment.SpecialFolder", c.FullName); Assert.AreEqual("System.Environment+SpecialFolder", c.ReflectionName); @@ -113,7 +113,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void VoidTest() { - ITypeDefinition c = Mscorlib.GetClass(typeof(void)); + ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(void)); Assert.IsNotNull(c, "System.Void not found"); Assert.AreEqual(0, c.GetMethods(ctx).Count()); Assert.AreEqual(0, c.GetProperties(ctx).Count()); @@ -131,11 +131,11 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void NestedClassInGenericClassTest() { - ITypeDefinition dictionary = Mscorlib.GetClass(typeof(Dictionary<,>)); + ITypeDefinition dictionary = Mscorlib.GetTypeDefinition(typeof(Dictionary<,>)); Assert.IsNotNull(dictionary); - ITypeDefinition valueCollection = Mscorlib.GetClass(typeof(Dictionary<,>.ValueCollection)); + ITypeDefinition valueCollection = Mscorlib.GetTypeDefinition(typeof(Dictionary<,>.ValueCollection)); Assert.IsNotNull(valueCollection); - var dictionaryRT = new ParameterizedType(dictionary, new[] { Mscorlib.GetClass(typeof(string)), Mscorlib.GetClass(typeof(int)) }); + var dictionaryRT = new ParameterizedType(dictionary, new[] { Mscorlib.GetTypeDefinition(typeof(string)), Mscorlib.GetTypeDefinition(typeof(int)) }); IProperty valueProperty = dictionaryRT.GetProperties(ctx).Single(p => p.Name == "Values"); IType parameterizedValueCollection = valueProperty.ReturnType.Resolve(ctx); Assert.AreEqual("System.Collections.Generic.Dictionary`2+ValueCollection[[System.String],[System.Int32]]", parameterizedValueCollection.ReflectionName); @@ -145,7 +145,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void ValueCollectionCountModifiers() { - ITypeDefinition valueCollection = Mscorlib.GetClass(typeof(Dictionary<,>.ValueCollection)); + ITypeDefinition valueCollection = Mscorlib.GetTypeDefinition(typeof(Dictionary<,>.ValueCollection)); Assert.AreEqual(Accessibility.Public, valueCollection.Accessibility); Assert.IsTrue(valueCollection.IsSealed); Assert.IsFalse(valueCollection.IsAbstract); @@ -162,7 +162,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void MathAcosModifiers() { - ITypeDefinition math = Mscorlib.GetClass(typeof(Math)); + ITypeDefinition math = Mscorlib.GetTypeDefinition(typeof(Math)); Assert.AreEqual(Accessibility.Public, math.Accessibility); Assert.IsTrue(math.IsSealed); Assert.IsTrue(math.IsAbstract); @@ -180,7 +180,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void EncodingModifiers() { - ITypeDefinition encoding = Mscorlib.GetClass(typeof(Encoding)); + ITypeDefinition encoding = Mscorlib.GetTypeDefinition(typeof(Encoding)); Assert.AreEqual(Accessibility.Public, encoding.Accessibility); Assert.IsFalse(encoding.IsSealed); Assert.IsTrue(encoding.IsAbstract); @@ -213,7 +213,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void UnicodeEncodingModifiers() { - ITypeDefinition encoding = Mscorlib.GetClass(typeof(UnicodeEncoding)); + ITypeDefinition encoding = Mscorlib.GetTypeDefinition(typeof(UnicodeEncoding)); Assert.AreEqual(Accessibility.Public, encoding.Accessibility); Assert.IsFalse(encoding.IsSealed); Assert.IsFalse(encoding.IsAbstract); @@ -230,7 +230,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void UTF32EncodingModifiers() { - ITypeDefinition encoding = Mscorlib.GetClass(typeof(UTF32Encoding)); + ITypeDefinition encoding = Mscorlib.GetTypeDefinition(typeof(UTF32Encoding)); Assert.AreEqual(Accessibility.Public, encoding.Accessibility); Assert.IsTrue(encoding.IsSealed); Assert.IsFalse(encoding.IsAbstract); diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/GetAllBaseTypesTest.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/GetAllBaseTypesTest.cs index af7453b70..095e455ca 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/GetAllBaseTypesTest.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/GetAllBaseTypesTest.cs @@ -100,8 +100,8 @@ namespace ICSharpCode.NRefactory.TypeSystem c, c.BaseTypes[0].Resolve(context), c.BaseTypes[1].Resolve(context), - mscorlib.GetClass(typeof(IEnumerable)), - mscorlib.GetClass(typeof(object)) + mscorlib.GetTypeDefinition(typeof(IEnumerable)), + mscorlib.GetTypeDefinition(typeof(object)) }; Assert.AreEqual(expected, c.GetAllBaseTypes(context).OrderBy(t => t.ReflectionName).ToArray()); @@ -114,15 +114,35 @@ namespace ICSharpCode.NRefactory.TypeSystem // don't use a Cecil-loaded struct for this test; we're testing the implicit addition of System.ValueType DefaultTypeDefinition s = new DefaultTypeDefinition(mscorlib, string.Empty, "S"); s.ClassType = ClassType.Struct; - s.BaseTypes.Add(new ParameterizedType(mscorlib.GetClass(typeof(IEquatable<>)), new[] { s })); + s.BaseTypes.Add(new ParameterizedType(mscorlib.GetTypeDefinition(typeof(IEquatable<>)), new[] { s })); IType[] expected = { s, s.BaseTypes[0].Resolve(context), - mscorlib.GetClass(typeof(object)), - mscorlib.GetClass(typeof(ValueType)) + mscorlib.GetTypeDefinition(typeof(object)), + mscorlib.GetTypeDefinition(typeof(ValueType)) }; Assert.AreEqual(expected, s.GetAllBaseTypes(context).OrderBy(t => t.ReflectionName).ToArray()); } + + [Test] + public void BaseTypesOfListOfString() + { + Assert.AreEqual( + GetTypes(typeof(List), typeof(object), + typeof(IList), typeof(ICollection), typeof(IEnumerable), + typeof(IEnumerable), typeof(ICollection), typeof(IList)), + GetAllBaseTypes(typeof(List))); + } + + [Test] + public void BaseTypeDefinitionsOfListOfString() + { + Assert.AreEqual( + GetTypes(typeof(List<>), typeof(object), + typeof(IList), typeof(ICollection), typeof(IEnumerable), + typeof(IEnumerable<>), typeof(ICollection<>), typeof(IList<>)), + typeof(List).ToTypeReference().Resolve(context).GetAllBaseTypeDefinitions(context).OrderBy(t => t.ReflectionName).ToArray()); + } } } diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/ReflectionHelperTests.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/ReflectionHelperTests.cs index 64662a999..537ed2319 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/ReflectionHelperTests.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/ReflectionHelperTests.cs @@ -16,7 +16,7 @@ namespace ICSharpCode.NRefactory.TypeSystem void TestGetClass(Type type) { - ITypeDefinition t = CecilLoaderTests.Mscorlib.GetClass(type); + ITypeDefinition t = CecilLoaderTests.Mscorlib.GetTypeDefinition(type); Assert.IsNotNull(t, type.FullName); Assert.AreEqual(type.FullName, t.ReflectionName); } @@ -142,7 +142,7 @@ namespace ICSharpCode.NRefactory.TypeSystem Assert.AreEqual("System.Converter`2[[?],[?]]", parameterType.ToTypeReference().Resolve(context).ReflectionName); // now try with parent entity: - IMethod convertAll = context.GetClass(typeof(List<>)).Methods.Single(m => m.Name == "ConvertAll"); + IMethod convertAll = context.GetTypeDefinition(typeof(List<>)).Methods.Single(m => m.Name == "ConvertAll"); Assert.AreEqual("System.Converter`2[[`0],[``0]]", parameterType.ToTypeReference(entity: convertAll).Resolve(context).ReflectionName); } @@ -163,7 +163,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void ParseOpenGenericReflectionName() { - IMethod convertAll = context.GetClass(typeof(List<>)).Methods.Single(m => m.Name == "ConvertAll"); + IMethod convertAll = context.GetTypeDefinition(typeof(List<>)).Methods.Single(m => m.Name == "ConvertAll"); Assert.AreEqual("System.Converter`2[[?],[?]]", ReflectionHelper.ParseReflectionName("System.Converter`2[[`0],[``0]]").Resolve(context).ReflectionName); Assert.AreEqual("System.Converter`2[[`0],[``0]]", ReflectionHelper.ParseReflectionName("System.Converter`2[[`0],[``0]]", convertAll).Resolve(context).ReflectionName); } diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/TestInterningProvider.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/TestInterningProvider.cs index e3ebea8fc..11d53549a 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/TestInterningProvider.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/TestInterningProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) 2010 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; @@ -130,7 +130,7 @@ namespace ICSharpCode.NRefactory.TypeSystem public void InternProject(IProjectContent pc) { - foreach (var c in TreeTraversal.PreOrder(pc.GetClasses(), c => c.InnerClasses)) { + foreach (var c in TreeTraversal.PreOrder(pc.GetClasses(), c => c.NestedTypes)) { Intern(c.Namespace); Intern(c.Name); foreach (IMember m in c.Members) { diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs index 5092401ed..edb0bce50 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.TestCase.cs @@ -10,6 +10,8 @@ using System.Runtime.InteropServices; namespace ICSharpCode.NRefactory.TypeSystem.TestCase { + public delegate S GenericDelegate(T input) where T : S where S : class; + public class SimplePublicClass { public void Method() {} diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs index bd2a786a1..80e4071ba 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs @@ -28,13 +28,13 @@ namespace ICSharpCode.NRefactory.TypeSystem ITypeDefinition GetClass(Type type) { - return testCasePC.GetClass(type); + return testCasePC.GetTypeDefinition(type); } [Test] public void SimplePublicClassTest() { - ITypeDefinition c = testCasePC.GetClass(typeof(SimplePublicClass)); + ITypeDefinition c = testCasePC.GetTypeDefinition(typeof(SimplePublicClass)); Assert.AreEqual(typeof(SimplePublicClass).Name, c.Name); Assert.AreEqual(typeof(SimplePublicClass).FullName, c.FullName); Assert.AreEqual(typeof(SimplePublicClass).Namespace, c.Namespace); @@ -50,8 +50,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void SimplePublicClassMethodTest() { - ITypeDefinition c = testCasePC.GetClass(typeof(SimplePublicClass)); - Assert.AreEqual(2, c.Methods.Count); + ITypeDefinition c = testCasePC.GetTypeDefinition(typeof(SimplePublicClass)); IMethod method = c.Methods.Single(m => m.Name == "Method"); Assert.AreEqual(typeof(SimplePublicClass).FullName + ".Method", method.FullName); @@ -68,7 +67,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void DynamicType() { - ITypeDefinition testClass = testCasePC.GetClass(typeof(DynamicTest)); + ITypeDefinition testClass = testCasePC.GetTypeDefinition(typeof(DynamicTest)); Assert.AreSame(SharedTypes.Dynamic, testClass.Properties.Single().ReturnType.Resolve(ctx)); Assert.AreEqual(0, testClass.Properties.Single().Attributes.Count); } @@ -76,7 +75,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void DynamicTypeInGenerics() { - ITypeDefinition testClass = testCasePC.GetClass(typeof(DynamicTest)); + ITypeDefinition testClass = testCasePC.GetTypeDefinition(typeof(DynamicTest)); IMethod m1 = testClass.Methods.Single(me => me.Name == "DynamicGenerics1"); Assert.AreEqual("System.Collections.Generic.List`1[[dynamic]]", m1.ReturnType.Resolve(ctx).ReflectionName); @@ -104,7 +103,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void DynamicParameterHasNoAttributes() { - ITypeDefinition testClass = testCasePC.GetClass(typeof(DynamicTest)); + ITypeDefinition testClass = testCasePC.GetTypeDefinition(typeof(DynamicTest)); IMethod m1 = testClass.Methods.Single(me => me.Name == "DynamicGenerics1"); Assert.AreEqual(0, m1.Parameters[0].Attributes.Count); } @@ -134,7 +133,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void TestClassTypeParameters() { - var testClass = testCasePC.GetClass(typeof(GenericClass<,>)); + var testClass = testCasePC.GetTypeDefinition(typeof(GenericClass<,>)); Assert.AreEqual(EntityType.TypeDefinition, testClass.TypeParameters[0].OwnerType); Assert.AreEqual(EntityType.TypeDefinition, testClass.TypeParameters[1].OwnerType); Assert.AreSame(testClass.TypeParameters[1], testClass.TypeParameters[0].Constraints[0].Resolve(ctx)); @@ -143,7 +142,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void TestMethod() { - var testClass = testCasePC.GetClass(typeof(GenericClass<,>)); + var testClass = testCasePC.GetTypeDefinition(typeof(GenericClass<,>)); IMethod m = testClass.Methods.Single(me => me.Name == "TestMethod"); Assert.AreEqual("K", m.TypeParameters[0].Name); @@ -158,7 +157,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void GetIndex() { - var testClass = testCasePC.GetClass(typeof(GenericClass<,>)); + var testClass = testCasePC.GetTypeDefinition(typeof(GenericClass<,>)); IMethod m = testClass.Methods.Single(me => me.Name == "GetIndex"); Assert.AreEqual("T", m.TypeParameters[0].Name); @@ -174,7 +173,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void PropertyWithProtectedSetter() { - var testClass = testCasePC.GetClass(typeof(PropertyTest)); + var testClass = testCasePC.GetTypeDefinition(typeof(PropertyTest)); IProperty p = testClass.Properties.Single(pr => pr.Name == "PropertyWithProtectedSetter"); Assert.IsTrue(p.CanGet); Assert.IsTrue(p.CanSet); @@ -186,7 +185,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void PropertyWithPrivateSetter() { - var testClass = testCasePC.GetClass(typeof(PropertyTest)); + var testClass = testCasePC.GetTypeDefinition(typeof(PropertyTest)); IProperty p = testClass.Properties.Single(pr => pr.Name == "PropertyWithPrivateSetter"); Assert.IsTrue(p.CanGet); Assert.IsTrue(p.CanSet); @@ -198,7 +197,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void Indexer() { - var testClass = testCasePC.GetClass(typeof(PropertyTest)); + var testClass = testCasePC.GetTypeDefinition(typeof(PropertyTest)); IProperty p = testClass.Properties.Single(pr => pr.IsIndexer); Assert.IsTrue(p.CanGet); Assert.AreEqual(Accessibility.Public, p.Accessibility); @@ -210,9 +209,9 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void EnumTest() { - var e = testCasePC.GetClass(typeof(MyEnum)); + var e = testCasePC.GetTypeDefinition(typeof(MyEnum)); Assert.AreEqual(ClassType.Enum, e.ClassType); - Assert.AreEqual(false, e.IsReferenceType); + Assert.AreEqual(false, e.IsReferenceType(ctx)); Assert.AreEqual("System.Int16", e.BaseTypes[0].Resolve(ctx).ReflectionName); Assert.AreEqual(new[] { "System.Enum" }, e.GetBaseTypes(ctx).Select(t => t.ReflectionName).ToArray()); } @@ -220,7 +219,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void EnumFieldsTest() { - var e = testCasePC.GetClass(typeof(MyEnum)); + var e = testCasePC.GetTypeDefinition(typeof(MyEnum)); Assert.AreEqual(5, e.Fields.Count); foreach (IField f in e.Fields) { @@ -267,21 +266,21 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void SerializableAttribute() { - IAttribute attr = ctx.GetClass(typeof(NonCustomAttributes)).Attributes.Single(); + IAttribute attr = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Attributes.Single(); Assert.AreEqual("System.SerializableAttribute", attr.AttributeType.Resolve(ctx).FullName); } [Test] public void NonSerializedAttribute() { - IField field = ctx.GetClass(typeof(NonCustomAttributes)).Fields.Single(f => f.Name == "NonSerializedField"); + IField field = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Fields.Single(f => f.Name == "NonSerializedField"); Assert.AreEqual("System.NonSerializedAttribute", field.Attributes.Single().AttributeType.Resolve(ctx).FullName); } [Test] public void ExplicitStructLayoutAttribute() { - IAttribute attr = ctx.GetClass(typeof(ExplicitFieldLayoutStruct)).Attributes.Single(); + IAttribute attr = ctx.GetTypeDefinition(typeof(ExplicitFieldLayoutStruct)).Attributes.Single(); Assert.AreEqual("System.Runtime.InteropServices.StructLayoutAttribute", attr.AttributeType.Resolve(ctx).FullName); IConstantValue arg1 = attr.GetPositionalArguments(ctx).Single(); Assert.AreEqual("System.Runtime.InteropServices.LayoutKind", arg1.GetValueType(ctx).FullName); @@ -302,13 +301,13 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void FieldOffsetAttribute() { - IField field = ctx.GetClass(typeof(ExplicitFieldLayoutStruct)).Fields.Single(f => f.Name == "Field0"); + IField field = ctx.GetTypeDefinition(typeof(ExplicitFieldLayoutStruct)).Fields.Single(f => f.Name == "Field0"); Assert.AreEqual("System.Runtime.InteropServices.FieldOffsetAttribute", field.Attributes.Single().AttributeType.Resolve(ctx).FullName); IConstantValue arg = field.Attributes.Single().GetPositionalArguments(ctx).Single(); Assert.AreEqual("System.Int32", arg.GetValueType(ctx).FullName); Assert.AreEqual(0, arg.GetValue(ctx)); - field = ctx.GetClass(typeof(ExplicitFieldLayoutStruct)).Fields.Single(f => f.Name == "Field100"); + field = ctx.GetTypeDefinition(typeof(ExplicitFieldLayoutStruct)).Fields.Single(f => f.Name == "Field100"); Assert.AreEqual("System.Runtime.InteropServices.FieldOffsetAttribute", field.Attributes.Single().AttributeType.Resolve(ctx).FullName); arg = field.Attributes.Single().GetPositionalArguments(ctx).Single(); Assert.AreEqual("System.Int32", arg.GetValueType(ctx).FullName); @@ -318,7 +317,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void DllImportAttribute() { - IMethod method = ctx.GetClass(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod"); + IMethod method = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod"); IAttribute dllImport = method.Attributes.Single(); Assert.AreEqual("System.Runtime.InteropServices.DllImportAttribute", dllImport.AttributeType.Resolve(ctx).FullName); Assert.AreEqual("unmanaged.dll", dllImport.GetPositionalArguments(ctx)[0].GetValue(ctx)); @@ -328,7 +327,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void InOutParametersOnRefMethod() { - IParameter p = ctx.GetClass(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod").Parameters.Single(); + IParameter p = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod").Parameters.Single(); Assert.IsTrue(p.IsRef); Assert.IsFalse(p.IsOut); Assert.AreEqual(2, p.Attributes.Count); @@ -339,7 +338,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void MarshalAsAttributeOnMethod() { - IMethod method = ctx.GetClass(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod"); + IMethod method = ctx.GetTypeDefinition(typeof(NonCustomAttributes)).Methods.Single(m => m.Name == "DllMethod"); IAttribute marshalAs = method.ReturnTypeAttributes.Single(); Assert.AreEqual((int)UnmanagedType.Bool, marshalAs.GetPositionalArguments(ctx).Single().GetValue(ctx)); } @@ -347,7 +346,7 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void MethodWithOutParameter() { - IParameter p = ctx.GetClass(typeof(ParameterTests)).Methods.Single(m => m.Name == "MethodWithOutParameter").Parameters.Single(); + IParameter p = ctx.GetTypeDefinition(typeof(ParameterTests)).Methods.Single(m => m.Name == "MethodWithOutParameter").Parameters.Single(); Assert.IsFalse(p.IsRef); Assert.IsTrue(p.IsOut); Assert.AreEqual(0, p.Attributes.Count); @@ -357,12 +356,43 @@ namespace ICSharpCode.NRefactory.TypeSystem [Test] public void MethodWithParamsArray() { - IParameter p = ctx.GetClass(typeof(ParameterTests)).Methods.Single(m => m.Name == "MethodWithParamsArray").Parameters.Single(); + IParameter p = ctx.GetTypeDefinition(typeof(ParameterTests)).Methods.Single(m => m.Name == "MethodWithParamsArray").Parameters.Single(); Assert.IsFalse(p.IsRef); Assert.IsFalse(p.IsOut); Assert.IsTrue(p.IsParams); Assert.AreEqual(0, p.Attributes.Count); Assert.IsTrue(p.Type is ArrayTypeReference); } + + [Test, Ignore("C# Parser does not set the variance")] + public void GenericDelegate_Variance() + { + ITypeDefinition type = ctx.GetTypeDefinition(typeof(GenericDelegate<,>)); + Assert.AreEqual(VarianceModifier.Contravariant, type.TypeParameters[0].Variance); + Assert.AreEqual(VarianceModifier.Covariant, type.TypeParameters[1].Variance); + + Assert.AreSame(type.TypeParameters[1], type.TypeParameters[0].Constraints[0]); + } + + [Test] + public void GenericDelegate_ReferenceTypeConstraints() + { + ITypeDefinition type = ctx.GetTypeDefinition(typeof(GenericDelegate<,>)); + Assert.IsFalse(type.TypeParameters[0].HasReferenceTypeConstraint); + Assert.IsTrue(type.TypeParameters[1].HasReferenceTypeConstraint); + + Assert.IsTrue(type.TypeParameters[0].IsReferenceType(ctx) == true); + Assert.IsTrue(type.TypeParameters[1].IsReferenceType(ctx) == true); + } + + [Test] + public void GenericDelegate_GetInvokeMethod() + { + IType type = typeof(GenericDelegate).ToTypeReference().Resolve(ctx); + IMethod m = type.GetDelegateInvokeMethod(); + Assert.AreEqual("Invoke", m.Name); + Assert.AreEqual("System.Object", m.ReturnType.Resolve(ctx).FullName); + Assert.AreEqual("System.String", m.Parameters[0].Type.Resolve(ctx).FullName); + } } } diff --git a/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs b/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs index 0e7546f9e..56c7d8ee9 100644 --- a/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs +++ b/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Ast string program = "Imports My.Name.Space\n"; var clause2 = new MemberImportsClause { - Member = new QualifiedType(new QualifiedType(new SimpleType("My"), new Identifier("Name", AstLocation.Empty)), new Identifier("Space", AstLocation.Empty)) + Member = new QualifiedType(new QualifiedType(new SimpleType("My"), new Identifier ("Name", AstLocation.Empty)), new Identifier ("Space", AstLocation.Empty)) }; var node = new ImportsStatement(); diff --git a/ICSharpCode.NRefactory.VB/Ast/AstNode.cs b/ICSharpCode.NRefactory.VB/Ast/AstNode.cs index d66abad92..7a79baf68 100644 --- a/ICSharpCode.NRefactory.VB/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.VB/Ast/AstNode.cs @@ -35,7 +35,7 @@ using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB { - public abstract class AstNode : PatternMatching.INode + public abstract class AstNode : AbstractAnnotatable, PatternMatching.INode { #region Null public static readonly AstNode Null = new NullAstNode (); @@ -443,157 +443,13 @@ namespace ICSharpCode.NRefactory.VB return copy; } - #region Annotation support - // Annotations: points either null (no annotations), to the single annotation, - // or to an AnnotationList. - // Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list) - object annotations; - - sealed class AnnotationList : List, ICloneable - { - // There are two uses for this custom list type: - // 1) it's private, and thus (unlike List) cannot be confused with real annotations - // 2) It allows us to simplify the cloning logic by making the list behave the same as a clonable annotation. - public AnnotationList(int initialCapacity) : base(initialCapacity) - { - } - - public object Clone() - { - lock (this) { - AnnotationList copy = new AnnotationList(this.Count); - for (int i = 0; i < this.Count; i++) { - object obj = this[i]; - ICloneable c = obj as ICloneable; - copy.Add(c != null ? c.Clone() : obj); - } - return copy; - } - } - } - - public void AddAnnotation(object annotation) + public override void AddAnnotation (object annotation) { - if (annotation == null) - throw new ArgumentNullException("annotation"); if (this.IsNull) throw new InvalidOperationException("Cannot add annotations to the null node"); - retry: // Retry until successful - object oldAnnotation = Interlocked.CompareExchange(ref this.annotations, annotation, null); - if (oldAnnotation == null) { - return; // we successfully added a single annotation - } - AnnotationList list = oldAnnotation as AnnotationList; - if (list == null) { - // we need to transform the old annotation into a list - list = new AnnotationList(4); - list.Add(oldAnnotation); - list.Add(annotation); - if (Interlocked.CompareExchange(ref this.annotations, list, oldAnnotation) != oldAnnotation) { - // the transformation failed (some other thread wrote to this.annotations first) - goto retry; - } - } else { - // once there's a list, use simple locking - lock (list) { - list.Add(annotation); - } - } - } - - public void RemoveAnnotations() where T : class - { - retry: // Retry until successful - object oldAnnotations = this.annotations; - AnnotationList list = oldAnnotations as AnnotationList; - if (list != null) { - lock (list) - list.RemoveAll(obj => obj is T); - } else if (oldAnnotations is T) { - if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations) { - // Operation failed (some other thread wrote to this.annotations first) - goto retry; - } - } + base.AddAnnotation (annotation); } - public void RemoveAnnotations(Type type) - { - if (type == null) - throw new ArgumentNullException("type"); - retry: // Retry until successful - object oldAnnotations = this.annotations; - AnnotationList list = oldAnnotations as AnnotationList; - if (list != null) { - lock (list) - list.RemoveAll(obj => type.IsInstanceOfType(obj)); - } else if (type.IsInstanceOfType(oldAnnotations)) { - if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations) { - // Operation failed (some other thread wrote to this.annotations first) - goto retry; - } - } - } - - public T Annotation() where T: class - { - object annotations = this.annotations; - AnnotationList list = annotations as AnnotationList; - if (list != null) { - lock (list) { - foreach (object obj in list) { - T t = obj as T; - if (t != null) - return t; - } - return null; - } - } else { - return annotations as T; - } - } - - public object Annotation(Type type) - { - if (type == null) - throw new ArgumentNullException("type"); - object annotations = this.annotations; - AnnotationList list = annotations as AnnotationList; - if (list != null) { - lock (list) { - foreach (object obj in list) { - if (type.IsInstanceOfType(obj)) - return obj; - } - } - } else { - if (type.IsInstanceOfType(annotations)) - return annotations; - } - return null; - } - - /// - /// Gets all annotations stored on this AstNode. - /// - public IEnumerable Annotations { - get { - object annotations = this.annotations; - AnnotationList list = annotations as AnnotationList; - if (list != null) { - lock (list) { - return list.ToArray(); - } - } else { - if (annotations != null) - return new object[] { annotations }; - else - return Enumerable.Empty(); - } - } - } - #endregion - public abstract S AcceptVisitor (IAstVisitor visitor, T data); #region Pattern Matching diff --git a/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs index 794615fc2..90be4263a 100644 --- a/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs @@ -21,7 +21,7 @@ namespace ICSharpCode.NRefactory.VB.Ast public string Name { get { return GetChildByRole (Roles.Identifier).Name; } - set { SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); } + set { SetChildByRole(Roles.Identifier, new Identifier (value, AstLocation.Empty)); } } public AstNodeCollection Constraints { diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs index b91a753e0..5c392a73a 100644 --- a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.VB.Ast return builder.ToString (); } set { - GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty))); + GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier (ident, AstLocation.Empty))); } } diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs index 28b669d9c..eadd4f031 100644 --- a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs @@ -20,9 +20,11 @@ namespace ICSharpCode.NRefactory.VB.Ast public ClassType ClassType { get; set; } - public Identifier Name { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } + public string Name { + get { return GetChildByRole(Roles.Identifier).Name; } + set { + SetChildByRole(Roles.Identifier, new Identifier (value, AstLocation.Empty)); + } } public AstNodeCollection TypeParameters { @@ -44,7 +46,7 @@ namespace ICSharpCode.NRefactory.VB.Ast MatchAttributesAndModifiers(t, match) && Members.DoMatch(t.Members, match) && ClassType == t.ClassType && - Name.DoMatch(t.Name, match) && + MatchString(Name, t.Name) && TypeParameters.DoMatch(t.TypeParameters, match) && InheritsType.DoMatch(t.InheritsType, match) && ImplementsTypes.DoMatch(t.ImplementsTypes, match); diff --git a/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs b/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs index 2dbb28516..116f9918c 100644 --- a/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs +++ b/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.VB.Ast return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs b/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs index 6ddc198d7..590671b9c 100644 --- a/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs +++ b/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs @@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.VB.Ast public SimpleType(string identifier, AstLocation location) { - SetChildByRole (Roles.Identifier, new Identifier(identifier, location)); + SetChildByRole (Roles.Identifier, new Identifier (identifier, location)); } public string Identifier { @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.VB.Ast return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory.VB/Parser/Parser.cs b/ICSharpCode.NRefactory.VB/Parser/Parser.cs index 1b2b8d939..aa12c27f3 100644 --- a/ICSharpCode.NRefactory.VB/Parser/Parser.cs +++ b/ICSharpCode.NRefactory.VB/Parser/Parser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; @@ -402,7 +402,7 @@ partial class VBParser while (la.kind == 26) { Get(); Identifier(); - type = new QualifiedType(type, new Identifier(t.val, t.Location)); + type = new QualifiedType(type, new Identifier (t.val, t.Location)); } } @@ -445,7 +445,7 @@ partial class VBParser var result = new AliasImportsClause(); NodeStart(result); AstType alias; Identifier(); - result.Name = new Identifier(t.val, t.Location); + result.Name = new Identifier (t.val, t.Location); Expect(20); TypeName(out alias); result.Alias = alias; diff --git a/ICSharpCode.NRefactory/CSharp/Analysis/ControlFlow.cs b/ICSharpCode.NRefactory/CSharp/Analysis/ControlFlow.cs index 1660e99b1..bfaaf11f5 100644 --- a/ICSharpCode.NRefactory/CSharp/Analysis/ControlFlow.cs +++ b/ICSharpCode.NRefactory/CSharp/Analysis/ControlFlow.cs @@ -143,7 +143,12 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis Dictionary labels; List gotoStatements; - public IList BuildControlFlowGraph(Statement statement, ITypeResolveContext context, CancellationToken cancellationToken = default(CancellationToken)) + public IList BuildControlFlowGraph(Statement statement, ITypeResolveContext context) + { + return BuildControlFlowGraph(statement, context, CancellationToken.None); + } + + public IList BuildControlFlowGraph(Statement statement, ITypeResolveContext context, CancellationToken cancellationToken) { return BuildControlFlowGraph(statement, new ResolveVisitor( new CSharpResolver(context, cancellationToken), diff --git a/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs b/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs index d4cc6e1c5..edef14f63 100644 --- a/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs +++ b/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs @@ -79,12 +79,22 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis Queue nodesWithModifiedInput = new Queue(); - public DefiniteAssignmentAnalysis(Statement rootStatement, CancellationToken cancellationToken = default(CancellationToken)) + public DefiniteAssignmentAnalysis(Statement rootStatement) + : this(rootStatement, null, CancellationToken.None) + { + } + + public DefiniteAssignmentAnalysis(Statement rootStatement, CancellationToken cancellationToken) : this(rootStatement, null, cancellationToken) { } - public DefiniteAssignmentAnalysis(Statement rootStatement, ITypeResolveContext context, CancellationToken cancellationToken = default(CancellationToken)) + public DefiniteAssignmentAnalysis(Statement rootStatement, ITypeResolveContext context) + : this(rootStatement, context, CancellationToken.None) + { + } + + public DefiniteAssignmentAnalysis(Statement rootStatement, ITypeResolveContext context, CancellationToken cancellationToken) : this(rootStatement, new ResolveVisitor(new CSharpResolver(context ?? MinimalResolveContext.Instance, cancellationToken), null, ConstantModeResolveVisitorNavigator.Skip)) { @@ -167,12 +177,14 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis /// This method can be used to restrict the analysis to only a part of the method. /// Only the control flow paths that are fully contained within the selected part will be analyzed. /// - /// Both 'start' and 'end' are inclusive. - public void SetAnalyzedRange(Statement start, Statement end) + /// By default, both 'start' and 'end' are inclusive. + public void SetAnalyzedRange(Statement start, Statement end, bool startInclusive = true, bool endInclusive = true) { - Debug.Assert(beginNodeDict.ContainsKey(start) && endNodeDict.ContainsKey(end)); - int startIndex = beginNodeDict[start].Index; - int endIndex = endNodeDict[end].Index; + var dictForStart = startInclusive ? beginNodeDict : endNodeDict; + var dictForEnd = endInclusive ? endNodeDict : beginNodeDict; + Debug.Assert(dictForStart.ContainsKey(start) && dictForEnd.ContainsKey(end)); + int startIndex = dictForStart[start].Index; + int endIndex = dictForEnd[end].Index; if (startIndex > endIndex) throw new ArgumentException("The start statement must be lexically preceding the end statement"); this.analyzedRangeStart = startIndex; diff --git a/ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs b/ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs index d9909d0d4..64fc13493 100644 --- a/ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs +++ b/ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.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; @@ -14,7 +14,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis /// /// Resolve context represents the minimal mscorlib required for evaluating constants. /// - sealed class MinimalResolveContext : IProjectContent, ISynchronizedTypeResolveContext + sealed class MinimalResolveContext : AbstractAnnotatable, IProjectContent, ISynchronizedTypeResolveContext { static readonly Lazy instance = new Lazy(() => new MinimalResolveContext()); @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis }; } - public ITypeDefinition GetClass(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) + public ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) { foreach (ITypeDefinition type in types) { if (nameComparer.Equals(type.Name, name) && nameComparer.Equals(type.Namespace, nameSpace) && type.TypeParameterCount == typeParameterCount) @@ -67,12 +67,12 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis return null; } - public IEnumerable GetClasses() + public IEnumerable GetTypes() { return types; } - public IEnumerable GetClasses(string nameSpace, StringComparer nameComparer) + public IEnumerable GetTypes(string nameSpace, StringComparer nameComparer) { return types.Where(t => nameComparer.Equals(t.Namespace, nameSpace)); } @@ -112,5 +112,16 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis { // exit from Synchronize() block } + + IParsedFile IProjectContent.GetFile(string fileName) + { + return null; + } + + IEnumerable IProjectContent.Files { + get { + return EmptyList.Instance; + } + } } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs b/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs index d055c25a2..a535257ef 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs @@ -23,7 +23,6 @@ // 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.Collections; using System.Collections.Generic; @@ -33,7 +32,7 @@ using System.Threading; namespace ICSharpCode.NRefactory.CSharp { - public abstract class AstNode : PatternMatching.INode + public abstract class AstNode : AbstractAnnotatable, PatternMatching.INode { #region Null public static readonly AstNode Null = new NullAstNode (); @@ -57,7 +56,7 @@ namespace ICSharpCode.NRefactory.CSharp return default (S); } - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) { return other == null || other.IsNull; } @@ -65,16 +64,16 @@ namespace ICSharpCode.NRefactory.CSharp #endregion #region PatternPlaceholder - public static implicit operator AstNode(PatternMatching.Pattern pattern) + public static implicit operator AstNode (PatternMatching.Pattern pattern) { - return pattern != null ? new PatternPlaceholder(pattern) : null; + return pattern != null ? new PatternPlaceholder (pattern) : null; } sealed class PatternPlaceholder : AstNode, PatternMatching.INode { readonly PatternMatching.Pattern child; - public PatternPlaceholder(PatternMatching.Pattern child) + public PatternPlaceholder (PatternMatching.Pattern child) { this.child = child; } @@ -83,19 +82,19 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data) + public override S AcceptVisitor (IAstVisitor visitor, T data) { - return visitor.VisitPatternPlaceholder(this, child, data); + return visitor.VisitPatternPlaceholder (this, child, data); } - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) { - return child.DoMatch(other, match); + return child.DoMatch (other, match); } - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) + bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) { - return child.DoMatchCollection(role, pos, match, backtrackingInfo); + return child.DoMatchCollection (role, pos, match, backtrackingInfo); } } #endregion @@ -163,7 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp get { AstNode next; for (AstNode cur = firstChild; cur != null; cur = next) { - Debug.Assert(cur.parent == this); + Debug.Assert (cur.parent == this); // Remember next before yielding cur. // This allows removing/replacing nodes while iterating through the list. next = cur.nextSibling; @@ -188,7 +187,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public IEnumerable Descendants { get { - return Utils.TreeTraversal.PreOrder(this.Children, n => n.Children); + return Utils.TreeTraversal.PreOrder (this.Children, n => n.Children); } } @@ -197,7 +196,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public IEnumerable DescendantsAndSelf { get { - return Utils.TreeTraversal.PreOrder(this, n => n.Children); + return Utils.TreeTraversal.PreOrder (this, n => n.Children); } } @@ -205,10 +204,10 @@ namespace ICSharpCode.NRefactory.CSharp /// Gets the first child with the specified role. /// Returns the role's null object if the child is not found. /// - public T GetChildByRole(Role role) where T : AstNode + public T GetChildByRole (Role role) where T : AstNode { if (role == null) - throw new ArgumentNullException("role"); + throw new ArgumentNullException ("role"); for (var cur = firstChild; cur != null; cur = cur.nextSibling) { if (cur.role == role) return (T)cur; @@ -216,37 +215,37 @@ namespace ICSharpCode.NRefactory.CSharp return role.NullObject; } - public AstNodeCollection GetChildrenByRole(Role role) where T : AstNode + public AstNodeCollection GetChildrenByRole (Role role) where T : AstNode { - return new AstNodeCollection(this, role); + return new AstNodeCollection (this, role); } - protected void SetChildByRole(Role role, T newChild) where T : AstNode + protected void SetChildByRole (Role role, T newChild) where T : AstNode { - AstNode oldChild = GetChildByRole(role); + AstNode oldChild = GetChildByRole (role); if (oldChild.IsNull) - AddChild(newChild, role); + AddChild (newChild, role); else - oldChild.ReplaceWith(newChild); + oldChild.ReplaceWith (newChild); } - public void AddChild(T child, Role role) where T : AstNode + public void AddChild (T child, Role role) where T : AstNode { if (role == null) - throw new ArgumentNullException("role"); + throw new ArgumentNullException ("role"); if (child == null || child.IsNull) return; if (this.IsNull) - throw new InvalidOperationException("Cannot add children to null nodes"); + throw new InvalidOperationException ("Cannot add children to null nodes"); if (child.parent != null) throw new ArgumentException ("Node is already used in another tree.", "child"); - AddChildUnsafe(child, role); + AddChildUnsafe (child, role); } /// /// Adds a child without performing any safety checks. /// - void AddChildUnsafe(AstNode child, Role role) + void AddChildUnsafe (AstNode child, Role role) { child.parent = this; child.role = role; @@ -259,12 +258,12 @@ namespace ICSharpCode.NRefactory.CSharp } } - public void InsertChildBefore(AstNode nextSibling, T child, Role role) where T : AstNode + public void InsertChildBefore (AstNode nextSibling, T child, Role role) where T : AstNode { if (role == null) - throw new ArgumentNullException("role"); + throw new ArgumentNullException ("role"); if (nextSibling == null || nextSibling.IsNull) { - AddChild(child, role); + AddChild (child, role); return; } @@ -276,11 +275,10 @@ namespace ICSharpCode.NRefactory.CSharp throw new ArgumentException ("NextSibling is not a child of this node.", "nextSibling"); // No need to test for "Cannot add children to null nodes", // as there isn't any valid nextSibling in null nodes. - InsertChildBeforeUnsafe(nextSibling, child, role); + InsertChildBeforeUnsafe (nextSibling, child, role); } - - void InsertChildBeforeUnsafe(AstNode nextSibling, AstNode child, Role role) + void InsertChildBeforeUnsafe (AstNode nextSibling, AstNode child, Role role) { child.parent = this; child.role = role; @@ -288,38 +286,38 @@ namespace ICSharpCode.NRefactory.CSharp child.prevSibling = nextSibling.prevSibling; if (nextSibling.prevSibling != null) { - Debug.Assert(nextSibling.prevSibling.nextSibling == nextSibling); + Debug.Assert (nextSibling.prevSibling.nextSibling == nextSibling); nextSibling.prevSibling.nextSibling = child; } else { - Debug.Assert(firstChild == nextSibling); + Debug.Assert (firstChild == nextSibling); firstChild = child; } nextSibling.prevSibling = child; } - public void InsertChildAfter(AstNode prevSibling, T child, Role role) where T : AstNode + public void InsertChildAfter (AstNode prevSibling, T child, Role role) where T : AstNode { - InsertChildBefore((prevSibling == null || prevSibling.IsNull) ? firstChild : prevSibling.nextSibling, child, role); + InsertChildBefore ((prevSibling == null || prevSibling.IsNull) ? firstChild : prevSibling.nextSibling, child, role); } /// /// Removes this node from its parent. /// - public void Remove() + public void Remove () { if (parent != null) { if (prevSibling != null) { - Debug.Assert(prevSibling.nextSibling == this); + Debug.Assert (prevSibling.nextSibling == this); prevSibling.nextSibling = nextSibling; } else { - Debug.Assert(parent.firstChild == this); + Debug.Assert (parent.firstChild == this); parent.firstChild = nextSibling; } if (nextSibling != null) { - Debug.Assert(nextSibling.prevSibling == this); + Debug.Assert (nextSibling.prevSibling == this); nextSibling.prevSibling = prevSibling; } else { - Debug.Assert(parent.lastChild == this); + Debug.Assert (parent.lastChild == this); parent.lastChild = prevSibling; } parent = null; @@ -332,28 +330,28 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Replaces this node with the new node. /// - public void ReplaceWith(AstNode newNode) + public void ReplaceWith (AstNode newNode) { if (newNode == null || newNode.IsNull) { - Remove(); + Remove (); return; } if (newNode == this) return; // nothing to do... if (parent == null) { - throw new InvalidOperationException(this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); + throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); } // Because this method doesn't statically check the new node's type with the role, // we perform a runtime test: - if (!role.IsValid(newNode)) { - throw new ArgumentException (string.Format("The new node '{0}' is not valid in the role {1}", newNode.GetType().Name, role.ToString()), "newNode"); + if (!role.IsValid (newNode)) { + throw new ArgumentException (string.Format ("The new node '{0}' is not valid in the role {1}", newNode.GetType ().Name, role.ToString ()), "newNode"); } if (newNode.parent != null) { // newNode is used within this tree? - if (newNode.Ancestors.Contains(this)) { + if (newNode.Ancestors.Contains (this)) { // e.g. "parenthesizedExpr.ReplaceWith(parenthesizedExpr.Expression);" // enable automatic removal - newNode.Remove(); + newNode.Remove (); } else { throw new ArgumentException ("Node is already used in another tree.", "newNode"); } @@ -365,17 +363,17 @@ namespace ICSharpCode.NRefactory.CSharp newNode.nextSibling = nextSibling; if (parent != null) { if (prevSibling != null) { - Debug.Assert(prevSibling.nextSibling == this); + Debug.Assert (prevSibling.nextSibling == this); prevSibling.nextSibling = newNode; } else { - Debug.Assert(parent.firstChild == this); + Debug.Assert (parent.firstChild == this); parent.firstChild = newNode; } if (nextSibling != null) { - Debug.Assert(nextSibling.prevSibling == this); + Debug.Assert (nextSibling.prevSibling == this); nextSibling.prevSibling = newNode; } else { - Debug.Assert(parent.lastChild == this); + Debug.Assert (parent.lastChild == this); parent.lastChild = newNode; } parent = null; @@ -385,31 +383,31 @@ namespace ICSharpCode.NRefactory.CSharp } } - public AstNode ReplaceWith(Func replaceFunction) + public AstNode ReplaceWith (Func replaceFunction) { if (replaceFunction == null) - throw new ArgumentNullException("replaceFunction"); + throw new ArgumentNullException ("replaceFunction"); if (parent == null) { - throw new InvalidOperationException(this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); + throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); } AstNode oldParent = parent; AstNode oldSuccessor = nextSibling; Role oldRole = role; - Remove(); - AstNode replacement = replaceFunction(this); + Remove (); + AstNode replacement = replaceFunction (this); if (oldSuccessor != null && oldSuccessor.parent != oldParent) - throw new InvalidOperationException("replace function changed nextSibling of node being replaced?"); + throw new InvalidOperationException ("replace function changed nextSibling of node being replaced?"); if (!(replacement == null || replacement.IsNull)) { if (replacement.parent != null) - throw new InvalidOperationException("replace function must return the root of a tree"); - if (!oldRole.IsValid(replacement)) { - throw new InvalidOperationException (string.Format("The new node '{0}' is not valid in the role {1}", replacement.GetType().Name, oldRole.ToString())); + throw new InvalidOperationException ("replace function must return the root of a tree"); + if (!oldRole.IsValid (replacement)) { + throw new InvalidOperationException (string.Format ("The new node '{0}' is not valid in the role {1}", replacement.GetType ().Name, oldRole.ToString ())); } if (oldSuccessor != null) - oldParent.InsertChildBeforeUnsafe(oldSuccessor, replacement, oldRole); + oldParent.InsertChildBeforeUnsafe (oldSuccessor, replacement, oldRole); else - oldParent.AddChildUnsafe(replacement, oldRole); + oldParent.AddChildUnsafe (replacement, oldRole); } return replacement; } @@ -417,10 +415,10 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Clones the whole subtree starting at this AST node. /// - /// Annotations are copied over to the new nodes; and any annotations implementating ICloneable will be cloned. - public AstNode Clone() + /// Annotations are copied over to the new nodes; and any annotations implementing ICloneable will be cloned. + public AstNode Clone () { - AstNode copy = (AstNode)MemberwiseClone(); + AstNode copy = (AstNode)MemberwiseClone (); // First, reset the shallow pointer copies copy.parent = null; copy.role = Roles.Root; @@ -431,186 +429,35 @@ namespace ICSharpCode.NRefactory.CSharp // Then perform a deep copy: for (AstNode cur = firstChild; cur != null; cur = cur.nextSibling) { - copy.AddChildUnsafe(cur.Clone(), cur.role); + copy.AddChildUnsafe (cur.Clone (), cur.role); } // Finally, clone the annotation, if necessary - ICloneable annotations = copy.annotations as ICloneable; // read from copy (for thread-safety) - if (annotations != null) - copy.annotations = annotations.Clone(); + ICloneable copiedAnnotations = copy.annotations as ICloneable; // read from copy (for thread-safety) + if (copiedAnnotations != null) + copy.annotations = copiedAnnotations.Clone(); return copy; } - #region Annotation support - // Annotations: points either null (no annotations), to the single annotation, - // or to an AnnotationList. - // Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list) - object annotations; - - sealed class AnnotationList : List, ICloneable - { - // There are two uses for this custom list type: - // 1) it's private, and thus (unlike List) cannot be confused with real annotations - // 2) It allows us to simplify the cloning logic by making the list behave the same as a clonable annotation. - public AnnotationList(int initialCapacity) : base(initialCapacity) - { - } - - public object Clone() - { - lock (this) { - AnnotationList copy = new AnnotationList(this.Count); - for (int i = 0; i < this.Count; i++) { - object obj = this[i]; - ICloneable c = obj as ICloneable; - copy.Add(c != null ? c.Clone() : obj); - } - return copy; - } - } - } - - public void AddAnnotation(object annotation) - { - if (annotation == null) - throw new ArgumentNullException("annotation"); - if (this.IsNull) - throw new InvalidOperationException("Cannot add annotations to the null node"); - retry: // Retry until successful - object oldAnnotation = Interlocked.CompareExchange(ref this.annotations, annotation, null); - if (oldAnnotation == null) { - return; // we successfully added a single annotation - } - AnnotationList list = oldAnnotation as AnnotationList; - if (list == null) { - // we need to transform the old annotation into a list - list = new AnnotationList(4); - list.Add(oldAnnotation); - list.Add(annotation); - if (Interlocked.CompareExchange(ref this.annotations, list, oldAnnotation) != oldAnnotation) { - // the transformation failed (some other thread wrote to this.annotations first) - goto retry; - } - } else { - // once there's a list, use simple locking - lock (list) { - list.Add(annotation); - } - } - } - - public void RemoveAnnotations() where T : class - { - retry: // Retry until successful - object oldAnnotations = this.annotations; - AnnotationList list = oldAnnotations as AnnotationList; - if (list != null) { - lock (list) - list.RemoveAll(obj => obj is T); - } else if (oldAnnotations is T) { - if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations) { - // Operation failed (some other thread wrote to this.annotations first) - goto retry; - } - } - } - - public void RemoveAnnotations(Type type) - { - if (type == null) - throw new ArgumentNullException("type"); - retry: // Retry until successful - object oldAnnotations = this.annotations; - AnnotationList list = oldAnnotations as AnnotationList; - if (list != null) { - lock (list) - list.RemoveAll(obj => type.IsInstanceOfType(obj)); - } else if (type.IsInstanceOfType(oldAnnotations)) { - if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations) { - // Operation failed (some other thread wrote to this.annotations first) - goto retry; - } - } - } - - public T Annotation() where T: class - { - object annotations = this.annotations; - AnnotationList list = annotations as AnnotationList; - if (list != null) { - lock (list) { - foreach (object obj in list) { - T t = obj as T; - if (t != null) - return t; - } - return null; - } - } else { - return annotations as T; - } - } - - public object Annotation(Type type) - { - if (type == null) - throw new ArgumentNullException("type"); - object annotations = this.annotations; - AnnotationList list = annotations as AnnotationList; - if (list != null) { - lock (list) { - foreach (object obj in list) { - if (type.IsInstanceOfType(obj)) - return obj; - } - } - } else { - if (type.IsInstanceOfType(annotations)) - return annotations; - } - return null; - } - - /// - /// Gets all annotations stored on this AstNode. - /// - public IEnumerable Annotations { - get { - object annotations = this.annotations; - AnnotationList list = annotations as AnnotationList; - if (list != null) { - lock (list) { - return list.ToArray(); - } - } else { - if (annotations != null) - return new object[] { annotations }; - else - return Enumerable.Empty(); - } - } - } - #endregion - public abstract S AcceptVisitor (IAstVisitor visitor, T data); #region Pattern Matching - protected static bool MatchString(string name1, string name2) + protected static bool MatchString (string name1, string name2) { - return string.IsNullOrEmpty(name1) || name1 == name2; + return string.IsNullOrEmpty (name1) || name1 == name2; } - protected internal abstract bool DoMatch(AstNode other, PatternMatching.Match match); + protected internal abstract bool DoMatch (AstNode other, PatternMatching.Match match); - bool PatternMatching.INode.DoMatch(PatternMatching.INode other, PatternMatching.Match match) + bool PatternMatching.INode.DoMatch (PatternMatching.INode other, PatternMatching.Match match) { AstNode o = other as AstNode; // try matching if other is null, or if other is an AstNode - return (other == null || o != null) && DoMatch(o, match); + return (other == null || o != null) && DoMatch (o, match); } - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) + bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) { AstNode o = pos as AstNode; return (pos == null || o != null) && DoMatch (o, match); @@ -623,6 +470,7 @@ namespace ICSharpCode.NRefactory.CSharp PatternMatching.INode PatternMatching.INode.FirstChild { get { return firstChild; } } + #endregion public AstNode GetNextNode () @@ -655,8 +503,168 @@ namespace ICSharpCode.NRefactory.CSharp return null; } + public AstNode GetNodeAt (int line, int column) + { + return GetNodeAt (new AstLocation (line, column)); + } + + public AstNode GetNodeAt (AstLocation location, Predicate pred = null) + { + AstNode result = null; + AstNode node = this; + while (node.FirstChild != null) { + var child = node.FirstChild; + while (child != null) { + if (child.StartLocation <= location && location < child.EndLocation) { + if (pred == null || pred (child)) + result = child; + node = child; + break; + } + child = child.NextSibling; + } + // found no better child node - therefore the parent is the right one. + if (child == null) + break; + } + return result; + } + + public T GetNodeAt (int line, int column) where T : AstNode + { + return GetNodeAt (new AstLocation (line, column)); + } + + /// + /// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// + public T GetNodeAt (AstLocation location) where T : AstNode + { + T result = null; + AstNode node = this; + while (node.FirstChild != null) { + var child = node.FirstChild; + while (child != null) { + if (child.StartLocation <= location && location < child.EndLocation) { + if (child is T) + result = (T)child; + node = child; + break; + } + child = child.NextSibling; + } + // found no better child node - therefore the parent is the right one. + if (child == null) + break; + } + return result; + } + + public AstNode GetResolveableNodeAt (int line, int column) + { + return GetResolveableNodeAt (new AstLocation (line, column)); + } + + /// + /// Gets a node that can be resolved at location. + /// + public AstNode GetResolveableNodeAt (AstLocation location) + { + return GetNodeAt (location, delegate (AstNode n) { + + if (n is TypeDeclaration) { + var decl = (TypeDeclaration)n; + return decl.NameToken.StartLocation <= location && location <= decl.NameToken.EndLocation; + } + + if (n is DelegateDeclaration) { + var decl = (DelegateDeclaration)n; + return decl.NameToken.StartLocation <= location && location <= decl.NameToken.EndLocation; + } + + if (n is MemberDeclaration) { + var decl = (MemberDeclaration)n; + return decl.NameToken.StartLocation <= location && location <= decl.NameToken.EndLocation; + } + + if (n is ConstructorDeclaration) { + var decl = (ConstructorDeclaration)n; + return decl.IdentifierToken.StartLocation <= location && location <= decl.IdentifierToken.EndLocation; + } + + if (n is DestructorDeclaration) { + var decl = (DestructorDeclaration)n; + return decl.IdentifierToken.StartLocation <= location && location <= decl.IdentifierToken.EndLocation; + } + + if (n is VariableInitializer) { + var decl = (VariableInitializer)n; + return decl.NameToken.StartLocation <= location && location <= decl.NameToken.EndLocation; + } + + if (n is ParameterDeclaration) { + var decl = (ParameterDeclaration)n; + return decl.NameToken.StartLocation <= location && location <= decl.NameToken.EndLocation; + } + + if (n is MemberReferenceExpression) { + var decl = (MemberReferenceExpression)n; + return decl.MemberNameToken.StartLocation <= location && location <= decl.MemberNameToken.EndLocation; + } + + return n is IdentifierExpression || n is AstType; + }); + } + + public IEnumerable GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn) + { + return GetNodesBetween (new AstLocation (startLine, startColumn), new AstLocation (endLine, endColumn)); + } + + public IEnumerable GetNodesBetween (AstLocation start, AstLocation end) + { + AstNode node = this; + while (node != null) { + AstNode next; + if (start <= node.StartLocation && node.EndLocation <= end) { + // Remember next before yielding node. + // This allows iteration to continue when the caller removes/replaces the node. + next = node.NextSibling; + yield return node; + } else { + if (node.EndLocation <= start) { + next = node.NextSibling; + } else { + next = node.FirstChild; + } + } + + if (next != null && next.StartLocation > end) + yield break; + node = next; + } + } + + public bool Contains (int line, int column) + { + return Contains (new AstLocation (line, column)); + } + + public bool Contains (AstLocation location) + { + return this.StartLocation <= location && location < this.EndLocation; + } + + public override void AddAnnotation (object annotation) + { + if (this.IsNull) + throw new InvalidOperationException ("Cannot add annotations to the null node"); + base.AddAnnotation (annotation); + } + // 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"); + static readonly Role RootRole = new Role ("Root"); public static class Roles { @@ -666,41 +674,38 @@ namespace ICSharpCode.NRefactory.CSharp public static readonly Role Root = RootRole; // some pre defined constants for common roles - public static readonly Role Identifier = new Role("Identifier", CSharp.Identifier.Null); - - public static readonly Role Body = new Role("Body", CSharp.BlockStatement.Null); - public static readonly Role Parameter = new Role("Parameter"); - public static readonly Role Argument = new Role("Argument", CSharp.Expression.Null); - public static readonly Role Type = new Role("Type", CSharp.AstType.Null); - public static readonly Role Expression = new Role("Expression", CSharp.Expression.Null); - public static readonly Role TargetExpression = new Role("Target", CSharp.Expression.Null); - public readonly static Role Condition = new Role("Condition", CSharp.Expression.Null); - - public static readonly Role TypeParameter = new Role("TypeParameter"); - public static readonly Role TypeArgument = new Role("TypeArgument", CSharp.AstType.Null); - public readonly static Role Constraint = new Role("Constraint"); - public static readonly Role Variable = new Role("Variable"); - public static readonly Role EmbeddedStatement = new Role("EmbeddedStatement", CSharp.Statement.Null); - - public static readonly Role Keyword = new Role("Keyword", CSharpTokenNode.Null); - public static readonly Role InKeyword = new Role("InKeyword", CSharpTokenNode.Null); + public static readonly Role Identifier = new Role ("Identifier", CSharp.Identifier.Null); + public static readonly Role Body = new Role ("Body", CSharp.BlockStatement.Null); + public static readonly Role Parameter = new Role ("Parameter"); + public static readonly Role Argument = new Role ("Argument", CSharp.Expression.Null); + public static readonly Role Type = new Role ("Type", CSharp.AstType.Null); + public static readonly Role Expression = new Role ("Expression", CSharp.Expression.Null); + public static readonly Role TargetExpression = new Role ("Target", CSharp.Expression.Null); + public readonly static Role Condition = new Role ("Condition", CSharp.Expression.Null); + public static readonly Role TypeParameter = new Role ("TypeParameter"); + public static readonly Role TypeArgument = new Role ("TypeArgument", CSharp.AstType.Null); + public readonly static Role Constraint = new Role ("Constraint"); + public static readonly Role Variable = new Role ("Variable"); + public static readonly Role EmbeddedStatement = new Role ("EmbeddedStatement", CSharp.Statement.Null); + public static readonly Role Keyword = new Role ("Keyword", CSharpTokenNode.Null); + public static readonly Role InKeyword = new Role ("InKeyword", CSharpTokenNode.Null); // some pre defined constants for most used punctuation - public static readonly Role LPar = new Role("LPar", CSharpTokenNode.Null); - public static readonly Role RPar = new Role("RPar", CSharpTokenNode.Null); - public static readonly Role LBracket = new Role("LBracket", CSharpTokenNode.Null); - public static readonly Role RBracket = new Role("RBracket", CSharpTokenNode.Null); - public static readonly Role LBrace = new Role("LBrace", CSharpTokenNode.Null); - public static readonly Role RBrace = new Role("RBrace", CSharpTokenNode.Null); - public static readonly Role LChevron = new Role("LChevron", CSharpTokenNode.Null); - public static readonly Role RChevron = new Role("RChevron", CSharpTokenNode.Null); - public static readonly Role Comma = new Role("Comma", CSharpTokenNode.Null); - public static readonly Role Dot = new Role("Dot", CSharpTokenNode.Null); - public static readonly Role Semicolon = new Role("Semicolon", CSharpTokenNode.Null); - public static readonly Role Assign = new Role("Assign", CSharpTokenNode.Null); - public static readonly Role Colon = new Role("Colon", CSharpTokenNode.Null); - - public static readonly Role Comment = new Role("Comment"); + public static readonly Role LPar = new Role ("LPar", CSharpTokenNode.Null); + public static readonly Role RPar = new Role ("RPar", CSharpTokenNode.Null); + public static readonly Role LBracket = new Role ("LBracket", CSharpTokenNode.Null); + public static readonly Role RBracket = new Role ("RBracket", CSharpTokenNode.Null); + public static readonly Role LBrace = new Role ("LBrace", CSharpTokenNode.Null); + public static readonly Role RBrace = new Role ("RBrace", CSharpTokenNode.Null); + public static readonly Role LChevron = new Role ("LChevron", CSharpTokenNode.Null); + public static readonly Role RChevron = new Role ("RChevron", CSharpTokenNode.Null); + public static readonly Role Comma = new Role ("Comma", CSharpTokenNode.Null); + public static readonly Role Dot = new Role ("Dot", CSharpTokenNode.Null); + public static readonly Role Semicolon = new Role ("Semicolon", CSharpTokenNode.Null); + public static readonly Role Assign = new Role ("Assign", CSharpTokenNode.Null); + public static readonly Role Colon = new Role ("Colon", CSharpTokenNode.Null); + public static readonly Role Comment = new Role ("Comment"); + public static readonly Role Error = new Role ("Error"); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/CSharpTokenNode.cs b/ICSharpCode.NRefactory/CSharp/Ast/CSharpTokenNode.cs index a776f259f..b125413d0 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/CSharpTokenNode.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/CSharpTokenNode.cs @@ -1,4 +1,4 @@ -// +// // TokenNode.cs // // Author: @@ -27,7 +27,7 @@ using System; namespace ICSharpCode.NRefactory.CSharp { - public class CSharpTokenNode : AstNode + public class CSharpTokenNode : AstNode, IRelocatable { public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode (); class NullCSharpTokenNode : CSharpTokenNode @@ -80,6 +80,13 @@ namespace ICSharpCode.NRefactory.CSharp this.tokenLength = tokenLength; } + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + this.startLocation = startLocation; + } + #endregion + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCSharpTokenNode (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/CSharpUtil.cs b/ICSharpCode.NRefactory/CSharp/Ast/CSharpUtil.cs new file mode 100644 index 000000000..46f528d46 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Ast/CSharpUtil.cs @@ -0,0 +1,95 @@ +// +// CSharpUtil.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; +using ICSharpCode.NRefactory.CSharp; + +namespace ICSharpCode.NRefactory.CSharp +{ + public static class CSharpUtil + { + public static Expression InvertCondition (Expression condition) + { + return InvertConditionInternal (condition.Clone ()); + } + + static Expression InvertConditionInternal (Expression condition) + { + if (condition is ParenthesizedExpression) { + ((ParenthesizedExpression)condition).Expression = InvertCondition (((ParenthesizedExpression)condition).Expression); + return condition; + } + + if (condition is UnaryOperatorExpression) { + var uOp = (UnaryOperatorExpression)condition; + if (uOp.Operator == UnaryOperatorType.Not) + return uOp.Expression; + return new UnaryOperatorExpression (UnaryOperatorType.Not, uOp); + } + + if (condition is BinaryOperatorExpression) { + var bOp = (BinaryOperatorExpression)condition; + switch (bOp.Operator) { + case BinaryOperatorType.GreaterThan: + bOp.Operator = BinaryOperatorType.LessThanOrEqual; + return bOp; + case BinaryOperatorType.GreaterThanOrEqual: + bOp.Operator = BinaryOperatorType.LessThan; + return bOp; + case BinaryOperatorType.Equality: + bOp.Operator = BinaryOperatorType.InEquality; + return bOp; + case BinaryOperatorType.InEquality: + bOp.Operator = BinaryOperatorType.Equality; + return bOp; + case BinaryOperatorType.LessThan: + bOp.Operator = BinaryOperatorType.GreaterThanOrEqual; + return bOp; + case BinaryOperatorType.LessThanOrEqual: + bOp.Operator = BinaryOperatorType.GreaterThan; + return bOp; + default: + return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition)); + } + } + + if (condition is ConditionalExpression) { + var cEx = condition as ConditionalExpression; + cEx.Condition = InvertCondition (cEx.Condition); + return cEx; + } + if (condition is PrimitiveExpression) { + var pex = condition as PrimitiveExpression; + if (pex.Value is bool) { + pex.Value = !((bool)pex.Value); + return pex; + } + } + + return new UnaryOperatorExpression (UnaryOperatorType.Not, condition); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs b/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs index 9a5047719..889e8d048 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs @@ -25,6 +25,7 @@ // THE SOFTWARE. using System; using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { @@ -38,67 +39,48 @@ namespace ICSharpCode.NRefactory.CSharp } } - public CompilationUnit () - { + List errors = new List (); + + public List Errors { + get { return errors; } } - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - CompilationUnit o = other as CompilationUnit; - return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match); + /// + /// Gets the expression that was on top of the parse stack. + /// This is the only way to get an expression that isn't part of a statment. + /// (eg. when an error follows an expression). + /// + /// This is used for code completion to 'get the expression before a token - like ., <, ('. + /// + public AstNode TopExpression { + get; + internal set; } - public AstNode GetNodeAt (int line, int column) + public CompilationUnit () { - return GetNodeAt (new AstLocation (line, column)); } - public AstNode GetNodeAt (AstLocation location) + public IEnumerable GetTypes (bool includeInnerTypes = false) { - AstNode node = this; - while (node.FirstChild != null) { - var child = node.FirstChild; - while (child != null) { - if (child.StartLocation <= location && location < child.EndLocation) { - node = child; - break; - } - child = child.NextSibling; + Stack nodeStack = new Stack (); + nodeStack.Push (this); + while (nodeStack.Count > 0) { + var curNode = nodeStack.Pop (); + if (curNode is TypeDeclaration) + yield return (TypeDeclaration)curNode; + foreach (var child in curNode.Children) { + if (!(child is Statement || child is Expression) && + (child.Role != TypeDeclaration.MemberRole || (child is TypeDeclaration && includeInnerTypes))) + nodeStack.Push (child); } - // found no better child node - therefore the parent is the right one. - if (child == null) - break; } - return node; } - public IEnumerable GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn) - { - return GetNodesBetween (new AstLocation (startLine, startColumn), new AstLocation (endLine, endColumn)); - } - - public IEnumerable GetNodesBetween (AstLocation start, AstLocation end) + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { - AstNode node = this; - while (node != null) { - AstNode next; - if (start <= node.StartLocation && node.EndLocation <= end) { - // Remember next before yielding node. - // This allows iteration to continue when the caller removes/replaces the node. - next = node.NextSibling; - yield return node; - } else { - if (node.EndLocation < start) { - next = node.NextSibling; - } else { - next = node.FirstChild; - } - } - - if (next != null && next.StartLocation > end) - yield break; - node = next; - } + CompilationUnit o = other as CompilationUnit; + return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match); } public override S AcceptVisitor (IAstVisitor visitor, T data) diff --git a/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs b/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs index b888cdea2..813f47213 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp public int PointerRank { get { - return GetChildrenByRole(PointerRole).Count(); + return GetChildrenByRole(PointerRole).Count; } set { if (value < 0) @@ -141,7 +141,7 @@ namespace ICSharpCode.NRefactory.CSharp } public int Dimensions { - get { return 1 + GetChildrenByRole(Roles.Comma).Count(); } + get { return 1 + GetChildrenByRole(Roles.Comma).Count; } set { int d = this.Dimensions; while (d > value) { diff --git a/ICSharpCode.NRefactory/CSharp/Ast/ErrorNode.cs b/ICSharpCode.NRefactory/CSharp/Ast/ErrorNode.cs new file mode 100644 index 000000000..af2fed750 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Ast/ErrorNode.cs @@ -0,0 +1,79 @@ +// +// ErrorNode.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Xamarin (http://www.xamarin.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 +{ + /// + /// Represents a parsing error in the ast. At the moment it only represents missing closing bracket. + /// This closing bracket is replaced by a node at the highest possible position. + /// (To make GetAstNodeAt (line, col) working). + /// + public class ErrorNode : AstNode + { + static AstLocation maxLoc = new AstLocation (int.MaxValue, int.MaxValue); + + public override NodeType NodeType { + get { + return NodeType.Unknown; + } + } + + public override AstLocation StartLocation { + get { + return maxLoc; + } + } + + public override AstLocation EndLocation { + get { + return maxLoc; + } + } + + public ErrorNode () + { + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + // nothing + return default (S); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as ErrorNode; + return o != null; + } + + public override string ToString () + { + return "[ErrorNode]"; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs index b057acbdf..3c23f54f8 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Type<[EMPTY]> /// - public class EmptyExpression : Expression + public class EmptyExpression : Expression, IRelocatable { AstLocation location; @@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.CSharp return location; } } - + public override AstLocation EndLocation { get { return location; @@ -54,7 +54,14 @@ namespace ICSharpCode.NRefactory.CSharp { this.location = location; } - + + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + this.location = startLocation; + } + #endregion + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitEmptyExpression (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs index bbc6898c1..e982f1320 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.CSharp public IdentifierExpression(string identifier, AstLocation location) { - SetChildByRole(Roles.Identifier, new Identifier(identifier, location)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (identifier, location)); } // public Identifier IdentifierToken { @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs index 60d7a17ed..4a7decbe0 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs @@ -1,4 +1,4 @@ -// +// // MemberReferenceExpression.cs // // Author: @@ -43,7 +43,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier MemberNameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs index df51dcf93..73bcb2e27 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs @@ -15,7 +15,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier IdentifierToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole(Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs index 3ac10d387..21e805b67 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs @@ -1,4 +1,4 @@ -// +// // PointerReferenceExpression.cs // // Author: @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PrimitiveExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PrimitiveExpression.cs index cc4fbe1c0..22e16e29b 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PrimitiveExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PrimitiveExpression.cs @@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Represents a literal value. /// - public class PrimitiveExpression : Expression + public class PrimitiveExpression : Expression, IRelocatable { public static readonly object AnyValue = new object(); @@ -40,16 +40,22 @@ namespace ICSharpCode.NRefactory.CSharp } } - int length; + string literalValue; public override AstLocation EndLocation { get { - return new AstLocation (StartLocation.Line, StartLocation.Column + length); + return new AstLocation (StartLocation.Line, StartLocation.Column + literalValue.Length); } } public object Value { get; - private set; + set; + } + + public string LiteralValue { + get { + return literalValue; + } } public PrimitiveExpression (object value) @@ -57,12 +63,25 @@ namespace ICSharpCode.NRefactory.CSharp this.Value = value; } - public PrimitiveExpression (object value, AstLocation startLocation, int length) + public PrimitiveExpression (object value, string literalValue) + { + this.Value = value; + this.literalValue = literalValue ?? ""; + } + + public PrimitiveExpression (object value, AstLocation startLocation, string literalValue) { this.Value = value; this.startLocation = startLocation; - this.length = length; + this.literalValue = literalValue ?? ""; + } + + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + this.startLocation = startLocation; } + #endregion public override S AcceptVisitor (IAstVisitor visitor, T data) { diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs index 9841a7468..5cf887703 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } @@ -120,7 +120,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } @@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole(Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } @@ -237,7 +237,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole(JoinIdentifierRole).Name; } set { - SetChildByRole(JoinIdentifierRole, new Identifier(value, AstLocation.Empty)); + SetChildByRole(JoinIdentifierRole, Identifier.Create (value, AstLocation.Empty)); } } @@ -277,7 +277,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (IntoIdentifierRole).Name; } set { - SetChildByRole(IntoIdentifierRole, new Identifier(value, AstLocation.Empty)); + SetChildByRole(IntoIdentifierRole, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs index 877771736..95235527f 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs @@ -47,16 +47,31 @@ namespace ICSharpCode.NRefactory.CSharp public AstNodeCollection Arguments { get { return base.GetChildrenByRole (Roles.Argument); } } - + + // HasArgumentList == false: [Empty] + public bool HasArgumentList { + get; + set; + } + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAttribute (this, data); } - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) { Attribute o = other as Attribute; - return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match); + return o != null && this.Type.DoMatch (o.Type, match) && this.Arguments.DoMatch (o.Arguments, match); + } + + public override string ToString () + { + if (IsNull) + return "Null"; + var w = new System.IO.StringWriter (); + AcceptVisitor (new OutputVisitor (w, new CSharpFormattingOptions ()), null); + return w.ToString (); } } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Comment.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Comment.cs index 4f757b264..61b424f49 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Comment.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Comment.cs @@ -1,4 +1,4 @@ -// +// // Comment.cs // // Author: @@ -32,7 +32,7 @@ namespace ICSharpCode.NRefactory.CSharp Documentation } - public class Comment : AstNode + public class Comment : AstNode, IRelocatable { public override NodeType NodeType { get { @@ -81,6 +81,15 @@ namespace ICSharpCode.NRefactory.CSharp this.startLocation = startLocation; this.endLocation = endLocation; } + + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + int lineDelta = startLocation.Line - this.startLocation.Line; + endLocation = new AstLocation (endLocation.Line + lineDelta, lineDelta != 0 ? endLocation.Column : endLocation.Column + startLocation.Column - this.startLocation.Column); + this.startLocation = startLocation; + } + #endregion public override S AcceptVisitor (IAstVisitor visitor, T data) { diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs index 8bac245c7..48c4e0ecb 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs @@ -1,4 +1,4 @@ -// +// // Constraint.cs // // Author: @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs index e014a4b3f..c33c0bf24 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs @@ -1,4 +1,4 @@ -// +// // DelegateDeclaration.cs // // Author: @@ -50,7 +50,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs index bdd8c0f04..7d9a33df4 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs index 07dee45b7..c580f3790 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs @@ -1,4 +1,4 @@ -// +// // NamespaceDeclaration.cs // // Author: @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp return builder.ToString (); } set { - GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty))); + GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident, AstLocation.Empty))); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs index df7ac2138..945c936cd 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs @@ -1,4 +1,4 @@ -// +// // TypeDeclaration.cs // // Author: @@ -55,7 +55,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs index 84c9b2f50..ee2d58eb3 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs @@ -35,7 +35,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs index a157ce62f..7fd3dfa09 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs @@ -1,4 +1,4 @@ -// +// // UsingAliasDeclaration.cs // // Author: @@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (AliasRole).Name; } set { - SetChildByRole(AliasRole, new Identifier(value, AstLocation.Empty)); + SetChildByRole(AliasRole, Identifier.Create (value, AstLocation.Empty)); } } @@ -72,13 +72,13 @@ namespace ICSharpCode.NRefactory.CSharp public UsingAliasDeclaration (string alias, string nameSpace) { - AddChild (new Identifier (alias, AstLocation.Empty), AliasRole); + AddChild (Identifier.Create (alias, AstLocation.Empty), AliasRole); AddChild (new SimpleType (nameSpace), ImportRole); } public UsingAliasDeclaration (string alias, AstType import) { - AddChild (new Identifier (alias, AstLocation.Empty), AliasRole); + AddChild (Identifier.Create (alias, AstLocation.Empty), AliasRole); AddChild (import, ImportRole); } diff --git a/ICSharpCode.NRefactory/CSharp/Formatter/Change.cs b/ICSharpCode.NRefactory/CSharp/Ast/IRelocatable.cs similarity index 56% rename from ICSharpCode.NRefactory/CSharp/Formatter/Change.cs rename to ICSharpCode.NRefactory/CSharp/Ast/IRelocatable.cs index f2a241c1d..48205191f 100644 --- a/ICSharpCode.NRefactory/CSharp/Formatter/Change.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/IRelocatable.cs @@ -1,5 +1,5 @@ // -// Change.cs +// IRelocationable.cs // // Author: // Mike Krüger @@ -25,48 +25,11 @@ // THE SOFTWARE. using System; -namespace ICSharpCode.NRefactory +namespace ICSharpCode.NRefactory.CSharp { - public class Change + public interface IRelocatable { - 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); - } + void SetStartLocation (AstLocation startLocation); } - } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs b/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs index 70f1ddca4..12bd64475 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs @@ -1,4 +1,4 @@ -// +// // Identifier.cs // // Author: @@ -28,9 +28,9 @@ using System; namespace ICSharpCode.NRefactory.CSharp { - public class Identifier : AstNode + public class Identifier : AstNode, IRelocatable { - public static readonly new Identifier Null = new NullIdentifier (); + public static readonly Identifier Null = new NullIdentifier (); class NullIdentifier : Identifier { public override bool IsNull { @@ -66,40 +66,69 @@ namespace ICSharpCode.NRefactory.CSharp } } - /// - /// True if this is a verbatim identifier (starting with '@') - /// - public bool IsVerbatim { - get; - set; - } - AstLocation startLocation; public override AstLocation StartLocation { get { return startLocation; } + + } + + public virtual bool IsVerbatim { + get { + return false; + } + } + + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + this.startLocation = startLocation; } + #endregion public override AstLocation EndLocation { get { - return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + (IsVerbatim ? 1 : 0)); + return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length); } } - private Identifier () + Identifier () { this.name = string.Empty; } - public Identifier (string name, AstLocation location) + protected Identifier (string name, AstLocation location) { if (name == null) throw new ArgumentNullException("name"); - IsVerbatim = name.StartsWith ("@"); - this.Name = IsVerbatim ? name.Substring (1) : name; + this.Name = name; this.startLocation = location; } + + public static Identifier Create (string name) + { + return Create (name, AstLocation.Empty); + } + + public static Identifier Create (string name, AstLocation location) + { + if (name == null) + throw new ArgumentNullException("name"); + if (name.Length > 0 && name[0] == '@') + return new VerbatimIdentifier(name.Substring (1), location); + return new Identifier (name, location); + } + + public static Identifier Create (string name, AstLocation location, bool isVerbatim) + { + if (name == null) + throw new ArgumentNullException("name"); + + if (isVerbatim) + return new VerbatimIdentifier(name, location); + return new Identifier (name, location); + } public override S AcceptVisitor (IAstVisitor visitor, T data) { @@ -111,5 +140,24 @@ namespace ICSharpCode.NRefactory.CSharp Identifier o = other as Identifier; return o != null && !o.IsNull && MatchString(this.Name, o.Name); } + + class VerbatimIdentifier : Identifier + { + public override AstLocation EndLocation { + get { + return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + 1); // @"..." + } + } + + public override bool IsVerbatim { + get { + return true; + } + } + + public VerbatimIdentifier(string name, AstLocation location) : base (name, location) + { + } + } } -} +} \ No newline at end of file diff --git a/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs b/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs index b91048a5c..771623eac 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs @@ -1,4 +1,4 @@ -// +// // FullTypeName.cs // // Author: @@ -47,7 +47,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier MemberNameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } @@ -55,6 +64,29 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (Roles.TypeArgument); } } + public MemberType () + { + } + + public MemberType (AstType target, string memberName) + { + this.Target = target; + this.MemberName = memberName; + } + + public MemberType (AstType target, string memberName, IEnumerable typeArguments) + { + this.Target = target; + this.MemberName = memberName; + foreach (var arg in typeArguments) { + AddChild (arg, Roles.TypeArgument); + } + } + + public MemberType (AstType target, string memberName, params AstType[] typeArguments) : this (target, memberName, (IEnumerable)typeArguments) + { + } + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitMemberType (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/ObservableAstVisitor.cs b/ICSharpCode.NRefactory/CSharp/Ast/ObservableAstVisitor.cs new file mode 100644 index 000000000..253f6ef3c --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Ast/ObservableAstVisitor.cs @@ -0,0 +1,1141 @@ +// +// ObservableAstVisitor.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 ObservableAstVisitor: IAstVisitor + { + S VisitChildren (AstNode node, T data) + { + AstNode next; + for (var child = node.FirstChild; child != null; child = next) { + // Store next to allow the loop to continue + // if the visitor removes/replaces child. + next = child.NextSibling; + child.AcceptVisitor (this, data); + } + return default (S); + } + + public event Action CompilationUnitVisited; + + S IAstVisitor.VisitCompilationUnit (CompilationUnit unit, T data) + { + var handler = CompilationUnitVisited; + if (handler != null) + handler (unit, data); + return VisitChildren (unit, data); + } + + public event Action CommentVisited; + + S IAstVisitor.VisitComment (Comment comment, T data) + { + var handler = CommentVisited; + if (handler != null) + handler (comment, data); + return VisitChildren (comment, data); + } + + public event Action IdentifierVisited; + + S IAstVisitor.VisitIdentifier (Identifier identifier, T data) + { + var handler = IdentifierVisited; + if (handler != null) + handler (identifier, data); + return VisitChildren (identifier, data); + } + + public event Action CSharpTokenNodeVisited; + + S IAstVisitor.VisitCSharpTokenNode (CSharpTokenNode token, T data) + { + var handler = CSharpTokenNodeVisited; + if (handler != null) + handler (token, data); + return VisitChildren (token, data); + } + + public event Action PrimitiveTypeVisited; + + S IAstVisitor.VisitPrimitiveType (PrimitiveType primitiveType, T data) + { + var handler = PrimitiveTypeVisited; + if (handler != null) + handler (primitiveType, data); + return VisitChildren (primitiveType, data); + } + + public event Action ComposedTypeVisited; + + S IAstVisitor.VisitComposedType (ComposedType composedType, T data) + { + var handler = ComposedTypeVisited; + if (handler != null) + handler (composedType, data); + return VisitChildren (composedType, data); + } + + public event Action SimpleTypeVisited; + + S IAstVisitor.VisitSimpleType (SimpleType simpleType, T data) + { + var handler = SimpleTypeVisited; + if (handler != null) + handler (simpleType, data); + return VisitChildren (simpleType, data); + } + + public event Action MemberTypeVisited; + + S IAstVisitor.VisitMemberType (MemberType memberType, T data) + { + var handler = MemberTypeVisited; + if (handler != null) + handler (memberType, data); + return VisitChildren (memberType, data); + } + + public event Action AttributeVisited; + + S IAstVisitor.VisitAttribute (Attribute attribute, T data) + { + var handler = AttributeVisited; + if (handler != null) + handler (attribute, data); + return VisitChildren (attribute, data); + } + + public event Action AttributeSectionVisited; + + S IAstVisitor.VisitAttributeSection (AttributeSection attributeSection, T data) + { + var handler = AttributeSectionVisited; + if (handler != null) + handler (attributeSection, data); + return VisitChildren (attributeSection, data); + } + + public event Action DelegateDeclarationVisited; + + S IAstVisitor.VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, T data) + { + var handler = DelegateDeclarationVisited; + if (handler != null) + handler (delegateDeclaration, data); + return VisitChildren (delegateDeclaration, data); + } + + public event Action NamespaceDeclarationVisited; + + S IAstVisitor.VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, T data) + { + var handler = NamespaceDeclarationVisited; + if (handler != null) + handler (namespaceDeclaration, data); + return VisitChildren (namespaceDeclaration, data); + } + + public event Action TypeDeclarationVisited; + + S IAstVisitor.VisitTypeDeclaration (TypeDeclaration typeDeclaration, T data) + { + var handler = TypeDeclarationVisited; + if (handler != null) + handler (typeDeclaration, data); + return VisitChildren (typeDeclaration, data); + } + + public event Action TypeParameterDeclarationVisited; + + S IAstVisitor.VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration, T data) + { + var handler = TypeParameterDeclarationVisited; + if (handler != null) + handler (typeParameterDeclaration, data); + return VisitChildren (typeParameterDeclaration, data); + } + + public event Action EnumMemberDeclarationVisited; + + S IAstVisitor.VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, T data) + { + var handler = EnumMemberDeclarationVisited; + if (handler != null) + handler (enumMemberDeclaration, data); + return VisitChildren (enumMemberDeclaration, data); + } + + public event Action UsingDeclarationVisited; + + S IAstVisitor.VisitUsingDeclaration (UsingDeclaration usingDeclaration, T data) + { + var handler = UsingDeclarationVisited; + if (handler != null) + handler (usingDeclaration, data); + return VisitChildren (usingDeclaration, data); + } + + public event Action UsingAliasDeclarationVisited; + + S IAstVisitor.VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, T data) + { + var handler = UsingAliasDeclarationVisited; + if (handler != null) + handler (usingDeclaration, data); + return VisitChildren (usingDeclaration, data); + } + + public event Action ExternAliasDeclarationVisited; + + S IAstVisitor.VisitExternAliasDeclaration (ExternAliasDeclaration externAliasDeclaration, T data) + { + var handler = ExternAliasDeclarationVisited; + if (handler != null) + handler (externAliasDeclaration, data); + return VisitChildren (externAliasDeclaration, data); + } + + public event Action ConstructorDeclarationVisited; + + S IAstVisitor.VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data) + { + var handler = ConstructorDeclarationVisited; + if (handler != null) + handler (constructorDeclaration, data); + return VisitChildren (constructorDeclaration, data); + } + + public event Action ConstructorInitializerVisited; + + S IAstVisitor.VisitConstructorInitializer (ConstructorInitializer constructorInitializer, T data) + { + var handler = ConstructorInitializerVisited; + if (handler != null) + handler (constructorInitializer, data); + return VisitChildren (constructorInitializer, data); + } + + public event Action DestructorDeclarationVisited; + + S IAstVisitor.VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, T data) + { + var handler = DestructorDeclarationVisited; + if (handler != null) + handler (destructorDeclaration, data); + return VisitChildren (destructorDeclaration, data); + } + + public event Action EventDeclarationVisited; + + S IAstVisitor.VisitEventDeclaration (EventDeclaration eventDeclaration, T data) + { + var handler = EventDeclarationVisited; + if (handler != null) + handler (eventDeclaration, data); + return VisitChildren (eventDeclaration, data); + } + + public event Action CustomEventDeclarationVisited; + + S IAstVisitor.VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration, T data) + { + var handler = CustomEventDeclarationVisited; + if (handler != null) + handler (eventDeclaration, data); + return VisitChildren (eventDeclaration, data); + } + + public event Action FieldDeclarationVisited; + + S IAstVisitor.VisitFieldDeclaration (FieldDeclaration fieldDeclaration, T data) + { + var handler = FieldDeclarationVisited; + if (handler != null) + handler (fieldDeclaration, data); + return VisitChildren (fieldDeclaration, data); + } + + public event Action FixedFieldDeclarationVisited; + + S IAstVisitor.VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, T data) + { + var handler = FixedFieldDeclarationVisited; + if (handler != null) + handler (fixedFieldDeclaration, data); + return VisitChildren (fixedFieldDeclaration, data); + } + + public event Action FixedVariableInitializerVisited; + + S IAstVisitor.VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, T data) + { + var handler = FixedVariableInitializerVisited; + if (handler != null) + handler (fixedVariableInitializer, data); + return VisitChildren (fixedVariableInitializer, data); + } + + public event Action IndexerDeclarationVisited; + + S IAstVisitor.VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data) + { + var handler = IndexerDeclarationVisited; + if (handler != null) + handler (indexerDeclaration, data); + return VisitChildren (indexerDeclaration, data); + } + + public event Action MethodDeclarationVisited; + + S IAstVisitor.VisitMethodDeclaration (MethodDeclaration methodDeclaration, T data) + { + var handler = MethodDeclarationVisited; + if (handler != null) + handler (methodDeclaration, data); + return VisitChildren (methodDeclaration, data); + } + + public event Action OperatorDeclarationVisited; + + S IAstVisitor.VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, T data) + { + var handler = OperatorDeclarationVisited; + if (handler != null) + handler (operatorDeclaration, data); + return VisitChildren (operatorDeclaration, data); + } + + public event Action PropertyDeclarationVisited; + + S IAstVisitor.VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, T data) + { + var handler = PropertyDeclarationVisited; + if (handler != null) + handler (propertyDeclaration, data); + return VisitChildren (propertyDeclaration, data); + } + + public event Action AccessorVisited; + + S IAstVisitor.VisitAccessor (Accessor accessor, T data) + { + var handler = AccessorVisited; + if (handler != null) + handler (accessor, data); + return VisitChildren (accessor, data); + } + + public event Action VariableInitializerVisited; + + S IAstVisitor.VisitVariableInitializer (VariableInitializer variableInitializer, T data) + { + var handler = VariableInitializerVisited; + if (handler != null) + handler (variableInitializer, data); + return VisitChildren (variableInitializer, data); + } + + public event Action ParameterDeclarationVisited; + + S IAstVisitor.VisitParameterDeclaration (ParameterDeclaration parameterDeclaration, T data) + { + var handler = ParameterDeclarationVisited; + if (handler != null) + handler (parameterDeclaration, data); + return VisitChildren (parameterDeclaration, data); + } + + public event Action ConstraintVisited; + + S IAstVisitor.VisitConstraint (Constraint constraint, T data) + { + var handler = ConstraintVisited; + if (handler != null) + handler (constraint, data); + return VisitChildren (constraint, data); + } + + public event Action BlockStatementVisited; + + S IAstVisitor.VisitBlockStatement (BlockStatement blockStatement, T data) + { + var handler = BlockStatementVisited; + if (handler != null) + handler (blockStatement, data); + return VisitChildren (blockStatement, data); + } + + public event Action ExpressionStatementVisited; + + S IAstVisitor.VisitExpressionStatement (ExpressionStatement expressionStatement, T data) + { + var handler = ExpressionStatementVisited; + if (handler != null) + handler (expressionStatement, data); + return VisitChildren (expressionStatement, data); + } + + public event Action BreakStatementVisited; + + S IAstVisitor.VisitBreakStatement (BreakStatement breakStatement, T data) + { + var handler = BreakStatementVisited; + if (handler != null) + handler (breakStatement, data); + return VisitChildren (breakStatement, data); + } + + public event Action CheckedStatementVisited; + + S IAstVisitor.VisitCheckedStatement (CheckedStatement checkedStatement, T data) + { + var handler = CheckedStatementVisited; + if (handler != null) + handler (checkedStatement, data); + return VisitChildren (checkedStatement, data); + } + + public event Action ContinueStatementVisited; + + S IAstVisitor.VisitContinueStatement (ContinueStatement continueStatement, T data) + { + var handler = ContinueStatementVisited; + if (handler != null) + handler (continueStatement, data); + return VisitChildren (continueStatement, data); + } + + public event Action DoWhileStatementVisited; + + S IAstVisitor.VisitDoWhileStatement (DoWhileStatement doWhileStatement, T data) + { + var handler = DoWhileStatementVisited; + if (handler != null) + handler (doWhileStatement, data); + return VisitChildren (doWhileStatement, data); + } + + public event Action EmptyStatementVisited; + + S IAstVisitor.VisitEmptyStatement (EmptyStatement emptyStatement, T data) + { + var handler = EmptyStatementVisited; + if (handler != null) + handler (emptyStatement, data); + return VisitChildren (emptyStatement, data); + } + + public event Action FixedStatementVisited; + + S IAstVisitor.VisitFixedStatement (FixedStatement fixedStatement, T data) + { + var handler = FixedStatementVisited; + if (handler != null) + handler (fixedStatement, data); + return VisitChildren (fixedStatement, data); + } + + public event Action ForeachStatementVisited; + + S IAstVisitor.VisitForeachStatement (ForeachStatement foreachStatement, T data) + { + var handler = ForeachStatementVisited; + if (handler != null) + handler (foreachStatement, data); + return VisitChildren (foreachStatement, data); + } + + public event Action ForStatementVisited; + + S IAstVisitor.VisitForStatement (ForStatement forStatement, T data) + { + var handler = ForStatementVisited; + if (handler != null) + handler (forStatement, data); + return VisitChildren (forStatement, data); + } + + public event Action GotoCaseStatementVisited; + + S IAstVisitor.VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement, T data) + { + var handler = GotoCaseStatementVisited; + if (handler != null) + handler (gotoCaseStatement, data); + return VisitChildren (gotoCaseStatement, data); + } + + public event Action GotoDefaultStatementVisited; + + S IAstVisitor.VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement, T data) + { + var handler = GotoDefaultStatementVisited; + if (handler != null) + handler (gotoDefaultStatement, data); + return VisitChildren (gotoDefaultStatement, data); + } + + public event Action GotoStatementVisited; + + S IAstVisitor.VisitGotoStatement (GotoStatement gotoStatement, T data) + { + var handler = GotoStatementVisited; + if (handler != null) + handler (gotoStatement, data); + return VisitChildren (gotoStatement, data); + } + + public event Action IfElseStatementVisited; + + S IAstVisitor.VisitIfElseStatement (IfElseStatement ifElseStatement, T data) + { + var handler = IfElseStatementVisited; + if (handler != null) + handler (ifElseStatement, data); + return VisitChildren (ifElseStatement, data); + } + + public event Action LabelStatementVisited; + + S IAstVisitor.VisitLabelStatement (LabelStatement labelStatement, T data) + { + var handler = LabelStatementVisited; + if (handler != null) + handler (labelStatement, data); + return VisitChildren (labelStatement, data); + } + + public event Action LockStatementVisited; + + S IAstVisitor.VisitLockStatement (LockStatement lockStatement, T data) + { + var handler = LockStatementVisited; + if (handler != null) + handler (lockStatement, data); + return VisitChildren (lockStatement, data); + } + + public event Action ReturnStatementVisited; + + S IAstVisitor.VisitReturnStatement (ReturnStatement returnStatement, T data) + { + var handler = ReturnStatementVisited; + if (handler != null) + handler (returnStatement, data); + return VisitChildren (returnStatement, data); + } + + public event Action SwitchStatementVisited; + + S IAstVisitor.VisitSwitchStatement (SwitchStatement switchStatement, T data) + { + var handler = SwitchStatementVisited; + if (handler != null) + handler (switchStatement, data); + return VisitChildren (switchStatement, data); + } + + public event Action SwitchSectionVisited; + + S IAstVisitor.VisitSwitchSection (SwitchSection switchSection, T data) + { + var handler = SwitchSectionVisited; + if (handler != null) + handler (switchSection, data); + return VisitChildren (switchSection, data); + } + + public event Action CaseLabelVisited; + + S IAstVisitor.VisitCaseLabel (CaseLabel caseLabel, T data) + { + var handler = CaseLabelVisited; + if (handler != null) + handler (caseLabel, data); + return VisitChildren (caseLabel, data); + } + + public event Action ThrowStatementVisited; + + S IAstVisitor.VisitThrowStatement (ThrowStatement throwStatement, T data) + { + var handler = ThrowStatementVisited; + if (handler != null) + handler (throwStatement, data); + return VisitChildren (throwStatement, data); + } + + public event Action TryCatchStatementVisited; + + S IAstVisitor.VisitTryCatchStatement (TryCatchStatement tryCatchStatement, T data) + { + var handler = TryCatchStatementVisited; + if (handler != null) + handler (tryCatchStatement, data); + return VisitChildren (tryCatchStatement, data); + } + + public event Action CatchClauseVisited; + + S IAstVisitor.VisitCatchClause (CatchClause catchClause, T data) + { + var handler = CatchClauseVisited; + if (handler != null) + handler (catchClause, data); + return VisitChildren (catchClause, data); + } + + public event Action UncheckedStatementVisited; + + S IAstVisitor.VisitUncheckedStatement (UncheckedStatement uncheckedStatement, T data) + { + var handler = UncheckedStatementVisited; + if (handler != null) + handler (uncheckedStatement, data); + return VisitChildren (uncheckedStatement, data); + } + + public event Action UnsafeStatementVisited; + + S IAstVisitor.VisitUnsafeStatement (UnsafeStatement unsafeStatement, T data) + { + var handler = UnsafeStatementVisited; + if (handler != null) + handler (unsafeStatement, data); + return VisitChildren (unsafeStatement, data); + } + + public event Action UsingStatementVisited; + + S IAstVisitor.VisitUsingStatement (UsingStatement usingStatement, T data) + { + var handler = UsingStatementVisited; + if (handler != null) + handler (usingStatement, data); + return VisitChildren (usingStatement, data); + } + + public event Action VariableDeclarationStatementVisited; + + S IAstVisitor.VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, T data) + { + var handler = VariableDeclarationStatementVisited; + if (handler != null) + handler (variableDeclarationStatement, data); + return VisitChildren (variableDeclarationStatement, data); + } + + public event Action WhileStatementVisited; + + S IAstVisitor.VisitWhileStatement (WhileStatement whileStatement, T data) + { + var handler = WhileStatementVisited; + if (handler != null) + handler (whileStatement, data); + return VisitChildren (whileStatement, data); + } + + public event Action YieldBreakStatementVisited; + + S IAstVisitor.VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, T data) + { + var handler = YieldBreakStatementVisited; + if (handler != null) + handler (yieldBreakStatement, data); + return VisitChildren (yieldBreakStatement, data); + } + + public event Action YieldStatementVisited; + + S IAstVisitor.VisitYieldStatement (YieldStatement yieldStatement, T data) + { + var handler = YieldStatementVisited; + if (handler != null) + handler (yieldStatement, data); + return VisitChildren (yieldStatement, data); + } + + public event Action AnonymousMethodExpressionVisited; + + S IAstVisitor.VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, T data) + { + var handler = AnonymousMethodExpressionVisited; + if (handler != null) + handler (anonymousMethodExpression, data); + return VisitChildren (anonymousMethodExpression, data); + } + + public event Action LambdaExpressionVisited; + + S IAstVisitor.VisitLambdaExpression (LambdaExpression lambdaExpression, T data) + { + var handler = LambdaExpressionVisited; + if (handler != null) + handler (lambdaExpression, data); + return VisitChildren (lambdaExpression, data); + } + + public event Action AssignmentExpressionVisited; + + S IAstVisitor.VisitAssignmentExpression (AssignmentExpression assignmentExpression, T data) + { + var handler = AssignmentExpressionVisited; + if (handler != null) + handler (assignmentExpression, data); + return VisitChildren (assignmentExpression, data); + } + + public event Action BaseReferenceExpressionVisited; + + S IAstVisitor.VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, T data) + { + var handler = BaseReferenceExpressionVisited; + if (handler != null) + handler (baseReferenceExpression, data); + return VisitChildren (baseReferenceExpression, data); + } + + public event Action BinaryOperatorExpressionVisited; + + S IAstVisitor.VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, T data) + { + var handler = BinaryOperatorExpressionVisited; + if (handler != null) + handler (binaryOperatorExpression, data); + return VisitChildren (binaryOperatorExpression, data); + } + + public event Action CastExpressionVisited; + + S IAstVisitor.VisitCastExpression (CastExpression castExpression, T data) + { + var handler = CastExpressionVisited; + if (handler != null) + handler (castExpression, data); + return VisitChildren (castExpression, data); + } + + public event Action CheckedExpressionVisited; + + S IAstVisitor.VisitCheckedExpression (CheckedExpression checkedExpression, T data) + { + var handler = CheckedExpressionVisited; + if (handler != null) + handler (checkedExpression, data); + return VisitChildren (checkedExpression, data); + } + + public event Action ConditionalExpressionVisited; + + S IAstVisitor.VisitConditionalExpression (ConditionalExpression conditionalExpression, T data) + { + var handler = ConditionalExpressionVisited; + if (handler != null) + handler (conditionalExpression, data); + return VisitChildren (conditionalExpression, data); + } + + public event Action IdentifierExpressionVisited; + + S IAstVisitor.VisitIdentifierExpression (IdentifierExpression identifierExpression, T data) + { + var handler = IdentifierExpressionVisited; + if (handler != null) + handler (identifierExpression, data); + return VisitChildren (identifierExpression, data); + } + + public event Action IndexerExpressionVisited; + + S IAstVisitor.VisitIndexerExpression (IndexerExpression indexerExpression, T data) + { + var handler = IndexerExpressionVisited; + if (handler != null) + handler (indexerExpression, data); + return VisitChildren (indexerExpression, data); + } + + public event Action InvocationExpressionVisited; + + S IAstVisitor.VisitInvocationExpression (InvocationExpression invocationExpression, T data) + { + var handler = InvocationExpressionVisited; + if (handler != null) + handler (invocationExpression, data); + return VisitChildren (invocationExpression, data); + } + + public event Action DirectionExpressionVisited; + + S IAstVisitor.VisitDirectionExpression (DirectionExpression directionExpression, T data) + { + var handler = DirectionExpressionVisited; + if (handler != null) + handler (directionExpression, data); + return VisitChildren (directionExpression, data); + } + + public event Action MemberReferenceExpressionVisited; + + S IAstVisitor.VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, T data) + { + var handler = MemberReferenceExpressionVisited; + if (handler != null) + handler (memberReferenceExpression, data); + return VisitChildren (memberReferenceExpression, data); + } + + public event Action NullReferenceExpressionVisited; + + S IAstVisitor.VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, T data) + { + var handler = NullReferenceExpressionVisited; + if (handler != null) + handler (nullReferenceExpression, data); + return VisitChildren (nullReferenceExpression, data); + } + + public event Action ObjectCreateExpressionVisited; + + S IAstVisitor.VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, T data) + { + var handler = ObjectCreateExpressionVisited; + if (handler != null) + handler (objectCreateExpression, data); + return VisitChildren (objectCreateExpression, data); + } + + public event Action AnonymousTypeCreateExpressionVisited; + + S IAstVisitor.VisitAnonymousTypeCreateExpression (AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data) + { + var handler = AnonymousTypeCreateExpressionVisited; + if (handler != null) + handler (anonymousTypeCreateExpression, data); + return VisitChildren (anonymousTypeCreateExpression, data); + } + + public event Action ArrayCreateExpressionVisited; + + S IAstVisitor.VisitArrayCreateExpression (ArrayCreateExpression arraySCreateExpression, T data) + { + var handler = ArrayCreateExpressionVisited; + if (handler != null) + handler (arraySCreateExpression, data); + return VisitChildren (arraySCreateExpression, data); + } + + public event Action ParenthesizedExpressionVisited; + + S IAstVisitor.VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, T data) + { + var handler = ParenthesizedExpressionVisited; + if (handler != null) + handler (parenthesizedExpression, data); + return VisitChildren (parenthesizedExpression, data); + } + + public event Action PointerReferenceExpressionVisited; + + S IAstVisitor.VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, T data) + { + var handler = PointerReferenceExpressionVisited; + if (handler != null) + handler (pointerReferenceExpression, data); + return VisitChildren (pointerReferenceExpression, data); + } + + public event Action PrimitiveExpressionVisited; + + S IAstVisitor.VisitPrimitiveExpression (PrimitiveExpression primitiveExpression, T data) + { + var handler = PrimitiveExpressionVisited; + if (handler != null) + handler (primitiveExpression, data); + return VisitChildren (primitiveExpression, data); + } + + public event Action SizeOfExpressionVisited; + + S IAstVisitor.VisitSizeOfExpression (SizeOfExpression sizeOfExpression, T data) + { + var handler = SizeOfExpressionVisited; + if (handler != null) + handler (sizeOfExpression, data); + return VisitChildren (sizeOfExpression, data); + } + + public event Action StackAllocExpressionVisited; + + S IAstVisitor.VisitStackAllocExpression (StackAllocExpression stackAllocExpression, T data) + { + var handler = StackAllocExpressionVisited; + if (handler != null) + handler (stackAllocExpression, data); + return VisitChildren (stackAllocExpression, data); + } + + public event Action ThisReferenceExpressionVisited; + + S IAstVisitor.VisitThisReferenceExpression (ThisReferenceExpression thisReferenceExpression, T data) + { + var handler = ThisReferenceExpressionVisited; + if (handler != null) + handler (thisReferenceExpression, data); + return VisitChildren (thisReferenceExpression, data); + } + + public event Action TypeOfExpressionVisited; + + S IAstVisitor.VisitTypeOfExpression (TypeOfExpression typeOfExpression, T data) + { + var handler = TypeOfExpressionVisited; + if (handler != null) + handler (typeOfExpression, data); + return VisitChildren (typeOfExpression, data); + } + + public event Action TypeReferenceExpressionVisited; + + S IAstVisitor.VisitTypeReferenceExpression (TypeReferenceExpression typeReferenceExpression, T data) + { + var handler = TypeReferenceExpressionVisited; + if (handler != null) + handler (typeReferenceExpression, data); + return VisitChildren (typeReferenceExpression, data); + } + + public event Action UnaryOperatorExpressionVisited; + + S IAstVisitor.VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, T data) + { + var handler = UnaryOperatorExpressionVisited; + if (handler != null) + handler (unaryOperatorExpression, data); + return VisitChildren (unaryOperatorExpression, data); + } + + public event Action UncheckedExpressionVisited; + + S IAstVisitor.VisitUncheckedExpression (UncheckedExpression uncheckedExpression, T data) + { + var handler = UncheckedExpressionVisited; + if (handler != null) + handler (uncheckedExpression, data); + return VisitChildren (uncheckedExpression, data); + } + + public event Action QueryExpressionVisited; + + S IAstVisitor.VisitQueryExpression (QueryExpression queryExpression, T data) + { + var handler = QueryExpressionVisited; + if (handler != null) + handler (queryExpression, data); + return VisitChildren (queryExpression, data); + } + + public event Action QueryContinuationClauseVisited; + + S IAstVisitor.VisitQueryContinuationClause (QueryContinuationClause queryContinuationClause, T data) + { + var handler = QueryContinuationClauseVisited; + if (handler != null) + handler (queryContinuationClause, data); + return VisitChildren (queryContinuationClause, data); + } + + public event Action QueryFromClauseVisited; + + S IAstVisitor.VisitQueryFromClause (QueryFromClause queryFromClause, T data) + { + var handler = QueryFromClauseVisited; + if (handler != null) + handler (queryFromClause, data); + return VisitChildren (queryFromClause, data); + } + + public event Action QueryLetClauseVisited; + + S IAstVisitor.VisitQueryLetClause (QueryLetClause queryLetClause, T data) + { + var handler = QueryLetClauseVisited; + if (handler != null) + handler (queryLetClause, data); + return VisitChildren (queryLetClause, data); + } + + public event Action QueryWhereClauseVisited; + + S IAstVisitor.VisitQueryWhereClause (QueryWhereClause queryWhereClause, T data) + { + var handler = QueryWhereClauseVisited; + if (handler != null) + handler (queryWhereClause, data); + return VisitChildren (queryWhereClause, data); + } + + public event Action QueryJoinClauseVisited; + + S IAstVisitor.VisitQueryJoinClause (QueryJoinClause queryJoinClause, T data) + { + var handler = QueryJoinClauseVisited; + if (handler != null) + handler (queryJoinClause, data); + return VisitChildren (queryJoinClause, data); + } + + public event Action QueryOrderClauseVisited; + + S IAstVisitor.VisitQueryOrderClause (QueryOrderClause queryOrderClause, T data) + { + var handler = QueryOrderClauseVisited; + if (handler != null) + handler (queryOrderClause, data); + return VisitChildren (queryOrderClause, data); + } + + public event Action QueryOrderingVisited; + + S IAstVisitor.VisitQueryOrdering (QueryOrdering queryOrdering, T data) + { + var handler = QueryOrderingVisited; + if (handler != null) + handler (queryOrdering, data); + return VisitChildren (queryOrdering, data); + } + + public event Action QuerySelectClauseVisited; + + S IAstVisitor.VisitQuerySelectClause (QuerySelectClause querySelectClause, T data) + { + var handler = QuerySelectClauseVisited; + if (handler != null) + handler (querySelectClause, data); + return VisitChildren (querySelectClause, data); + } + + public event Action QueryGroupClauseVisited; + + S IAstVisitor.VisitQueryGroupClause (QueryGroupClause queryGroupClause, T data) + { + var handler = QueryGroupClauseVisited; + if (handler != null) + handler (queryGroupClause, data); + return VisitChildren (queryGroupClause, data); + } + + public event Action AsExpressionVisited; + + S IAstVisitor.VisitAsExpression (AsExpression asExpression, T data) + { + var handler = AsExpressionVisited; + if (handler != null) + handler (asExpression, data); + return VisitChildren (asExpression, data); + } + + public event Action IsExpressionVisited; + + S IAstVisitor.VisitIsExpression (IsExpression isExpression, T data) + { + var handler = IsExpressionVisited; + if (handler != null) + handler (isExpression, data); + return VisitChildren (isExpression, data); + } + + public event Action DefaultValueExpressionVisited; + + S IAstVisitor.VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, T data) + { + var handler = DefaultValueExpressionVisited; + if (handler != null) + handler (defaultValueExpression, data); + return VisitChildren (defaultValueExpression, data); + } + + public event Action UndocumentedExpressionVisited; + + S IAstVisitor.VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression, T data) + { + var handler = UndocumentedExpressionVisited; + if (handler != null) + handler (undocumentedExpression, data); + return VisitChildren (undocumentedExpression, data); + } + + public event Action ArrayInitializerExpressionVisited; + + S IAstVisitor.VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression, T data) + { + var handler = ArrayInitializerExpressionVisited; + if (handler != null) + handler (arrayInitializerExpression, data); + return VisitChildren (arrayInitializerExpression, data); + } + + public event Action ArraySpecifierVisited; + + S IAstVisitor.VisitArraySpecifier (ArraySpecifier arraySpecifier, T data) + { + var handler = ArraySpecifierVisited; + if (handler != null) + handler (arraySpecifier, data); + return VisitChildren (arraySpecifier, data); + } + + public event Action NamedArgumentExpressionVisited; + + S IAstVisitor.VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression, T data) + { + var handler = NamedArgumentExpressionVisited; + if (handler != null) + handler (namedArgumentExpression, data); + return VisitChildren (namedArgumentExpression, data); + } + + public event Action EmptyExpressionVisited; + + S IAstVisitor.VisitEmptyExpression (EmptyExpression emptyExpression, T data) + { + var handler = EmptyExpressionVisited; + if (handler != null) + handler (emptyExpression, data); + return VisitChildren (emptyExpression, data); + } + + S IAstVisitor.VisitPatternPlaceholder (AstNode placeholder, PatternMatching.Pattern pattern, T data) + { + return VisitChildren (placeholder, data); + } + } +} + + diff --git a/ICSharpCode.NRefactory/CSharp/Ast/PrimitiveType.cs b/ICSharpCode.NRefactory/CSharp/Ast/PrimitiveType.cs index 2a2b41dff..26c93b21a 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/PrimitiveType.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/PrimitiveType.cs @@ -29,7 +29,7 @@ using System.Linq; namespace ICSharpCode.NRefactory.CSharp { - public class PrimitiveType : AstType + public class PrimitiveType : AstType, IRelocatable { public string Keyword { get; set; } public AstLocation Location { get; set; } @@ -60,6 +60,14 @@ namespace ICSharpCode.NRefactory.CSharp } } + + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + this.Location = startLocation; + } + #endregion + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPrimitiveType (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs b/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs index 237b3b55b..2609473e7 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs @@ -1,4 +1,4 @@ -// +// // FullTypeName.cs // // Author: @@ -44,7 +44,19 @@ namespace ICSharpCode.NRefactory.CSharp public SimpleType(string identifier, AstLocation location) { - SetChildByRole (Roles.Identifier, new Identifier(identifier, location)); + SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (identifier, location)); + } + + public SimpleType (string identifier, IEnumerable typeArguments) + { + this.Identifier = identifier; + foreach (var arg in typeArguments) { + AddChild (arg, Roles.TypeArgument); + } + } + + public SimpleType (string identifier, params AstType[] typeArguments) : this (identifier, (IEnumerable)typeArguments) + { } public string Identifier { @@ -52,7 +64,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier IdentifierToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs index 3ee53863e..c75adbec6 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs @@ -1,4 +1,4 @@ -// +// // EmptyStatement.cs // // Author: @@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// ; /// - public class EmptyStatement : Statement + public class EmptyStatement : Statement, IRelocatable { public AstLocation Location { get; @@ -48,6 +48,13 @@ namespace ICSharpCode.NRefactory.CSharp } } + #region IRelocationable implementation + void IRelocatable.SetStartLocation (AstLocation startLocation) + { + this.Location = startLocation; + } + #endregion + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitEmptyStatement (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs index 6caf3883e..52be5da59 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs @@ -1,4 +1,4 @@ -// +// // ForeachStatement.cs // // Author: @@ -49,7 +49,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier VariableNameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole(Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs index 2eeeb0bc3..0bcc5e238 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs @@ -1,4 +1,4 @@ -// +// // GotoStatement.cs // // Author: @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(value)) SetChildByRole(Roles.Identifier, null); else - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs index 3ebdc3302..b23c80a4c 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs @@ -1,4 +1,4 @@ -// +// // LabelStatement.cs // // Author: @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs index f7404229a..c3fd4dd3f 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs @@ -156,6 +156,15 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } + public CaseLabel () + { + } + + public CaseLabel (Expression expression) + { + this.Expression = expression; + } + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCaseLabel (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs index ccd1fb7b6..77ef45e6b 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs @@ -1,4 +1,4 @@ -// +// // TryCatchStatement.cs // // Author: @@ -140,7 +140,16 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(value)) SetChildByRole (Roles.Identifier, null); else - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier VariableNameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole(Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs index e5066c1c3..54f473684 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs @@ -61,6 +61,11 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } + public VariableInitializer GetVariable (string name) + { + return Variables.FirstOrDefault (vi => vi.Name == name); + } + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitVariableDeclarationStatement (this, data); diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs index af5e584dc..019c55444 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs @@ -58,9 +58,14 @@ namespace ICSharpCode.NRefactory.CSharp } } - protected bool MatchAttributesAndModifiers(AttributedNode o, PatternMatching.Match match) + protected bool MatchAttributesAndModifiers (AttributedNode o, PatternMatching.Match match) { - return (this.Modifiers == Modifiers.Any || this.Modifiers == o.Modifiers) && this.Attributes.DoMatch(o.Attributes, match); + return (this.Modifiers == Modifiers.Any || this.Modifiers == o.Modifiers) && this.Attributes.DoMatch (o.Attributes, match); + } + + public bool HasModifier (Modifiers mod) + { + return (Modifiers & mod) == mod; } } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs index a86214b97..afcc2d47d 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs @@ -40,6 +40,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public string Name { get; set; } + public Identifier IdentifierToken { + get { return GetChildByRole (Roles.Identifier); } + set { SetChildByRole (Roles.Identifier, value); } + } + public CSharpTokenNode LParToken { get { return GetChildByRole (Roles.LPar); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs index 8a892b275..829682e73 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs @@ -41,6 +41,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public string Name { get; set; } + public Identifier IdentifierToken { + get { return GetChildByRole (Roles.Identifier); } + set { SetChildByRole (Roles.Identifier, value); } + } + public CSharpTokenNode LParToken { get { return GetChildByRole (Roles.LPar); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs index e2784f565..8c3156298 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs @@ -1,4 +1,4 @@ -// +// // EnumMemberDeclaration.cs // // Author: @@ -36,7 +36,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs index 930d31a0e..1d5d9da93 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs @@ -1,4 +1,4 @@ -// +// // FixedFieldDeclaration.cs // // Author: @@ -54,10 +54,19 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } - + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); + } + } + public CSharpTokenNode LBracketToken { get { return GetChildByRole (Roles.LBracket); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs index a7e1b74e4..f2fd81683 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs @@ -1,4 +1,4 @@ -// +// // AbstractMember.cs // // Author: @@ -48,7 +48,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs index 7215412eb..31d123232 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs @@ -23,52 +23,55 @@ // 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.Collections.Generic; using System.Linq; namespace ICSharpCode.NRefactory.CSharp { - public enum OperatorType { + public enum OperatorType + { + // Values must correspond to Mono.CSharp.Operator.OpType + // due to the casts used in OperatorDeclaration. + // Unary operators - LogicalNot, - OnesComplement, - Increment, - Decrement, - True, - False, + LogicalNot = Mono.CSharp.Operator.OpType.LogicalNot, + OnesComplement = Mono.CSharp.Operator.OpType.OnesComplement, + Increment = Mono.CSharp.Operator.OpType.Increment, + Decrement = Mono.CSharp.Operator.OpType.Decrement, + True = Mono.CSharp.Operator.OpType.True, + False = Mono.CSharp.Operator.OpType.False, // Unary and Binary operators - Addition, - Subtraction, + Addition = Mono.CSharp.Operator.OpType.Addition, + Subtraction = Mono.CSharp.Operator.OpType.Subtraction, - UnaryPlus, - UnaryNegation, + UnaryPlus = Mono.CSharp.Operator.OpType.UnaryPlus, + UnaryNegation = Mono.CSharp.Operator.OpType.UnaryNegation, // Binary operators - Multiply, - Division, - Modulus, - BitwiseAnd, - BitwiseOr, - ExclusiveOr, - LeftShift, - RightShift, - Equality, - Inequality, - GreaterThan, - LessThan, - GreaterThanOrEqual, - LessThanOrEqual, + Multiply = Mono.CSharp.Operator.OpType.Multiply, + Division = Mono.CSharp.Operator.OpType.Division, + Modulus = Mono.CSharp.Operator.OpType.Modulus, + BitwiseAnd = Mono.CSharp.Operator.OpType.BitwiseAnd, + BitwiseOr = Mono.CSharp.Operator.OpType.BitwiseOr, + ExclusiveOr = Mono.CSharp.Operator.OpType.ExclusiveOr, + LeftShift = Mono.CSharp.Operator.OpType.LeftShift, + RightShift = Mono.CSharp.Operator.OpType.RightShift, + Equality = Mono.CSharp.Operator.OpType.Equality, + Inequality = Mono.CSharp.Operator.OpType.Inequality, + GreaterThan = Mono.CSharp.Operator.OpType.GreaterThan, + LessThan = Mono.CSharp.Operator.OpType.LessThan, + GreaterThanOrEqual = Mono.CSharp.Operator.OpType.GreaterThanOrEqual, + LessThanOrEqual = Mono.CSharp.Operator.OpType.LessThanOrEqual, // Implicit and Explicit - Implicit, - Explicit + Implicit = Mono.CSharp.Operator.OpType.Implicit, + Explicit = Mono.CSharp.Operator.OpType.Explicit } public class OperatorDeclaration : AttributedNode { - public static readonly Role OperatorTypeRole = new Role("OperatorType", CSharpTokenNode.Null); + public static readonly Role OperatorTypeRole = new Role ("OperatorType", CSharpTokenNode.Null); public static readonly Role OperatorKeywordRole = Roles.Keyword; public OperatorType OperatorType { @@ -78,7 +81,7 @@ namespace ICSharpCode.NRefactory.CSharp public AstType ReturnType { get { return GetChildByRole (Roles.Type); } - set { SetChildByRole(Roles.Type, value); } + set { SetChildByRole (Roles.Type, value); } } public CSharpTokenNode LParToken { @@ -98,14 +101,28 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Body, value); } } - public static string GetName(OperatorType type) + /// + /// Gets the operator type from the method name, or null, if the method does not represent one of the known operator types. + /// + public static OperatorType? GetOperatorType(string methodName) + { + return (OperatorType?)Mono.CSharp.Operator.GetType(methodName); + } + + /// + /// Gets the method name for the operator type. ("op_Addition", "op_Implicit", etc.) + /// + public static string GetName (OperatorType type) { - return Mono.CSharp.Operator.GetMetadataName((Mono.CSharp.Operator.OpType)type); + return Mono.CSharp.Operator.GetMetadataName ((Mono.CSharp.Operator.OpType)type); } - public static string GetToken(OperatorType type) + /// + /// Gets the token for the operator type ("+", "implicit", etc.) + /// + public static string GetToken (OperatorType type) { - return Mono.CSharp.Operator.GetName((Mono.CSharp.Operator.OpType)type); + return Mono.CSharp.Operator.GetName ((Mono.CSharp.Operator.OpType)type); } public override NodeType NodeType { @@ -118,15 +135,15 @@ namespace ICSharpCode.NRefactory.CSharp } public string Name { - get { return GetName(this.OperatorType); } + get { return GetName (this.OperatorType); } } - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) { OperatorDeclaration o = other as OperatorDeclaration; - return o != null && this.MatchAttributesAndModifiers(o, match) && this.OperatorType == o.OperatorType - && this.ReturnType.DoMatch(o.ReturnType, match) - && this.Parameters.DoMatch(o.Parameters, match) && this.Body.DoMatch(o.Body, match); + return o != null && this.MatchAttributesAndModifiers (o, match) && this.OperatorType == o.OperatorType + && this.ReturnType.DoMatch (o.ReturnType, match) + && this.Parameters.DoMatch (o.Parameters, match) && this.Body.DoMatch (o.Body, match); } } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs index 5544c5aa7..287611ef6 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs @@ -1,4 +1,4 @@ -// +// // ParameterDeclarationExpression.cs // // Author: @@ -68,7 +68,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs index c90d172c1..6e1d57272 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs @@ -1,4 +1,4 @@ -// +// // VariableInitializer.cs // // Author: @@ -85,7 +85,16 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); + } + } + + public Identifier NameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } diff --git a/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs b/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs index f28e42ff5..2b08ae116 100644 --- a/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs @@ -28,6 +28,7 @@ using System.Text; using System.Collections.Generic; using System.Linq; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.CSharp.Refactoring; namespace ICSharpCode.NRefactory.CSharp { @@ -35,7 +36,8 @@ namespace ICSharpCode.NRefactory.CSharp { CSharpFormattingOptions policy; ITextEditorAdapter data; - List changes = new List (); + IActionFactory factory; + List changes = new List (); Indent curIndent = new Indent (); public int IndentLevel { @@ -52,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp set; } - public List Changes { + public List Changes { get { return this.changes; } } @@ -66,15 +68,18 @@ namespace ICSharpCode.NRefactory.CSharp set; } - public AstFormattingVisitor (CSharpFormattingOptions policy, ITextEditorAdapter data) + public AstFormattingVisitor (CSharpFormattingOptions policy, ITextEditorAdapter data, IActionFactory factory) { + if (factory == null) + throw new ArgumentNullException ("factory"); this.policy = policy; this.data = data; this.curIndent.TabsToSpaces = this.data.TabsToSpaces; this.curIndent.TabSize = this.data.TabSize; + this.factory = factory; CorrectBlankLines = true; } - + public override object VisitCompilationUnit (CompilationUnit unit, object data) { base.VisitCompilationUnit (unit, data); @@ -90,11 +95,20 @@ namespace ICSharpCode.NRefactory.CSharp do { line++; } while (line < data.LineCount && data.GetEditableLength (line) == data.GetIndentation (line).Length); - var start = data.GetLineEndOffset (loc.Line); + var start = data.LocationToOffset (node.EndLocation.Line, node.EndLocation.Column); + + int foundBlankLines = line - loc.Line - 1; + StringBuilder sb = new StringBuilder (); - for (int i = 0; i < blankLines; i++) + for (int i = 0; i < blankLines - foundBlankLines; i++) sb.Append (data.EolMarker); - int removedChars = line < data.LineCount ? data.GetLineOffset (line) - start : 0; + + int ws = start; + while (ws < data.Length && IsSpacing (data.GetCharAt (ws))) + ws++; + int removedChars = ws - start; + if (foundBlankLines > blankLines) + removedChars += data.GetLineEndOffset (loc.Line + foundBlankLines - blankLines) - data.GetLineEndOffset (loc.Line); AddChange (start, removedChars, sb.ToString ()); } @@ -107,7 +121,6 @@ namespace ICSharpCode.NRefactory.CSharp 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 (); @@ -118,20 +131,20 @@ namespace ICSharpCode.NRefactory.CSharp 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); + if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) + EnsureBlankLinesAfter (usingDeclaration, policy.BlankLinesAfterUsings); 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); + if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) + EnsureBlankLinesAfter (usingDeclaration, policy.BlankLinesAfterUsings); return null; } @@ -528,12 +541,12 @@ namespace ICSharpCode.NRefactory.CSharp } return base.VisitFieldDeclaration (fieldDeclaration, data); } - + public override object VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, object data) { FixIndentationForceNewLine (fixedFieldDeclaration.StartLocation); FormatCommas (fixedFieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma); - if (fixedFieldDeclaration.NextSibling is FieldDeclaration || fixedFieldDeclaration.NextSibling is FixedFieldDeclaration ) { + if (fixedFieldDeclaration.NextSibling is FieldDeclaration || fixedFieldDeclaration.NextSibling is FixedFieldDeclaration) { EnsureBlankLinesAfter (fixedFieldDeclaration, policy.BlankLinesBetweenFields); } else if (IsMember (fixedFieldDeclaration.NextSibling)) { EnsureBlankLinesAfter (fixedFieldDeclaration, policy.BlankLinesBetweenMembers); @@ -952,10 +965,10 @@ namespace ICSharpCode.NRefactory.CSharp 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); + //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)); + changes.Add (factory.CreateTextReplaceAction (offset, removedChars, insertedText)); } public bool IsLineIsEmptyUpToEol (AstLocation startLocation) @@ -1556,13 +1569,13 @@ namespace ICSharpCode.NRefactory.CSharp void FixIndentation (AstLocation location, int relOffset) { - if (location.Line < 0 || location.Line >= data.LineCount) { + if (location.Line < 1 || location.Line > data.LineCount) { Console.WriteLine ("Invalid location " + location); Console.WriteLine (Environment.StackTrace); return; } - string lineIndent = data.GetIndentation (location.Line); + 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); @@ -1573,9 +1586,9 @@ namespace ICSharpCode.NRefactory.CSharp { string lineIndent = data.GetIndentation (location.Line); string indentString = this.curIndent.IndentString; - if (indentString != lineIndent && location.Column - 1 == lineIndent.Length) { + if (location.Column - 1 == lineIndent.Length) { AddChange (data.GetLineOffset (location.Line), lineIndent.Length, indentString); - } else { + } else { int offset = data.LocationToOffset (location.Line, location.Column); int start = SearchWhitespaceLineStart (offset); if (start > 0) { @@ -1593,4 +1606,3 @@ namespace ICSharpCode.NRefactory.CSharp } } } - diff --git a/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs b/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs index b6acd11bf..4568f8736 100644 --- a/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs +++ b/ICSharpCode.NRefactory/CSharp/Formatter/ITextEditorAdapter.cs @@ -23,30 +23,61 @@ // 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.Collections.Generic; namespace ICSharpCode.NRefactory { public interface ITextEditorAdapter { bool TabsToSpaces { get; } + int TabSize { get; } + string EolMarker { get; } - string Text { 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); + void Replace (int offset, int count, string text); } + + /* + public static class ITextEditorAdapterHelperMethods + { + public static void AcceptChanges (this ITextEditorAdapter adapter, List changes) + { + for (int i = 0; i < changes.Count; i++) { + changes [i].PerformChange (adapter); + var replaceChange = changes [i]; + for (int j = i + 1; j < changes.Count; j++) { + var change = changes [j]; + if (replaceChange.Offset >= 0 && change.Offset >= 0) { + if (replaceChange.Offset < change.Offset) { + change.Offset -= replaceChange.RemovedChars; + if (!string.IsNullOrEmpty (replaceChange.InsertedText)) + change.Offset += replaceChange.InsertedText.Length; + } else if (replaceChange.Offset < change.Offset + change.RemovedChars) { + change.RemovedChars -= replaceChange.RemovedChars; + change.Offset = replaceChange.Offset + (!string.IsNullOrEmpty (replaceChange.InsertedText) ? replaceChange.InsertedText.Length : 0); + } + } + } + } + } + }*/ } diff --git a/ICSharpCode.NRefactory/CSharp/OutputVisitor/InsertParenthesesVisitor.cs b/ICSharpCode.NRefactory/CSharp/OutputVisitor/InsertParenthesesVisitor.cs index cfa12e17a..8e2e5981b 100644 --- a/ICSharpCode.NRefactory/CSharp/OutputVisitor/InsertParenthesesVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/OutputVisitor/InsertParenthesesVisitor.cs @@ -156,6 +156,41 @@ namespace ICSharpCode.NRefactory.CSharp Parenthesize(castExpression.Expression); } } + // The above issue can also happen with PrimitiveExpressions representing negative values: + PrimitiveExpression pe = castExpression.Expression as PrimitiveExpression; + if (pe != null && pe.Value != null && TypeCanBeMisinterpretedAsExpression(castExpression.Type)) { + TypeCode typeCode = Type.GetTypeCode(pe.Value.GetType()); + switch (typeCode) { + case TypeCode.SByte: + if ((sbyte)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + case TypeCode.Int16: + if ((short)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + case TypeCode.Int32: + if ((int)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + case TypeCode.Int64: + if ((long)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + case TypeCode.Single: + if ((float)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + case TypeCode.Double: + if ((double)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + case TypeCode.Decimal: + if ((decimal)pe.Value < 0) + Parenthesize(castExpression.Expression); + break; + } + } return base.VisitCastExpression(castExpression, data); } diff --git a/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs index 79eec56d9..34589023d 100644 --- a/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs @@ -1,6 +1,5 @@ // 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; using System.Collections.Generic; using System.Diagnostics; @@ -21,9 +20,8 @@ namespace ICSharpCode.NRefactory.CSharp { readonly IOutputFormatter formatter; readonly CSharpFormattingOptions policy; - - readonly Stack containerStack = new Stack(); - readonly Stack positionStack = new Stack(); + readonly Stack containerStack = new Stack (); + readonly Stack positionStack = new Stack (); /// /// Used to insert the minimal amount of spaces so that the lexer recognizes the tokens that were written. @@ -42,47 +40,81 @@ namespace ICSharpCode.NRefactory.CSharp Division } - public OutputVisitor(TextWriter textWriter, CSharpFormattingOptions formattingPolicy) + public OutputVisitor (TextWriter textWriter, CSharpFormattingOptions formattingPolicy) { if (textWriter == null) - throw new ArgumentNullException("textWriter"); + throw new ArgumentNullException ("textWriter"); if (formattingPolicy == null) - throw new ArgumentNullException("formattingPolicy"); - this.formatter = new TextWriterOutputFormatter(textWriter); + throw new ArgumentNullException ("formattingPolicy"); + this.formatter = new TextWriterOutputFormatter (textWriter); this.policy = formattingPolicy; } - public OutputVisitor(IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) + public OutputVisitor (IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { if (formatter == null) - throw new ArgumentNullException("formatter"); + throw new ArgumentNullException ("formatter"); if (formattingPolicy == null) - throw new ArgumentNullException("formattingPolicy"); + throw new ArgumentNullException ("formattingPolicy"); this.formatter = formatter; this.policy = formattingPolicy; } #region StartNode/EndNode - void StartNode(AstNode node) + public event EventHandler OutputStarted; + + protected virtual void OnOutputStarted (AstNodeEventArgs e) { - // Ensure that nodes are visited in the proper nested order. - // Jumps to different subtrees are allowed only for the child of a placeholder node. - Debug.Assert(containerStack.Count == 0 || node.Parent == containerStack.Peek() || containerStack.Peek().NodeType == NodeType.Pattern); - if (positionStack.Count > 0) - WriteSpecialsUpToNode(node); - containerStack.Push(node); - positionStack.Push(node.FirstChild); - formatter.StartNode(node); + EventHandler handler = this.OutputStarted; + if (handler != null) + handler (this, e); } - object EndNode(AstNode node) + public event EventHandler OutputFinished; + + protected virtual void OnOutputFinished (AstNodeEventArgs e) { - Debug.Assert(node == containerStack.Peek()); - AstNode pos = positionStack.Pop(); - Debug.Assert(pos == null || pos.Parent == node); - WriteSpecials(pos, null); - containerStack.Pop(); - formatter.EndNode(node); + EventHandler handler = this.OutputFinished; + if (handler != null) + handler (this, e); + } + + [Serializable] + public sealed class AstNodeEventArgs : EventArgs + { + public AstNode AstNode { + get; + private set; + } + + public AstNodeEventArgs (AstNode node) + { + this.AstNode = node; + } + } + + void StartNode (AstNode node) + { + // Ensure that nodes are visited in the proper nested order. + // Jumps to different subtrees are allowed only for the child of a placeholder node. + Debug.Assert (containerStack.Count == 0 || node.Parent == containerStack.Peek () || containerStack.Peek ().NodeType == NodeType.Pattern); + if (positionStack.Count > 0) + WriteSpecialsUpToNode (node); + containerStack.Push (node); + positionStack.Push (node.FirstChild); + OnOutputStarted (new AstNodeEventArgs (node)); + formatter.StartNode (node); + } + + object EndNode (AstNode node) + { + Debug.Assert (node == containerStack.Peek ()); + AstNode pos = positionStack.Pop (); + Debug.Assert (pos == null || pos.Parent == node); + WriteSpecials (pos, null); + containerStack.Pop (); + OnOutputFinished (new AstNodeEventArgs (node)); + formatter.EndNode (node); return null; } #endregion @@ -91,11 +123,11 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Writes all specials from start to end (exclusive). Does not touch the positionStack. /// - void WriteSpecials(AstNode start, AstNode end) + void WriteSpecials (AstNode start, AstNode end) { for (AstNode pos = start; pos != end; pos = pos.NextSibling) { if (pos.Role == AstNode.Roles.Comment) { - pos.AcceptVisitor(this, null); + pos.AcceptVisitor (this, null); } } } @@ -104,12 +136,12 @@ namespace ICSharpCode.NRefactory.CSharp /// Writes all specials between the current position (in the positionStack) and the next /// node with the specified role. Advances the current position. /// - void WriteSpecialsUpToRole(Role role) + void WriteSpecialsUpToRole (Role role) { for (AstNode pos = positionStack.Peek(); pos != null; pos = pos.NextSibling) { if (pos.Role == role) { - WriteSpecials(positionStack.Pop(), pos); - positionStack.Push(pos); + WriteSpecials (positionStack.Pop (), pos); + positionStack.Push (pos); break; } } @@ -119,24 +151,24 @@ namespace ICSharpCode.NRefactory.CSharp /// Writes all specials between the current position (in the positionStack) and the specified node. /// Advances the current position. /// - void WriteSpecialsUpToNode(AstNode node) + void WriteSpecialsUpToNode (AstNode node) { for (AstNode pos = positionStack.Peek(); pos != null; pos = pos.NextSibling) { if (pos == node) { - WriteSpecials(positionStack.Pop(), pos); - positionStack.Push(pos); + WriteSpecials (positionStack.Pop (), pos); + positionStack.Push (pos); break; } } } - void WriteSpecialsUpToRole(Role role, AstNode nextNode) + void WriteSpecialsUpToRole (Role role, AstNode nextNode) { // Look for the role between the current position and the nextNode. for (AstNode pos = positionStack.Peek(); pos != null && pos != nextNode; pos = pos.NextSibling) { if (pos.Role == AstNode.Roles.Comma) { - WriteSpecials(positionStack.Pop(), pos); - positionStack.Push(pos); + WriteSpecials (positionStack.Pop (), pos); + positionStack.Push (pos); break; } } @@ -149,37 +181,37 @@ namespace ICSharpCode.NRefactory.CSharp /// /// The next node after the comma. /// When set prevents printing a space after comma. - void Comma(AstNode nextNode, bool noSpaceAfterComma = false) + void Comma (AstNode nextNode, bool noSpaceAfterComma = false) { - WriteSpecialsUpToRole(AstNode.Roles.Comma, nextNode); - Space(policy.SpaceBeforeBracketComma); // TODO: Comma policy has changed. - formatter.WriteToken(","); + WriteSpecialsUpToRole (AstNode.Roles.Comma, nextNode); + Space (policy.SpaceBeforeBracketComma); // TODO: Comma policy has changed. + formatter.WriteToken (","); lastWritten = LastWritten.Other; - Space(!noSpaceAfterComma && policy.SpaceAfterBracketComma); // TODO: Comma policy has changed. + Space (!noSpaceAfterComma && policy.SpaceAfterBracketComma); // TODO: Comma policy has changed. } - void WriteCommaSeparatedList(IEnumerable list) + void WriteCommaSeparatedList (IEnumerable list) { bool isFirst = true; foreach (AstNode node in list) { if (isFirst) { isFirst = false; } else { - Comma(node); + Comma (node); } - node.AcceptVisitor(this, null); + node.AcceptVisitor (this, null); } } - void WriteCommaSeparatedListInParenthesis(IEnumerable list, bool spaceWithin) + void WriteCommaSeparatedListInParenthesis (IEnumerable list, bool spaceWithin) { - LPar(); - if (list.Any()) { - Space(spaceWithin); - WriteCommaSeparatedList(list); - Space(spaceWithin); + LPar (); + if (list.Any ()) { + Space (spaceWithin); + WriteCommaSeparatedList (list); + Space (spaceWithin); } - RPar(); + RPar (); } #if DOTNET35 @@ -205,18 +237,18 @@ namespace ICSharpCode.NRefactory.CSharp #endif - void WriteCommaSeparatedListInBrackets(IEnumerable list, bool spaceWithin) + void WriteCommaSeparatedListInBrackets (IEnumerable list, bool spaceWithin) { - WriteToken("[", AstNode.Roles.LBracket); - if (list.Any()) { - Space(spaceWithin); - WriteCommaSeparatedList(list.SafeCast()); - Space(spaceWithin); + WriteToken ("[", AstNode.Roles.LBracket); + if (list.Any ()) { + Space (spaceWithin); + WriteCommaSeparatedList (list.SafeCast ()); + Space (spaceWithin); } - WriteToken("]", AstNode.Roles.RBracket); + WriteToken ("]", AstNode.Roles.RBracket); } - void WriteCommaSeparatedListInBrackets(IEnumerable list) + void WriteCommaSeparatedListInBrackets (IEnumerable list) { WriteToken ("[", AstNode.Roles.LBracket); if (list.Any ()) { @@ -232,47 +264,46 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Writes a keyword, and all specials up to /// - void WriteKeyword(string keyword, Role tokenRole = null) + void WriteKeyword (string keyword, Role tokenRole = null) { - WriteSpecialsUpToRole(tokenRole ?? AstNode.Roles.Keyword); + WriteSpecialsUpToRole (tokenRole ?? AstNode.Roles.Keyword); if (lastWritten == LastWritten.KeywordOrIdentifier) - formatter.Space(); - formatter.WriteKeyword(keyword); + formatter.Space (); + formatter.WriteKeyword (keyword); lastWritten = LastWritten.KeywordOrIdentifier; } - void WriteIdentifier(string identifier, Role identifierRole = null) + void WriteIdentifier (string identifier, Role identifierRole = null) { - WriteSpecialsUpToRole(identifierRole ?? AstNode.Roles.Identifier); - if (IsKeyword(identifier, containerStack.Peek())) { + WriteSpecialsUpToRole (identifierRole ?? AstNode.Roles.Identifier); + if (IsKeyword (identifier, containerStack.Peek ())) { if (lastWritten == LastWritten.KeywordOrIdentifier) - Space(); // this space is not strictly required, so we call Space() - formatter.WriteToken("@"); + Space (); // this space is not strictly required, so we call Space() + formatter.WriteToken ("@"); } else if (lastWritten == LastWritten.KeywordOrIdentifier) { - formatter.Space(); // this space is strictly required, so we directly call the formatter + formatter.Space (); // this space is strictly required, so we directly call the formatter } - formatter.WriteIdentifier(identifier); + formatter.WriteIdentifier (identifier); lastWritten = LastWritten.KeywordOrIdentifier; } - void WriteToken(string token, Role tokenRole) + void WriteToken (string token, Role tokenRole) { - WriteSpecialsUpToRole(tokenRole); + WriteSpecialsUpToRole (tokenRole); // Avoid that two +, - or ? tokens are combined into a ++, -- or ?? token. // Note that we don't need to handle tokens like = because there's no valid // C# program that contains the single token twice in a row. // (for +, - and &, this can happen with unary operators; // for ?, this can happen in "a is int? ? b : c" or "a as int? ?? 0"; // and for /, this can happen with "1/ *ptr" or "1/ //comment".) - if (lastWritten == LastWritten.Plus && token[0] == '+' - || lastWritten == LastWritten.Minus && token[0] == '-' - || lastWritten == LastWritten.Ampersand && token[0] == '&' - || lastWritten == LastWritten.QuestionMark && token[0] == '?' - || lastWritten == LastWritten.Division && token[0] == '*') - { - formatter.Space(); - } - formatter.WriteToken(token); + if (lastWritten == LastWritten.Plus && token [0] == '+' + || lastWritten == LastWritten.Minus && token [0] == '-' + || lastWritten == LastWritten.Ampersand && token [0] == '&' + || lastWritten == LastWritten.QuestionMark && token [0] == '?' + || lastWritten == LastWritten.Division && token [0] == '*') { + formatter.Space (); + } + formatter.WriteToken (token); if (token == "+") lastWritten = LastWritten.Plus; else if (token == "-") @@ -287,58 +318,59 @@ namespace ICSharpCode.NRefactory.CSharp lastWritten = LastWritten.Other; } - void LPar() + void LPar () { - WriteToken("(", AstNode.Roles.LPar); + WriteToken ("(", AstNode.Roles.LPar); } - void RPar() + void RPar () { - WriteToken(")", AstNode.Roles.LPar); + WriteToken (")", AstNode.Roles.LPar); } /// /// Marks the end of a statement /// - void Semicolon() + void Semicolon () { - Role role = containerStack.Peek().Role; // get the role of the current node + Role role = containerStack.Peek ().Role; // get the role of the current node if (!(role == ForStatement.InitializerRole || role == ForStatement.IteratorRole || role == UsingStatement.ResourceAcquisitionRole)) { - WriteToken(";", AstNode.Roles.Semicolon); - NewLine(); + WriteToken (";", AstNode.Roles.Semicolon); + NewLine (); } } /// /// Writes a space depending on policy. /// - void Space(bool addSpace = true) + void Space (bool addSpace = true) { if (addSpace) { - formatter.Space(); + formatter.Space (); lastWritten = LastWritten.Whitespace; } } - void NewLine() + void NewLine () { - formatter.NewLine(); + formatter.NewLine (); lastWritten = LastWritten.Whitespace; } - void OpenBrace(BraceStyle style) + void OpenBrace (BraceStyle style) { - WriteSpecialsUpToRole(AstNode.Roles.LBrace); - formatter.OpenBrace(style); + WriteSpecialsUpToRole (AstNode.Roles.LBrace); + formatter.OpenBrace (style); lastWritten = LastWritten.Other; } - void CloseBrace(BraceStyle style) + void CloseBrace (BraceStyle style) { - WriteSpecialsUpToRole(AstNode.Roles.RBrace); - formatter.CloseBrace(style); + WriteSpecialsUpToRole (AstNode.Roles.RBrace); + formatter.CloseBrace (style); lastWritten = LastWritten.Other; } + #endregion #region IsKeyword Test @@ -354,7 +386,6 @@ namespace ICSharpCode.NRefactory.CSharp "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while" }; - static readonly HashSet queryKeywords = new HashSet { "from", "where", "join", "on", "equals", "into", "let", "orderby", "ascending", "descending", "select", "group", "by" @@ -363,456 +394,473 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Determines whether the specified identifier is a keyword in the given context. /// - public static bool IsKeyword(string identifier, AstNode context) + public static bool IsKeyword (string identifier, AstNode context) { - if (unconditionalKeywords.Contains(identifier)) + if (unconditionalKeywords.Contains (identifier)) return true; - if (context.Ancestors.Any(a => a is QueryExpression)) { - if (queryKeywords.Contains(identifier)) + if (context.Ancestors.Any (a => a is QueryExpression)) { + if (queryKeywords.Contains (identifier)) return true; } return false; } + #endregion #region Write constructs - void WriteTypeArguments(IEnumerable typeArguments) + void WriteTypeArguments (IEnumerable typeArguments) { - if (typeArguments.Any()) { - WriteToken("<", AstNode.Roles.LChevron); - WriteCommaSeparatedList(typeArguments); - WriteToken(">", AstNode.Roles.RChevron); + if (typeArguments.Any ()) { + WriteToken ("<", AstNode.Roles.LChevron); + WriteCommaSeparatedList (typeArguments); + WriteToken (">", AstNode.Roles.RChevron); } } - void WriteTypeParameters(IEnumerable typeParameters) + void WriteTypeParameters (IEnumerable typeParameters) { - if (typeParameters.Any()) { - WriteToken("<", AstNode.Roles.LChevron); - WriteCommaSeparatedList(typeParameters.SafeCast()); - WriteToken(">", AstNode.Roles.RChevron); + if (typeParameters.Any ()) { + WriteToken ("<", AstNode.Roles.LChevron); + WriteCommaSeparatedList (typeParameters.SafeCast ()); + WriteToken (">", AstNode.Roles.RChevron); } } - void WriteModifiers(IEnumerable modifierTokens) + void WriteModifiers (IEnumerable modifierTokens) { foreach (CSharpModifierToken modifier in modifierTokens) { - modifier.AcceptVisitor(this, null); + modifier.AcceptVisitor (this, null); } } - void WriteQualifiedIdentifier(IEnumerable identifiers) + void WriteQualifiedIdentifier (IEnumerable identifiers) { bool first = true; foreach (Identifier ident in identifiers) { if (first) { first = false; if (lastWritten == LastWritten.KeywordOrIdentifier) - formatter.Space(); + formatter.Space (); } else { - WriteSpecialsUpToRole(AstNode.Roles.Dot, ident); - formatter.WriteToken("."); + WriteSpecialsUpToRole (AstNode.Roles.Dot, ident); + formatter.WriteToken ("."); lastWritten = LastWritten.Other; } - WriteSpecialsUpToNode(ident); - formatter.WriteIdentifier(ident.Name); + WriteSpecialsUpToNode (ident); + formatter.WriteIdentifier (ident.Name); lastWritten = LastWritten.KeywordOrIdentifier; } } - void WriteEmbeddedStatement(Statement embeddedStatement) + void WriteEmbeddedStatement (Statement embeddedStatement) { if (embeddedStatement.IsNull) return; BlockStatement block = embeddedStatement as BlockStatement; if (block != null) - VisitBlockStatement(block, null); - else - embeddedStatement.AcceptVisitor(this, null); + VisitBlockStatement (block, null); + else { + NewLine (); + formatter.Indent (); + embeddedStatement.AcceptVisitor (this, null); + formatter.Unindent (); + } } - void WriteMethodBody(BlockStatement body) + void WriteMethodBody (BlockStatement body) { if (body.IsNull) - Semicolon(); + Semicolon (); else - VisitBlockStatement(body, null); + VisitBlockStatement (body, null); } - void WriteAttributes(IEnumerable attributes) + void WriteAttributes (IEnumerable attributes) { foreach (AttributeSection attr in attributes) { - attr.AcceptVisitor(this, null); + attr.AcceptVisitor (this, null); } } - void WritePrivateImplementationType(AstType privateImplementationType) + void WritePrivateImplementationType (AstType privateImplementationType) { if (!privateImplementationType.IsNull) { - privateImplementationType.AcceptVisitor(this, null); - WriteToken(".", AstNode.Roles.Dot); + privateImplementationType.AcceptVisitor (this, null); + WriteToken (".", AstNode.Roles.Dot); } } + #endregion #region Expressions - public object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) + public object VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, object data) { - StartNode(anonymousMethodExpression); - WriteKeyword("delegate"); + StartNode (anonymousMethodExpression); + WriteKeyword ("delegate"); if (anonymousMethodExpression.HasParameterList) { - Space(policy.SpaceBeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(anonymousMethodExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + Space (policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis (anonymousMethodExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); } - anonymousMethodExpression.Body.AcceptVisitor(this, data); - return EndNode(anonymousMethodExpression); + anonymousMethodExpression.Body.AcceptVisitor (this, data); + return EndNode (anonymousMethodExpression); } - public object VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, object data) + public object VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression, object data) { - StartNode(undocumentedExpression); + StartNode (undocumentedExpression); switch (undocumentedExpression.UndocumentedExpressionType) { case UndocumentedExpressionType.ArgList: case UndocumentedExpressionType.ArgListAccess: - WriteKeyword("__arglist"); + WriteKeyword ("__arglist"); break; case UndocumentedExpressionType.MakeRef: - WriteKeyword("__makeref"); + WriteKeyword ("__makeref"); break; case UndocumentedExpressionType.RefType: - WriteKeyword("__reftype"); + WriteKeyword ("__reftype"); break; case UndocumentedExpressionType.RefValue: - WriteKeyword("__refvalue"); + WriteKeyword ("__refvalue"); break; } if (undocumentedExpression.Arguments.Count > 0) { - Space(policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(undocumentedExpression.Arguments, policy.SpaceWithinMethodCallParentheses); + Space (policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis (undocumentedExpression.Arguments, policy.SpaceWithinMethodCallParentheses); } - return EndNode(undocumentedExpression); + return EndNode (undocumentedExpression); } - public object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) + public object VisitArrayCreateExpression (ArrayCreateExpression arrayCreateExpression, object data) { - StartNode(arrayCreateExpression); - WriteKeyword("new"); - arrayCreateExpression.Type.AcceptVisitor(this, data); - WriteCommaSeparatedListInBrackets(arrayCreateExpression.Arguments); + StartNode (arrayCreateExpression); + WriteKeyword ("new"); + arrayCreateExpression.Type.AcceptVisitor (this, data); + WriteCommaSeparatedListInBrackets (arrayCreateExpression.Arguments); foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) - specifier.AcceptVisitor(this, data); - arrayCreateExpression.Initializer.AcceptVisitor(this, data); - return EndNode(arrayCreateExpression); + specifier.AcceptVisitor (this, data); + arrayCreateExpression.Initializer.AcceptVisitor (this, data); + return EndNode (arrayCreateExpression); } - public object VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, object data) + public object VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression, object data) { - StartNode(arrayInitializerExpression); + StartNode (arrayInitializerExpression); BraceStyle style; if (policy.PlaceArrayInitializersOnNewLine == ArrayInitializerPlacement.AlwaysNewLine) style = BraceStyle.NextLine; else style = BraceStyle.EndOfLine; - OpenBrace(style); + OpenBrace (style); bool isFirst = true; foreach (AstNode node in arrayInitializerExpression.Elements) { if (isFirst) { isFirst = false; } else { - Comma(node); - NewLine(); + Comma (node); + NewLine (); } - node.AcceptVisitor(this, null); + node.AcceptVisitor (this, null); } - NewLine(); - CloseBrace(style); - return EndNode(arrayInitializerExpression); + NewLine (); + CloseBrace (style); + return EndNode (arrayInitializerExpression); } - public object VisitAsExpression(AsExpression asExpression, object data) + public object VisitAsExpression (AsExpression asExpression, object data) { - StartNode(asExpression); - asExpression.Expression.AcceptVisitor(this, data); - Space(); - WriteKeyword("as"); - Space(); - asExpression.Type.AcceptVisitor(this, data); - return EndNode(asExpression); + StartNode (asExpression); + asExpression.Expression.AcceptVisitor (this, data); + Space (); + WriteKeyword ("as"); + Space (); + asExpression.Type.AcceptVisitor (this, data); + return EndNode (asExpression); } - public object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) + public object VisitAssignmentExpression (AssignmentExpression assignmentExpression, object data) { - StartNode(assignmentExpression); - assignmentExpression.Left.AcceptVisitor(this, data); - Space(policy.SpaceAroundAssignment); - WriteToken(AssignmentExpression.GetOperatorSymbol(assignmentExpression.Operator), AssignmentExpression.OperatorRole); - Space(policy.SpaceAroundAssignment); - assignmentExpression.Right.AcceptVisitor(this, data); - return EndNode(assignmentExpression); + StartNode (assignmentExpression); + assignmentExpression.Left.AcceptVisitor (this, data); + Space (policy.SpaceAroundAssignment); + WriteToken (AssignmentExpression.GetOperatorSymbol (assignmentExpression.Operator), AssignmentExpression.OperatorRole); + Space (policy.SpaceAroundAssignment); + assignmentExpression.Right.AcceptVisitor (this, data); + return EndNode (assignmentExpression); } - public object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) + public object VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, object data) { - StartNode(baseReferenceExpression); - WriteKeyword("base"); - return EndNode(baseReferenceExpression); + StartNode (baseReferenceExpression); + WriteKeyword ("base"); + return EndNode (baseReferenceExpression); } - public object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) + public object VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, object data) { - StartNode(binaryOperatorExpression); - binaryOperatorExpression.Left.AcceptVisitor(this, data); + StartNode (binaryOperatorExpression); + binaryOperatorExpression.Left.AcceptVisitor (this, data); bool spacePolicy; switch (binaryOperatorExpression.Operator) { - case BinaryOperatorType.BitwiseAnd: - case BinaryOperatorType.BitwiseOr: - case BinaryOperatorType.ExclusiveOr: - spacePolicy = policy.SpaceAroundBitwiseOperator; - break; - case BinaryOperatorType.ConditionalAnd: - case BinaryOperatorType.ConditionalOr: - spacePolicy = policy.SpaceAroundLogicalOperator; - break; - case BinaryOperatorType.GreaterThan: - case BinaryOperatorType.GreaterThanOrEqual: - case BinaryOperatorType.LessThanOrEqual: - case BinaryOperatorType.LessThan: - spacePolicy = policy.SpaceAroundRelationalOperator; - break; - case BinaryOperatorType.Equality: - case BinaryOperatorType.InEquality: - spacePolicy = policy.SpaceAroundEqualityOperator; - break; - case BinaryOperatorType.Add: - case BinaryOperatorType.Subtract: - spacePolicy = policy.SpaceAroundAdditiveOperator; - break; - case BinaryOperatorType.Multiply: - case BinaryOperatorType.Divide: - case BinaryOperatorType.Modulus: - spacePolicy = policy.SpaceAroundMultiplicativeOperator; - break; - case BinaryOperatorType.ShiftLeft: - case BinaryOperatorType.ShiftRight: - spacePolicy = policy.SpaceAroundShiftOperator; - break; - case BinaryOperatorType.NullCoalescing: - spacePolicy = true; - break; - default: - throw new NotSupportedException("Invalid value for BinaryOperatorType"); + case BinaryOperatorType.BitwiseAnd: + case BinaryOperatorType.BitwiseOr: + case BinaryOperatorType.ExclusiveOr: + spacePolicy = policy.SpaceAroundBitwiseOperator; + break; + case BinaryOperatorType.ConditionalAnd: + case BinaryOperatorType.ConditionalOr: + spacePolicy = policy.SpaceAroundLogicalOperator; + break; + case BinaryOperatorType.GreaterThan: + case BinaryOperatorType.GreaterThanOrEqual: + case BinaryOperatorType.LessThanOrEqual: + case BinaryOperatorType.LessThan: + spacePolicy = policy.SpaceAroundRelationalOperator; + break; + case BinaryOperatorType.Equality: + case BinaryOperatorType.InEquality: + spacePolicy = policy.SpaceAroundEqualityOperator; + break; + case BinaryOperatorType.Add: + case BinaryOperatorType.Subtract: + spacePolicy = policy.SpaceAroundAdditiveOperator; + break; + case BinaryOperatorType.Multiply: + case BinaryOperatorType.Divide: + case BinaryOperatorType.Modulus: + spacePolicy = policy.SpaceAroundMultiplicativeOperator; + break; + case BinaryOperatorType.ShiftLeft: + case BinaryOperatorType.ShiftRight: + spacePolicy = policy.SpaceAroundShiftOperator; + break; + case BinaryOperatorType.NullCoalescing: + spacePolicy = true; + break; + default: + throw new NotSupportedException ("Invalid value for BinaryOperatorType"); } - Space(spacePolicy); - WriteToken(BinaryOperatorExpression.GetOperatorSymbol(binaryOperatorExpression.Operator), BinaryOperatorExpression.OperatorRole); - Space(spacePolicy); - binaryOperatorExpression.Right.AcceptVisitor(this, data); - return EndNode(binaryOperatorExpression); + Space (spacePolicy); + WriteToken (BinaryOperatorExpression.GetOperatorSymbol (binaryOperatorExpression.Operator), BinaryOperatorExpression.OperatorRole); + Space (spacePolicy); + binaryOperatorExpression.Right.AcceptVisitor (this, data); + return EndNode (binaryOperatorExpression); } - public object VisitCastExpression(CastExpression castExpression, object data) + public object VisitCastExpression (CastExpression castExpression, object data) { - StartNode(castExpression); - LPar(); - Space(policy.SpacesWithinCastParentheses); - castExpression.Type.AcceptVisitor(this, data); - Space(policy.SpacesWithinCastParentheses); - RPar(); - Space(policy.SpaceAfterTypecast); - castExpression.Expression.AcceptVisitor(this, data); - return EndNode(castExpression); + StartNode (castExpression); + LPar (); + Space (policy.SpacesWithinCastParentheses); + castExpression.Type.AcceptVisitor (this, data); + Space (policy.SpacesWithinCastParentheses); + RPar (); + Space (policy.SpaceAfterTypecast); + castExpression.Expression.AcceptVisitor (this, data); + return EndNode (castExpression); } - public object VisitCheckedExpression(CheckedExpression checkedExpression, object data) + public object VisitCheckedExpression (CheckedExpression checkedExpression, object data) { - StartNode(checkedExpression); - WriteKeyword("checked"); - LPar(); - Space(policy.SpacesWithinCheckedExpressionParantheses); - checkedExpression.Expression.AcceptVisitor(this, data); - Space(policy.SpacesWithinCheckedExpressionParantheses); - RPar(); - return EndNode(checkedExpression); + StartNode (checkedExpression); + WriteKeyword ("checked"); + LPar (); + Space (policy.SpacesWithinCheckedExpressionParantheses); + checkedExpression.Expression.AcceptVisitor (this, data); + Space (policy.SpacesWithinCheckedExpressionParantheses); + RPar (); + return EndNode (checkedExpression); } - public object VisitConditionalExpression(ConditionalExpression conditionalExpression, object data) + public object VisitConditionalExpression (ConditionalExpression conditionalExpression, object data) { - StartNode(conditionalExpression); - conditionalExpression.Condition.AcceptVisitor(this, data); + StartNode (conditionalExpression); + conditionalExpression.Condition.AcceptVisitor (this, data); - Space(policy.SpaceBeforeConditionalOperatorCondition); - WriteToken("?", ConditionalExpression.QuestionMarkRole); - Space(policy.SpaceAfterConditionalOperatorCondition); + Space (policy.SpaceBeforeConditionalOperatorCondition); + WriteToken ("?", ConditionalExpression.QuestionMarkRole); + Space (policy.SpaceAfterConditionalOperatorCondition); - conditionalExpression.TrueExpression.AcceptVisitor(this, data); + conditionalExpression.TrueExpression.AcceptVisitor (this, data); - Space(policy.SpaceBeforeConditionalOperatorSeparator); - WriteToken(":", ConditionalExpression.ColonRole); - Space(policy.SpaceAfterConditionalOperatorSeparator); + Space (policy.SpaceBeforeConditionalOperatorSeparator); + WriteToken (":", ConditionalExpression.ColonRole); + Space (policy.SpaceAfterConditionalOperatorSeparator); - conditionalExpression.FalseExpression.AcceptVisitor(this, data); + conditionalExpression.FalseExpression.AcceptVisitor (this, data); - return EndNode(conditionalExpression); + return EndNode (conditionalExpression); } - public object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) + public object VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, object data) { - StartNode(defaultValueExpression); + StartNode (defaultValueExpression); - WriteKeyword("default"); - LPar(); - Space(policy.SpacesWithinTypeOfParentheses); - defaultValueExpression.Type.AcceptVisitor(this, data); - Space(policy.SpacesWithinTypeOfParentheses); - RPar(); + WriteKeyword ("default"); + LPar (); + Space (policy.SpacesWithinTypeOfParentheses); + defaultValueExpression.Type.AcceptVisitor (this, data); + Space (policy.SpacesWithinTypeOfParentheses); + RPar (); - return EndNode(defaultValueExpression); + return EndNode (defaultValueExpression); } - public object VisitDirectionExpression(DirectionExpression directionExpression, object data) + public object VisitDirectionExpression (DirectionExpression directionExpression, object data) { - StartNode(directionExpression); + StartNode (directionExpression); switch (directionExpression.FieldDirection) { - case FieldDirection.Out: - WriteKeyword("out"); - break; - case FieldDirection.Ref: - WriteKeyword("ref"); - break; - default: - throw new NotSupportedException("Invalid value for FieldDirection"); + case FieldDirection.Out: + WriteKeyword ("out"); + break; + case FieldDirection.Ref: + WriteKeyword ("ref"); + break; + default: + throw new NotSupportedException ("Invalid value for FieldDirection"); } - Space(); - directionExpression.Expression.AcceptVisitor(this, data); + Space (); + directionExpression.Expression.AcceptVisitor (this, data); - return EndNode(directionExpression); + return EndNode (directionExpression); } - public object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) + public object VisitIdentifierExpression (IdentifierExpression identifierExpression, object data) { - StartNode(identifierExpression); - WriteIdentifier(identifierExpression.Identifier); - WriteTypeArguments(identifierExpression.TypeArguments); - return EndNode(identifierExpression); + StartNode (identifierExpression); + WriteIdentifier (identifierExpression.Identifier); + WriteTypeArguments (identifierExpression.TypeArguments); + return EndNode (identifierExpression); } - public object VisitIndexerExpression(IndexerExpression indexerExpression, object data) + public object VisitIndexerExpression (IndexerExpression indexerExpression, object data) { - StartNode(indexerExpression); - indexerExpression.Target.AcceptVisitor(this, data); - Space(policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInBrackets(indexerExpression.Arguments); - return EndNode(indexerExpression); + StartNode (indexerExpression); + indexerExpression.Target.AcceptVisitor (this, data); + Space (policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInBrackets (indexerExpression.Arguments); + return EndNode (indexerExpression); } - public object VisitInvocationExpression(InvocationExpression invocationExpression, object data) + public object VisitInvocationExpression (InvocationExpression invocationExpression, object data) { - StartNode(invocationExpression); - invocationExpression.Target.AcceptVisitor(this, data); - Space(policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(invocationExpression.Arguments, policy.SpaceWithinMethodCallParentheses); - return EndNode(invocationExpression); + StartNode (invocationExpression); + invocationExpression.Target.AcceptVisitor (this, data); + Space (policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis (invocationExpression.Arguments, policy.SpaceWithinMethodCallParentheses); + return EndNode (invocationExpression); } - public object VisitIsExpression(IsExpression isExpression, object data) + public object VisitIsExpression (IsExpression isExpression, object data) { - StartNode(isExpression); - isExpression.Expression.AcceptVisitor(this, data); - Space(); - WriteKeyword("is"); - isExpression.Type.AcceptVisitor(this, data); - return EndNode(isExpression); + StartNode (isExpression); + isExpression.Expression.AcceptVisitor (this, data); + Space (); + WriteKeyword ("is"); + isExpression.Type.AcceptVisitor (this, data); + return EndNode (isExpression); } - public object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) + public object VisitLambdaExpression (LambdaExpression lambdaExpression, object data) { - StartNode(lambdaExpression); - if (LambdaNeedsParenthesis(lambdaExpression)) { - WriteCommaSeparatedListInParenthesis(lambdaExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + StartNode (lambdaExpression); + if (LambdaNeedsParenthesis (lambdaExpression)) { + WriteCommaSeparatedListInParenthesis (lambdaExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); } else { - lambdaExpression.Parameters.Single().AcceptVisitor(this, data); + lambdaExpression.Parameters.Single ().AcceptVisitor (this, data); } - Space(); - WriteToken("=>", LambdaExpression.ArrowRole); - Space(); - lambdaExpression.Body.AcceptVisitor(this, data); - return EndNode(lambdaExpression); + Space (); + WriteToken ("=>", LambdaExpression.ArrowRole); + Space (); + lambdaExpression.Body.AcceptVisitor (this, data); + return EndNode (lambdaExpression); } - bool LambdaNeedsParenthesis(LambdaExpression lambdaExpression) + bool LambdaNeedsParenthesis (LambdaExpression lambdaExpression) { if (lambdaExpression.Parameters.Count != 1) return true; - var p = lambdaExpression.Parameters.Single(); + var p = lambdaExpression.Parameters.Single (); return !(p.Type.IsNull && p.ParameterModifier == ParameterModifier.None); } - public object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) + public object VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, object data) { - StartNode(memberReferenceExpression); - memberReferenceExpression.Target.AcceptVisitor(this, data); - WriteToken(".", MemberReferenceExpression.Roles.Dot); - WriteIdentifier(memberReferenceExpression.MemberName); - WriteTypeArguments(memberReferenceExpression.TypeArguments); - return EndNode(memberReferenceExpression); + StartNode (memberReferenceExpression); + memberReferenceExpression.Target.AcceptVisitor (this, data); + WriteToken (".", MemberReferenceExpression.Roles.Dot); + WriteIdentifier (memberReferenceExpression.MemberName); + WriteTypeArguments (memberReferenceExpression.TypeArguments); + return EndNode (memberReferenceExpression); } - public object VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data) + public object VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression, object data) { - StartNode(namedArgumentExpression); - WriteIdentifier(namedArgumentExpression.Identifier); - WriteToken(":", NamedArgumentExpression.Roles.Colon); - Space(); - namedArgumentExpression.Expression.AcceptVisitor(this, data); - return EndNode(namedArgumentExpression); + StartNode (namedArgumentExpression); + WriteIdentifier (namedArgumentExpression.Identifier); + if (namedArgumentExpression.Parent is ArrayInitializerExpression) { + Space(); + WriteToken("=", NamedArgumentExpression.Roles.Assign); + } else { + WriteToken(":", NamedArgumentExpression.Roles.Colon); + } + Space (); + namedArgumentExpression.Expression.AcceptVisitor (this, data); + return EndNode (namedArgumentExpression); } - public object VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, object data) + public object VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, object data) { - StartNode(nullReferenceExpression); - WriteKeyword("null"); - return EndNode(nullReferenceExpression); + StartNode (nullReferenceExpression); + WriteKeyword ("null"); + return EndNode (nullReferenceExpression); } - public object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data) + public object VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, object data) { - StartNode(objectCreateExpression); - WriteKeyword("new"); - objectCreateExpression.Type.AcceptVisitor(this, data); - Space(policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(objectCreateExpression.Arguments, policy.SpaceWithinMethodCallParentheses); - objectCreateExpression.Initializer.AcceptVisitor(this, data); - return EndNode(objectCreateExpression); + StartNode (objectCreateExpression); + WriteKeyword ("new"); + objectCreateExpression.Type.AcceptVisitor (this, data); + bool useParenthesis = objectCreateExpression.Arguments.Any() || objectCreateExpression.Initializer.IsNull; + // also use parenthesis if there is an '(' token and this isn't an anonymous type + if (!objectCreateExpression.LParToken.IsNull && !objectCreateExpression.Type.IsNull) + useParenthesis = true; + if (useParenthesis) { + Space (policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis (objectCreateExpression.Arguments, policy.SpaceWithinMethodCallParentheses); + } + objectCreateExpression.Initializer.AcceptVisitor (this, data); + return EndNode (objectCreateExpression); } - public object VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data) + public object VisitAnonymousTypeCreateExpression (AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data) { - StartNode(anonymousTypeCreateExpression); - WriteKeyword("new"); - Space(); - LPar(); - RPar(); - Space(); - OpenBrace(policy.AnonymousMethodBraceStyle); + StartNode (anonymousTypeCreateExpression); + WriteKeyword ("new"); + Space (); + LPar (); + RPar (); + Space (); + OpenBrace (policy.AnonymousMethodBraceStyle); foreach (AstNode node in anonymousTypeCreateExpression.Initializer) { - node.AcceptVisitor(this, null); + node.AcceptVisitor (this, null); if (node.NextSibling != null) - Comma(node); + Comma (node); NewLine (); } - CloseBrace(policy.AnonymousMethodBraceStyle); - return EndNode(anonymousTypeCreateExpression); + CloseBrace (policy.AnonymousMethodBraceStyle); + return EndNode (anonymousTypeCreateExpression); } - public object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) + public object VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, object data) { - StartNode(parenthesizedExpression); - LPar(); - Space(policy.SpacesWithinParentheses); - parenthesizedExpression.Expression.AcceptVisitor(this, data); - Space(policy.SpacesWithinParentheses); - RPar(); - return EndNode(parenthesizedExpression); + StartNode (parenthesizedExpression); + LPar (); + Space (policy.SpacesWithinParentheses); + parenthesizedExpression.Expression.AcceptVisitor (this, data); + Space (policy.SpacesWithinParentheses); + RPar (); + return EndNode (parenthesizedExpression); } public object VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, object data) @@ -827,529 +875,554 @@ namespace ICSharpCode.NRefactory.CSharp public object VisitEmptyExpression (EmptyExpression emptyExpression, object data) { + StartNode (emptyExpression); return EndNode (emptyExpression); } + #region VisitPrimitiveExpression - public object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) + public object VisitPrimitiveExpression (PrimitiveExpression primitiveExpression, object data) { - StartNode(primitiveExpression); - WritePrimitiveValue(primitiveExpression.Value); - return EndNode(primitiveExpression); + StartNode (primitiveExpression); + if (!string.IsNullOrEmpty (primitiveExpression.LiteralValue)) { + formatter.WriteToken (primitiveExpression.LiteralValue); + } else { + WritePrimitiveValue (primitiveExpression.Value); + } + return EndNode (primitiveExpression); } - void WritePrimitiveValue(object val) + void WritePrimitiveValue (object val) { if (val == null) { // usually NullReferenceExpression should be used for this, but we'll handle it anyways - WriteKeyword("null"); + WriteKeyword ("null"); return; } if (val is bool) { if ((bool)val) { - WriteKeyword("true"); + WriteKeyword ("true"); } else { - WriteKeyword("false"); + WriteKeyword ("false"); } return; } if (val is string) { - formatter.WriteToken("\"" + ConvertString(val.ToString()) + "\""); + formatter.WriteToken ("\"" + ConvertString (val.ToString ()) + "\""); lastWritten = LastWritten.Other; } else if (val is char) { - formatter.WriteToken("'" + ConvertCharLiteral((char)val) + "'"); + formatter.WriteToken ("'" + ConvertCharLiteral ((char)val) + "'"); lastWritten = LastWritten.Other; } else if (val is decimal) { - formatter.WriteToken(((decimal)val).ToString(NumberFormatInfo.InvariantInfo) + "m"); + formatter.WriteToken (((decimal)val).ToString (NumberFormatInfo.InvariantInfo) + "m"); lastWritten = LastWritten.Other; } else if (val is float) { float f = (float)val; - if (float.IsInfinity(f) || float.IsNaN(f)) { + if (float.IsInfinity (f) || float.IsNaN (f)) { // Strictly speaking, these aren't PrimitiveExpressions; // but we still support writing these to make life easier for code generators. - WriteKeyword("float"); - WriteToken(".", AstNode.Roles.Dot); - if (float.IsPositiveInfinity(f)) - WriteIdentifier("PositiveInfinity"); - else if (float.IsNegativeInfinity(f)) - WriteIdentifier("NegativeInfinity"); + WriteKeyword ("float"); + WriteToken (".", AstNode.Roles.Dot); + if (float.IsPositiveInfinity (f)) + WriteIdentifier ("PositiveInfinity"); + else if (float.IsNegativeInfinity (f)) + WriteIdentifier ("NegativeInfinity"); else - WriteIdentifier("NaN"); + WriteIdentifier ("NaN"); return; } - formatter.WriteToken(f.ToString("R", NumberFormatInfo.InvariantInfo) + "f"); + formatter.WriteToken (f.ToString ("R", NumberFormatInfo.InvariantInfo) + "f"); lastWritten = LastWritten.Other; } else if (val is double) { double f = (double)val; - if (double.IsInfinity(f) || double.IsNaN(f)) { + if (double.IsInfinity (f) || double.IsNaN (f)) { // Strictly speaking, these aren't PrimitiveExpressions; // but we still support writing these to make life easier for code generators. - WriteKeyword("double"); - WriteToken(".", AstNode.Roles.Dot); - if (double.IsPositiveInfinity(f)) - WriteIdentifier("PositiveInfinity"); - else if (double.IsNegativeInfinity(f)) - WriteIdentifier("NegativeInfinity"); + WriteKeyword ("double"); + WriteToken (".", AstNode.Roles.Dot); + if (double.IsPositiveInfinity (f)) + WriteIdentifier ("PositiveInfinity"); + else if (double.IsNegativeInfinity (f)) + WriteIdentifier ("NegativeInfinity"); else - WriteIdentifier("NaN"); + WriteIdentifier ("NaN"); return; } - string number = f.ToString("R", NumberFormatInfo.InvariantInfo); - if (number.IndexOf('.') < 0 && number.IndexOf('E') < 0) + string number = f.ToString ("R", NumberFormatInfo.InvariantInfo); + if (number.IndexOf ('.') < 0 && number.IndexOf ('E') < 0) number += ".0"; - formatter.WriteToken(number); + formatter.WriteToken (number); // needs space if identifier follows number; this avoids mistaking the following identifier as type suffix lastWritten = LastWritten.KeywordOrIdentifier; } else if (val is IFormattable) { - StringBuilder b = new StringBuilder(); + StringBuilder b = new StringBuilder (); // if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) { // b.Append("0x"); // b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo)); // } else { - b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo)); + b.Append (((IFormattable)val).ToString (null, NumberFormatInfo.InvariantInfo)); // } if (val is uint || val is ulong) { - b.Append("u"); + b.Append ("u"); } if (val is long || val is ulong) { - b.Append("L"); + b.Append ("L"); } - formatter.WriteToken(b.ToString()); + formatter.WriteToken (b.ToString ()); // needs space if identifier follows number; this avoids mistaking the following identifier as type suffix lastWritten = LastWritten.KeywordOrIdentifier; } else { - formatter.WriteToken(val.ToString()); + formatter.WriteToken (val.ToString ()); lastWritten = LastWritten.Other; } } - static string ConvertCharLiteral(char ch) + static string ConvertCharLiteral (char ch) { - if (ch == '\'') return "\\'"; - return ConvertChar(ch); + if (ch == '\'') + return "\\'"; + return ConvertChar (ch); } - static string ConvertChar(char ch) + /// + /// Gets the escape sequence for the specified character. + /// + /// This method does not convert ' or ". + public static string ConvertChar(char ch) { switch (ch) { - case '\\': - return "\\\\"; - case '\0': - return "\\0"; - case '\a': - return "\\a"; - case '\b': - return "\\b"; - case '\f': - return "\\f"; - case '\n': - return "\\n"; - case '\r': - return "\\r"; - case '\t': - return "\\t"; - case '\v': - return "\\v"; - default: - if (char.IsControl(ch) || char.IsSurrogate(ch)) { - return "\\u" + ((int)ch).ToString("x4"); - } else { - return ch.ToString(); - } + case '\\': + return "\\\\"; + case '\0': + return "\\0"; + case '\a': + return "\\a"; + case '\b': + return "\\b"; + case '\f': + return "\\f"; + case '\n': + return "\\n"; + case '\r': + return "\\r"; + case '\t': + return "\\t"; + case '\v': + return "\\v"; + default: + if (char.IsControl(ch) || char.IsSurrogate(ch) || + // print all uncommon white spaces as numbers + (char.IsWhiteSpace(ch) && ch != ' ')) { + return "\\u" + ((int)ch).ToString ("x4"); + } else { + return ch.ToString (); + } } } - static string ConvertString(string str) + /// + /// Converts special characters to escape sequences within the given string. + /// + public static string ConvertString(string str) { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder (); foreach (char ch in str) { if (ch == '"') - sb.Append("\\\""); + sb.Append ("\\\""); else - sb.Append(ConvertChar(ch)); + sb.Append (ConvertChar (ch)); } - return sb.ToString(); + return sb.ToString (); } + #endregion - public object VisitSizeOfExpression(SizeOfExpression sizeOfExpression, object data) + public object VisitSizeOfExpression (SizeOfExpression sizeOfExpression, object data) { - StartNode(sizeOfExpression); + StartNode (sizeOfExpression); - WriteKeyword("sizeof"); - LPar(); - Space(policy.SpacesWithinSizeOfParentheses); - sizeOfExpression.Type.AcceptVisitor(this, data); - Space(policy.SpacesWithinSizeOfParentheses); - RPar(); + WriteKeyword ("sizeof"); + LPar (); + Space (policy.SpacesWithinSizeOfParentheses); + sizeOfExpression.Type.AcceptVisitor (this, data); + Space (policy.SpacesWithinSizeOfParentheses); + RPar (); - return EndNode(sizeOfExpression); + return EndNode (sizeOfExpression); } - public object VisitStackAllocExpression(StackAllocExpression stackAllocExpression, object data) + public object VisitStackAllocExpression (StackAllocExpression stackAllocExpression, object data) { - StartNode(stackAllocExpression); - WriteKeyword("stackalloc"); - stackAllocExpression.Type.AcceptVisitor(this, data); - WriteCommaSeparatedListInBrackets(new[] { stackAllocExpression.CountExpression }); - return EndNode(stackAllocExpression); + StartNode (stackAllocExpression); + WriteKeyword ("stackalloc"); + stackAllocExpression.Type.AcceptVisitor (this, data); + WriteCommaSeparatedListInBrackets (new[] { stackAllocExpression.CountExpression }); + return EndNode (stackAllocExpression); } - public object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) + public object VisitThisReferenceExpression (ThisReferenceExpression thisReferenceExpression, object data) { - StartNode(thisReferenceExpression); - WriteKeyword("this"); - return EndNode(thisReferenceExpression); + StartNode (thisReferenceExpression); + WriteKeyword ("this"); + return EndNode (thisReferenceExpression); } - public object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) + public object VisitTypeOfExpression (TypeOfExpression typeOfExpression, object data) { - StartNode(typeOfExpression); + StartNode (typeOfExpression); - WriteKeyword("typeof"); - LPar(); - Space(policy.SpacesWithinTypeOfParentheses); - typeOfExpression.Type.AcceptVisitor(this, data); - Space(policy.SpacesWithinTypeOfParentheses); - RPar(); + WriteKeyword ("typeof"); + LPar (); + Space (policy.SpacesWithinTypeOfParentheses); + typeOfExpression.Type.AcceptVisitor (this, data); + Space (policy.SpacesWithinTypeOfParentheses); + RPar (); - return EndNode(typeOfExpression); + return EndNode (typeOfExpression); } - public object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) + public object VisitTypeReferenceExpression (TypeReferenceExpression typeReferenceExpression, object data) { - StartNode(typeReferenceExpression); - typeReferenceExpression.Type.AcceptVisitor(this, data); - return EndNode(typeReferenceExpression); + StartNode (typeReferenceExpression); + typeReferenceExpression.Type.AcceptVisitor (this, data); + return EndNode (typeReferenceExpression); } - public object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) + public object VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, object data) { - StartNode(unaryOperatorExpression); + StartNode (unaryOperatorExpression); UnaryOperatorType opType = unaryOperatorExpression.Operator; - string opSymbol = UnaryOperatorExpression.GetOperatorSymbol(opType); + string opSymbol = UnaryOperatorExpression.GetOperatorSymbol (opType); if (!(opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement)) - WriteToken(opSymbol, UnaryOperatorExpression.OperatorRole); - unaryOperatorExpression.Expression.AcceptVisitor(this, data); + WriteToken (opSymbol, UnaryOperatorExpression.OperatorRole); + unaryOperatorExpression.Expression.AcceptVisitor (this, data); if (opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement) - WriteToken(opSymbol, UnaryOperatorExpression.OperatorRole); - return EndNode(unaryOperatorExpression); + WriteToken (opSymbol, UnaryOperatorExpression.OperatorRole); + return EndNode (unaryOperatorExpression); } - public object VisitUncheckedExpression(UncheckedExpression uncheckedExpression, object data) + public object VisitUncheckedExpression (UncheckedExpression uncheckedExpression, object data) { - StartNode(uncheckedExpression); - WriteKeyword("unchecked"); - LPar(); - Space(policy.SpacesWithinCheckedExpressionParantheses); - uncheckedExpression.Expression.AcceptVisitor(this, data); - Space(policy.SpacesWithinCheckedExpressionParantheses); - RPar(); - return EndNode(uncheckedExpression); + StartNode (uncheckedExpression); + WriteKeyword ("unchecked"); + LPar (); + Space (policy.SpacesWithinCheckedExpressionParantheses); + uncheckedExpression.Expression.AcceptVisitor (this, data); + Space (policy.SpacesWithinCheckedExpressionParantheses); + RPar (); + return EndNode (uncheckedExpression); } + #endregion #region Query Expressions - public object VisitQueryExpression(QueryExpression queryExpression, object data) + public object VisitQueryExpression (QueryExpression queryExpression, object data) { - StartNode(queryExpression); + StartNode (queryExpression); + bool indent = !(queryExpression.Parent is QueryContinuationClause); + if (indent) { + formatter.Indent(); + NewLine(); + } bool first = true; foreach (var clause in queryExpression.Clauses) { if (first) { first = false; } else { if (!(clause is QueryContinuationClause)) - NewLine(); + NewLine (); } - clause.AcceptVisitor(this, data); - } - return EndNode(queryExpression); - } - - public object VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, object data) - { - StartNode(queryContinuationClause); - queryContinuationClause.PrecedingQuery.AcceptVisitor(this, data); - Space(); - WriteKeyword("into", QueryContinuationClause.IntoKeywordRole); - Space(); - WriteIdentifier(queryContinuationClause.Identifier); - return EndNode(queryContinuationClause); - } - - public object VisitQueryFromClause(QueryFromClause queryFromClause, object data) - { - StartNode(queryFromClause); - WriteKeyword("from", QueryFromClause.FromKeywordRole); - queryFromClause.Type.AcceptVisitor(this, data); - Space(); - WriteIdentifier(queryFromClause.Identifier); - Space(); - WriteKeyword("in", QueryFromClause.InKeywordRole); - Space(); - queryFromClause.Expression.AcceptVisitor(this, data); - return EndNode(queryFromClause); - } - - public object VisitQueryLetClause(QueryLetClause queryLetClause, object data) - { - StartNode(queryLetClause); - WriteKeyword("let"); - Space(); - WriteIdentifier(queryLetClause.Identifier); - Space(policy.SpaceAroundAssignment); - WriteToken("=", QueryLetClause.Roles.Assign); - Space(policy.SpaceAroundAssignment); - queryLetClause.Expression.AcceptVisitor(this, data); - return EndNode(queryLetClause); - } - - public object VisitQueryWhereClause(QueryWhereClause queryWhereClause, object data) - { - StartNode(queryWhereClause); - WriteKeyword("where"); - Space(); - queryWhereClause.Condition.AcceptVisitor(this, data); - return EndNode(queryWhereClause); - } - - public object VisitQueryJoinClause(QueryJoinClause queryJoinClause, object data) - { - StartNode(queryJoinClause); - WriteKeyword("join", QueryJoinClause.JoinKeywordRole); - queryJoinClause.Type.AcceptVisitor(this, data); - Space(); - WriteIdentifier(queryJoinClause.JoinIdentifier, QueryJoinClause.JoinIdentifierRole); - Space(); - WriteKeyword("in", QueryJoinClause.InKeywordRole); - Space(); - queryJoinClause.InExpression.AcceptVisitor(this, data); - Space(); - WriteKeyword("on", QueryJoinClause.OnKeywordRole); - Space(); - queryJoinClause.OnExpression.AcceptVisitor(this, data); - Space(); - WriteKeyword("equals", QueryJoinClause.EqualsKeywordRole); - Space(); - queryJoinClause.EqualsExpression.AcceptVisitor(this, data); + clause.AcceptVisitor (this, data); + } + if (indent) + formatter.Unindent(); + return EndNode (queryExpression); + } + + public object VisitQueryContinuationClause (QueryContinuationClause queryContinuationClause, object data) + { + StartNode (queryContinuationClause); + queryContinuationClause.PrecedingQuery.AcceptVisitor (this, data); + Space (); + WriteKeyword ("into", QueryContinuationClause.IntoKeywordRole); + Space (); + WriteIdentifier (queryContinuationClause.Identifier); + return EndNode (queryContinuationClause); + } + + public object VisitQueryFromClause (QueryFromClause queryFromClause, object data) + { + StartNode (queryFromClause); + WriteKeyword ("from", QueryFromClause.FromKeywordRole); + queryFromClause.Type.AcceptVisitor (this, data); + Space (); + WriteIdentifier (queryFromClause.Identifier); + Space (); + WriteKeyword ("in", QueryFromClause.InKeywordRole); + Space (); + queryFromClause.Expression.AcceptVisitor (this, data); + return EndNode (queryFromClause); + } + + public object VisitQueryLetClause (QueryLetClause queryLetClause, object data) + { + StartNode (queryLetClause); + WriteKeyword ("let"); + Space (); + WriteIdentifier (queryLetClause.Identifier); + Space (policy.SpaceAroundAssignment); + WriteToken ("=", QueryLetClause.Roles.Assign); + Space (policy.SpaceAroundAssignment); + queryLetClause.Expression.AcceptVisitor (this, data); + return EndNode (queryLetClause); + } + + public object VisitQueryWhereClause (QueryWhereClause queryWhereClause, object data) + { + StartNode (queryWhereClause); + WriteKeyword ("where"); + Space (); + queryWhereClause.Condition.AcceptVisitor (this, data); + return EndNode (queryWhereClause); + } + + public object VisitQueryJoinClause (QueryJoinClause queryJoinClause, object data) + { + StartNode (queryJoinClause); + WriteKeyword ("join", QueryJoinClause.JoinKeywordRole); + queryJoinClause.Type.AcceptVisitor (this, data); + Space (); + WriteIdentifier (queryJoinClause.JoinIdentifier, QueryJoinClause.JoinIdentifierRole); + Space (); + WriteKeyword ("in", QueryJoinClause.InKeywordRole); + Space (); + queryJoinClause.InExpression.AcceptVisitor (this, data); + Space (); + WriteKeyword ("on", QueryJoinClause.OnKeywordRole); + Space (); + queryJoinClause.OnExpression.AcceptVisitor (this, data); + Space (); + WriteKeyword ("equals", QueryJoinClause.EqualsKeywordRole); + Space (); + queryJoinClause.EqualsExpression.AcceptVisitor (this, data); if (queryJoinClause.IsGroupJoin) { - Space(); - WriteKeyword("into", QueryJoinClause.IntoKeywordRole); - WriteIdentifier(queryJoinClause.IntoIdentifier, QueryJoinClause.IntoIdentifierRole); + Space (); + WriteKeyword ("into", QueryJoinClause.IntoKeywordRole); + WriteIdentifier (queryJoinClause.IntoIdentifier, QueryJoinClause.IntoIdentifierRole); } - return EndNode(queryJoinClause); + return EndNode (queryJoinClause); } - public object VisitQueryOrderClause(QueryOrderClause queryOrderClause, object data) + public object VisitQueryOrderClause (QueryOrderClause queryOrderClause, object data) { - StartNode(queryOrderClause); - WriteKeyword("orderby"); - Space(); - WriteCommaSeparatedList(queryOrderClause.Orderings.SafeCast()); - return EndNode(queryOrderClause); + StartNode (queryOrderClause); + WriteKeyword ("orderby"); + Space (); + WriteCommaSeparatedList (queryOrderClause.Orderings.SafeCast ()); + return EndNode (queryOrderClause); } - public object VisitQueryOrdering(QueryOrdering queryOrdering, object data) + public object VisitQueryOrdering (QueryOrdering queryOrdering, object data) { - StartNode(queryOrdering); - queryOrdering.Expression.AcceptVisitor(this, data); + StartNode (queryOrdering); + queryOrdering.Expression.AcceptVisitor (this, data); switch (queryOrdering.Direction) { - case QueryOrderingDirection.Ascending: - Space(); - WriteKeyword("ascending"); - break; - case QueryOrderingDirection.Descending: - Space(); - WriteKeyword("descending"); - break; + case QueryOrderingDirection.Ascending: + Space (); + WriteKeyword ("ascending"); + break; + case QueryOrderingDirection.Descending: + Space (); + WriteKeyword ("descending"); + break; } - return EndNode(queryOrdering); + return EndNode (queryOrdering); } - public object VisitQuerySelectClause(QuerySelectClause querySelectClause, object data) + public object VisitQuerySelectClause (QuerySelectClause querySelectClause, object data) { - StartNode(querySelectClause); - WriteKeyword("select"); - Space(); - querySelectClause.Expression.AcceptVisitor(this, data); - return EndNode(querySelectClause); + StartNode (querySelectClause); + WriteKeyword ("select"); + Space (); + querySelectClause.Expression.AcceptVisitor (this, data); + return EndNode (querySelectClause); } - public object VisitQueryGroupClause(QueryGroupClause queryGroupClause, object data) + public object VisitQueryGroupClause (QueryGroupClause queryGroupClause, object data) { - StartNode(queryGroupClause); - WriteKeyword("group", QueryGroupClause.GroupKeywordRole); - Space(); - queryGroupClause.Projection.AcceptVisitor(this, data); - Space(); - WriteKeyword("by", QueryGroupClause.ByKeywordRole); - Space(); - queryGroupClause.Key.AcceptVisitor(this, data); - return EndNode(queryGroupClause); + StartNode (queryGroupClause); + WriteKeyword ("group", QueryGroupClause.GroupKeywordRole); + Space (); + queryGroupClause.Projection.AcceptVisitor (this, data); + Space (); + WriteKeyword ("by", QueryGroupClause.ByKeywordRole); + Space (); + queryGroupClause.Key.AcceptVisitor (this, data); + return EndNode (queryGroupClause); } + #endregion #region GeneralScope - public object VisitAttribute(Attribute attribute, object data) + public object VisitAttribute (Attribute attribute, object data) { - StartNode(attribute); - attribute.Type.AcceptVisitor(this, data); - Space(policy.SpaceBeforeMethodCallParentheses); - if (attribute.Arguments.Count != 0 || !attribute.GetChildByRole(AstNode.Roles.LPar).IsNull) - WriteCommaSeparatedListInParenthesis(attribute.Arguments, policy.SpaceWithinMethodCallParentheses); - return EndNode(attribute); + StartNode (attribute); + attribute.Type.AcceptVisitor (this, data); + Space (policy.SpaceBeforeMethodCallParentheses); + if (attribute.Arguments.Count != 0 || !attribute.GetChildByRole (AstNode.Roles.LPar).IsNull) + WriteCommaSeparatedListInParenthesis (attribute.Arguments, policy.SpaceWithinMethodCallParentheses); + return EndNode (attribute); } - public object VisitAttributeSection(AttributeSection attributeSection, object data) + public object VisitAttributeSection (AttributeSection attributeSection, object data) { - StartNode(attributeSection); - WriteToken("[", AstNode.Roles.LBracket); + StartNode (attributeSection); + WriteToken ("[", AstNode.Roles.LBracket); if (!string.IsNullOrEmpty (attributeSection.AttributeTarget)) { - WriteToken(attributeSection.AttributeTarget, AttributeSection.TargetRole); - WriteToken(":", AttributeSection.Roles.Colon); - Space(); + WriteToken (attributeSection.AttributeTarget, AttributeSection.TargetRole); + WriteToken (":", AttributeSection.Roles.Colon); + Space (); } - WriteCommaSeparatedList(attributeSection.Attributes.SafeCast()); - WriteToken("]", AstNode.Roles.RBracket); + WriteCommaSeparatedList (attributeSection.Attributes.SafeCast ()); + WriteToken ("]", AstNode.Roles.RBracket); if (attributeSection.Parent is ParameterDeclaration || attributeSection.Parent is TypeParameterDeclaration) - Space(); + Space (); else - NewLine(); - return EndNode(attributeSection); + NewLine (); + return EndNode (attributeSection); } - public object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data) + public object VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, object data) { - StartNode(delegateDeclaration); - WriteAttributes(delegateDeclaration.Attributes); - WriteModifiers(delegateDeclaration.ModifierTokens); - WriteKeyword("delegate"); - delegateDeclaration.ReturnType.AcceptVisitor(this, data); - Space(); - WriteIdentifier(delegateDeclaration.Name); - WriteTypeParameters(delegateDeclaration.TypeParameters); - Space(policy.SpaceBeforeDelegateDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(delegateDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + StartNode (delegateDeclaration); + WriteAttributes (delegateDeclaration.Attributes); + WriteModifiers (delegateDeclaration.ModifierTokens); + WriteKeyword ("delegate"); + delegateDeclaration.ReturnType.AcceptVisitor (this, data); + Space (); + WriteIdentifier (delegateDeclaration.Name); + WriteTypeParameters (delegateDeclaration.TypeParameters); + Space (policy.SpaceBeforeDelegateDeclarationParentheses); + WriteCommaSeparatedListInParenthesis (delegateDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); foreach (Constraint constraint in delegateDeclaration.Constraints) { - constraint.AcceptVisitor(this, data); + constraint.AcceptVisitor (this, data); } - Semicolon(); - return EndNode(delegateDeclaration); + Semicolon (); + return EndNode (delegateDeclaration); } - public object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) + public object VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, object data) { - StartNode(namespaceDeclaration); - WriteKeyword("namespace"); - WriteQualifiedIdentifier(namespaceDeclaration.Identifiers); - OpenBrace(policy.NamespaceBraceStyle); + StartNode (namespaceDeclaration); + WriteKeyword ("namespace"); + WriteQualifiedIdentifier (namespaceDeclaration.Identifiers); + OpenBrace (policy.NamespaceBraceStyle); foreach (var member in namespaceDeclaration.Members) - member.AcceptVisitor(this, data); - CloseBrace(policy.NamespaceBraceStyle); - NewLine(); - return EndNode(namespaceDeclaration); + member.AcceptVisitor (this, data); + CloseBrace (policy.NamespaceBraceStyle); + NewLine (); + return EndNode (namespaceDeclaration); } - public object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) + public object VisitTypeDeclaration (TypeDeclaration typeDeclaration, object data) { - StartNode(typeDeclaration); - WriteAttributes(typeDeclaration.Attributes); - WriteModifiers(typeDeclaration.ModifierTokens); + StartNode (typeDeclaration); + WriteAttributes (typeDeclaration.Attributes); + WriteModifiers (typeDeclaration.ModifierTokens); BraceStyle braceStyle; switch (typeDeclaration.ClassType) { - case ClassType.Enum: - WriteKeyword("enum"); - braceStyle = policy.EnumBraceStyle; - break; - case ClassType.Interface: - WriteKeyword("interface"); - braceStyle = policy.InterfaceBraceStyle; - break; - case ClassType.Struct: - WriteKeyword("struct"); - braceStyle = policy.StructBraceStyle; - break; - default: - WriteKeyword("class"); - braceStyle = policy.ClassBraceStyle; - break; + case ClassType.Enum: + WriteKeyword ("enum"); + braceStyle = policy.EnumBraceStyle; + break; + case ClassType.Interface: + WriteKeyword ("interface"); + braceStyle = policy.InterfaceBraceStyle; + break; + case ClassType.Struct: + WriteKeyword ("struct"); + braceStyle = policy.StructBraceStyle; + break; + default: + WriteKeyword ("class"); + braceStyle = policy.ClassBraceStyle; + break; } - WriteIdentifier(typeDeclaration.Name); - WriteTypeParameters(typeDeclaration.TypeParameters); - if (typeDeclaration.BaseTypes.Any()) { - Space(); - WriteToken(":", TypeDeclaration.ColonRole); - Space(); - WriteCommaSeparatedList(typeDeclaration.BaseTypes); + WriteIdentifier (typeDeclaration.Name); + WriteTypeParameters (typeDeclaration.TypeParameters); + if (typeDeclaration.BaseTypes.Any ()) { + Space (); + WriteToken (":", TypeDeclaration.ColonRole); + Space (); + WriteCommaSeparatedList (typeDeclaration.BaseTypes); } foreach (Constraint constraint in typeDeclaration.Constraints) { - constraint.AcceptVisitor(this, data); + constraint.AcceptVisitor (this, data); } - OpenBrace(braceStyle); + OpenBrace (braceStyle); if (typeDeclaration.ClassType == ClassType.Enum) { bool first = true; foreach (var member in typeDeclaration.Members) { if (first) { first = false; } else { - Comma(member, noSpaceAfterComma: true); - NewLine(); + Comma (member, noSpaceAfterComma: true); + NewLine (); } - member.AcceptVisitor(this, data); + member.AcceptVisitor (this, data); } - NewLine(); + NewLine (); } else { foreach (var member in typeDeclaration.Members) { - member.AcceptVisitor(this, data); + member.AcceptVisitor (this, data); } } - CloseBrace(braceStyle); - NewLine(); - return EndNode(typeDeclaration); + CloseBrace (braceStyle); + NewLine (); + return EndNode (typeDeclaration); } - public object VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, object data) + public object VisitUsingAliasDeclaration (UsingAliasDeclaration usingAliasDeclaration, object data) { - StartNode(usingAliasDeclaration); - WriteKeyword("using"); - WriteIdentifier(usingAliasDeclaration.Alias, UsingAliasDeclaration.AliasRole); - Space(policy.SpaceAroundEqualityOperator); - WriteToken("=", AstNode.Roles.Assign); - Space(policy.SpaceAroundEqualityOperator); - usingAliasDeclaration.Import.AcceptVisitor(this, data); - Semicolon(); - return EndNode(usingAliasDeclaration); + StartNode (usingAliasDeclaration); + WriteKeyword ("using"); + WriteIdentifier (usingAliasDeclaration.Alias, UsingAliasDeclaration.AliasRole); + Space (policy.SpaceAroundEqualityOperator); + WriteToken ("=", AstNode.Roles.Assign); + Space (policy.SpaceAroundEqualityOperator); + usingAliasDeclaration.Import.AcceptVisitor (this, data); + Semicolon (); + return EndNode (usingAliasDeclaration); } - public object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) + public object VisitUsingDeclaration (UsingDeclaration usingDeclaration, object data) { - StartNode(usingDeclaration); - WriteKeyword("using"); - usingDeclaration.Import.AcceptVisitor(this, data); - Semicolon(); - return EndNode(usingDeclaration); + StartNode (usingDeclaration); + WriteKeyword ("using"); + usingDeclaration.Import.AcceptVisitor (this, data); + Semicolon (); + return EndNode (usingDeclaration); } - public object VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, object data) + public object VisitExternAliasDeclaration (ExternAliasDeclaration externAliasDeclaration, object data) { - StartNode(externAliasDeclaration); - WriteKeyword("extern"); + StartNode (externAliasDeclaration); + WriteKeyword ("extern"); Space (); - WriteKeyword("alias"); + WriteKeyword ("alias"); Space (); - externAliasDeclaration.NameToken.AcceptVisitor(this, data); - Semicolon(); - return EndNode(externAliasDeclaration); + externAliasDeclaration.NameToken.AcceptVisitor (this, data); + Semicolon (); + return EndNode (externAliasDeclaration); } - #endregion #region Statements - public object VisitBlockStatement(BlockStatement blockStatement, object data) + public object VisitBlockStatement (BlockStatement blockStatement, object data) { - StartNode(blockStatement); + StartNode (blockStatement); BraceStyle style; if (blockStatement.Parent is AnonymousMethodExpression || blockStatement.Parent is LambdaExpression) { style = policy.AnonymousMethodBraceStyle; @@ -1369,501 +1442,529 @@ namespace ICSharpCode.NRefactory.CSharp else if (blockStatement.Parent.Role == CustomEventDeclaration.RemoveAccessorRole) style = policy.EventRemoveBraceStyle; else - throw new NotSupportedException("Unknown type of accessor"); + throw new NotSupportedException ("Unknown type of accessor"); } else { style = policy.StatementBraceStyle; } - OpenBrace(style); + OpenBrace (style); foreach (var node in blockStatement.Statements) { - node.AcceptVisitor(this, data); + node.AcceptVisitor (this, data); } - CloseBrace(style); - NewLine(); - return EndNode(blockStatement); + CloseBrace (style); + NewLine (); + return EndNode (blockStatement); } - public object VisitBreakStatement(BreakStatement breakStatement, object data) + public object VisitBreakStatement (BreakStatement breakStatement, object data) { - StartNode(breakStatement); - WriteKeyword("break"); - Semicolon(); - return EndNode(breakStatement); + StartNode (breakStatement); + WriteKeyword ("break"); + Semicolon (); + return EndNode (breakStatement); } - public object VisitCheckedStatement(CheckedStatement checkedStatement, object data) + public object VisitCheckedStatement (CheckedStatement checkedStatement, object data) { - StartNode(checkedStatement); - WriteKeyword("checked"); - checkedStatement.Body.AcceptVisitor(this, data); - return EndNode(checkedStatement); + StartNode (checkedStatement); + WriteKeyword ("checked"); + checkedStatement.Body.AcceptVisitor (this, data); + return EndNode (checkedStatement); } - public object VisitContinueStatement(ContinueStatement continueStatement, object data) + public object VisitContinueStatement (ContinueStatement continueStatement, object data) { - StartNode(continueStatement); - WriteKeyword("continue"); - Semicolon(); - return EndNode(continueStatement); + StartNode (continueStatement); + WriteKeyword ("continue"); + Semicolon (); + return EndNode (continueStatement); } - public object VisitDoWhileStatement(DoWhileStatement doWhileStatement, object data) + public object VisitDoWhileStatement (DoWhileStatement doWhileStatement, object data) { - StartNode(doWhileStatement); - WriteKeyword("do", DoWhileStatement.DoKeywordRole); - WriteEmbeddedStatement(doWhileStatement.EmbeddedStatement); - WriteKeyword("while", DoWhileStatement.WhileKeywordRole); - Space(policy.SpaceBeforeWhileParentheses); - LPar(); - Space(policy.SpacesWithinWhileParentheses); - doWhileStatement.Condition.AcceptVisitor(this, data); - Space(policy.SpacesWithinWhileParentheses); - RPar(); - Semicolon(); - return EndNode(doWhileStatement); + StartNode (doWhileStatement); + WriteKeyword ("do", DoWhileStatement.DoKeywordRole); + WriteEmbeddedStatement (doWhileStatement.EmbeddedStatement); + WriteKeyword ("while", DoWhileStatement.WhileKeywordRole); + Space (policy.SpaceBeforeWhileParentheses); + LPar (); + Space (policy.SpacesWithinWhileParentheses); + doWhileStatement.Condition.AcceptVisitor (this, data); + Space (policy.SpacesWithinWhileParentheses); + RPar (); + Semicolon (); + return EndNode (doWhileStatement); } - public object VisitEmptyStatement(EmptyStatement emptyStatement, object data) + public object VisitEmptyStatement (EmptyStatement emptyStatement, object data) { - StartNode(emptyStatement); - Semicolon(); - return EndNode(emptyStatement); + StartNode (emptyStatement); + Semicolon (); + return EndNode (emptyStatement); } - public object VisitExpressionStatement(ExpressionStatement expressionStatement, object data) + public object VisitExpressionStatement (ExpressionStatement expressionStatement, object data) { - StartNode(expressionStatement); - expressionStatement.Expression.AcceptVisitor(this, data); - Semicolon(); - return EndNode(expressionStatement); + StartNode (expressionStatement); + expressionStatement.Expression.AcceptVisitor (this, data); + Semicolon (); + return EndNode (expressionStatement); } - public object VisitFixedStatement(FixedStatement fixedStatement, object data) + public object VisitFixedStatement (FixedStatement fixedStatement, object data) { - StartNode(fixedStatement); - WriteKeyword("fixed"); - Space(policy.SpaceBeforeUsingParentheses); - LPar(); - Space(policy.SpacesWithinUsingParentheses); - fixedStatement.Type.AcceptVisitor(this, data); - Space(); - WriteCommaSeparatedList(fixedStatement.Variables); - Space(policy.SpacesWithinUsingParentheses); - RPar(); - WriteEmbeddedStatement(fixedStatement.EmbeddedStatement); - return EndNode(fixedStatement); + StartNode (fixedStatement); + WriteKeyword ("fixed"); + Space (policy.SpaceBeforeUsingParentheses); + LPar (); + Space (policy.SpacesWithinUsingParentheses); + fixedStatement.Type.AcceptVisitor (this, data); + Space (); + WriteCommaSeparatedList (fixedStatement.Variables); + Space (policy.SpacesWithinUsingParentheses); + RPar (); + WriteEmbeddedStatement (fixedStatement.EmbeddedStatement); + return EndNode (fixedStatement); } - public object VisitForeachStatement(ForeachStatement foreachStatement, object data) + public object VisitForeachStatement (ForeachStatement foreachStatement, object data) { - StartNode(foreachStatement); - WriteKeyword("foreach"); - Space(policy.SpaceBeforeForeachParentheses); - LPar(); - 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.SpacesWithinForeachParentheses); - RPar(); - WriteEmbeddedStatement(foreachStatement.EmbeddedStatement); - return EndNode(foreachStatement); + StartNode (foreachStatement); + WriteKeyword ("foreach"); + Space (policy.SpaceBeforeForeachParentheses); + LPar (); + 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.SpacesWithinForeachParentheses); + RPar (); + WriteEmbeddedStatement (foreachStatement.EmbeddedStatement); + return EndNode (foreachStatement); } - public object VisitForStatement(ForStatement forStatement, object data) + public object VisitForStatement (ForStatement forStatement, object data) { - StartNode(forStatement); - WriteKeyword("for"); - Space(policy.SpaceBeforeForParentheses); - LPar(); - Space(policy.SpacesWithinForParentheses); + StartNode (forStatement); + WriteKeyword ("for"); + Space (policy.SpaceBeforeForParentheses); + LPar (); + Space (policy.SpacesWithinForParentheses); - WriteCommaSeparatedList(forStatement.Initializers.SafeCast()); + WriteCommaSeparatedList (forStatement.Initializers.SafeCast ()); Space (policy.SpaceBeforeForSemicolon); - WriteToken(";", AstNode.Roles.Semicolon); + WriteToken (";", AstNode.Roles.Semicolon); Space (policy.SpaceAfterForSemicolon); - forStatement.Condition.AcceptVisitor(this, data); + forStatement.Condition.AcceptVisitor (this, data); Space (policy.SpaceBeforeForSemicolon); - WriteToken(";", AstNode.Roles.Semicolon); - Space(policy.SpaceAfterForSemicolon); + WriteToken (";", AstNode.Roles.Semicolon); + Space (policy.SpaceAfterForSemicolon); - WriteCommaSeparatedList(forStatement.Iterators.SafeCast()); + WriteCommaSeparatedList (forStatement.Iterators.SafeCast ()); - Space(policy.SpacesWithinForParentheses); - RPar(); - WriteEmbeddedStatement(forStatement.EmbeddedStatement); - return EndNode(forStatement); + Space (policy.SpacesWithinForParentheses); + RPar (); + WriteEmbeddedStatement (forStatement.EmbeddedStatement); + return EndNode (forStatement); } - public object VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, object data) + public object VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement, object data) { - StartNode(gotoCaseStatement); - WriteKeyword("goto"); - WriteKeyword("case", GotoCaseStatement.CaseKeywordRole); - Space(); - gotoCaseStatement.LabelExpression.AcceptVisitor(this, data); - Semicolon(); - return EndNode(gotoCaseStatement); + StartNode (gotoCaseStatement); + WriteKeyword ("goto"); + WriteKeyword ("case", GotoCaseStatement.CaseKeywordRole); + Space (); + gotoCaseStatement.LabelExpression.AcceptVisitor (this, data); + Semicolon (); + return EndNode (gotoCaseStatement); } - public object VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, object data) + public object VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement, object data) { - StartNode(gotoDefaultStatement); - WriteKeyword("goto"); - WriteKeyword("default", GotoDefaultStatement.DefaultKeywordRole); - Semicolon(); - return EndNode(gotoDefaultStatement); + StartNode (gotoDefaultStatement); + WriteKeyword ("goto"); + WriteKeyword ("default", GotoDefaultStatement.DefaultKeywordRole); + Semicolon (); + return EndNode (gotoDefaultStatement); } - public object VisitGotoStatement(GotoStatement gotoStatement, object data) + public object VisitGotoStatement (GotoStatement gotoStatement, object data) { - StartNode(gotoStatement); - WriteKeyword("goto"); - WriteIdentifier(gotoStatement.Label); - Semicolon(); - return EndNode(gotoStatement); + StartNode (gotoStatement); + WriteKeyword ("goto"); + WriteIdentifier (gotoStatement.Label); + Semicolon (); + return EndNode (gotoStatement); } - public object VisitIfElseStatement(IfElseStatement ifElseStatement, object data) + public object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) { - StartNode(ifElseStatement); - WriteKeyword("if", IfElseStatement.IfKeywordRole); - Space(policy.SpaceBeforeIfParentheses); - LPar(); - Space(policy.SpacesWithinIfParentheses); - ifElseStatement.Condition.AcceptVisitor(this, data); - Space(policy.SpacesWithinIfParentheses); - RPar(); - WriteEmbeddedStatement(ifElseStatement.TrueStatement); + StartNode (ifElseStatement); + WriteKeyword ("if", IfElseStatement.IfKeywordRole); + Space (policy.SpaceBeforeIfParentheses); + LPar (); + Space (policy.SpacesWithinIfParentheses); + ifElseStatement.Condition.AcceptVisitor (this, data); + Space (policy.SpacesWithinIfParentheses); + RPar (); + WriteEmbeddedStatement (ifElseStatement.TrueStatement); if (!ifElseStatement.FalseStatement.IsNull) { - WriteKeyword("else", IfElseStatement.ElseKeywordRole); - WriteEmbeddedStatement(ifElseStatement.FalseStatement); + WriteKeyword ("else", IfElseStatement.ElseKeywordRole); + WriteEmbeddedStatement (ifElseStatement.FalseStatement); } - return EndNode(ifElseStatement); + return EndNode (ifElseStatement); } - public object VisitLabelStatement(LabelStatement labelStatement, object data) + public object VisitLabelStatement (LabelStatement labelStatement, object data) { - StartNode(labelStatement); - WriteIdentifier(labelStatement.Label); - WriteToken(":", LabelStatement.Roles.Colon); - NewLine(); - return EndNode(labelStatement); + StartNode (labelStatement); + WriteIdentifier (labelStatement.Label); + WriteToken (":", LabelStatement.Roles.Colon); + bool foundLabelledStatement = false; + for (AstNode tmp = labelStatement.NextSibling; tmp != null; tmp = tmp.NextSibling) { + if (tmp.Role == labelStatement.Role) { + foundLabelledStatement = true; + } + } + if (!foundLabelledStatement) { + // introduce an EmptyStatement so that the output becomes syntactically valid + WriteToken(";", LabelStatement.Roles.Semicolon); + } + NewLine (); + return EndNode (labelStatement); } - public object VisitLockStatement(LockStatement lockStatement, object data) + public object VisitLockStatement (LockStatement lockStatement, object data) { - StartNode(lockStatement); - WriteKeyword("lock"); - Space(policy.SpaceBeforeLockParentheses); - LPar(); - Space(policy.SpacesWithinLockParentheses); - lockStatement.Expression.AcceptVisitor(this, data); - Space(policy.SpacesWithinLockParentheses); - RPar(); - WriteEmbeddedStatement(lockStatement.EmbeddedStatement); - return EndNode(lockStatement); + StartNode (lockStatement); + WriteKeyword ("lock"); + Space (policy.SpaceBeforeLockParentheses); + LPar (); + Space (policy.SpacesWithinLockParentheses); + lockStatement.Expression.AcceptVisitor (this, data); + Space (policy.SpacesWithinLockParentheses); + RPar (); + WriteEmbeddedStatement (lockStatement.EmbeddedStatement); + return EndNode (lockStatement); } - public object VisitReturnStatement(ReturnStatement returnStatement, object data) + public object VisitReturnStatement (ReturnStatement returnStatement, object data) { - StartNode(returnStatement); - WriteKeyword("return"); + StartNode (returnStatement); + WriteKeyword ("return"); if (!returnStatement.Expression.IsNull) { - Space(); - returnStatement.Expression.AcceptVisitor(this, data); + Space (); + returnStatement.Expression.AcceptVisitor (this, data); } - Semicolon(); - return EndNode(returnStatement); - } - - public object VisitSwitchStatement(SwitchStatement switchStatement, object data) - { - StartNode(switchStatement); - WriteKeyword("switch"); - Space(policy.SpaceBeforeSwitchParentheses); - LPar(); - Space(policy.SpacesWithinSwitchParentheses); - switchStatement.Expression.AcceptVisitor(this, data); - Space(policy.SpacesWithinSwitchParentheses); - RPar(); - OpenBrace(policy.StatementBraceStyle); + Semicolon (); + return EndNode (returnStatement); + } + + public object VisitSwitchStatement (SwitchStatement switchStatement, object data) + { + StartNode (switchStatement); + WriteKeyword ("switch"); + Space (policy.SpaceBeforeSwitchParentheses); + LPar (); + Space (policy.SpacesWithinSwitchParentheses); + switchStatement.Expression.AcceptVisitor (this, data); + Space (policy.SpacesWithinSwitchParentheses); + RPar (); + OpenBrace (policy.StatementBraceStyle); + if (!policy.IndentSwitchBody) + formatter.Unindent (); + foreach (var section in switchStatement.SwitchSections) - section.AcceptVisitor(this, data); - CloseBrace(policy.StatementBraceStyle); - NewLine(); - return EndNode(switchStatement); + section.AcceptVisitor (this, data); + + if (!policy.IndentSwitchBody) + formatter.Indent (); + CloseBrace (policy.StatementBraceStyle); + NewLine (); + return EndNode (switchStatement); } - public object VisitSwitchSection(SwitchSection switchSection, object data) + public object VisitSwitchSection (SwitchSection switchSection, object data) { - StartNode(switchSection); + StartNode (switchSection); bool first = true; foreach (var label in switchSection.CaseLabels) { if (!first) - NewLine(); - label.AcceptVisitor(this, data); + NewLine (); + label.AcceptVisitor (this, data); first = false; } - foreach (var statement in switchSection.Statements) - statement.AcceptVisitor(this, data); - return EndNode(switchSection); + if (policy.IndentCaseBody) + formatter.Indent (); + + foreach (var statement in switchSection.Statements) { + NewLine (); + statement.AcceptVisitor (this, data); + } + + if (policy.IndentCaseBody) + formatter.Unindent (); + + return EndNode (switchSection); } - public object VisitCaseLabel(CaseLabel caseLabel, object data) + public object VisitCaseLabel (CaseLabel caseLabel, object data) { - StartNode(caseLabel); + StartNode (caseLabel); if (caseLabel.Expression.IsNull) { - WriteKeyword("default"); + WriteKeyword ("default"); } else { - WriteKeyword("case"); - Space(); - caseLabel.Expression.AcceptVisitor(this, data); + WriteKeyword ("case"); + Space (); + caseLabel.Expression.AcceptVisitor (this, data); } - WriteToken(":", CaseLabel.Roles.Colon); - return EndNode(caseLabel); + WriteToken (":", CaseLabel.Roles.Colon); + return EndNode (caseLabel); } - public object VisitThrowStatement(ThrowStatement throwStatement, object data) + public object VisitThrowStatement (ThrowStatement throwStatement, object data) { - StartNode(throwStatement); - WriteKeyword("throw"); + StartNode (throwStatement); + WriteKeyword ("throw"); if (!throwStatement.Expression.IsNull) { - Space(); - throwStatement.Expression.AcceptVisitor(this, data); + Space (); + throwStatement.Expression.AcceptVisitor (this, data); } - Semicolon(); - return EndNode(throwStatement); + Semicolon (); + return EndNode (throwStatement); } - public object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) + public object VisitTryCatchStatement (TryCatchStatement tryCatchStatement, object data) { - StartNode(tryCatchStatement); - WriteKeyword("try", TryCatchStatement.TryKeywordRole); - tryCatchStatement.TryBlock.AcceptVisitor(this, data); + StartNode (tryCatchStatement); + WriteKeyword ("try", TryCatchStatement.TryKeywordRole); + tryCatchStatement.TryBlock.AcceptVisitor (this, data); foreach (var catchClause in tryCatchStatement.CatchClauses) - catchClause.AcceptVisitor(this, data); + catchClause.AcceptVisitor (this, data); if (!tryCatchStatement.FinallyBlock.IsNull) { - WriteKeyword("finally", TryCatchStatement.FinallyKeywordRole); - tryCatchStatement.FinallyBlock.AcceptVisitor(this, data); + WriteKeyword ("finally", TryCatchStatement.FinallyKeywordRole); + tryCatchStatement.FinallyBlock.AcceptVisitor (this, data); } - return EndNode(tryCatchStatement); + return EndNode (tryCatchStatement); } - public object VisitCatchClause(CatchClause catchClause, object data) + public object VisitCatchClause (CatchClause catchClause, object data) { - StartNode(catchClause); - WriteKeyword("catch"); + StartNode (catchClause); + WriteKeyword ("catch"); if (!catchClause.Type.IsNull) { - Space(policy.SpaceBeforeCatchParentheses); - LPar(); - Space(policy.SpacesWithinCatchParentheses); - catchClause.Type.AcceptVisitor(this, data); - Space(); - WriteIdentifier(catchClause.VariableName); - Space(policy.SpacesWithinCatchParentheses); - RPar(); + Space (policy.SpaceBeforeCatchParentheses); + LPar (); + Space (policy.SpacesWithinCatchParentheses); + catchClause.Type.AcceptVisitor (this, data); + if (!string.IsNullOrEmpty(catchClause.VariableName)) { + Space (); + WriteIdentifier (catchClause.VariableName); + } + Space (policy.SpacesWithinCatchParentheses); + RPar (); } - catchClause.Body.AcceptVisitor(this, data); - return EndNode(catchClause); + catchClause.Body.AcceptVisitor (this, data); + return EndNode (catchClause); } - public object VisitUncheckedStatement(UncheckedStatement uncheckedStatement, object data) + public object VisitUncheckedStatement (UncheckedStatement uncheckedStatement, object data) { - StartNode(uncheckedStatement); - WriteKeyword("unchecked"); - uncheckedStatement.Body.AcceptVisitor(this, data); - return EndNode(uncheckedStatement); + StartNode (uncheckedStatement); + WriteKeyword ("unchecked"); + uncheckedStatement.Body.AcceptVisitor (this, data); + return EndNode (uncheckedStatement); } - public object VisitUnsafeStatement(UnsafeStatement unsafeStatement, object data) + public object VisitUnsafeStatement (UnsafeStatement unsafeStatement, object data) { - StartNode(unsafeStatement); - WriteKeyword("unsafe"); - unsafeStatement.Body.AcceptVisitor(this, data); - return EndNode(unsafeStatement); + StartNode (unsafeStatement); + WriteKeyword ("unsafe"); + unsafeStatement.Body.AcceptVisitor (this, data); + return EndNode (unsafeStatement); } - public object VisitUsingStatement(UsingStatement usingStatement, object data) + public object VisitUsingStatement (UsingStatement usingStatement, object data) { - StartNode(usingStatement); - WriteKeyword("using"); - Space(policy.SpaceBeforeUsingParentheses); - LPar(); - Space(policy.SpacesWithinUsingParentheses); + StartNode (usingStatement); + WriteKeyword ("using"); + Space (policy.SpaceBeforeUsingParentheses); + LPar (); + Space (policy.SpacesWithinUsingParentheses); - usingStatement.ResourceAcquisition.AcceptVisitor(this, data); + usingStatement.ResourceAcquisition.AcceptVisitor (this, data); - Space(policy.SpacesWithinUsingParentheses); - RPar(); + Space (policy.SpacesWithinUsingParentheses); + RPar (); - WriteEmbeddedStatement(usingStatement.EmbeddedStatement); + WriteEmbeddedStatement (usingStatement.EmbeddedStatement); - return EndNode(usingStatement); + return EndNode (usingStatement); } - public object VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, object data) + public object VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, object data) { - StartNode(variableDeclarationStatement); - variableDeclarationStatement.Type.AcceptVisitor(this, data); - Space(); - WriteCommaSeparatedList(variableDeclarationStatement.Variables); - Semicolon(); - return EndNode(variableDeclarationStatement); + StartNode (variableDeclarationStatement); + variableDeclarationStatement.Type.AcceptVisitor (this, data); + Space (); + WriteCommaSeparatedList (variableDeclarationStatement.Variables); + Semicolon (); + return EndNode (variableDeclarationStatement); } - public object VisitWhileStatement(WhileStatement whileStatement, object data) + public object VisitWhileStatement (WhileStatement whileStatement, object data) { - StartNode(whileStatement); - WriteKeyword("while", WhileStatement.WhileKeywordRole); - Space(policy.SpaceBeforeWhileParentheses); - LPar(); - Space(policy.SpacesWithinWhileParentheses); - whileStatement.Condition.AcceptVisitor(this, data); - Space(policy.SpacesWithinWhileParentheses); - RPar(); - WriteEmbeddedStatement(whileStatement.EmbeddedStatement); - return EndNode(whileStatement); + StartNode (whileStatement); + WriteKeyword ("while", WhileStatement.WhileKeywordRole); + Space (policy.SpaceBeforeWhileParentheses); + LPar (); + Space (policy.SpacesWithinWhileParentheses); + whileStatement.Condition.AcceptVisitor (this, data); + Space (policy.SpacesWithinWhileParentheses); + RPar (); + WriteEmbeddedStatement (whileStatement.EmbeddedStatement); + return EndNode (whileStatement); } - public object VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, object data) + public object VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, object data) { - StartNode(yieldBreakStatement); - WriteKeyword("yield", YieldBreakStatement.YieldKeywordRole); - WriteKeyword("break", YieldBreakStatement.BreakKeywordRole); - Semicolon(); - return EndNode(yieldBreakStatement); + StartNode (yieldBreakStatement); + WriteKeyword ("yield", YieldBreakStatement.YieldKeywordRole); + WriteKeyword ("break", YieldBreakStatement.BreakKeywordRole); + Semicolon (); + return EndNode (yieldBreakStatement); } - public object VisitYieldStatement(YieldStatement yieldStatement, object data) + public object VisitYieldStatement (YieldStatement yieldStatement, object data) { - StartNode(yieldStatement); - WriteKeyword("yield", YieldStatement.YieldKeywordRole); - WriteKeyword("return", YieldStatement.ReturnKeywordRole); - Space(); - yieldStatement.Expression.AcceptVisitor(this, data); - Semicolon(); - return EndNode(yieldStatement); + StartNode (yieldStatement); + WriteKeyword ("yield", YieldStatement.YieldKeywordRole); + WriteKeyword ("return", YieldStatement.ReturnKeywordRole); + Space (); + yieldStatement.Expression.AcceptVisitor (this, data); + Semicolon (); + return EndNode (yieldStatement); } + #endregion #region TypeMembers - public object VisitAccessor(Accessor accessor, object data) + public object VisitAccessor (Accessor accessor, object data) { - StartNode(accessor); - WriteAttributes(accessor.Attributes); - WriteModifiers(accessor.ModifierTokens); + StartNode (accessor); + WriteAttributes (accessor.Attributes); + WriteModifiers (accessor.ModifierTokens); if (accessor.Role == PropertyDeclaration.GetterRole) { - WriteKeyword("get"); + WriteKeyword ("get"); } else if (accessor.Role == PropertyDeclaration.SetterRole) { - WriteKeyword("set"); + WriteKeyword ("set"); } else if (accessor.Role == CustomEventDeclaration.AddAccessorRole) { - WriteKeyword("add"); + WriteKeyword ("add"); } else if (accessor.Role == CustomEventDeclaration.RemoveAccessorRole) { - WriteKeyword("remove"); + WriteKeyword ("remove"); } - WriteMethodBody(accessor.Body); - return EndNode(accessor); + WriteMethodBody (accessor.Body); + return EndNode (accessor); } - public object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) + public object VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, object data) { - StartNode(constructorDeclaration); - WriteAttributes(constructorDeclaration.Attributes); - WriteModifiers(constructorDeclaration.ModifierTokens); + StartNode (constructorDeclaration); + WriteAttributes (constructorDeclaration.Attributes); + WriteModifiers (constructorDeclaration.ModifierTokens); TypeDeclaration type = constructorDeclaration.Parent as TypeDeclaration; - WriteIdentifier(type != null ? type.Name : constructorDeclaration.Name); - Space(policy.SpaceBeforeConstructorDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + WriteIdentifier (type != null ? type.Name : constructorDeclaration.Name); + Space (policy.SpaceBeforeConstructorDeclarationParentheses); + WriteCommaSeparatedListInParenthesis (constructorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); if (!constructorDeclaration.Initializer.IsNull) { - Space(); - constructorDeclaration.Initializer.AcceptVisitor(this, data); + Space (); + constructorDeclaration.Initializer.AcceptVisitor (this, data); } - WriteMethodBody(constructorDeclaration.Body); - return EndNode(constructorDeclaration); + WriteMethodBody (constructorDeclaration.Body); + return EndNode (constructorDeclaration); } - public object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) + public object VisitConstructorInitializer (ConstructorInitializer constructorInitializer, object data) { - StartNode(constructorInitializer); - WriteToken(":", ConstructorInitializer.Roles.Colon); - Space(); + StartNode (constructorInitializer); + WriteToken (":", ConstructorInitializer.Roles.Colon); + Space (); if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) { - WriteKeyword("this"); + WriteKeyword ("this"); } else { - WriteKeyword("base"); + WriteKeyword ("base"); } - Space(policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis(constructorInitializer.Arguments, policy.SpaceWithinMethodCallParentheses); - return EndNode(constructorInitializer); + Space (policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis (constructorInitializer.Arguments, policy.SpaceWithinMethodCallParentheses); + return EndNode (constructorInitializer); } - public object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) + public object VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, object data) { - StartNode(destructorDeclaration); - WriteAttributes(destructorDeclaration.Attributes); - WriteModifiers(destructorDeclaration.ModifierTokens); - WriteToken("~", DestructorDeclaration.TildeRole); + StartNode (destructorDeclaration); + WriteAttributes (destructorDeclaration.Attributes); + WriteModifiers (destructorDeclaration.ModifierTokens); + WriteToken ("~", DestructorDeclaration.TildeRole); TypeDeclaration type = destructorDeclaration.Parent as TypeDeclaration; - WriteIdentifier(type != null ? type.Name : destructorDeclaration.Name); - Space(policy.SpaceBeforeConstructorDeclarationParentheses); - LPar(); - RPar(); - WriteMethodBody(destructorDeclaration.Body); - return EndNode(destructorDeclaration); + WriteIdentifier (type != null ? type.Name : destructorDeclaration.Name); + Space (policy.SpaceBeforeConstructorDeclarationParentheses); + LPar (); + RPar (); + WriteMethodBody (destructorDeclaration.Body); + return EndNode (destructorDeclaration); } - public object VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data) + public object VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, object data) { - StartNode(enumMemberDeclaration); - WriteAttributes(enumMemberDeclaration.Attributes); - WriteModifiers(enumMemberDeclaration.ModifierTokens); - WriteIdentifier(enumMemberDeclaration.Name); + StartNode (enumMemberDeclaration); + WriteAttributes (enumMemberDeclaration.Attributes); + WriteModifiers (enumMemberDeclaration.ModifierTokens); + WriteIdentifier (enumMemberDeclaration.Name); if (!enumMemberDeclaration.Initializer.IsNull) { - Space(policy.SpaceAroundAssignment); - WriteToken("=", EnumMemberDeclaration.Roles.Assign); - Space(policy.SpaceAroundAssignment); - enumMemberDeclaration.Initializer.AcceptVisitor(this, data); - } - return EndNode(enumMemberDeclaration); - } - - public object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) - { - StartNode(eventDeclaration); - WriteAttributes(eventDeclaration.Attributes); - WriteModifiers(eventDeclaration.ModifierTokens); - WriteKeyword("event"); - eventDeclaration.ReturnType.AcceptVisitor(this, data); - Space(); - WriteCommaSeparatedList(eventDeclaration.Variables); - Semicolon(); - return EndNode(eventDeclaration); - } - - public object VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration, object data) - { - StartNode(customEventDeclaration); - WriteAttributes(customEventDeclaration.Attributes); - WriteModifiers(customEventDeclaration.ModifierTokens); - WriteKeyword("event"); - customEventDeclaration.ReturnType.AcceptVisitor(this, data); - Space(); - WritePrivateImplementationType(customEventDeclaration.PrivateImplementationType); - WriteIdentifier(customEventDeclaration.Name); - OpenBrace(policy.EventBraceStyle); + Space (policy.SpaceAroundAssignment); + WriteToken ("=", EnumMemberDeclaration.Roles.Assign); + Space (policy.SpaceAroundAssignment); + enumMemberDeclaration.Initializer.AcceptVisitor (this, data); + } + return EndNode (enumMemberDeclaration); + } + + public object VisitEventDeclaration (EventDeclaration eventDeclaration, object data) + { + StartNode (eventDeclaration); + WriteAttributes (eventDeclaration.Attributes); + WriteModifiers (eventDeclaration.ModifierTokens); + WriteKeyword ("event"); + eventDeclaration.ReturnType.AcceptVisitor (this, data); + Space (); + WriteCommaSeparatedList (eventDeclaration.Variables); + Semicolon (); + return EndNode (eventDeclaration); + } + + public object VisitCustomEventDeclaration (CustomEventDeclaration customEventDeclaration, object data) + { + StartNode (customEventDeclaration); + WriteAttributes (customEventDeclaration.Attributes); + WriteModifiers (customEventDeclaration.ModifierTokens); + WriteKeyword ("event"); + customEventDeclaration.ReturnType.AcceptVisitor (this, data); + Space (); + WritePrivateImplementationType (customEventDeclaration.PrivateImplementationType); + WriteIdentifier (customEventDeclaration.Name); + OpenBrace (policy.EventBraceStyle); // output add/remove in their original order foreach (AstNode node in customEventDeclaration.Children) { if (node.Role == CustomEventDeclaration.AddAccessorRole || node.Role == CustomEventDeclaration.RemoveAccessorRole) { - node.AcceptVisitor(this, data); + node.AcceptVisitor (this, data); } } - CloseBrace(policy.EventBraceStyle); - NewLine(); - return EndNode(customEventDeclaration); + CloseBrace (policy.EventBraceStyle); + NewLine (); + return EndNode (customEventDeclaration); } public object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) @@ -1880,399 +1981,402 @@ namespace ICSharpCode.NRefactory.CSharp public object VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, object data) { - StartNode(fixedFieldDeclaration); - WriteAttributes(fixedFieldDeclaration.Attributes); - WriteModifiers(fixedFieldDeclaration.ModifierTokens); - WriteKeyword("fixed"); - Space(); + StartNode (fixedFieldDeclaration); + WriteAttributes (fixedFieldDeclaration.Attributes); + WriteModifiers (fixedFieldDeclaration.ModifierTokens); + WriteKeyword ("fixed"); + Space (); fixedFieldDeclaration.ReturnType.AcceptVisitor (this, data); - Space(); - WriteCommaSeparatedList(fixedFieldDeclaration.Variables); - Semicolon(); - return EndNode(fixedFieldDeclaration); + Space (); + WriteCommaSeparatedList (fixedFieldDeclaration.Variables); + Semicolon (); + return EndNode (fixedFieldDeclaration); } public object VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, object data) { - StartNode(fixedVariableInitializer); - WriteIdentifier(fixedVariableInitializer.Name); + StartNode (fixedVariableInitializer); + WriteIdentifier (fixedVariableInitializer.Name); if (!fixedVariableInitializer.CountExpression.IsNull) { - WriteToken("[", AstNode.Roles.LBracket); - Space(policy.SpacesWithinBrackets); - fixedVariableInitializer.CountExpression.AcceptVisitor(this, data); - Space(policy.SpacesWithinBrackets); - WriteToken("]", AstNode.Roles.RBracket); + WriteToken ("[", AstNode.Roles.LBracket); + Space (policy.SpacesWithinBrackets); + fixedVariableInitializer.CountExpression.AcceptVisitor (this, data); + Space (policy.SpacesWithinBrackets); + WriteToken ("]", AstNode.Roles.RBracket); } - return EndNode(fixedVariableInitializer); + return EndNode (fixedVariableInitializer); } - public object VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, object data) + public object VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, object data) { - StartNode(indexerDeclaration); - WriteAttributes(indexerDeclaration.Attributes); - WriteModifiers(indexerDeclaration.ModifierTokens); - indexerDeclaration.ReturnType.AcceptVisitor(this, data); - WritePrivateImplementationType(indexerDeclaration.PrivateImplementationType); + StartNode (indexerDeclaration); + WriteAttributes (indexerDeclaration.Attributes); + WriteModifiers (indexerDeclaration.ModifierTokens); + indexerDeclaration.ReturnType.AcceptVisitor (this, data); + WritePrivateImplementationType (indexerDeclaration.PrivateImplementationType); WriteKeyword ("this"); - Space(policy.SpaceBeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInBrackets(indexerDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); - OpenBrace(policy.PropertyBraceStyle); + Space (policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInBrackets (indexerDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + OpenBrace (policy.PropertyBraceStyle); // output get/set in their original order foreach (AstNode node in indexerDeclaration.Children) { if (node.Role == IndexerDeclaration.GetterRole || node.Role == IndexerDeclaration.SetterRole) { - node.AcceptVisitor(this, data); + node.AcceptVisitor (this, data); } } - CloseBrace(policy.PropertyBraceStyle); - NewLine(); - return EndNode(indexerDeclaration); + CloseBrace (policy.PropertyBraceStyle); + NewLine (); + return EndNode (indexerDeclaration); } - public object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) + public object VisitMethodDeclaration (MethodDeclaration methodDeclaration, object data) { - StartNode(methodDeclaration); - WriteAttributes(methodDeclaration.Attributes); - WriteModifiers(methodDeclaration.ModifierTokens); - methodDeclaration.ReturnType.AcceptVisitor(this, data); - Space(); - WritePrivateImplementationType(methodDeclaration.PrivateImplementationType); - WriteIdentifier(methodDeclaration.Name); - WriteTypeParameters(methodDeclaration.TypeParameters); - Space(policy.SpaceBeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(methodDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + StartNode (methodDeclaration); + WriteAttributes (methodDeclaration.Attributes); + WriteModifiers (methodDeclaration.ModifierTokens); + methodDeclaration.ReturnType.AcceptVisitor (this, data); + Space (); + WritePrivateImplementationType (methodDeclaration.PrivateImplementationType); + WriteIdentifier (methodDeclaration.Name); + WriteTypeParameters (methodDeclaration.TypeParameters); + Space (policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis (methodDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); foreach (Constraint constraint in methodDeclaration.Constraints) { - constraint.AcceptVisitor(this, data); + constraint.AcceptVisitor (this, data); } - WriteMethodBody(methodDeclaration.Body); - return EndNode(methodDeclaration); + WriteMethodBody (methodDeclaration.Body); + return EndNode (methodDeclaration); } - public object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) + public object VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, object data) { - StartNode(operatorDeclaration); - WriteAttributes(operatorDeclaration.Attributes); - WriteModifiers(operatorDeclaration.ModifierTokens); + StartNode (operatorDeclaration); + WriteAttributes (operatorDeclaration.Attributes); + WriteModifiers (operatorDeclaration.ModifierTokens); if (operatorDeclaration.OperatorType == OperatorType.Explicit) { - WriteKeyword("explicit", OperatorDeclaration.OperatorTypeRole); + WriteKeyword ("explicit", OperatorDeclaration.OperatorTypeRole); } else if (operatorDeclaration.OperatorType == OperatorType.Implicit) { - WriteKeyword("implicit", OperatorDeclaration.OperatorTypeRole); + WriteKeyword ("implicit", OperatorDeclaration.OperatorTypeRole); } else { - operatorDeclaration.ReturnType.AcceptVisitor(this, data); + operatorDeclaration.ReturnType.AcceptVisitor (this, data); } - WriteKeyword("operator", OperatorDeclaration.OperatorKeywordRole); - Space(); + WriteKeyword ("operator", OperatorDeclaration.OperatorKeywordRole); + Space (); if (operatorDeclaration.OperatorType == OperatorType.Explicit - || operatorDeclaration.OperatorType == OperatorType.Implicit) - { - operatorDeclaration.ReturnType.AcceptVisitor(this, data); + || operatorDeclaration.OperatorType == OperatorType.Implicit) { + operatorDeclaration.ReturnType.AcceptVisitor (this, data); } else { - WriteToken(OperatorDeclaration.GetToken(operatorDeclaration.OperatorType), OperatorDeclaration.OperatorTypeRole); + WriteToken (OperatorDeclaration.GetToken (operatorDeclaration.OperatorType), OperatorDeclaration.OperatorTypeRole); } - Space(policy.SpaceBeforeMethodDeclarationParentheses); - WriteCommaSeparatedListInParenthesis(operatorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); - WriteMethodBody(operatorDeclaration.Body); - return EndNode(operatorDeclaration); + Space (policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis (operatorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + WriteMethodBody (operatorDeclaration.Body); + return EndNode (operatorDeclaration); } - public object VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, object data) + public object VisitParameterDeclaration (ParameterDeclaration parameterDeclaration, object data) { - StartNode(parameterDeclaration); - WriteAttributes(parameterDeclaration.Attributes); + StartNode (parameterDeclaration); + WriteAttributes (parameterDeclaration.Attributes); switch (parameterDeclaration.ParameterModifier) { - case ParameterModifier.Ref: - WriteKeyword("ref", ParameterDeclaration.ModifierRole); - break; - case ParameterModifier.Out: - WriteKeyword("out", ParameterDeclaration.ModifierRole); - break; - case ParameterModifier.Params: - WriteKeyword("params", ParameterDeclaration.ModifierRole); - break; - case ParameterModifier.This: - WriteKeyword("this", ParameterDeclaration.ModifierRole); - break; + case ParameterModifier.Ref: + WriteKeyword ("ref", ParameterDeclaration.ModifierRole); + break; + case ParameterModifier.Out: + WriteKeyword ("out", ParameterDeclaration.ModifierRole); + break; + case ParameterModifier.Params: + WriteKeyword ("params", ParameterDeclaration.ModifierRole); + break; + case ParameterModifier.This: + WriteKeyword ("this", ParameterDeclaration.ModifierRole); + break; } - parameterDeclaration.Type.AcceptVisitor(this, data); - if (!parameterDeclaration.Type.IsNull && !string.IsNullOrEmpty(parameterDeclaration.Name)) - Space(); - if (!string.IsNullOrEmpty(parameterDeclaration.Name)) - WriteIdentifier(parameterDeclaration.Name); + parameterDeclaration.Type.AcceptVisitor (this, data); + if (!parameterDeclaration.Type.IsNull && !string.IsNullOrEmpty (parameterDeclaration.Name)) + Space (); + if (!string.IsNullOrEmpty (parameterDeclaration.Name)) + WriteIdentifier (parameterDeclaration.Name); if (!parameterDeclaration.DefaultExpression.IsNull) { - Space(policy.SpaceAroundAssignment); - WriteToken("=", ParameterDeclaration.Roles.Assign); - Space(policy.SpaceAroundAssignment); - parameterDeclaration.DefaultExpression.AcceptVisitor(this, data); + Space (policy.SpaceAroundAssignment); + WriteToken ("=", ParameterDeclaration.Roles.Assign); + Space (policy.SpaceAroundAssignment); + parameterDeclaration.DefaultExpression.AcceptVisitor (this, data); } - return EndNode(parameterDeclaration); + return EndNode (parameterDeclaration); } - public object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) + public object VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, object data) { - StartNode(propertyDeclaration); - WriteAttributes(propertyDeclaration.Attributes); - WriteModifiers(propertyDeclaration.ModifierTokens); - propertyDeclaration.ReturnType.AcceptVisitor(this, data); - Space(); - WritePrivateImplementationType(propertyDeclaration.PrivateImplementationType); - WriteIdentifier(propertyDeclaration.Name); - OpenBrace(policy.PropertyBraceStyle); + StartNode (propertyDeclaration); + WriteAttributes (propertyDeclaration.Attributes); + WriteModifiers (propertyDeclaration.ModifierTokens); + propertyDeclaration.ReturnType.AcceptVisitor (this, data); + Space (); + WritePrivateImplementationType (propertyDeclaration.PrivateImplementationType); + WriteIdentifier (propertyDeclaration.Name); + OpenBrace (policy.PropertyBraceStyle); // output get/set in their original order foreach (AstNode node in propertyDeclaration.Children) { if (node.Role == IndexerDeclaration.GetterRole || node.Role == IndexerDeclaration.SetterRole) { - node.AcceptVisitor(this, data); + node.AcceptVisitor (this, data); } } - CloseBrace(policy.PropertyBraceStyle); - NewLine(); - return EndNode(propertyDeclaration); + CloseBrace (policy.PropertyBraceStyle); + NewLine (); + return EndNode (propertyDeclaration); } + #endregion #region Other nodes - public object VisitVariableInitializer(VariableInitializer variableInitializer, object data) + public object VisitVariableInitializer (VariableInitializer variableInitializer, object data) { - StartNode(variableInitializer); - WriteIdentifier(variableInitializer.Name); + StartNode (variableInitializer); + WriteIdentifier (variableInitializer.Name); if (!variableInitializer.Initializer.IsNull) { - Space(policy.SpaceAroundAssignment); - WriteToken("=", VariableInitializer.Roles.Assign); - Space(policy.SpaceAroundAssignment); - variableInitializer.Initializer.AcceptVisitor(this, data); + Space (policy.SpaceAroundAssignment); + WriteToken ("=", VariableInitializer.Roles.Assign); + Space (policy.SpaceAroundAssignment); + variableInitializer.Initializer.AcceptVisitor (this, data); } - return EndNode(variableInitializer); + return EndNode (variableInitializer); } - public object VisitCompilationUnit(CompilationUnit compilationUnit, object data) + public object VisitCompilationUnit (CompilationUnit compilationUnit, object data) { // don't do node tracking as we visit all children directly foreach (AstNode node in compilationUnit.Children) - node.AcceptVisitor(this, data); + node.AcceptVisitor (this, data); return null; } - public object VisitSimpleType(SimpleType simpleType, object data) + public object VisitSimpleType (SimpleType simpleType, object data) { - StartNode(simpleType); - WriteIdentifier(simpleType.Identifier); - WriteTypeArguments(simpleType.TypeArguments); - return EndNode(simpleType); + StartNode (simpleType); + WriteIdentifier (simpleType.Identifier); + WriteTypeArguments (simpleType.TypeArguments); + return EndNode (simpleType); } - public object VisitMemberType(MemberType memberType, object data) + public object VisitMemberType (MemberType memberType, object data) { - StartNode(memberType); - memberType.Target.AcceptVisitor(this, data); + StartNode (memberType); + memberType.Target.AcceptVisitor (this, data); if (memberType.IsDoubleColon) - WriteToken("::", MemberType.Roles.Dot); + WriteToken ("::", MemberType.Roles.Dot); else - WriteToken(".", MemberType.Roles.Dot); - WriteIdentifier(memberType.MemberName); - WriteTypeArguments(memberType.TypeArguments); - return EndNode(memberType); + WriteToken (".", MemberType.Roles.Dot); + WriteIdentifier (memberType.MemberName); + WriteTypeArguments (memberType.TypeArguments); + return EndNode (memberType); } - public object VisitComposedType(ComposedType composedType, object data) + public object VisitComposedType (ComposedType composedType, object data) { - StartNode(composedType); - composedType.BaseType.AcceptVisitor(this, data); + StartNode (composedType); + composedType.BaseType.AcceptVisitor (this, data); if (composedType.HasNullableSpecifier) - WriteToken("?", ComposedType.NullableRole); + WriteToken ("?", ComposedType.NullableRole); for (int i = 0; i < composedType.PointerRank; i++) - WriteToken("*", ComposedType.PointerRole); + WriteToken ("*", ComposedType.PointerRole); foreach (var node in composedType.ArraySpecifiers) - node.AcceptVisitor(this, data); - return EndNode(composedType); + node.AcceptVisitor (this, data); + return EndNode (composedType); } - public object VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) + public object VisitArraySpecifier (ArraySpecifier arraySpecifier, object data) { - StartNode(arraySpecifier); - WriteToken("[", ArraySpecifier.Roles.LBracket); + StartNode (arraySpecifier); + WriteToken ("[", ArraySpecifier.Roles.LBracket); foreach (var comma in arraySpecifier.GetChildrenByRole(ArraySpecifier.Roles.Comma)) { - WriteSpecialsUpToNode(comma); - formatter.WriteToken(","); + WriteSpecialsUpToNode (comma); + formatter.WriteToken (","); lastWritten = LastWritten.Other; } - WriteToken("]", ArraySpecifier.Roles.RBracket); - return EndNode(arraySpecifier); + WriteToken ("]", ArraySpecifier.Roles.RBracket); + return EndNode (arraySpecifier); } - public object VisitPrimitiveType(PrimitiveType primitiveType, object data) + public object VisitPrimitiveType (PrimitiveType primitiveType, object data) { - StartNode(primitiveType); - WriteKeyword(primitiveType.Keyword); + StartNode (primitiveType); + WriteKeyword (primitiveType.Keyword); if (primitiveType.Keyword == "new") { // new() constraint - LPar(); - RPar(); + LPar (); + RPar (); } - return EndNode(primitiveType); + return EndNode (primitiveType); } - public object VisitComment(Comment comment, object data) + public object VisitComment (Comment comment, object data) { if (lastWritten == LastWritten.Division) { // When there's a comment starting after a division operator // "1.0 / /*comment*/a", then we need to insert a space in front of the comment. - formatter.Space(); + formatter.Space (); } - formatter.WriteComment(comment.CommentType, comment.Content); + formatter.StartNode(comment); + formatter.WriteComment (comment.CommentType, comment.Content); + formatter.EndNode(comment); lastWritten = LastWritten.Whitespace; return null; } - public object VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, object data) + public object VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration, object data) { - StartNode(typeParameterDeclaration); - WriteAttributes(typeParameterDeclaration.Attributes); + StartNode (typeParameterDeclaration); + WriteAttributes (typeParameterDeclaration.Attributes); switch (typeParameterDeclaration.Variance) { - case VarianceModifier.Invariant: - break; - case VarianceModifier.Covariant: - WriteKeyword("out"); - break; - case VarianceModifier.Contravariant: - WriteKeyword("in"); - break; - default: - throw new NotSupportedException("Invalid value for VarianceModifier"); + case VarianceModifier.Invariant: + break; + case VarianceModifier.Covariant: + WriteKeyword ("out"); + break; + case VarianceModifier.Contravariant: + WriteKeyword ("in"); + break; + default: + throw new NotSupportedException ("Invalid value for VarianceModifier"); } - WriteIdentifier(typeParameterDeclaration.Name); - return EndNode(typeParameterDeclaration); + WriteIdentifier (typeParameterDeclaration.Name); + return EndNode (typeParameterDeclaration); } - public object VisitConstraint(Constraint constraint, object data) + public object VisitConstraint (Constraint constraint, object data) { - StartNode(constraint); - Space(); - WriteKeyword("where"); - WriteIdentifier(constraint.TypeParameter); - Space(); - WriteToken(":", Constraint.ColonRole); - Space(); - WriteCommaSeparatedList(constraint.BaseTypes); - return EndNode(constraint); + StartNode (constraint); + Space (); + WriteKeyword ("where"); + WriteIdentifier (constraint.TypeParameter); + Space (); + WriteToken (":", Constraint.ColonRole); + Space (); + WriteCommaSeparatedList (constraint.BaseTypes); + return EndNode (constraint); } - public object VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, object data) + public object VisitCSharpTokenNode (CSharpTokenNode cSharpTokenNode, object data) { CSharpModifierToken mod = cSharpTokenNode as CSharpModifierToken; if (mod != null) { - StartNode(mod); - WriteKeyword(CSharpModifierToken.GetModifierName(mod.Modifier)); - return EndNode(mod); + StartNode (mod); + WriteKeyword (CSharpModifierToken.GetModifierName (mod.Modifier)); + return EndNode (mod); } else { - throw new NotSupportedException("Should never visit individual tokens"); + throw new NotSupportedException ("Should never visit individual tokens"); } } - public object VisitIdentifier(Identifier identifier, object data) + public object VisitIdentifier (Identifier identifier, object data) { - StartNode(identifier); - WriteIdentifier(identifier.Name); - return EndNode(identifier); + StartNode (identifier); + WriteIdentifier (identifier.Name); + return EndNode (identifier); } + #endregion #region Pattern Nodes - public object VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, object data) + public object VisitPatternPlaceholder (AstNode placeholder, PatternMatching.Pattern pattern, object data) { - StartNode(placeholder); - pattern.AcceptVisitor(this, data); - return EndNode(placeholder); + StartNode (placeholder); + pattern.AcceptVisitor (this, data); + return EndNode (placeholder); } - object IPatternAstVisitor.VisitAnyNode(AnyNode anyNode, object data) + object IPatternAstVisitor.VisitAnyNode (AnyNode anyNode, object data) { - if (!string.IsNullOrEmpty(anyNode.GroupName)) { - WriteIdentifier(anyNode.GroupName); - WriteToken(":", AstNode.Roles.Colon); + if (!string.IsNullOrEmpty (anyNode.GroupName)) { + WriteIdentifier (anyNode.GroupName); + WriteToken (":", AstNode.Roles.Colon); } - WriteKeyword("anyNode"); + WriteKeyword ("anyNode"); return null; } - object IPatternAstVisitor.VisitBackreference(Backreference backreference, object data) + object IPatternAstVisitor.VisitBackreference (Backreference backreference, object data) { - WriteKeyword("backreference"); - LPar(); - WriteIdentifier(backreference.ReferencedGroupName); - RPar(); + WriteKeyword ("backreference"); + LPar (); + WriteIdentifier (backreference.ReferencedGroupName); + RPar (); return null; } - object IPatternAstVisitor.VisitIdentifierExpressionBackreference(IdentifierExpressionBackreference identifierExpressionBackreference, object data) + object IPatternAstVisitor.VisitIdentifierExpressionBackreference (IdentifierExpressionBackreference identifierExpressionBackreference, object data) { - WriteKeyword("identifierBackreference"); - LPar(); - WriteIdentifier(identifierExpressionBackreference.ReferencedGroupName); - RPar(); + WriteKeyword ("identifierBackreference"); + LPar (); + WriteIdentifier (identifierExpressionBackreference.ReferencedGroupName); + RPar (); return null; } - object IPatternAstVisitor.VisitChoice(Choice choice, object data) + object IPatternAstVisitor.VisitChoice (Choice choice, object data) { - WriteKeyword("choice"); - Space(); - LPar(); - NewLine(); - formatter.Indent(); + WriteKeyword ("choice"); + Space (); + LPar (); + NewLine (); + formatter.Indent (); foreach (INode alternative in choice) { - VisitNodeInPattern(alternative, data); - if (alternative != choice.Last()) - WriteToken(",", AstNode.Roles.Comma); - NewLine(); + VisitNodeInPattern (alternative, data); + if (alternative != choice.Last ()) + WriteToken (",", AstNode.Roles.Comma); + NewLine (); } - formatter.Unindent(); - RPar(); + formatter.Unindent (); + RPar (); return null; } - object IPatternAstVisitor.VisitNamedNode(NamedNode namedNode, object data) + object IPatternAstVisitor.VisitNamedNode (NamedNode namedNode, object data) { - if (!string.IsNullOrEmpty(namedNode.GroupName)) { - WriteIdentifier(namedNode.GroupName); - WriteToken(":", AstNode.Roles.Colon); + if (!string.IsNullOrEmpty (namedNode.GroupName)) { + WriteIdentifier (namedNode.GroupName); + WriteToken (":", AstNode.Roles.Colon); } - VisitNodeInPattern(namedNode.ChildNode, data); + VisitNodeInPattern (namedNode.ChildNode, data); return null; } - object IPatternAstVisitor.VisitRepeat(Repeat repeat, object data) + object IPatternAstVisitor.VisitRepeat (Repeat repeat, object data) { - WriteKeyword("repeat"); - LPar(); + WriteKeyword ("repeat"); + LPar (); if (repeat.MinCount != 0 || repeat.MaxCount != int.MaxValue) { - WriteIdentifier(repeat.MinCount.ToString()); - WriteToken(",", AstNode.Roles.Comma); - WriteIdentifier(repeat.MaxCount.ToString()); - WriteToken(",", AstNode.Roles.Comma); + WriteIdentifier (repeat.MinCount.ToString ()); + WriteToken (",", AstNode.Roles.Comma); + WriteIdentifier (repeat.MaxCount.ToString ()); + WriteToken (",", AstNode.Roles.Comma); } - VisitNodeInPattern(repeat.ChildNode, data); - RPar(); + VisitNodeInPattern (repeat.ChildNode, data); + RPar (); return null; } - object IPatternAstVisitor.VisitOptionalNode(OptionalNode optionalNode, object data) + object IPatternAstVisitor.VisitOptionalNode (OptionalNode optionalNode, object data) { - WriteKeyword("optional"); - LPar(); - VisitNodeInPattern(optionalNode.ChildNode, data); - RPar(); + WriteKeyword ("optional"); + LPar (); + VisitNodeInPattern (optionalNode.ChildNode, data); + RPar (); return null; } - void VisitNodeInPattern(INode childNode, object data) + void VisitNodeInPattern (INode childNode, object data) { AstNode astNode = childNode as AstNode; if (astNode != null) { - astNode.AcceptVisitor(this, data); + astNode.AcceptVisitor (this, data); } else { Pattern pattern = childNode as Pattern; if (pattern != null) { - pattern.AcceptVisitor(this, data); + pattern.AcceptVisitor (this, data); } else { - throw new InvalidOperationException("Unknown node type in pattern"); + throw new InvalidOperationException ("Unknown node type in pattern"); } } } diff --git a/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs b/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs index f8c1340e5..a901cb78a 100644 --- a/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs +++ b/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs @@ -14,12 +14,24 @@ namespace ICSharpCode.NRefactory.CSharp readonly TextWriter textWriter; int indentation; bool needsIndent = true; + + public int Indentation { + get { + return this.indentation; + } + set { + this.indentation = value; + } + } + + public string IndentationString { get; set; } public TextWriterOutputFormatter(TextWriter textWriter) { if (textWriter == null) throw new ArgumentNullException("textWriter"); this.textWriter = textWriter; + this.IndentationString = "\t"; } public void WriteIdentifier(string ident) @@ -48,18 +60,68 @@ namespace ICSharpCode.NRefactory.CSharp public void OpenBrace(BraceStyle style) { - WriteIndentation(); - textWriter.Write(' '); - textWriter.Write('{'); + switch (style) { + case BraceStyle.DoNotChange: + case BraceStyle.EndOfLine: + WriteIndentation(); + textWriter.Write(' '); + textWriter.Write('{'); + break; + case BraceStyle.EndOfLineWithoutSpace: + WriteIndentation(); + textWriter.Write('{'); + break; + case BraceStyle.NextLine: + NewLine (); + WriteIndentation(); + textWriter.Write('{'); + break; + + case BraceStyle.NextLineShifted: + NewLine (); + Indent(); + WriteIndentation(); + textWriter.Write('{'); + NewLine(); + return; + case BraceStyle.NextLineShifted2: + NewLine (); + Indent(); + WriteIndentation(); + textWriter.Write('{'); + break; + default: + throw new ArgumentOutOfRangeException (); + } Indent(); NewLine(); } public void CloseBrace(BraceStyle style) { - Unindent(); - WriteIndentation(); - textWriter.Write('}'); + switch (style) { + case BraceStyle.DoNotChange: + case BraceStyle.EndOfLine: + case BraceStyle.EndOfLineWithoutSpace: + case BraceStyle.NextLine: + Unindent(); + WriteIndentation(); + textWriter.Write('}'); + break; + case BraceStyle.NextLineShifted: + WriteIndentation(); + textWriter.Write('}'); + Unindent(); + break; + case BraceStyle.NextLineShifted2: + Unindent(); + WriteIndentation(); + textWriter.Write('}'); + Unindent(); + break; + default: + throw new ArgumentOutOfRangeException (); + } } void WriteIndentation() @@ -67,7 +129,7 @@ namespace ICSharpCode.NRefactory.CSharp if (needsIndent) { needsIndent = false; for (int i = 0; i < indentation; i++) { - textWriter.Write('\t'); + textWriter.Write(this.IndentationString); } } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs index b9af0e50f..d9274ecee 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs @@ -1,4 +1,4 @@ -// +// // CSharpParser.cs // // Author: @@ -23,6 +23,7 @@ // 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.Linq; using System.Collections.Generic; @@ -38,7 +39,8 @@ namespace ICSharpCode.NRefactory.CSharp class ConversionVisitor : StructuralVisitor { CompilationUnit unit = new CompilationUnit (); - + internal bool convertTypeSystemMode; + public CompilationUnit Unit { get { return unit; @@ -47,34 +49,44 @@ namespace ICSharpCode.NRefactory.CSharp unit = value; } } - - public LocationsBag LocationsBag { + + public LocationsBag LocationsBag { get; private set; } - - public ConversionVisitor (LocationsBag locationsBag) + + public ConversionVisitor (bool convertTypeSystemMode, LocationsBag locationsBag) { + this.convertTypeSystemMode = convertTypeSystemMode; this.LocationsBag = locationsBag; } - + public static AstLocation Convert (Mono.CSharp.Location loc) { return new AstLocation (loc.Row, loc.Column); } - + + #region Global Stack namespaceStack = new Stack (); - + void AddTypeArguments (ATypeNameExpression texpr, AstType result) { if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null) return; + var loc = LocationsBag.GetLocations (texpr.TypeArguments); + if (loc != null && loc.Count >= 2) + result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 2]), 1), AstType.Roles.LChevron); + int i = 0; foreach (var arg in texpr.TypeArguments.Args) { result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument); + if (loc != null && i < loc.Count - 2) + result.AddChild (new CSharpTokenNode (Convert (loc [i++]), 1), AstType.Roles.Comma); } + if (loc != null && loc.Count >= 2) + result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1]), 1), AstType.Roles.RChevron); } - + AstType ConvertToType (MemberName memberName) { AstType result; @@ -91,9 +103,12 @@ namespace ICSharpCode.NRefactory.CSharp } return result; } - + AstType ConvertToType (Mono.CSharp.Expression typeName) { + if (typeName == null) // may happen in typeof(Generic<,,,,>) + return new SimpleType (); + if (typeName is TypeExpression) { var typeExpr = (Mono.CSharp.TypeExpression)typeName; return new PrimitiveType (typeExpr.GetSignatureForError (), Convert (typeExpr.Location)); @@ -102,11 +117,7 @@ namespace ICSharpCode.NRefactory.CSharp if (typeName is Mono.CSharp.QualifiedAliasMember) { var qam = (Mono.CSharp.QualifiedAliasMember)typeName; var memberType = new MemberType (); - if (qam.LeftExpression == null) { - memberType.Target = new SimpleType ("global", Convert (qam.Location)); - } else { - memberType.Target = ConvertToType (qam.LeftExpression); - } + memberType.Target = new SimpleType (qam.alias, Convert (qam.Location)); memberType.IsDoubleColon = true; memberType.MemberName = qam.Name; return memberType; @@ -117,7 +128,7 @@ namespace ICSharpCode.NRefactory.CSharp var memberType = new MemberType (); memberType.AddChild (ConvertToType (ma.LeftExpression), MemberType.TargetRole); - memberType.MemberName = ma.Name; + memberType.MemberNameToken = Identifier.Create (ma.Name, Convert (ma.Location)); AddTypeArguments (ma, memberType); return memberType; @@ -134,37 +145,54 @@ namespace ICSharpCode.NRefactory.CSharp var cc = (ComposedCast)typeName; var baseType = ConvertToType (cc.Left); var result = new ComposedType () { BaseType = baseType }; - - if (cc.Spec.IsNullable) { - result.HasNullableSpecifier = true; - } else if (cc.Spec.IsPointer) { - result.PointerRank++; - } else { - var location = LocationsBag.GetLocations (cc.Spec); - var spec = new ArraySpecifier () { Dimensions = cc.Spec.Dimension }; - 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); - - result.ArraySpecifiers.Add (spec); + var ccSpec = cc.Spec; + while (ccSpec != null) { + if (ccSpec.IsNullable) { + result.HasNullableSpecifier = true; + } else if (ccSpec.IsPointer) { + result.PointerRank++; + } else { + var location = LocationsBag.GetLocations (ccSpec); + var spec = new ArraySpecifier () { Dimensions = ccSpec.Dimension }; + spec.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), FieldDeclaration.Roles.LBracket); + if (location != null) + spec.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FieldDeclaration.Roles.RBracket); + + result.ArraySpecifiers.Add (spec); + } + ccSpec = ccSpec.Next; } return result; } + if (typeName is SpecialContraintExpr) { + var sce = (SpecialContraintExpr)typeName; + switch (sce.Constraint) { + case SpecialConstraint.Class: + return new PrimitiveType ("class", Convert (sce.Location)); + case SpecialConstraint.Struct: + return new PrimitiveType ("struct", Convert (sce.Location)); + case SpecialConstraint.Constructor: + return new PrimitiveType ("new", Convert (sce.Location)); + } + } System.Console.WriteLine ("Error while converting :" + typeName + " - unknown type name"); System.Console.WriteLine (Environment.StackTrace); return new SimpleType ("unknown"); } - - IEnumerable GetAttributes (Attributes optAttributes) + + IEnumerable GetAttributes (List optAttributes) { - if (optAttributes == null || optAttributes.Attrs == null) + if (optAttributes == null) yield break; - - foreach (var attr in optAttributes.Attrs) { + foreach (var attr in optAttributes) { Attribute result = new Attribute (); result.Type = ConvertToType (attr.TypeNameExpression); - + var loc = LocationsBag.GetLocations (attr); + result.HasArgumentList = loc != null; + if (loc != null) + result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), AttributeSection.Roles.LPar); + if (attr.PosArguments != null) { foreach (var arg in attr.PosArguments) { result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument); @@ -172,31 +200,35 @@ namespace ICSharpCode.NRefactory.CSharp } if (attr.NamedArguments != null) { foreach (NamedArgument na in attr.NamedArguments) { - NamedArgumentExpression newArg = new NamedArgumentExpression (); - newArg.AddChild (new Identifier (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); + var newArg = new AssignmentExpression (); + newArg.Operator = AssignmentOperatorType.Assign; + newArg.AddChild (new IdentifierExpression (na.Name, Convert (na.Location)), AssignmentExpression.LeftRole); - var loc = LocationsBag.GetLocations (na); - if (loc != null) - newArg.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), NamedArgumentExpression.Roles.Assign); - newArg.AddChild ((Expression)na.Expr.Accept (this), NamedArgumentExpression.Roles.Expression); + var argLoc = LocationsBag.GetLocations (na); + if (argLoc != null) + newArg.AddChild (new CSharpTokenNode (Convert (argLoc[0]), 1), AssignmentExpression.Roles.Assign); + newArg.AddChild ((Expression)na.Expr.Accept (this), AssignmentExpression.RightRole); result.AddChild (newArg, Attribute.Roles.Argument); } } + if (loc != null) + result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), AttributeSection.Roles.RPar); + yield return result; } } - - AttributeSection ConvertAttributeSection (Attributes optAttributes) + + AttributeSection ConvertAttributeSection (List optAttributes) { - if (optAttributes == null || optAttributes.Attrs == null) + if (optAttributes == null) return null; + AttributeSection result = new AttributeSection (); var loc = LocationsBag.GetLocations (optAttributes); if (loc != null) result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), AttributeSection.Roles.LBracket); - result.AttributeTarget = optAttributes.Attrs.First ().ExplicitTarget; - + result.AttributeTarget = optAttributes.First ().ExplicitTarget; foreach (var attr in GetAttributes (optAttributes)) { result.AddChild (attr, AttributeSection.AttributeRole); } @@ -205,7 +237,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), AttributeSection.Roles.RBracket); return result; } - + public override void Visit (UsingsBag.Namespace nspace) { NamespaceDeclaration nDecl = null; @@ -229,18 +261,18 @@ namespace ICSharpCode.NRefactory.CSharp namespaceStack.Pop (); } } - + void ConvertNamespaceName (MemberName memberName, NamespaceDeclaration namespaceDecl) { AstNode insertPos = null; while (memberName != null) { - Identifier newIdent = new Identifier (memberName.Name, Convert (memberName.Location)); + Identifier newIdent = Identifier.Create (memberName.Name, Convert (memberName.Location)); namespaceDecl.InsertChildBefore (insertPos, newIdent, NamespaceDeclaration.Roles.Identifier); insertPos = newIdent; memberName = memberName.Left; } } - + public override void Visit (UsingsBag.Using u) { UsingDeclaration ud = new UsingDeclaration (); @@ -249,12 +281,12 @@ namespace ICSharpCode.NRefactory.CSharp ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingDeclaration.Roles.Semicolon); AddToNamespace (ud); } - + public override void Visit (UsingsBag.AliasUsing u) { UsingAliasDeclaration ud = new UsingAliasDeclaration (); ud.AddChild (new CSharpTokenNode (Convert (u.UsingLocation), "using".Length), UsingAliasDeclaration.Roles.Keyword); - ud.AddChild (new Identifier (u.Identifier.Value, Convert (u.Identifier.Location)), UsingAliasDeclaration.AliasRole); + ud.AddChild (Identifier.Create (u.Identifier.Value, Convert (u.Identifier.Location)), UsingAliasDeclaration.AliasRole); ud.AddChild (new CSharpTokenNode (Convert (u.AssignLocation), 1), UsingAliasDeclaration.Roles.Assign); ud.AddChild (ConvertImport (u.Nspace), UsingAliasDeclaration.ImportRole); ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingAliasDeclaration.Roles.Semicolon); @@ -266,7 +298,7 @@ namespace ICSharpCode.NRefactory.CSharp 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 (Identifier.Create (u.Identifier.Value, Convert (u.Identifier.Location)), ExternAliasDeclaration.Roles.Identifier); ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingAliasDeclaration.Roles.Semicolon); AddToNamespace (ud); } @@ -275,28 +307,28 @@ namespace ICSharpCode.NRefactory.CSharp { if (memberName.Left != null) { // left.name - var 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); + t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier); AddTypeArguments (t, (List)null, memberName.TypeArguments); return t; } else { - SimpleType t = new SimpleType (); - t.AddChild (new Identifier (memberName.Name, Convert (memberName.Location)), SimpleType.Roles.Identifier); + SimpleType t = new SimpleType(); + t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier); AddTypeArguments (t, (List)null, memberName.TypeArguments); return t; } } - + public override void Visit (MemberCore member) { Console.WriteLine ("Unknown member:"); Console.WriteLine (member.GetType () + "-> Member {0}", member.GetSignatureForError ()); } - + Stack typeStack = new Stack (); - + public override void Visit (Class c) { TypeDeclaration newType = new TypeDeclaration (); @@ -306,15 +338,15 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (c); AddModifiers (newType, location); if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location [0]), "class".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); - if (c.MemberName.TypeArguments != null) { + newType.AddChild (new CSharpTokenNode (Convert (location[0]), "class".Length), TypeDeclaration.Roles.Keyword); + newType.AddChild (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); + if (c.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (c.MemberName); if (typeArgLocation != null) - newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation [0]), 1), TypeDeclaration.Roles.LChevron); + newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation[0]), 1), TypeDeclaration.Roles.LChevron); AddTypeParameters (newType, typeArgLocation, c.MemberName.TypeArguments); if (typeArgLocation != null) - newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation [1]), 1), TypeDeclaration.Roles.RChevron); + newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation[1]), 1), TypeDeclaration.Roles.RChevron); AddConstraints (newType, c); } if (c.TypeBaseExpressions != null) { @@ -323,15 +355,19 @@ namespace ICSharpCode.NRefactory.CSharp } } if (location != null && location.Count > 1) - newType.AddChild (new CSharpTokenNode (Convert (location [1]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location[1]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); base.Visit (c); - if (location != null && location.Count > 2) - newType.AddChild (new CSharpTokenNode (Convert (location [2]), 1), AstNode.Roles.RBrace); + if (location != null && location.Count > 2) { + newType.AddChild (new CSharpTokenNode (Convert (location[2]), 1), AstNode.Roles.RBrace); + } else { + // parser error, set end node to max value. + newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Pop (); AddType (newType); } - + public override void Visit (Struct s) { TypeDeclaration newType = new TypeDeclaration (); @@ -340,15 +376,15 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (s); AddModifiers (newType, location); if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location [0]), "struct".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (s.MemberName.Name, Convert (s.MemberName.Location)), AstNode.Roles.Identifier); - if (s.MemberName.TypeArguments != null) { + newType.AddChild (new CSharpTokenNode (Convert (location[0]), "struct".Length), TypeDeclaration.Roles.Keyword); + newType.AddChild (Identifier.Create (s.MemberName.Name, Convert (s.MemberName.Location)), AstNode.Roles.Identifier); + if (s.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (s.MemberName); if (typeArgLocation != null) - newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation [0]), 1), TypeDeclaration.Roles.LChevron); + newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation[0]), 1), TypeDeclaration.Roles.LChevron); AddTypeParameters (newType, typeArgLocation, s.MemberName.TypeArguments); if (typeArgLocation != null) - newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation [1]), 1), TypeDeclaration.Roles.RChevron); + newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation[1]), 1), TypeDeclaration.Roles.RChevron); AddConstraints (newType, s); } @@ -359,15 +395,19 @@ namespace ICSharpCode.NRefactory.CSharp } if (location != null && location.Count > 1) - newType.AddChild (new CSharpTokenNode (Convert (location [1]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location[1]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); base.Visit (s); - if (location != null && location.Count > 2) - newType.AddChild (new CSharpTokenNode (Convert (location [2]), 1), AstNode.Roles.RBrace); + if (location != null && location.Count > 2) { + newType.AddChild (new CSharpTokenNode (Convert (location[2]), 1), AstNode.Roles.RBrace); + } else { + // parser error, set end node to max value. + newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Pop (); AddType (newType); } - + public override void Visit (Interface i) { TypeDeclaration newType = new TypeDeclaration (); @@ -376,15 +416,15 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (i); AddModifiers (newType, location); if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location [0]), "interface".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (i.MemberName.Name, Convert (i.MemberName.Location)), AstNode.Roles.Identifier); - if (i.MemberName.TypeArguments != null) { + newType.AddChild (new CSharpTokenNode (Convert (location[0]), "interface".Length), TypeDeclaration.Roles.Keyword); + newType.AddChild (Identifier.Create (i.MemberName.Name, Convert (i.MemberName.Location)), AstNode.Roles.Identifier); + if (i.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (i.MemberName); if (typeArgLocation != null) - newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation [0]), 1), MemberReferenceExpression.Roles.LChevron); + newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation[0]), 1), MemberReferenceExpression.Roles.LChevron); AddTypeParameters (newType, typeArgLocation, i.MemberName.TypeArguments); if (typeArgLocation != null) - newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation [1]), 1), MemberReferenceExpression.Roles.RChevron); + newType.AddChild (new CSharpTokenNode (Convert (typeArgLocation[1]), 1), MemberReferenceExpression.Roles.RChevron); AddConstraints (newType, i); } if (i.TypeBaseExpressions != null) { @@ -393,15 +433,19 @@ namespace ICSharpCode.NRefactory.CSharp } } if (location != null && location.Count > 1) - newType.AddChild (new CSharpTokenNode (Convert (location [1]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location[1]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); base.Visit (i); - if (location != null && location.Count > 2) - newType.AddChild (new CSharpTokenNode (Convert (location [2]), 1), AstNode.Roles.RBrace); + if (location != null && location.Count > 2) { + newType.AddChild (new CSharpTokenNode (Convert (location[2]), 1), AstNode.Roles.RBrace); + } else { + // parser error, set end node to max value. + newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Pop (); AddType (newType); } - + public override void Visit (Mono.CSharp.Delegate d) { DelegateDeclaration newDelegate = new DelegateDeclaration (); @@ -409,29 +453,29 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newDelegate, d); AddModifiers (newDelegate, location); if (location != null) - newDelegate.AddChild (new CSharpTokenNode (Convert (location [0]), "delegate".Length), TypeDeclaration.Roles.Keyword); + newDelegate.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), TypeDeclaration.Roles.Keyword); newDelegate.AddChild (ConvertToType (d.ReturnType), AstNode.Roles.Type); - newDelegate.AddChild (new Identifier (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); - if (d.MemberName.TypeArguments != null) { + newDelegate.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); + if (d.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (d.MemberName); if (typeArgLocation != null) - newDelegate.AddChild (new CSharpTokenNode (Convert (typeArgLocation [0]), 1), TypeDeclaration.Roles.LChevron); + newDelegate.AddChild (new CSharpTokenNode (Convert (typeArgLocation[0]), 1), TypeDeclaration.Roles.LChevron); AddTypeParameters (newDelegate, typeArgLocation, d.MemberName.TypeArguments); if (typeArgLocation != null) - newDelegate.AddChild (new CSharpTokenNode (Convert (typeArgLocation [1]), 1), TypeDeclaration.Roles.RChevron); + newDelegate.AddChild (new CSharpTokenNode (Convert (typeArgLocation[1]), 1), TypeDeclaration.Roles.RChevron); AddConstraints (newDelegate, d); } if (location != null) - newDelegate.AddChild (new CSharpTokenNode (Convert (location [1]), 1), DelegateDeclaration.Roles.LPar); + newDelegate.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DelegateDeclaration.Roles.LPar); AddParameter (newDelegate, d.Parameters); if (location != null) { - newDelegate.AddChild (new CSharpTokenNode (Convert (location [2]), 1), DelegateDeclaration.Roles.RPar); - newDelegate.AddChild (new CSharpTokenNode (Convert (location [3]), 1), DelegateDeclaration.Roles.Semicolon); + newDelegate.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DelegateDeclaration.Roles.RPar); + newDelegate.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DelegateDeclaration.Roles.Semicolon); } AddType (newDelegate); } - + void AddType (AttributedNode child) { if (typeStack.Count > 0) { @@ -440,7 +484,7 @@ namespace ICSharpCode.NRefactory.CSharp AddToNamespace (child); } } - + void AddToNamespace (AstNode child) { if (namespaceStack.Count > 0) { @@ -449,7 +493,7 @@ namespace ICSharpCode.NRefactory.CSharp unit.AddChild (child, CompilationUnit.MemberRole); } } - + public override void Visit (Mono.CSharp.Enum e) { TypeDeclaration newType = new TypeDeclaration (); @@ -460,29 +504,30 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newType, location); if (location != null) newType.AddChild (new CSharpTokenNode (Convert (location [0]), "enum".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (e.MemberName.Name, Convert (e.MemberName.Location)), AstNode.Roles.Identifier); + newType.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), AstNode.Roles.Identifier); - if (e.TypeBaseExpressions != null) { - foreach (var baseTypes in e.TypeBaseExpressions) { - newType.AddChild (ConvertToType (baseTypes), TypeDeclaration.BaseTypeRole); - } - } + if (e.BaseTypeExpression != null) + newType.AddChild (ConvertToType (e.BaseTypeExpression), TypeDeclaration.BaseTypeRole); if (location != null && location.Count > 1) - newType.AddChild (new CSharpTokenNode (Convert (location [1]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location[1]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); base.Visit (e); - if (location != null && location.Count > 2) - newType.AddChild (new CSharpTokenNode (Convert (location [2]), 1), AstNode.Roles.RBrace); + if (location != null && location.Count > 2) { + newType.AddChild (new CSharpTokenNode (Convert (location[2]), 1), AstNode.Roles.RBrace); + } else { + // parser error, set end node to max value. + newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Pop (); AddType (newType); } - + public override void Visit (EnumMember em) { EnumMemberDeclaration newField = new EnumMemberDeclaration (); AddAttributeSection (newField, em); - newField.AddChild (new Identifier (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); + newField.AddChild (Identifier.Create (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); if (em.Initializer != null) { newField.AddChild ((Expression)em.Initializer.Accept (this), EnumMemberDeclaration.InitializerRole); @@ -490,7 +535,6 @@ namespace ICSharpCode.NRefactory.CSharp typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); } - #endregion #region Type members @@ -508,7 +552,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type); var variable = new FixedVariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (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) @@ -527,7 +571,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma); variable = new FixedVariableInitializer (); - variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (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) @@ -540,7 +584,7 @@ namespace ICSharpCode.NRefactory.CSharp } } if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [1]), 1), FieldDeclaration.Roles.Semicolon); + newField.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FieldDeclaration.Roles.Semicolon); typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); } @@ -555,11 +599,11 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); if (f.Initializer != null) { if (location != null) - variable.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FieldDeclaration.Roles.Assign); + variable.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.Assign); variable.AddChild ((Expression)f.Initializer.Accept (this), VariableInitializer.Roles.Expression); } newField.AddChild (variable, FieldDeclaration.Roles.Variable); @@ -567,10 +611,10 @@ namespace ICSharpCode.NRefactory.CSharp 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.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location), 1), FieldDeclaration.Roles.Assign); variable.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); @@ -579,11 +623,11 @@ namespace ICSharpCode.NRefactory.CSharp } } if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1]), 1), FieldDeclaration.Roles.Semicolon); + newField.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), 1), FieldDeclaration.Roles.Semicolon); typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); } - + public override void Visit (Const f) { var location = LocationsBag.GetMemberLocation (f); @@ -592,11 +636,11 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newField, f); AddModifiers (newField, location); if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [0]), "const".Length), FieldDeclaration.Roles.Keyword); + newField.AddChild (new CSharpModifierToken (Convert (location [0]), Modifiers.Const), AttributedNode.ModifierRole); newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier); if (f.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (f.Initializer.Location), 1), VariableInitializer.Roles.Assign); @@ -607,10 +651,10 @@ namespace ICSharpCode.NRefactory.CSharp 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.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); if (decl.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location), 1), FieldDeclaration.Roles.Assign); variable.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); @@ -619,13 +663,13 @@ namespace ICSharpCode.NRefactory.CSharp } } if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [1]), 1), FieldDeclaration.Roles.Semicolon); + newField.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FieldDeclaration.Roles.Semicolon); typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); } - + public override void Visit (Operator o) { OperatorDeclaration newOperator = new OperatorDeclaration (); @@ -639,58 +683,43 @@ namespace ICSharpCode.NRefactory.CSharp if (o.OperatorType == Operator.OpType.Implicit) { if (location != null) { - newOperator.AddChild (new CSharpTokenNode (Convert (location [0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole); - newOperator.AddChild (new CSharpTokenNode (Convert (location [1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); + newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole); + newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); } } else if (o.OperatorType == Operator.OpType.Explicit) { if (location != null) { - newOperator.AddChild (new CSharpTokenNode (Convert (location [0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole); - newOperator.AddChild (new CSharpTokenNode (Convert (location [1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); + newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole); + newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); } } else { if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location [0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); + newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); - int opLength = 1; - switch (newOperator.OperatorType) { - case OperatorType.LeftShift: - case OperatorType.RightShift: - case OperatorType.LessThanOrEqual: - case OperatorType.GreaterThanOrEqual: - case OperatorType.Equality: - case OperatorType.Inequality: -// case OperatorType.LogicalAnd: -// case OperatorType.LogicalOr: - opLength = 2; - break; - case OperatorType.True: - opLength = "true".Length; - break; - case OperatorType.False: - opLength = "false".Length; - break; - } + int opLength = OperatorDeclaration.GetToken(newOperator.OperatorType).Length; if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location [1]), opLength), OperatorDeclaration.OperatorTypeRole); + newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), opLength), OperatorDeclaration.OperatorTypeRole); } if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location [2]), 1), OperatorDeclaration.Roles.LPar); + newOperator.AddChild (new CSharpTokenNode (Convert (location[2]), 1), OperatorDeclaration.Roles.LPar); AddParameter (newOperator, o.ParameterInfo); if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location [3]), 1), OperatorDeclaration.Roles.RPar); + newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar); if (o.Block != null) newOperator.AddChild ((BlockStatement)o.Block.Accept (this), OperatorDeclaration.Roles.Body); typeStack.Peek ().AddChild (newOperator, TypeDeclaration.MemberRole); } - - public void AddAttributeSection (AttributedNode parent, Attributable a) + + public void AddAttributeSection (AstNode parent, Attributable a) { - if (a.OptAttributes != null && a.OptAttributes.Attrs != null) - parent.AddChild (ConvertAttributeSection (a.OptAttributes), AttributedNode.AttributeRole); + if (a.OptAttributes == null) + return; + foreach (var attr in a.OptAttributes.Sections) { + parent.AddChild (ConvertAttributeSection (attr), AttributedNode.AttributeRole); + } } - + public override void Visit (Indexer indexer) { IndexerDeclaration newIndexer = new IndexerDeclaration (); @@ -703,13 +732,13 @@ namespace ICSharpCode.NRefactory.CSharp newIndexer.AddChild (ConvertToType (indexer.TypeName), IndexerDeclaration.Roles.Type); if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location [0]), 1), IndexerDeclaration.Roles.LBracket); + newIndexer.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IndexerDeclaration.Roles.LBracket); AddParameter (newIndexer, indexer.ParameterInfo); if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location [1]), 1), IndexerDeclaration.Roles.RBracket); + newIndexer.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IndexerDeclaration.Roles.RBracket); if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location [2]), 1), IndexerDeclaration.Roles.LBrace); + newIndexer.AddChild (new CSharpTokenNode (Convert (location[2]), 1), IndexerDeclaration.Roles.LBrace); if (indexer.Get != null) { Accessor getAccessor = new Accessor (); var getLocation = LocationsBag.GetMemberLocation (indexer.Get); @@ -721,7 +750,7 @@ namespace ICSharpCode.NRefactory.CSharp getAccessor.AddChild ((BlockStatement)indexer.Get.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (getLocation != null && getLocation.Count > 0) - newIndexer.AddChild (new CSharpTokenNode (Convert (getLocation [0]), 1), MethodDeclaration.Roles.Semicolon); + newIndexer.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newIndexer.AddChild (getAccessor, PropertyDeclaration.GetterRole); } @@ -738,17 +767,20 @@ namespace ICSharpCode.NRefactory.CSharp setAccessor.AddChild ((BlockStatement)indexer.Set.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (setLocation != null && setLocation.Count > 0) - newIndexer.AddChild (new CSharpTokenNode (Convert (setLocation [0]), 1), MethodDeclaration.Roles.Semicolon); + newIndexer.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newIndexer.AddChild (setAccessor, PropertyDeclaration.SetterRole); } - if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location [3]), 1), IndexerDeclaration.Roles.RBrace); - + if (location != null) { + newIndexer.AddChild (new CSharpTokenNode (Convert (location[3]), 1), IndexerDeclaration.Roles.RBrace); + } else { + // parser error, set end node to max value. + newIndexer.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Peek ().AddChild (newIndexer, TypeDeclaration.MemberRole); } - + public override void Visit (Method m) { MethodDeclaration newMethod = new MethodDeclaration (); @@ -760,24 +792,24 @@ namespace ICSharpCode.NRefactory.CSharp if (m.MethodName.Left != null) newMethod.AddChild (ConvertToType (m.MethodName.Left), MethodDeclaration.PrivateImplementationTypeRole); - newMethod.AddChild (new Identifier (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier); + newMethod.AddChild (Identifier.Create (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier); - if (m.MemberName.TypeArguments != null) { + if (m.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (m.MemberName); if (typeArgLocation != null) - newMethod.AddChild (new CSharpTokenNode (Convert (typeArgLocation [0]), 1), MemberReferenceExpression.Roles.LChevron); + newMethod.AddChild (new CSharpTokenNode (Convert (typeArgLocation[0]), 1), MemberReferenceExpression.Roles.LChevron); AddTypeParameters (newMethod, typeArgLocation, m.MemberName.TypeArguments); if (typeArgLocation != null) - newMethod.AddChild (new CSharpTokenNode (Convert (typeArgLocation [1]), 1), MemberReferenceExpression.Roles.RChevron); + newMethod.AddChild (new CSharpTokenNode (Convert (typeArgLocation[1]), 1), MemberReferenceExpression.Roles.RChevron); AddConstraints (newMethod, m.GenericMethod); } if (location != null) - newMethod.AddChild (new CSharpTokenNode (Convert (location [0]), 1), MethodDeclaration.Roles.LPar); + newMethod.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LPar); AddParameter (newMethod, m.ParameterInfo); if (location != null) - newMethod.AddChild (new CSharpTokenNode (Convert (location [1]), 1), MethodDeclaration.Roles.RPar); + newMethod.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RPar); if (m.Block != null) { var bodyBlock = (BlockStatement)m.Block.Accept (this); // if (m.Block is ToplevelBlock) { @@ -785,13 +817,16 @@ namespace ICSharpCode.NRefactory.CSharp // } else { newMethod.AddChild (bodyBlock, MethodDeclaration.Roles.Body); // } + } else if (location != null && location.Count < 3) { + // parser error, set end node to max value. + newMethod.AddChild (new ErrorNode (), AstNode.Roles.Error); } typeStack.Peek ().AddChild (newMethod, TypeDeclaration.MemberRole); } - + static Dictionary modifierTable = new Dictionary (); static string[] keywordTable; - + static ConversionVisitor () { modifierTable [Mono.CSharp.Modifiers.NEW] = ICSharpCode.NRefactory.CSharp.Modifiers.New; @@ -830,16 +865,16 @@ namespace ICSharpCode.NRefactory.CSharp keywordTable [(int)BuiltinTypeSpec.Type.Decimal] = "decimal"; keywordTable [(int)BuiltinTypeSpec.Type.Char] = "char"; } - + void AddModifiers (AttributedNode parent, LocationsBag.MemberLocations location) { if (location == null || location.Modifiers == null) return; foreach (var modifier in location.Modifiers) { - parent.AddChild (new CSharpModifierToken (Convert (modifier.Item2), modifierTable [modifier.Item1]), AttributedNode.ModifierRole); + parent.AddChild (new CSharpModifierToken (Convert (modifier.Item2), modifierTable[modifier.Item1]), AttributedNode.ModifierRole); } } - + public override void Visit (Property p) { PropertyDeclaration newProperty = new PropertyDeclaration (); @@ -850,10 +885,10 @@ namespace ICSharpCode.NRefactory.CSharp if (p.MemberName.Left != null) newProperty.AddChild (ConvertToType (p.MemberName.Left), PropertyDeclaration.PrivateImplementationTypeRole); - newProperty.AddChild (new Identifier (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier); + newProperty.AddChild (Identifier.Create (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier); if (location != null) - newProperty.AddChild (new CSharpTokenNode (Convert (location [0]), 1), MethodDeclaration.Roles.LBrace); + newProperty.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LBrace); if (p.Get != null) { Accessor getAccessor = new Accessor (); @@ -866,7 +901,7 @@ namespace ICSharpCode.NRefactory.CSharp getAccessor.AddChild ((BlockStatement)p.Get.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (getLocation != null && getLocation.Count > 0) - newProperty.AddChild (new CSharpTokenNode (Convert (getLocation [0]), 1), MethodDeclaration.Roles.Semicolon); + newProperty.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newProperty.AddChild (getAccessor, PropertyDeclaration.GetterRole); } @@ -882,29 +917,33 @@ namespace ICSharpCode.NRefactory.CSharp setAccessor.AddChild ((BlockStatement)p.Set.Block.Accept (this), MethodDeclaration.Roles.Body); } else { if (setLocation != null && setLocation.Count > 0) - newProperty.AddChild (new CSharpTokenNode (Convert (setLocation [0]), 1), MethodDeclaration.Roles.Semicolon); + newProperty.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon); } newProperty.AddChild (setAccessor, PropertyDeclaration.SetterRole); } - if (location != null) - newProperty.AddChild (new CSharpTokenNode (Convert (location [1]), 1), MethodDeclaration.Roles.RBrace); + if (location != null && location.Count > 1) { + newProperty.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RBrace); + } else { + // parser error, set end node to max value. + newProperty.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Peek ().AddChild (newProperty, TypeDeclaration.MemberRole); } - + public override void Visit (Constructor c) { ConstructorDeclaration newConstructor = new ConstructorDeclaration (); AddAttributeSection (newConstructor, c); var location = LocationsBag.GetMemberLocation (c); AddModifiers (newConstructor, location); - newConstructor.AddChild (new Identifier (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); + newConstructor.AddChild (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); if (location != null) - newConstructor.AddChild (new CSharpTokenNode (Convert (location [0]), 1), MethodDeclaration.Roles.LPar); + newConstructor.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LPar); AddParameter (newConstructor, c.ParameterInfo); if (location != null) - newConstructor.AddChild (new CSharpTokenNode (Convert (location [1]), 1), MethodDeclaration.Roles.RPar); + newConstructor.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RPar); if (c.Initializer != null) { var initializer = new ConstructorInitializer (); @@ -912,12 +951,12 @@ namespace ICSharpCode.NRefactory.CSharp var initializerLocation = LocationsBag.GetLocations (c.Initializer); if (initializerLocation != null) - newConstructor.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ConstructorDeclaration.Roles.Colon); + newConstructor.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ConstructorDeclaration.Roles.Colon); if (initializerLocation != null) - initializer.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ConstructorDeclaration.Roles.LPar); + initializer.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ConstructorDeclaration.Roles.LPar); AddArguments (initializer, LocationsBag.GetLocations (c.Initializer.Arguments), c.Initializer.Arguments); if (initializerLocation != null) - initializer.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ConstructorDeclaration.Roles.RPar); + initializer.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ConstructorDeclaration.Roles.RPar); newConstructor.AddChild (initializer, ConstructorDeclaration.InitializerRole); } @@ -926,7 +965,7 @@ namespace ICSharpCode.NRefactory.CSharp typeStack.Peek ().AddChild (newConstructor, TypeDeclaration.MemberRole); } - + public override void Visit (Destructor d) { DestructorDeclaration newDestructor = new DestructorDeclaration (); @@ -934,12 +973,12 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (d); AddModifiers (newDestructor, location); if (location != null) - newDestructor.AddChild (new CSharpTokenNode (Convert (location [0]), 1), DestructorDeclaration.TildeRole); - newDestructor.AddChild (new Identifier (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); + newDestructor.AddChild (new CSharpTokenNode (Convert (location[0]), 1), DestructorDeclaration.TildeRole); + newDestructor.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); if (location != null) { - newDestructor.AddChild (new CSharpTokenNode (Convert (location [1]), 1), DestructorDeclaration.Roles.LPar); - newDestructor.AddChild (new CSharpTokenNode (Convert (location [2]), 1), DestructorDeclaration.Roles.RPar); + newDestructor.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DestructorDeclaration.Roles.LPar); + newDestructor.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DestructorDeclaration.Roles.RPar); } if (d.Block != null) @@ -947,7 +986,7 @@ namespace ICSharpCode.NRefactory.CSharp typeStack.Peek ().AddChild (newDestructor, TypeDeclaration.MemberRole); } - + public override void Visit (EventField e) { EventDeclaration newEvent = new EventDeclaration (); @@ -956,15 +995,15 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newEvent, location); if (location != null) - newEvent.AddChild (new CSharpTokenNode (Convert (location [0]), "event".Length), EventDeclaration.Roles.Keyword); + newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), EventDeclaration.Roles.Keyword); newEvent.AddChild (ConvertToType (e.TypeName), AstNode.Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier); if (e.Initializer != null) { if (location != null) - variable.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FieldDeclaration.Roles.Assign); + variable.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.Assign); variable.AddChild ((Expression)e.Initializer.Accept (this), VariableInitializer.Roles.Expression); } newEvent.AddChild (variable, FieldDeclaration.Roles.Variable); @@ -972,10 +1011,10 @@ namespace ICSharpCode.NRefactory.CSharp foreach (var decl in e.Declarators) { var declLoc = LocationsBag.GetLocations (decl); if (declLoc != null) - newEvent.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma); + newEvent.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location), 1), FieldDeclaration.Roles.Assign); @@ -986,11 +1025,11 @@ namespace ICSharpCode.NRefactory.CSharp } if (location != null) - newEvent.AddChild (new CSharpTokenNode (Convert (location [1]), ";".Length), EventDeclaration.Roles.Semicolon); + newEvent.AddChild (new CSharpTokenNode (Convert (location[1]), ";".Length), EventDeclaration.Roles.Semicolon); typeStack.Peek ().AddChild (newEvent, TypeDeclaration.MemberRole); } - + public override void Visit (EventProperty ep) { CustomEventDeclaration newEvent = new CustomEventDeclaration (); @@ -999,15 +1038,15 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newEvent, location); if (location != null) - newEvent.AddChild (new CSharpTokenNode (Convert (location [0]), "event".Length), CustomEventDeclaration.Roles.Keyword); + newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), CustomEventDeclaration.Roles.Keyword); newEvent.AddChild (ConvertToType (ep.TypeName), CustomEventDeclaration.Roles.Type); if (ep.MemberName.Left != null) newEvent.AddChild (ConvertToType (ep.MemberName.Left), CustomEventDeclaration.PrivateImplementationTypeRole); - newEvent.AddChild (new Identifier (ep.MemberName.Name, Convert (ep.Location)), CustomEventDeclaration.Roles.Identifier); + newEvent.AddChild (Identifier.Create (ep.MemberName.Name, Convert (ep.Location)), CustomEventDeclaration.Roles.Identifier); if (location != null && location.Count >= 2) - newEvent.AddChild (new CSharpTokenNode (Convert (location [1]), 1), CustomEventDeclaration.Roles.LBrace); + newEvent.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CustomEventDeclaration.Roles.LBrace); if (ep.Add != null) { Accessor addAccessor = new Accessor (); @@ -1031,12 +1070,16 @@ namespace ICSharpCode.NRefactory.CSharp removeAccessor.AddChild ((BlockStatement)ep.Remove.Block.Accept (this), CustomEventDeclaration.Roles.Body); newEvent.AddChild (removeAccessor, CustomEventDeclaration.RemoveAccessorRole); } - if (location != null && location.Count >= 3) - newEvent.AddChild (new CSharpTokenNode (Convert (location [2]), 1), CustomEventDeclaration.Roles.RBrace); + if (location != null && location.Count >= 3) { + newEvent.AddChild (new CSharpTokenNode (Convert (location[2]), 1), CustomEventDeclaration.Roles.RBrace); + } else { + // parser error, set end node to max value. + newEvent.AddChild (new ErrorNode (), AstNode.Roles.Error); + } typeStack.Peek ().AddChild (newEvent, TypeDeclaration.MemberRole); } - + #endregion #region Statements @@ -1045,7 +1088,7 @@ namespace ICSharpCode.NRefactory.CSharp Console.WriteLine ("unknown statement:" + stmt); return null; } - + public override object Visit (BlockVariableDeclaration blockVariableDeclaration) { var result = new VariableDeclarationStatement (); @@ -1053,10 +1096,10 @@ namespace ICSharpCode.NRefactory.CSharp var varInit = new VariableInitializer (); var location = LocationsBag.GetLocations (blockVariableDeclaration); - varInit.AddChild (new Identifier (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (location != null) - varInit.AddChild (new CSharpTokenNode (Convert (location [0]), 1), VariableInitializer.Roles.Assign); + varInit.AddChild (new CSharpTokenNode (Convert (location[0]), 1), VariableInitializer.Roles.Assign); varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), VariableInitializer.Roles.Expression); } @@ -1068,7 +1111,7 @@ namespace ICSharpCode.NRefactory.CSharp 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); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); @@ -1078,11 +1121,11 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (init, VariableDeclarationStatement.Roles.Variable); } } - if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1]), 1), VariableDeclarationStatement.Roles.Semicolon); + if (location != null && (blockVariableDeclaration.Initializer == null || location.Count > 1)) + result.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), 1), VariableDeclarationStatement.Roles.Semicolon); return result; } - + public override object Visit (BlockConstantDeclaration blockVariableDeclaration) { var result = new VariableDeclarationStatement (); @@ -1094,10 +1137,10 @@ namespace ICSharpCode.NRefactory.CSharp 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); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (location != null) - varInit.AddChild (new CSharpTokenNode (Convert (location [1]), 1), VariableInitializer.Roles.Assign); + varInit.AddChild (new CSharpTokenNode (Convert (location[1]), 1), VariableInitializer.Roles.Assign); varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), VariableInitializer.Roles.Expression); } @@ -1107,37 +1150,41 @@ namespace ICSharpCode.NRefactory.CSharp foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); - init.AddChild (new Identifier (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + init.AddChild (Identifier.Create (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 (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.Comma); } else { if (loc != null && loc.Count > 0) - result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), VariableInitializer.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), VariableInitializer.Roles.Comma); } result.AddChild (init, VariableDeclarationStatement.Roles.Variable); } } - if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1]), 1), VariableDeclarationStatement.Roles.Semicolon); + if (location != null) { + result.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), 1), VariableDeclarationStatement.Roles.Semicolon); + } else { + // parser error, set end node to max value. + result.AddChild (new ErrorNode (), AstNode.Roles.Error); + } return result; } - + public override object Visit (Mono.CSharp.EmptyStatement emptyStatement) { var result = new EmptyStatement (); result.Location = Convert (emptyStatement.loc); return result; } - + public override object Visit (EmptyExpressionStatement emptyExpressionStatement) { return new EmptyExpression (Convert (emptyExpressionStatement.Location)); } - + public override object Visit (If ifStatement) { var result = new IfElseStatement (); @@ -1146,23 +1193,23 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (ifStatement.loc), "if".Length), IfElseStatement.IfKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), IfElseStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IfElseStatement.Roles.LPar); result.AddChild ((Expression)ifStatement.Expr.Accept (this), IfElseStatement.Roles.Condition); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), IfElseStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IfElseStatement.Roles.RPar); if (ifStatement.TrueStatement != null) result.AddChild ((Statement)ifStatement.TrueStatement.Accept (this), IfElseStatement.TrueRole); if (ifStatement.FalseStatement != null) { if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [2]), "else".Length), IfElseStatement.ElseKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[2]), "else".Length), IfElseStatement.ElseKeywordRole); result.AddChild ((Statement)ifStatement.FalseStatement.Accept (this), IfElseStatement.FalseRole); } return result; } - + public override object Visit (Do doStatement) { var result = new DoWhileStatement (); @@ -1170,18 +1217,18 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (doStatement.loc), "do".Length), DoWhileStatement.DoKeywordRole); result.AddChild ((Statement)doStatement.EmbeddedStatement.Accept (this), WhileStatement.Roles.EmbeddedStatement); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "while".Length), DoWhileStatement.WhileKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "while".Length), DoWhileStatement.WhileKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), DoWhileStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DoWhileStatement.Roles.LPar); result.AddChild ((Expression)doStatement.expr.Accept (this), DoWhileStatement.Roles.Condition); if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), DoWhileStatement.Roles.RPar); - result.AddChild (new CSharpTokenNode (Convert (location [3]), 1), DoWhileStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DoWhileStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DoWhileStatement.Roles.Semicolon); } return result; } - + public override object Visit (While whileStatement) { var result = new WhileStatement (); @@ -1198,14 +1245,13 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Statement)whileStatement.Statement.Accept (this), WhileStatement.Roles.EmbeddedStatement); return result; } - + void AddStatementOrList (ForStatement forStatement, Mono.CSharp.Statement init, Role role) { if (init == null) return; if (init is StatementList) { foreach (var stmt in ((StatementList)init).Statements) { - Console.WriteLine ("stmt:" + stmt); forStatement.AddChild ((Statement)stmt.Accept (this), role); } } else if (init is Mono.CSharp.EmptyStatement) { @@ -1244,7 +1290,7 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - + public override object Visit (StatementExpression statementExpression) { var result = new ExpressionStatement (); @@ -1253,10 +1299,10 @@ namespace ICSharpCode.NRefactory.CSharp 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); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ExpressionStatement.Roles.Semicolon); return result; } - + public override object Visit (Return returnStatement) { var result = new ReturnStatement (); @@ -1267,43 +1313,43 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (returnStatement); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ReturnStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ReturnStatement.Roles.Semicolon); return result; } - + public override object Visit (Goto gotoStatement) { var result = new GotoStatement (); var location = LocationsBag.GetLocations (gotoStatement); result.AddChild (new CSharpTokenNode (Convert (gotoStatement.loc), "goto".Length), GotoStatement.Roles.Keyword); - result.AddChild (new Identifier (gotoStatement.Target, Convert (gotoStatement.loc)), GotoStatement.Roles.Identifier); + result.AddChild (Identifier.Create (gotoStatement.Target, Convert (gotoStatement.loc)), GotoStatement.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), GotoStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), GotoStatement.Roles.Semicolon); return result; } - + public override object Visit (LabeledStatement labeledStatement) { var result = new LabelStatement (); - result.AddChild (new Identifier (labeledStatement.Name, Convert (labeledStatement.loc)), LabelStatement.Roles.Identifier); + result.AddChild (Identifier.Create (labeledStatement.Name, Convert (labeledStatement.loc)), LabelStatement.Roles.Identifier); return result; } - + public override object Visit (GotoDefault gotoDefault) { var result = new GotoDefaultStatement (); result.AddChild (new CSharpTokenNode (Convert (gotoDefault.loc), "goto".Length), GotoDefaultStatement.Roles.Keyword); var location = LocationsBag.GetLocations (gotoDefault); if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location [0]), "default".Length), GotoDefaultStatement.DefaultKeywordRole); - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), GotoDefaultStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "default".Length), GotoDefaultStatement.DefaultKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), GotoDefaultStatement.Roles.Semicolon); } return result; } - + public override object Visit (GotoCase gotoCase) { var result = new GotoCaseStatement (); @@ -1311,13 +1357,13 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (gotoCase); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "case".Length), GotoCaseStatement.CaseKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "case".Length), GotoCaseStatement.CaseKeywordRole); result.AddChild ((Expression)gotoCase.Expr.Accept (this), GotoCaseStatement.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), GotoCaseStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), GotoCaseStatement.Roles.Semicolon); return result; } - + public override object Visit (Throw throwStatement) { var result = new ThrowStatement (); @@ -1327,10 +1373,10 @@ namespace ICSharpCode.NRefactory.CSharp if (throwStatement.Expr != null) result.AddChild ((Expression)throwStatement.Expr.Accept (this), ThrowStatement.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ThrowStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ThrowStatement.Roles.Semicolon); return result; } - + public override object Visit (Break breakStatement) { var result = new BreakStatement (); @@ -1338,42 +1384,49 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (breakStatement.loc), "break".Length), BreakStatement.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), BreakStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), BreakStatement.Roles.Semicolon); return result; } - + public override object Visit (Continue continueStatement) { var result = new ContinueStatement (); var location = LocationsBag.GetLocations (continueStatement); result.AddChild (new CSharpTokenNode (Convert (continueStatement.loc), "continue".Length), ContinueStatement.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ContinueStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ContinueStatement.Roles.Semicolon); return result; } - + public static bool IsLower (Location left, Location right) { return left.Row < right.Row || left.Row == right.Row && left.Column < right.Column; } - + public UsingStatement CreateUsingStatement (Block blockStatement) { var usingResult = new UsingStatement (); - Mono.CSharp.Statement cur = blockStatement.Statements [0]; + Mono.CSharp.Statement cur = blockStatement.Statements[0]; if (cur is Using) { Using u = (Using)cur; usingResult.AddChild (new CSharpTokenNode (Convert (u.loc), "using".Length), UsingStatement.Roles.Keyword); usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation), 1), UsingStatement.Roles.LPar); if (u.Variables != null) { - usingResult.AddChild (ConvertToType (u.Variables.TypeExpression), UsingStatement.Roles.Type); - usingResult.AddChild (new Identifier (u.Variables.Variable.Name, Convert (u.Variables.Variable.Location)), UsingStatement.Roles.Identifier); + var initializer = new VariableInitializer () { + NameToken = Identifier.Create (u.Variables.Variable.Name, Convert (u.Variables.Variable.Location)), + }; + var loc = LocationsBag.GetLocations (u.Variables); if (loc != null) - usingResult.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), ContinueStatement.Roles.Assign); + initializer.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), VariableInitializer.Roles.Assign); if (u.Variables.Initializer != null) - usingResult.AddChild ((AstNode)u.Variables.Initializer.Accept (this), UsingStatement.ResourceAcquisitionRole); + initializer.Initializer = u.Variables.Initializer.Accept (this) as Expression; + var varDec = new VariableDeclarationStatement () { + Type = ConvertToType (u.Variables.TypeExpression), + Variables = { initializer } + }; + usingResult.AddChild (varDec, UsingStatement.ResourceAcquisitionRole); } cur = u.Statement; usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation), 1), UsingStatement.Roles.RPar); @@ -1381,9 +1434,12 @@ namespace ICSharpCode.NRefactory.CSharp } return usingResult; } - + void AddBlockChildren (BlockStatement result, Block blockStatement, ref int curLocal) { + if (convertTypeSystemMode) { + return; + } foreach (Mono.CSharp.Statement stmt in blockStatement.Statements) { if (stmt == null) continue; @@ -1398,7 +1454,7 @@ namespace ICSharpCode.NRefactory.CSharp } } } - + public override object Visit (Block blockStatement) { if (blockStatement.IsCompilerGenerated && blockStatement.Statements.Any ()) { @@ -1426,9 +1482,9 @@ namespace ICSharpCode.NRefactory.CSharp if (switchStatement.Expr != null) result.AddChild ((Expression)switchStatement.Expr.Accept (this), SwitchStatement.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), SwitchStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), SwitchStatement.Roles.RPar); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), SwitchStatement.Roles.LBrace); + result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), SwitchStatement.Roles.LBrace); foreach (var section in switchStatement.Sections) { var newSection = new SwitchSection (); foreach (var caseLabel in section.Labels) { @@ -1452,11 +1508,16 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (newSection, SwitchStatement.SwitchSectionRole); } - if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [3]), 1), SwitchStatement.Roles.RBrace); + if (location != null) { + result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), SwitchStatement.Roles.RBrace); + } else { + // parser error, set end node to max value. + result.AddChild (new ErrorNode (), AstNode.Roles.Error); + } + return result; } - + public override object Visit (Lock lockStatement) { var result = new LockStatement (); @@ -1464,16 +1525,16 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (lockStatement.loc), "lock".Length), LockStatement.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), LockStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), LockStatement.Roles.LPar); result.AddChild ((Expression)lockStatement.Expr.Accept (this), LockStatement.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), LockStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), LockStatement.Roles.RPar); result.AddChild ((Statement)lockStatement.Statement.Accept (this), LockStatement.Roles.EmbeddedStatement); return result; } - + public override object Visit (Unchecked uncheckedStatement) { var result = new UncheckedStatement (); @@ -1481,7 +1542,8 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((BlockStatement)uncheckedStatement.Block.Accept (this), UncheckedStatement.Roles.Body); return result; } - + + public override object Visit (Checked checkedStatement) { var result = new CheckedStatement (); @@ -1489,7 +1551,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((BlockStatement)checkedStatement.Block.Accept (this), CheckedStatement.Roles.Body); return result; } - + public override object Visit (Unsafe unsafeStatement) { var result = new UnsafeStatement (); @@ -1497,7 +1559,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((BlockStatement)unsafeStatement.Block.Accept (this), UnsafeStatement.Roles.Body); return result; } - + public override object Visit (Fixed fixedStatement) { var result = new FixedStatement (); @@ -1505,17 +1567,17 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), "fixed".Length), FixedStatement.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FixedStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar); if (fixedStatement.Variables != null) { var blockVariableDeclaration = fixedStatement.Variables; result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), FixedStatement.Roles.Type); var varInit = new VariableInitializer (); var initLocation = LocationsBag.GetLocations (blockVariableDeclaration); - varInit.AddChild (new Identifier (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (initLocation != null) - varInit.AddChild (new CSharpTokenNode (Convert (location [0]), 1), VariableInitializer.Roles.Assign); + varInit.AddChild (new CSharpTokenNode (Convert (location[0]), 1), VariableInitializer.Roles.Assign); varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), VariableInitializer.Roles.Expression); } @@ -1527,7 +1589,7 @@ namespace ICSharpCode.NRefactory.CSharp 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); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); @@ -1540,11 +1602,11 @@ namespace ICSharpCode.NRefactory.CSharp } if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), FixedStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar); result.AddChild ((Statement)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement); return result; } - + public override object Visit (TryFinally tryFinallyStatement) { TryCatchStatement result; @@ -1559,12 +1621,12 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((BlockStatement)tryFinallyStatement.Stmt.Accept (this), TryCatchStatement.TryBlockRole); } if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "finally".Length), TryCatchStatement.FinallyKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "finally".Length), TryCatchStatement.FinallyKeywordRole); result.AddChild ((BlockStatement)tryFinallyStatement.Fini.Accept (this), TryCatchStatement.FinallyBlockRole); return result; } - + CatchClause ConvertCatch (Catch ctch) { CatchClause result = new CatchClause (); @@ -1572,21 +1634,22 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (ctch.loc), "catch".Length), CatchClause.Roles.Keyword); if (ctch.TypeExpression != null) { if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), CatchClause.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CatchClause.Roles.LPar); result.AddChild (ConvertToType (ctch.TypeExpression), CatchClause.Roles.Type); if (ctch.Variable != null && !string.IsNullOrEmpty (ctch.Variable.Name)) - result.AddChild (new Identifier (ctch.Variable.Name, Convert (ctch.Variable.Location)), CatchClause.Roles.Identifier); + result.AddChild (Identifier.Create (ctch.Variable.Name, Convert (ctch.Variable.Location)), CatchClause.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), CatchClause.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CatchClause.Roles.RPar); } - - result.AddChild ((BlockStatement)ctch.Block.Accept (this), CatchClause.Roles.Body); + + if (ctch.Block != null) + result.AddChild ((BlockStatement)ctch.Block.Accept (this), CatchClause.Roles.Body); return result; } - + public override object Visit (TryCatch tryCatchStatement) { var result = new TryCatchStatement (); @@ -1601,7 +1664,7 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - + public override object Visit (Using usingStatement) { var result = new UsingStatement (); @@ -1610,7 +1673,6 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (usingStatement.loc), "using".Length), UsingStatement.Roles.Keyword); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UsingStatement.Roles.LPar); - if (usingStatement.Expression != null) result.AddChild ((AstNode)usingStatement.Expression.Accept (this), UsingStatement.ResourceAcquisitionRole); @@ -1621,7 +1683,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Statement)usingStatement.Statement.Accept (this), UsingStatement.Roles.EmbeddedStatement); return result; } - + public override object Visit (Foreach foreachStatement) { var result = new ForeachStatement (); @@ -1635,7 +1697,7 @@ namespace ICSharpCode.NRefactory.CSharp if (foreachStatement.TypeExpr != null) result.AddChild (ConvertToType (foreachStatement.TypeExpr), ForeachStatement.Roles.Type); if (foreachStatement.Variable != null) - result.AddChild (new Identifier (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier); + result.AddChild (Identifier.Create (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location [1]), "in".Length), ForeachStatement.Roles.InKeyword); @@ -1650,7 +1712,7 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - + public override object Visit (Yield yieldStatement) { var result = new YieldStatement (); @@ -1658,27 +1720,26 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (yieldStatement.loc), "yield".Length), YieldStatement.YieldKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "return".Length), YieldStatement.ReturnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "return".Length), YieldStatement.ReturnKeywordRole); if (yieldStatement.Expr != null) result.AddChild ((Expression)yieldStatement.Expr.Accept (this), YieldStatement.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), ";".Length), YieldStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[1]), ";".Length), YieldStatement.Roles.Semicolon); return result; } - + public override object Visit (YieldBreak yieldBreakStatement) { var result = new YieldBreakStatement (); var location = LocationsBag.GetLocations (yieldBreakStatement); result.AddChild (new CSharpTokenNode (Convert (yieldBreakStatement.loc), "yield".Length), YieldBreakStatement.YieldKeywordRole); if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location [0]), "break".Length), YieldBreakStatement.BreakKeywordRole); - result.AddChild (new CSharpTokenNode (Convert (location [1]), ";".Length), YieldBreakStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "break".Length), YieldBreakStatement.BreakKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), ";".Length), YieldBreakStatement.Roles.Semicolon); } return result; } - #endregion #region Expression @@ -1688,7 +1749,7 @@ namespace ICSharpCode.NRefactory.CSharp System.Console.WriteLine (Environment.StackTrace); return null; } - + public override object Visit (Mono.CSharp.DefaultParameterValueExpression defaultParameterValueExpression) { return defaultParameterValueExpression.Child.Accept (this); @@ -1701,14 +1762,12 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (LocalVariableReference localVariableReference) { - return new Identifier (localVariableReference.Name, Convert (localVariableReference.Location)); - ; + return Identifier.Create (localVariableReference.Name, Convert (localVariableReference.Location));; } public override object Visit (MemberAccess memberAccess) { Expression result; - Console.WriteLine (memberAccess.LeftExpression + "/" + memberAccess.Name); if (memberAccess.LeftExpression is Indirection) { var ind = memberAccess.LeftExpression as Indirection; result = new PointerReferenceExpression (); @@ -1722,137 +1781,144 @@ namespace ICSharpCode.NRefactory.CSharp } } - result.AddChild (new Identifier (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier); + result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier); - if (memberAccess.TypeArguments != null) { + if (memberAccess.TypeArguments != null) { var location = LocationsBag.GetLocations (memberAccess); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), MemberReferenceExpression.Roles.LChevron); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MemberReferenceExpression.Roles.LChevron); AddTypeArguments (result, location, memberAccess.TypeArguments); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), MemberReferenceExpression.Roles.RChevron); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MemberReferenceExpression.Roles.RChevron); } return result; } - + public override object Visit (QualifiedAliasMember qualifiedAliasMember) { var result = new MemberType (); result.Target = new SimpleType (qualifiedAliasMember.alias, Convert (qualifiedAliasMember.Location)); result.IsDoubleColon = true; var location = LocationsBag.GetLocations (qualifiedAliasMember); - result.AddChild (new Identifier (qualifiedAliasMember.Name, location != null ? Convert (location [0]) : AstLocation.Empty), MemberReferenceExpression.Roles.Identifier); + result.AddChild (Identifier.Create (qualifiedAliasMember.Name, location != null ? Convert (location[0]) : AstLocation.Empty), MemberReferenceExpression.Roles.Identifier); return new TypeReferenceExpression () { Type = result }; } - + public override object Visit (Constant constant) { if (constant.GetValue () == null) return new NullReferenceExpression (Convert (constant.Location)); - var result = new PrimitiveExpression (constant.GetValue (), Convert (constant.Location), constant.GetValueAsLiteral ().Length); + string literalValue; + if (constant is ILiteralConstant) { + literalValue = new string (((ILiteralConstant)constant).ParsedValue); + } else { + literalValue = constant.GetValueAsLiteral (); + } + var result = new PrimitiveExpression (constant.GetValue (), Convert (constant.Location), literalValue); return result; } public override object Visit (SimpleName simpleName) { var result = new IdentifierExpression (); - result.AddChild (new Identifier (simpleName.Name, Convert (simpleName.Location)), IdentifierExpression.Roles.Identifier); - if (simpleName.TypeArguments != null) { + result.AddChild (Identifier.Create (simpleName.Name, Convert (simpleName.Location)), IdentifierExpression.Roles.Identifier); + if (simpleName.TypeArguments != null) { var location = LocationsBag.GetLocations (simpleName); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), IdentifierExpression.Roles.LChevron); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IdentifierExpression.Roles.LChevron); AddTypeArguments (result, location, simpleName.TypeArguments); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), IdentifierExpression.Roles.RChevron); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IdentifierExpression.Roles.RChevron); } return result; } - + public override object Visit (BooleanExpression booleanExpression) { return booleanExpression.Expr.Accept (this); } + public override object Visit (Mono.CSharp.ParenthesizedExpression parenthesizedExpression) { var result = new ParenthesizedExpression (); var location = LocationsBag.GetLocations (parenthesizedExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ParenthesizedExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ParenthesizedExpression.Roles.LPar); result.AddChild ((Expression)parenthesizedExpression.Expr.Accept (this), ParenthesizedExpression.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ParenthesizedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ParenthesizedExpression.Roles.RPar); return result; } - + public override object Visit (Unary unaryExpression) { var result = new UnaryOperatorExpression (); switch (unaryExpression.Oper) { - case Unary.Operator.UnaryPlus: - result.Operator = UnaryOperatorType.Plus; - break; - case Unary.Operator.UnaryNegation: - result.Operator = UnaryOperatorType.Minus; - break; - case Unary.Operator.LogicalNot: - result.Operator = UnaryOperatorType.Not; - break; - case Unary.Operator.OnesComplement: - result.Operator = UnaryOperatorType.BitNot; - break; - case Unary.Operator.AddressOf: - result.Operator = UnaryOperatorType.AddressOf; - break; + case Unary.Operator.UnaryPlus: + result.Operator = UnaryOperatorType.Plus; + break; + case Unary.Operator.UnaryNegation: + result.Operator = UnaryOperatorType.Minus; + break; + case Unary.Operator.LogicalNot: + result.Operator = UnaryOperatorType.Not; + break; + case Unary.Operator.OnesComplement: + result.Operator = UnaryOperatorType.BitNot; + break; + case Unary.Operator.AddressOf: + result.Operator = UnaryOperatorType.AddressOf; + break; } result.AddChild (new CSharpTokenNode (Convert (unaryExpression.Location), 1), UnaryOperatorExpression.OperatorRole); result.AddChild ((Expression)unaryExpression.Expr.Accept (this), UnaryOperatorExpression.Roles.Expression); return result; } - + public override object Visit (UnaryMutator unaryMutatorExpression) { var result = new UnaryOperatorExpression (); var expression = (Expression)unaryMutatorExpression.Expr.Accept (this); switch (unaryMutatorExpression.UnaryMutatorMode) { - case UnaryMutator.Mode.PostDecrement: - result.Operator = UnaryOperatorType.PostDecrement; - result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); - result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); - break; - case UnaryMutator.Mode.PostIncrement: - result.Operator = UnaryOperatorType.PostIncrement; - result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); - result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); - break; + case UnaryMutator.Mode.PostDecrement: + result.Operator = UnaryOperatorType.PostDecrement; + result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); + break; + case UnaryMutator.Mode.PostIncrement: + result.Operator = UnaryOperatorType.PostIncrement; + result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); + break; - case UnaryMutator.Mode.PreIncrement: - result.Operator = UnaryOperatorType.Increment; - result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); - result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); - break; - case UnaryMutator.Mode.PreDecrement: - result.Operator = UnaryOperatorType.Decrement; - result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); - result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); - break; + case UnaryMutator.Mode.PreIncrement: + result.Operator = UnaryOperatorType.Increment; + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); + result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); + break; + case UnaryMutator.Mode.PreDecrement: + result.Operator = UnaryOperatorType.Decrement; + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location), 2), UnaryOperatorExpression.OperatorRole); + result.AddChild (expression, UnaryOperatorExpression.Roles.Expression); + break; } return result; } - + public override object Visit (Indirection indirectionExpression) { var result = new UnaryOperatorExpression (); result.Operator = UnaryOperatorType.Dereference; var location = LocationsBag.GetLocations (indirectionExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 2), UnaryOperatorExpression.OperatorRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 2), UnaryOperatorExpression.OperatorRole); result.AddChild ((Expression)indirectionExpression.Expr.Accept (this), UnaryOperatorExpression.Roles.Expression); return result; } - + public override object Visit (Is isExpression) { var result = new IsExpression (); @@ -1861,7 +1927,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (isExpression.ProbeType), IsExpression.Roles.Type); return result; } - + public override object Visit (As asExpression) { var result = new AsExpression (); @@ -1870,7 +1936,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (asExpression.ProbeType), AsExpression.Roles.Type); return result; } - + public override object Visit (Cast castExpression) { var result = new CastExpression (); @@ -1880,12 +1946,12 @@ namespace ICSharpCode.NRefactory.CSharp if (castExpression.TargetType != null) result.AddChild (ConvertToType (castExpression.TargetType), CastExpression.Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), CastExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CastExpression.Roles.RPar); if (castExpression.Expr != null) result.AddChild ((Expression)castExpression.Expr.Accept (this), CastExpression.Roles.Expression); return result; } - + public override object Visit (ComposedCast composedCast) { var result = new ComposedType (); @@ -1910,87 +1976,87 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - + public override object Visit (Mono.CSharp.DefaultValueExpression defaultValueExpression) { var result = new DefaultValueExpression (); result.AddChild (new CSharpTokenNode (Convert (defaultValueExpression.Location), "default".Length), CastExpression.Roles.Keyword); var location = LocationsBag.GetLocations (defaultValueExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), CastExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CastExpression.Roles.LPar); result.AddChild (ConvertToType (defaultValueExpression.Expr), CastExpression.Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), CastExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CastExpression.Roles.RPar); return result; } - + public override object Visit (Binary binaryExpression) { var result = new BinaryOperatorExpression (); int opLength = 1; switch (binaryExpression.Oper) { - case Binary.Operator.Multiply: - result.Operator = BinaryOperatorType.Multiply; - break; - case Binary.Operator.Division: - result.Operator = BinaryOperatorType.Divide; - break; - case Binary.Operator.Modulus: - result.Operator = BinaryOperatorType.Modulus; - break; - case Binary.Operator.Addition: - result.Operator = BinaryOperatorType.Add; - break; - case Binary.Operator.Subtraction: - result.Operator = BinaryOperatorType.Subtract; - break; - case Binary.Operator.LeftShift: - result.Operator = BinaryOperatorType.ShiftLeft; - opLength = 2; - break; - case Binary.Operator.RightShift: - result.Operator = BinaryOperatorType.ShiftRight; - opLength = 2; - break; - case Binary.Operator.LessThan: - result.Operator = BinaryOperatorType.LessThan; - break; - case Binary.Operator.GreaterThan: - result.Operator = BinaryOperatorType.GreaterThan; - break; - case Binary.Operator.LessThanOrEqual: - result.Operator = BinaryOperatorType.LessThanOrEqual; - opLength = 2; - break; - case Binary.Operator.GreaterThanOrEqual: - result.Operator = BinaryOperatorType.GreaterThanOrEqual; - opLength = 2; - break; - case Binary.Operator.Equality: - result.Operator = BinaryOperatorType.Equality; - opLength = 2; - break; - case Binary.Operator.Inequality: - result.Operator = BinaryOperatorType.InEquality; - opLength = 2; - break; - case Binary.Operator.BitwiseAnd: - result.Operator = BinaryOperatorType.BitwiseAnd; - break; - case Binary.Operator.ExclusiveOr: - result.Operator = BinaryOperatorType.ExclusiveOr; - break; - case Binary.Operator.BitwiseOr: - result.Operator = BinaryOperatorType.BitwiseOr; - break; - case Binary.Operator.LogicalAnd: - result.Operator = BinaryOperatorType.ConditionalAnd; - opLength = 2; - break; - case Binary.Operator.LogicalOr: - result.Operator = BinaryOperatorType.ConditionalOr; - opLength = 2; - break; + case Binary.Operator.Multiply: + result.Operator = BinaryOperatorType.Multiply; + break; + case Binary.Operator.Division: + result.Operator = BinaryOperatorType.Divide; + break; + case Binary.Operator.Modulus: + result.Operator = BinaryOperatorType.Modulus; + break; + case Binary.Operator.Addition: + result.Operator = BinaryOperatorType.Add; + break; + case Binary.Operator.Subtraction: + result.Operator = BinaryOperatorType.Subtract; + break; + case Binary.Operator.LeftShift: + result.Operator = BinaryOperatorType.ShiftLeft; + opLength = 2; + break; + case Binary.Operator.RightShift: + result.Operator = BinaryOperatorType.ShiftRight; + opLength = 2; + break; + case Binary.Operator.LessThan: + result.Operator = BinaryOperatorType.LessThan; + break; + case Binary.Operator.GreaterThan: + result.Operator = BinaryOperatorType.GreaterThan; + break; + case Binary.Operator.LessThanOrEqual: + result.Operator = BinaryOperatorType.LessThanOrEqual; + opLength = 2; + break; + case Binary.Operator.GreaterThanOrEqual: + result.Operator = BinaryOperatorType.GreaterThanOrEqual; + opLength = 2; + break; + case Binary.Operator.Equality: + result.Operator = BinaryOperatorType.Equality; + opLength = 2; + break; + case Binary.Operator.Inequality: + result.Operator = BinaryOperatorType.InEquality; + opLength = 2; + break; + case Binary.Operator.BitwiseAnd: + result.Operator = BinaryOperatorType.BitwiseAnd; + break; + case Binary.Operator.ExclusiveOr: + result.Operator = BinaryOperatorType.ExclusiveOr; + break; + case Binary.Operator.BitwiseOr: + result.Operator = BinaryOperatorType.BitwiseOr; + break; + case Binary.Operator.LogicalAnd: + result.Operator = BinaryOperatorType.ConditionalAnd; + opLength = 2; + break; + case Binary.Operator.LogicalOr: + result.Operator = BinaryOperatorType.ConditionalOr; + opLength = 2; + break; } result.AddChild ((Expression)binaryExpression.Left.Accept (this), BinaryOperatorExpression.LeftRole); @@ -1998,7 +2064,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)binaryExpression.Right.Accept (this), BinaryOperatorExpression.RightRole); return result; } - + public override object Visit (Mono.CSharp.Nullable.NullCoalescingOperator nullCoalescingOperator) { var result = new BinaryOperatorExpression (); @@ -2008,7 +2074,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)nullCoalescingOperator.Right.Accept (this), BinaryOperatorExpression.RightRole); return result; } - + public override object Visit (Conditional conditionalExpression) { var result = new ConditionalExpression (); @@ -2019,11 +2085,11 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (conditionalExpression.Location), 1), ConditionalExpression.QuestionMarkRole); result.AddChild ((Expression)conditionalExpression.TrueExpr.Accept (this), ConditionalExpression.TrueRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ConditionalExpression.ColonRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ConditionalExpression.ColonRole); result.AddChild ((Expression)conditionalExpression.FalseExpr.Accept (this), ConditionalExpression.FalseRole); return result; } - + void AddParameter (AstNode parent, Mono.CSharp.AParametersCollection parameters) { if (parameters == null) @@ -2037,6 +2103,7 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (p); ParameterDeclaration parameterDeclarationExpression = new ParameterDeclaration (); + AddAttributeSection (parameterDeclarationExpression, p); switch (p.ModFlags) { case Parameter.Modifier.OUT: parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out; @@ -2064,7 +2131,7 @@ namespace ICSharpCode.NRefactory.CSharp if (p.TypeExpression != null) // lambdas may have no types (a, b) => ... parameterDeclarationExpression.AddChild (ConvertToType (p.TypeExpression), ParameterDeclaration.Roles.Type); if (p.Name != null) - parameterDeclarationExpression.AddChild (new Identifier (p.Name, Convert (p.Location)), ParameterDeclaration.Roles.Identifier); + parameterDeclarationExpression.AddChild (Identifier.Create (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); @@ -2073,54 +2140,54 @@ namespace ICSharpCode.NRefactory.CSharp parent.AddChild (parameterDeclarationExpression, InvocationExpression.Roles.Parameter); } } - + void AddTypeParameters (AstNode parent, List 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 = (TypeParameterName)typeArguments.Args [i]; + parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma); + var arg = (TypeParameterName)typeArguments.Args[i]; if (arg == null) continue; - TypeParameterDeclaration tp = new TypeParameterDeclaration (); + TypeParameterDeclaration tp = new TypeParameterDeclaration(); // TODO: attributes - if (arg.Variance != Variance.None) - throw new NotImplementedException (); // TODO: variance - tp.AddChild (new Identifier (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); +// if (arg.Variance != Variance.None) +// throw new NotImplementedException(); // TODO: variance + tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); parent.AddChild (tp, InvocationExpression.Roles.TypeParameter); } } - + 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]; + 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) 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]; + 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 AddConstraints (AstNode parent, DeclSpace d) { if (d == null || d.Constraints == null) @@ -2131,7 +2198,7 @@ namespace ICSharpCode.NRefactory.CSharp var constraint = new Constraint (); if (location != null) 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 (Identifier.Create (c.TypeParameter.Value, Convert (c.TypeParameter.Location)), InvocationExpression.Roles.Identifier); if (location != null && location.Count > 1) constraint.AddChild (new CSharpTokenNode (Convert (location [1]), 1), Constraint.ColonRole); foreach (var expr in c.ConstraintExpressions) @@ -2139,24 +2206,24 @@ namespace ICSharpCode.NRefactory.CSharp parent.AddChild (constraint, AstNode.Roles.Constraint); } } - + Expression ConvertArgument (Argument arg) { if (arg is NamedArgument) { var na = (NamedArgument)arg; - NamedArgumentExpression newArg = new NamedArgumentExpression (); - newArg.AddChild (new Identifier (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); + NamedArgumentExpression newArg = new NamedArgumentExpression(); + newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); var loc = LocationsBag.GetLocations (na); if (loc != null) - newArg.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), NamedArgumentExpression.Roles.Assign); + newArg.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), NamedArgumentExpression.Roles.Assign); if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) { DirectionExpression direction = new DirectionExpression (); direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref; var argLocation = LocationsBag.GetLocations (arg); if (argLocation != null) - direction.AddChild (new CSharpTokenNode (Convert (argLocation [0]), "123".Length), InvocationExpression.Roles.Keyword); + direction.AddChild (new CSharpTokenNode (Convert (argLocation[0]), "123".Length), InvocationExpression.Roles.Keyword); direction.AddChild ((Expression)arg.Expr.Accept (this), InvocationExpression.Roles.Expression); newArg.AddChild (direction, NamedArgumentExpression.Roles.Expression); } else { @@ -2170,14 +2237,14 @@ namespace ICSharpCode.NRefactory.CSharp direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref; var argLocation = LocationsBag.GetLocations (arg); if (argLocation != null) - direction.AddChild (new CSharpTokenNode (Convert (argLocation [0]), "123".Length), InvocationExpression.Roles.Keyword); + direction.AddChild (new CSharpTokenNode (Convert (argLocation[0]), "123".Length), InvocationExpression.Roles.Keyword); direction.AddChild ((Expression)arg.Expr.Accept (this), InvocationExpression.Roles.Expression); return direction; } return (Expression)arg.Expr.Accept (this); } - + void AddArguments (AstNode parent, object location, Mono.CSharp.Arguments args) { if (args == null) @@ -2186,31 +2253,31 @@ namespace ICSharpCode.NRefactory.CSharp var commaLocations = LocationsBag.GetLocations (args); for (int i = 0; i < args.Count; i++) { - parent.AddChild (ConvertArgument (args [i]), InvocationExpression.Roles.Argument); + parent.AddChild (ConvertArgument (args[i]), InvocationExpression.Roles.Argument); if (commaLocations != null && i > 0) { int idx = commaLocations.Count - i; if (idx >= 0) - parent.AddChild (new CSharpTokenNode (Convert (commaLocations [idx]), 1), InvocationExpression.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (commaLocations[idx]), 1), InvocationExpression.Roles.Comma); } } if (commaLocations != null && commaLocations.Count > args.Count) - parent.AddChild (new CSharpTokenNode (Convert (commaLocations [0]), 1), InvocationExpression.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (commaLocations[0]), 1), InvocationExpression.Roles.Comma); } - + public override object Visit (Invocation invocationExpression) { var result = new InvocationExpression (); var location = LocationsBag.GetLocations (invocationExpression); result.AddChild ((Expression)invocationExpression.Expression.Accept (this), InvocationExpression.Roles.TargetExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), InvocationExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), InvocationExpression.Roles.LPar); AddArguments (result, location, invocationExpression.Arguments); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), InvocationExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), InvocationExpression.Roles.RPar); return result; } - + public override object Visit (New newExpression) { var result = new ObjectCreateExpression (); @@ -2221,18 +2288,20 @@ namespace ICSharpCode.NRefactory.CSharp if (newExpression.TypeRequested != null) result.AddChild (ConvertToType (newExpression.TypeRequested), ObjectCreateExpression.Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ObjectCreateExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ObjectCreateExpression.Roles.LPar); AddArguments (result, location, newExpression.Arguments); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ObjectCreateExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar); return result; } - + public override object Visit (NewAnonymousType newAnonymousType) { var result = new AnonymousTypeCreateExpression (); + if (newAnonymousType.Parameters == null) + return result; foreach (var par in newAnonymousType.Parameters) { var location = LocationsBag.GetLocations (par); @@ -2240,15 +2309,16 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression); } else { var namedArgument = new NamedArgumentExpression (); - namedArgument.AddChild (new Identifier (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier); - namedArgument.AddChild (new CSharpTokenNode (Convert (location [0]), 1), AnonymousTypeCreateExpression.Roles.Assign); + namedArgument.AddChild (Identifier.Create (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier); + namedArgument.AddChild (new CSharpTokenNode (Convert (location[0]), 1), AnonymousTypeCreateExpression.Roles.Assign); namedArgument.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression); result.AddChild (namedArgument, AnonymousTypeCreateExpression.Roles.Expression); } } return result; } - + + public override object Visit (NewInitialize newInitializeExpression) { var result = new ObjectCreateExpression (); @@ -2259,14 +2329,15 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (newInitializeExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ObjectCreateExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ObjectCreateExpression.Roles.LPar); AddArguments (result, location, newInitializeExpression.Arguments); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ObjectCreateExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar); return result; } - + + public override object Visit (ArrayCreation arrayCreationExpression) { var result = new ArrayCreateExpression (); @@ -2275,11 +2346,11 @@ namespace ICSharpCode.NRefactory.CSharp if (arrayCreationExpression.NewType != null) result.AddChild (ConvertToType (arrayCreationExpression.NewType), ArrayCreateExpression.Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ArrayCreateExpression.Roles.LBracket); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayCreateExpression.Roles.LBracket); if (arrayCreationExpression.Arguments != null) { var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments); - for (int i = 0; i < arrayCreationExpression.Arguments.Count; i++) { - result.AddChild ((Expression)arrayCreationExpression.Arguments [i].Accept (this), ArrayCreateExpression.Roles.Argument); + for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) { + result.AddChild ((Expression)arrayCreationExpression.Arguments[i].Accept (this), ArrayCreateExpression.Roles.Argument); if (commaLocations != null && i > 0) result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), ArrayCreateExpression.Roles.Comma); } @@ -2290,42 +2361,42 @@ namespace ICSharpCode.NRefactory.CSharp var loc = LocationsBag.GetLocations (next); spec.AddChild (new CSharpTokenNode (Convert (next.Location), 1), ArraySpecifier.Roles.LBracket); if (loc != null) - result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), ArraySpecifier.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), ArraySpecifier.Roles.RBracket); result.AddChild (spec, ArrayCreateExpression.AdditionalArraySpecifierRole); next = next.Next; } if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ArrayCreateExpression.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayCreateExpression.Roles.RBracket); if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) { var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers); - ArrayInitializerExpression initializer = new ArrayInitializerExpression (); + ArrayInitializerExpression initializer = new ArrayInitializerExpression(); initializer.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayCreateExpression.Roles.LBrace); var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements); for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) { - initializer.AddChild ((Expression)arrayCreationExpression.Initializers [i].Accept (this), ArrayInitializerExpression.Roles.Expression); + initializer.AddChild ((Expression)arrayCreationExpression.Initializers[i].Accept (this), ArrayInitializerExpression.Roles.Expression); if (commaLocations != null && i > 0) { initializer.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma); } } if (initLocation != null) - initializer.AddChild (new CSharpTokenNode (Convert (initLocation [initLocation.Count - 1]), 1), ArrayCreateExpression.Roles.RBrace); + initializer.AddChild (new CSharpTokenNode (Convert (initLocation[initLocation.Count - 1]), 1), ArrayCreateExpression.Roles.RBrace); result.AddChild (initializer, ArrayCreateExpression.InitializerRole); } return result; } - + public override object Visit (This thisExpression) { var result = new ThisReferenceExpression (); result.Location = Convert (thisExpression.Location); return result; } - + public override object Visit (ArglistAccess argListAccessExpression) { var result = new UndocumentedExpression () { @@ -2334,7 +2405,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (argListAccessExpression.Location), "__arglist".Length), UndocumentedExpression.Roles.Keyword); return result; } - + #region Undocumented expressions public override object Visit (Arglist argListExpression) { @@ -2342,52 +2413,52 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (argListExpression.Location), "__arglist".Length), UndocumentedExpression.Roles.Keyword); var location = LocationsBag.GetLocations (argListExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UndocumentedExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), UndocumentedExpression.Roles.LPar); AddArguments (result, location, argListExpression.Arguments); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); return result; } - + public override object Visit (MakeRefExpr makeRefExpr) { var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.RefValue }; result.AddChild (new CSharpTokenNode (Convert (makeRefExpr.Location), "__makeref".Length), UndocumentedExpression.Roles.Keyword); var location = LocationsBag.GetLocations (makeRefExpr); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UndocumentedExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), UndocumentedExpression.Roles.LPar); if (makeRefExpr.Expr != null) result.AddChild ((Expression)makeRefExpr.Expr.Accept (this), UndocumentedExpression.Roles.Argument); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); return result; } - + public override object Visit (RefTypeExpr refTypeExpr) { var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.RefValue }; result.AddChild (new CSharpTokenNode (Convert (refTypeExpr.Location), "__reftype".Length), UndocumentedExpression.Roles.Keyword); var location = LocationsBag.GetLocations (refTypeExpr); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UndocumentedExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), UndocumentedExpression.Roles.LPar); if (refTypeExpr.Expr != null) result.AddChild ((Expression)refTypeExpr.Expr.Accept (this), UndocumentedExpression.Roles.Argument); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); return result; } - + public override object Visit (RefValueExpr refValueExpr) { var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.RefValue }; result.AddChild (new CSharpTokenNode (Convert (refValueExpr.Location), "__refvalue".Length), UndocumentedExpression.Roles.Keyword); var location = LocationsBag.GetLocations (refValueExpr); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UndocumentedExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), UndocumentedExpression.Roles.LPar); if (refValueExpr.Expr != null) @@ -2397,10 +2468,9 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)refValueExpr.FullNamedExpression.Accept (this), UndocumentedExpression.Roles.Argument); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); return result; } - #endregion public override object Visit (TypeOf typeOfExpression) @@ -2408,51 +2478,51 @@ namespace ICSharpCode.NRefactory.CSharp var result = new TypeOfExpression (); var location = LocationsBag.GetLocations (typeOfExpression); result.AddChild (new CSharpTokenNode (Convert (typeOfExpression.Location), "typeof".Length), TypeOfExpression.Roles.Keyword); - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); result.AddChild (ConvertToType (typeOfExpression.TypeExpression), TypeOfExpression.Roles.Type); - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); return result; } - + public override object Visit (SizeOf sizeOfExpression) { var result = new SizeOfExpression (); var location = LocationsBag.GetLocations (sizeOfExpression); result.AddChild (new CSharpTokenNode (Convert (sizeOfExpression.Location), "sizeof".Length), TypeOfExpression.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); result.AddChild (ConvertToType (sizeOfExpression.QueriedType), TypeOfExpression.Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); return result; } - + public override object Visit (CheckedExpr checkedExpression) { var result = new CheckedExpression (); var location = LocationsBag.GetLocations (checkedExpression); result.AddChild (new CSharpTokenNode (Convert (checkedExpression.Location), "checked".Length), TypeOfExpression.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); result.AddChild ((Expression)checkedExpression.Expr.Accept (this), TypeOfExpression.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); return result; } - + public override object Visit (UnCheckedExpr uncheckedExpression) { var result = new UncheckedExpression (); var location = LocationsBag.GetLocations (uncheckedExpression); result.AddChild (new CSharpTokenNode (Convert (uncheckedExpression.Location), "unchecked".Length), TypeOfExpression.Roles.Keyword); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); result.AddChild ((Expression)uncheckedExpression.Expr.Accept (this), TypeOfExpression.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); return result; } - + public override object Visit (ElementAccess elementAccessExpression) { IndexerExpression result = new IndexerExpression (); @@ -2462,33 +2532,33 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (elementAccessExpression.Location), 1), TypeOfExpression.Roles.LBracket); AddArguments (result, location, elementAccessExpression.Arguments); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), TypeOfExpression.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.RBracket); return result; } - + public override object Visit (BaseThis baseAccessExpression) { var result = new BaseReferenceExpression (); result.Location = Convert (baseAccessExpression.Location); return result; } - + public override object Visit (StackAlloc stackAllocExpression) { var result = new StackAllocExpression (); var location = LocationsBag.GetLocations (stackAllocExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "stackalloc".Length), StackAllocExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "stackalloc".Length), StackAllocExpression.Roles.Keyword); result.AddChild (ConvertToType (stackAllocExpression.TypeExpression), StackAllocExpression.Roles.Type); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), StackAllocExpression.Roles.LBracket); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), StackAllocExpression.Roles.LBracket); result.AddChild ((Expression)stackAllocExpression.CountExpression.Accept (this), StackAllocExpression.Roles.Expression); if (location != null && location.Count > 2) - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), StackAllocExpression.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), StackAllocExpression.Roles.RBracket); return result; } - + public override object Visit (SimpleAssign simpleAssign) { var result = new AssignmentExpression (); @@ -2502,44 +2572,44 @@ namespace ICSharpCode.NRefactory.CSharp } return result; } - + public override object Visit (CompoundAssign compoundAssign) { var result = new AssignmentExpression (); int opLength = 2; switch (compoundAssign.Op) { - case Binary.Operator.Multiply: - result.Operator = AssignmentOperatorType.Multiply; - break; - case Binary.Operator.Division: - result.Operator = AssignmentOperatorType.Divide; - break; - case Binary.Operator.Modulus: - result.Operator = AssignmentOperatorType.Modulus; - break; - case Binary.Operator.Addition: - result.Operator = AssignmentOperatorType.Add; - break; - case Binary.Operator.Subtraction: - result.Operator = AssignmentOperatorType.Subtract; - break; - case Binary.Operator.LeftShift: - result.Operator = AssignmentOperatorType.ShiftLeft; - opLength = 3; - break; - case Binary.Operator.RightShift: - result.Operator = AssignmentOperatorType.ShiftRight; - opLength = 3; - break; - case Binary.Operator.BitwiseAnd: - result.Operator = AssignmentOperatorType.BitwiseAnd; - break; - case Binary.Operator.BitwiseOr: - result.Operator = AssignmentOperatorType.BitwiseOr; - break; - case Binary.Operator.ExclusiveOr: - result.Operator = AssignmentOperatorType.ExclusiveOr; - break; + case Binary.Operator.Multiply: + result.Operator = AssignmentOperatorType.Multiply; + break; + case Binary.Operator.Division: + result.Operator = AssignmentOperatorType.Divide; + break; + case Binary.Operator.Modulus: + result.Operator = AssignmentOperatorType.Modulus; + break; + case Binary.Operator.Addition: + result.Operator = AssignmentOperatorType.Add; + break; + case Binary.Operator.Subtraction: + result.Operator = AssignmentOperatorType.Subtract; + break; + case Binary.Operator.LeftShift: + result.Operator = AssignmentOperatorType.ShiftLeft; + opLength = 3; + break; + case Binary.Operator.RightShift: + result.Operator = AssignmentOperatorType.ShiftRight; + opLength = 3; + break; + case Binary.Operator.BitwiseAnd: + result.Operator = AssignmentOperatorType.BitwiseAnd; + break; + case Binary.Operator.BitwiseOr: + result.Operator = AssignmentOperatorType.BitwiseOr; + break; + case Binary.Operator.ExclusiveOr: + result.Operator = AssignmentOperatorType.ExclusiveOr; + break; } result.AddChild ((Expression)compoundAssign.Target.Accept (this), AssignmentExpression.LeftRole); @@ -2547,19 +2617,19 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)compoundAssign.Source.Accept (this), AssignmentExpression.RightRole); return result; } - + public override object Visit (Mono.CSharp.AnonymousMethodExpression anonymousMethodExpression) { var result = new AnonymousMethodExpression (); var location = LocationsBag.GetLocations (anonymousMethodExpression); if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location [0]), "delegate".Length), AnonymousMethodExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), AnonymousMethodExpression.Roles.Keyword); if (location.Count > 1) { result.HasParameterList = true; - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), AnonymousMethodExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), AnonymousMethodExpression.Roles.LPar); AddParameter (result, anonymousMethodExpression.Parameters); - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), AnonymousMethodExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), AnonymousMethodExpression.Roles.RPar); } } result.AddChild ((BlockStatement)anonymousMethodExpression.Block.Accept (this), AnonymousMethodExpression.Roles.Body); @@ -2592,12 +2662,12 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - + public override object Visit (ConstInitializer constInitializer) { return constInitializer.Expr.Accept (this); } - + public override object Visit (ArrayInitializer arrayInitializer) { var result = new ArrayInitializerExpression (); @@ -2605,19 +2675,19 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (arrayInitializer.Location), "{".Length), ArrayInitializerExpression.Roles.LBrace); var commaLocations = LocationsBag.GetLocations (arrayInitializer.Elements); for (int i = 0; i < arrayInitializer.Count; i++) { - result.AddChild ((Expression)arrayInitializer [i].Accept (this), ArrayInitializerExpression.Roles.Expression); + result.AddChild ((Expression)arrayInitializer[i].Accept (this), ArrayInitializerExpression.Roles.Expression); if (commaLocations != null && i < commaLocations.Count) - result.AddChild (new CSharpTokenNode (Convert (commaLocations [i]), ",".Length), ArrayInitializerExpression.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (commaLocations[i]), ",".Length), ArrayInitializerExpression.Roles.Comma); } if (location != null) { if (location.Count == 2) // optional comma - result.AddChild (new CSharpTokenNode (Convert (location [1]), ",".Length), ArrayInitializerExpression.Roles.Comma); - result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1]), "}".Length), ArrayInitializerExpression.Roles.RBrace); + result.AddChild (new CSharpTokenNode (Convert (location[1]), ",".Length), ArrayInitializerExpression.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), "}".Length), ArrayInitializerExpression.Roles.RBrace); } return result; } - + #endregion #region LINQ expressions @@ -2628,13 +2698,12 @@ namespace ICSharpCode.NRefactory.CSharp var currentClause = queryExpression.next; while (currentClause != null) { - Console.WriteLine (currentClause); QueryClause clause = (QueryClause)currentClause.Accept (this); if (clause is QueryContinuationClause) { // insert preceding query at beginning of QueryContinuationClause - clause.InsertChildAfter (null, result, QueryContinuationClause.PrecedingQueryRole); + clause.InsertChildAfter(null, result, QueryContinuationClause.PrecedingQueryRole); // create a new QueryExpression for the remaining query - result = new QueryExpression (); + result = new QueryExpression(); } result.AddChild (clause, QueryExpression.ClauseRole); currentClause = currentClause.next; @@ -2642,13 +2711,13 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - + public override object Visit (Mono.CSharp.Linq.QueryStartClause queryStart) { if (queryStart.Expr == null) { var intoClause = new QueryContinuationClause (); intoClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "into".Length), QueryContinuationClause.IntoKeywordRole); - intoClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), QueryContinuationClause.Roles.Identifier); + intoClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryContinuationClause.Roles.Identifier); return intoClause; } @@ -2660,14 +2729,14 @@ namespace ICSharpCode.NRefactory.CSharp if (queryStart.IdentifierType != null) fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type); - fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); + fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); if (location != null) - fromClause.AddChild (new CSharpTokenNode (Convert (location [0]), "in".Length), QueryFromClause.InKeywordRole); + fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole); fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression); return fromClause; } - + public override object Visit (Mono.CSharp.Linq.SelectMany queryStart) { var fromClause = new QueryFromClause (); @@ -2678,14 +2747,14 @@ namespace ICSharpCode.NRefactory.CSharp if (queryStart.IdentifierType != null) fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type); - fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); + fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); if (location != null) - fromClause.AddChild (new CSharpTokenNode (Convert (location [0]), "in".Length), QueryFromClause.InKeywordRole); + fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole); fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression); return fromClause; } - + public override object Visit (Mono.CSharp.Linq.Select sel) { var result = new QuerySelectClause (); @@ -2693,7 +2762,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)sel.Expr.Accept (this), QueryWhereClause.Roles.Expression); return result; } - + public override object Visit (Mono.CSharp.Linq.GroupBy groupBy) { var result = new QueryGroupClause (); @@ -2701,87 +2770,87 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (groupBy.Location), "group".Length), QueryGroupClause.GroupKeywordRole); result.AddChild ((Expression)groupBy.ElementSelector.Accept (this), QueryGroupClause.KeyRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "by".Length), QueryGroupClause.ByKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "by".Length), QueryGroupClause.ByKeywordRole); result.AddChild ((Expression)groupBy.Expr.Accept (this), QueryGroupClause.ProjectionRole); return result; } - + public override object Visit (Mono.CSharp.Linq.Let l) { var result = new QueryLetClause (); var location = LocationsBag.GetLocations (l); result.AddChild (new CSharpTokenNode (Convert (l.Location), "let".Length), QueryLetClause.Roles.Keyword); - result.AddChild (new Identifier (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Identifier.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), QueryLetClause.Roles.Assign); + result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), QueryLetClause.Roles.Assign); result.AddChild ((Expression)l.Expr.Accept (this), QueryLetClause.Roles.Expression); return result; } - + public override object Visit (Mono.CSharp.Linq.Where w) { var result = new QueryWhereClause (); var location = LocationsBag.GetLocations (w); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "where".Length), QueryWhereClause.Roles.Keyword); + 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) { var result = new QueryJoinClause (); var location = LocationsBag.GetLocations (join); result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); - result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "in".Length), QueryJoinClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), "on".Length), QueryJoinClause.OnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); // TODO: on expression if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); // TODO: equals expression return result; } - + public override object Visit (Mono.CSharp.Linq.GroupJoin join) { var result = new QueryJoinClause (); var location = LocationsBag.GetLocations (join); result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); - result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), "in".Length), QueryJoinClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [1]), "on".Length), QueryJoinClause.OnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); // TODO: on expression if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); // TODO: equals expression if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [3]), "into".Length), QueryJoinClause.IntoKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location[3]), "into".Length), QueryJoinClause.IntoKeywordRole); - result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); return result; } - + public override object Visit (Mono.CSharp.Linq.OrderByAscending orderByAscending) { var result = new QueryOrderClause (); @@ -2792,12 +2861,12 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (orderByAscending); if (location != null) { ordering.Direction = QueryOrderingDirection.Ascending; - ordering.AddChild (new CSharpTokenNode (Convert (location [0]), "ascending".Length), QueryWhereClause.Roles.Keyword); + ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; } - + public override object Visit (Mono.CSharp.Linq.OrderByDescending orderByDescending) { var result = new QueryOrderClause (); @@ -2808,12 +2877,12 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (orderByDescending); if (location != null) { ordering.Direction = QueryOrderingDirection.Descending; - ordering.AddChild (new CSharpTokenNode (Convert (location [0]), "ascending".Length), QueryWhereClause.Roles.Keyword); + ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; - } - + } + public override object Visit (Mono.CSharp.Linq.ThenByAscending thenByAscending) { var result = new QueryOrderClause (); @@ -2824,12 +2893,12 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (thenByAscending); if (location != null) { ordering.Direction = QueryOrderingDirection.Ascending; - ordering.AddChild (new CSharpTokenNode (Convert (location [0]), "ascending".Length), QueryWhereClause.Roles.Keyword); + ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; } - + public override object Visit (Mono.CSharp.Linq.ThenByDescending thenByDescending) { var result = new QueryOrderClause (); @@ -2840,57 +2909,87 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (thenByDescending); if (location != null) { ordering.Direction = QueryOrderingDirection.Descending; - ordering.AddChild (new CSharpTokenNode (Convert (location [0]), "ascending".Length), QueryWhereClause.Roles.Keyword); + ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; } #endregion } - - public static void InsertComment (AstNode node, Comment comment) + + public CSharpParser () { - if (node.EndLocation < comment.StartLocation) { - node.AddChild (comment, AstNode.Roles.Comment); - return; - } - - foreach (var child in node.Children) { - if (child.StartLocation < comment.StartLocation && comment.StartLocation < child.EndLocation) { - InsertComment (child, comment); - return; - } - if (comment.StartLocation < child.StartLocation) { - node.InsertChildBefore (child, comment, AstNode.Roles.Comment); - return; - } - } - - node.AddChild (comment, AstNode.Roles.Comment); + CompilerArguments = new string[] { "-v", "-unsafe"}; } - + + public CSharpParser (string[] args) + { + CompilerArguments = args; + } + + static AstNode GetOuterLeft (AstNode node) + { + var outerLeft = node; + while (outerLeft.FirstChild != null) + outerLeft = outerLeft.FirstChild; + return outerLeft; + } + + static AstNode NextLeaf (AstNode node) + { + if (node == null) + return null; + var next = node.NextSibling; + if (next == null) + return node.Parent; + return GetOuterLeft(next); + } + static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor) { + var leaf = GetOuterLeft(conversionVisitor.Unit); + 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 domComment = new Comment (type, start, end); - domComment.StartsLine = comment.StartsLine; - domComment.Content = comment.Content; - InsertComment (conversionVisitor.Unit, domComment); + if (comment == null) + continue; + if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation)) + continue; + 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; + + while (true) { + var nextLeaf = NextLeaf(leaf); + // instert comment at the end + if (nextLeaf == null) { + var node = leaf.Parent ?? conversionVisitor.Unit; + node.AddChild(domComment, AstNode.Roles.Comment); + leaf = domComment; + break; + } + + // comment is between 2 nodes + if (leaf.EndLocation <= domComment.StartLocation && domComment.StartLocation <= nextLeaf.StartLocation) { + var node = leaf.Parent ?? conversionVisitor.Unit; + node.InsertChildAfter(leaf, domComment, AstNode.Roles.Comment); + leaf = domComment; + break; + } + leaf = nextLeaf; } } } - - internal static CompilationUnit Parse (CompilerCompilationUnit top) + + internal static CompilationUnit Parse (bool convertTypeSystemMode, CompilerCompilationUnit top) { if (top == null) return null; - CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag); + CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (convertTypeSystemMode, top.LocationsBag); + conversionVisitor.AddAttributeSection (conversionVisitor.Unit, top.ModuleCompiled); top.UsingsBag.Global.Accept (conversionVisitor); InsertComments (top, conversionVisitor); return conversionVisitor.Unit; @@ -2898,37 +2997,42 @@ namespace ICSharpCode.NRefactory.CSharp public class ErrorReportPrinter : ReportPrinter { -// public readonly List Errors = new List (); + readonly string fileName; + public readonly List Errors = new List (); + + public ErrorReportPrinter (string fileName) + { + this.fileName = fileName; + } public override void Print (AbstractMessage msg) { - Console.WriteLine (msg.MessageType + " (" + msg.Location + ")" + ": " + msg.Text); base.Print (msg); -// Error newError = new Error (msg.IsWarning ? ErrorType.Warning : ErrorType.Error, msg.Location.Row, msg.Location.Column, msg.Text); -// Errors.Add (newError); + var newError = new Error (msg.IsWarning ? ErrorType.Warning : ErrorType.Error, msg.Text, new DomRegion (fileName, msg.Location.Row, msg.Location.Column)); + Errors.Add (newError); } } - ErrorReportPrinter errorReportPrinter = new ErrorReportPrinter (); - + ErrorReportPrinter errorReportPrinter = new ErrorReportPrinter (null); + 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) + + public CompilationUnit Parse (TextReader reader, int line = 0) { // TODO: can we optimize this to avoid the text->stream->text roundtrip? using (MemoryStream stream = new MemoryStream ()) { @@ -2939,57 +3043,98 @@ namespace ICSharpCode.NRefactory.CSharp w.Write (buffer, 0, read); w.Flush (); // we can't close the StreamWriter because that would also close the MemoryStream stream.Position = 0; - return Parse (stream); + return Parse (stream, line); } } - public CompilationUnit Parse (Stream stream) + public static void AdjustLineLocations (AstNode node, int line) + { + if (node is IRelocatable) { + ((IRelocatable)node).SetStartLocation (new AstLocation (node.StartLocation.Line + line, node.StartLocation.Column)); + } + foreach (var child in node.Children) { + AdjustLineLocations (child, line); + } + } + + public CompilationUnit Parse (CompilerCompilationUnit top, int line) + { + if (top == null) + return null; + CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (GenerateTypeSystemMode, top.LocationsBag); + conversionVisitor.AddAttributeSection (conversionVisitor.Unit, top.ModuleCompiled); + top.UsingsBag.Global.Accept (conversionVisitor); + InsertComments (top, conversionVisitor); + if (CompilationUnitCallback != null) + CompilationUnitCallback (top); + if (line != 0) + AdjustLineLocations (conversionVisitor.Unit, line); + if (top.LastYYValue is Mono.CSharp.Expression) + conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept (conversionVisitor) as AstNode; + return conversionVisitor.Unit; + } + + public string[] CompilerArguments { + get; + private set; + } + + public Action CompilationUnitCallback { + get; + set; + } + + public bool GenerateTypeSystemMode { + get; + set; + } + + public CompilationUnit Parse (Stream stream, int line = 0) { lock (CompilerCallableEntryPoint.parseLock) { - CompilerCompilationUnit top = CompilerCallableEntryPoint.ParseFile (new string[] { "-v", "-unsafe"}, stream, "parsed.cs", errorReportPrinter); - if (top == null) - return null; - CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag); - top.UsingsBag.Global.Accept (conversionVisitor); - InsertComments (top, conversionVisitor); - return conversionVisitor.Unit; + errorReportPrinter = new ErrorReportPrinter (""); + CompilerCompilationUnit top = CompilerCallableEntryPoint.ParseFile (CompilerArguments, stream, "parsed.cs", errorReportPrinter); + var unit = Parse (top, line); + unit.Errors.AddRange (errorReportPrinter.Errors); + return unit; } } - public IEnumerable ParseTypeMembers (TextReader reader) + public IEnumerable ParseTypeMembers (TextReader reader, int lineModifier = 0) { - string code = "unsafe partial class MyClass { " + reader.ReadToEnd () + "}"; - var cu = Parse (new StringReader (code)); + string code = "unsafe partial class MyClass { " + Environment.NewLine + reader.ReadToEnd () + "}"; + var cu = Parse (new StringReader (code), -1 + lineModifier); + if (cu == null) + return Enumerable.Empty (); var td = cu.Children.FirstOrDefault () as TypeDeclaration; if (td != null) return td.Members; return Enumerable.Empty (); } - - public IEnumerable ParseStatements (TextReader reader) + + public IEnumerable ParseStatements(TextReader reader, int lineModifier = 0) { - string code = "void M() { " + reader.ReadToEnd () + "}"; - var members = ParseTypeMembers (new StringReader (code)); - var method = members.FirstOrDefault () as MethodDeclaration; + string code = "void M() { " + Environment.NewLine + reader.ReadToEnd() + "}"; + var members = ParseTypeMembers(new StringReader(code), lineModifier - 1); + var method = members.FirstOrDefault() as MethodDeclaration; if (method != null && method.Body != null) return method.Body.Statements; return Enumerable.Empty (); } - - public AstType ParseTypeReference (TextReader reader) + + public AstType ParseTypeReference(TextReader reader) { - string code = reader.ReadToEnd () + " a;"; - var members = ParseTypeMembers (new StringReader (code)); - var field = members.FirstOrDefault () as FieldDeclaration; - Console.WriteLine ("field : " + field.ReturnType); + string code = reader.ReadToEnd() + " a;"; + var members = ParseTypeMembers(new StringReader(code)); + var field = members.FirstOrDefault() as FieldDeclaration; if (field != null) return field.ReturnType; return AstType.Null; } - - public AstNode ParseExpression (TextReader reader) + + public AstNode ParseExpression(TextReader reader) { - var es = ParseStatements (new StringReader ("tmp = " + reader.ReadToEnd () + ";")).FirstOrDefault () as ExpressionStatement; + var es = ParseStatements(new StringReader("tmp = " + Environment.NewLine + reader.ReadToEnd() + ";"), -1).FirstOrDefault() as ExpressionStatement; if (es != null) { AssignmentExpression ae = es.Expression as AssignmentExpression; if (ae != null) @@ -3001,10 +3146,10 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Parses a file snippet; guessing what the code snippet represents (compilation unit, type members, block, type reference, expression). /// - public AstNode ParseSnippet (TextReader reader) + public AstNode ParseSnippet(TextReader reader) { // TODO: add support for parsing a part of a file - throw new NotImplementedException (); + throw new NotImplementedException(); } } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs b/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs index 0fe039f8c..954518842 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs @@ -12,13 +12,14 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Represents a file that was parsed and converted for the type system. /// - public sealed class ParsedFile : AbstractFreezable + public sealed class ParsedFile : AbstractFreezable, IParsedFile { readonly string fileName; readonly UsingScope rootUsingScope; IList topLevelTypeDefinitions = new List(); IList assemblyAttributes = new List(); IList usingScopes = new List(); + IList errors = new List (); protected override void FreezeInternal() { @@ -43,14 +44,30 @@ namespace ICSharpCode.NRefactory.CSharp get { return fileName; } } + DateTime parseTime = DateTime.Now; + public DateTime ParseTime { + get { + return parseTime; + } + } + public UsingScope RootUsingScope { get { return rootUsingScope; } } + public IList Errors { + get { return errors; } + internal set { errors = (List)value; } + } + public IList UsingScopes { get { return usingScopes; } } + public IProjectContent ProjectContent { + get { return rootUsingScope.ProjectContent; } + } + public IList TopLevelTypeDefinitions { get { return topLevelTypeDefinitions; } } @@ -70,9 +87,37 @@ namespace ICSharpCode.NRefactory.CSharp public ITypeDefinition GetTopLevelTypeDefinition(AstLocation location) { - foreach (ITypeDefinition typeDef in topLevelTypeDefinitions) { - if (typeDef.Region.IsInside(location.Line, location.Column)) - return typeDef; + return FindEntity(topLevelTypeDefinitions, location); + } + + public ITypeDefinition GetTypeDefinition(AstLocation location) + { + ITypeDefinition parent = null; + ITypeDefinition type = GetTopLevelTypeDefinition(location); + while (type != null) { + parent = type; + type = FindEntity(parent.NestedTypes, location); + } + return parent; + } + + public IMember GetMember(AstLocation location) + { + ITypeDefinition type = GetTypeDefinition(location); + if (type == null) + return null; + return FindEntity(type.Methods, location) + ?? FindEntity(type.Fields, location) + ?? FindEntity(type.Properties, location) + ?? (IMember)FindEntity(type.Events, location); + } + + static T FindEntity(IList list, AstLocation location) where T : class, IEntity + { + // This could be improved using a binary search + foreach (T entity in list) { + if (entity.Region.IsInside(location.Line, location.Column)) + return entity; } return null; } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs index 66865d53c..ccd273ba5 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs @@ -80,6 +80,14 @@ namespace ICSharpCode.NRefactory.CSharp node.GetChildByRole(AstNode.Roles.RBrace).EndLocation); } + #region Compilation Unit + public override IEntity VisitCompilationUnit (CompilationUnit unit, object data) + { + parsedFile.Errors = unit.Errors; + return base.VisitCompilationUnit (unit, data); + } + #endregion + #region Using Declarations public override IEntity VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, object data) { @@ -126,7 +134,8 @@ namespace ICSharpCode.NRefactory.CSharp DefaultTypeDefinition newType; if (currentTypeDefinition != null) { newType = new DefaultTypeDefinition(currentTypeDefinition, name); - currentTypeDefinition.InnerClasses.Add(newType); + newType.TypeParameters.AddRange(currentTypeDefinition.TypeParameters); + currentTypeDefinition.NestedTypes.Add(newType); } else { newType = new DefaultTypeDefinition(usingScope.ProjectContent, usingScope.NamespaceName, name); parsedFile.TopLevelTypeDefinitions.Add(newType); @@ -149,7 +158,7 @@ namespace ICSharpCode.NRefactory.CSharp else if (td.ClassType == ClassType.Enum || td.ClassType == ClassType.Struct) td.IsSealed = true; // enums/structs are implicitly sealed - ConvertTypeParameters(td.TypeParameters, typeDeclaration.TypeParameters, typeDeclaration.Constraints); + ConvertTypeParameters(td.TypeParameters, typeDeclaration.TypeParameters, typeDeclaration.Constraints, EntityType.TypeDefinition); foreach (AstType baseType in typeDeclaration.BaseTypes) { td.BaseTypes.Add(ConvertType(baseType)); @@ -175,7 +184,7 @@ namespace ICSharpCode.NRefactory.CSharp ApplyModifiers(td, delegateDeclaration.Modifiers); td.IsSealed = true; // delegates are implicitly sealed - ConvertTypeParameters(td.TypeParameters, delegateDeclaration.TypeParameters, delegateDeclaration.Constraints); + ConvertTypeParameters(td.TypeParameters, delegateDeclaration.TypeParameters, delegateDeclaration.Constraints, EntityType.TypeDefinition); ITypeReference returnType = ConvertType(delegateDeclaration.ReturnType); List parameters = new List(); @@ -263,7 +272,7 @@ namespace ICSharpCode.NRefactory.CSharp #region Fields public override IEntity VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { - bool isSingleField = fieldDeclaration.Variables.Count() == 1; + bool isSingleField = fieldDeclaration.Variables.Count == 1; Modifiers modifiers = fieldDeclaration.Modifiers; DefaultField field = null; foreach (VariableInitializer vi in fieldDeclaration.Variables) { @@ -303,7 +312,12 @@ namespace ICSharpCode.NRefactory.CSharp if (!enumMemberDeclaration.Initializer.IsNull) { field.ConstantValue = ConvertConstantValue(currentTypeDefinition, enumMemberDeclaration.Initializer); } else { - throw new NotImplementedException(); + IField prevField = currentTypeDefinition.Fields.LastOrDefault(); + if (prevField == null || prevField.ConstantValue == null) { + field.ConstantValue = ConvertConstantValue(currentTypeDefinition, new PrimitiveExpression(0)); + } else { + field.ConstantValue = new IncrementConstantValue(prevField.ConstantValue); + } } currentTypeDefinition.Fields.Add(field); @@ -320,7 +334,7 @@ namespace ICSharpCode.NRefactory.CSharp m.BodyRegion = MakeRegion(methodDeclaration.Body); - ConvertTypeParameters(m.TypeParameters, methodDeclaration.TypeParameters, methodDeclaration.Constraints); + ConvertTypeParameters(m.TypeParameters, methodDeclaration.TypeParameters, methodDeclaration.Constraints, EntityType.Method); m.ReturnType = ConvertType(methodDeclaration.ReturnType); ConvertAttributes(m.Attributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget != "return")); ConvertAttributes(m.ReturnTypeAttributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget == "return")); @@ -339,10 +353,41 @@ namespace ICSharpCode.NRefactory.CSharp return m; } - void ConvertTypeParameters(IList output, IEnumerable typeParameters, IEnumerable constraints) - { - if (typeParameters.Any()) - throw new NotImplementedException(); + void ConvertTypeParameters(IList output, AstNodeCollection typeParameters, AstNodeCollection constraints, EntityType ownerType) + { + // output might be non-empty when type parameters were copied from an outer class + int index = output.Count; + List list = new List(); + foreach (TypeParameterDeclaration tpDecl in typeParameters) { + DefaultTypeParameter tp = new DefaultTypeParameter(ownerType, index++, tpDecl.Name); + ConvertAttributes(tp.Attributes, tpDecl.Attributes); + tp.Variance = tpDecl.Variance; + list.Add(tp); + output.Add(tp); // tp must be added to list here so that it can be referenced by constraints + } + foreach (Constraint c in constraints) { + foreach (var tp in list) { + if (tp.Name == c.TypeParameter) { + foreach (AstType type in c.BaseTypes) { + PrimitiveType primType = type as PrimitiveType; + if (primType != null) { + if (primType.Keyword == "new") { + tp.HasDefaultConstructorConstraint = true; + continue; + } else if (primType.Keyword == "class") { + tp.HasReferenceTypeConstraint = true; + continue; + } else if (primType.Keyword == "struct") { + tp.HasValueTypeConstraint = true; + continue; + } + } + tp.Constraints.Add(ConvertType(type)); + } + break; + } + } + } } DefaultExplicitInterfaceImplementation ConvertInterfaceImplementation(AstType interfaceType, string memberName) @@ -459,6 +504,8 @@ namespace ICSharpCode.NRefactory.CSharp IAccessor ConvertAccessor(Accessor accessor, Accessibility defaultAccessibility) { + if (accessor.IsNull) + return null; DefaultAccessor a = new DefaultAccessor(); a.Accessibility = GetAccessibility(accessor.Modifiers) ?? defaultAccessibility; a.Region = MakeRegion(accessor); @@ -476,7 +523,7 @@ namespace ICSharpCode.NRefactory.CSharp #region Events public override IEntity VisitEventDeclaration(EventDeclaration eventDeclaration, object data) { - bool isSingleEvent = eventDeclaration.Variables.Count() == 1; + bool isSingleEvent = eventDeclaration.Variables.Count == 1; Modifiers modifiers = eventDeclaration.Modifiers; DefaultEvent ev = null; foreach (VariableInitializer vi in eventDeclaration.Variables) { @@ -542,6 +589,11 @@ namespace ICSharpCode.NRefactory.CSharp static void ApplyModifiers(TypeSystem.Implementation.AbstractMember m, Modifiers modifiers) { + // members from interfaces are always Public. + if (m.DeclaringTypeDefinition.ClassType == ClassType.Interface) { + m.Accessibility = Accessibility.Public; + return; + } m.Accessibility = GetAccessibility(modifiers) ?? Accessibility.Private; m.IsAbstract = (modifiers & Modifiers.Abstract) != 0; m.IsOverride = (modifiers & Modifiers.Override) != 0; @@ -623,11 +675,11 @@ namespace ICSharpCode.NRefactory.CSharp string name = ((IdentifierExpression)ae.Left).Identifier; if (namedArguments == null) namedArguments = new List>(); - namedArguments.Add(new KeyValuePair(name, ConvertAttributeArgument(nae.Expression))); + namedArguments.Add(new KeyValuePair(name, ConvertAttributeArgument(ae.Right))); } else { if (positionalArguments == null) positionalArguments = new List(); - positionalArguments.Add(ConvertAttributeArgument(nae.Expression)); + positionalArguments.Add(ConvertAttributeArgument(expr)); } } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs index 9bf488ce0..5576bcc5f 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/anonymous.cs @@ -830,15 +830,20 @@ namespace Mono.CSharp { } } - Dictionary compatibles; + readonly Dictionary compatibles; + readonly bool is_async; + public ParametersBlock Block; - public AnonymousMethodExpression (Location loc) + public AnonymousMethodExpression (bool isAsync, Location loc) { + this.is_async = isAsync; this.loc = loc; this.compatibles = new Dictionary (); } + #region Properties + public override string ExprClassName { get { return "anonymous method"; @@ -850,11 +855,21 @@ namespace Mono.CSharp { return Parameters != ParametersCompiled.Undefined; } } - + + public bool IsAsync { + get { + return is_async; + } + } + public ParametersCompiled Parameters { - get { return Block.Parameters; } + get { + return Block.Parameters; + } } + #endregion + // // Returns true if the body of lambda expression can be implicitly // converted to the delegate of type `delegate_type' @@ -1003,9 +1018,16 @@ namespace Mono.CSharp { } using (ec.Set (ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType)) { - am = CompatibleMethodBody (ec, tic, InternalType.Arglist, delegate_type); - if (am != null) - am = am.Compatible (ec); + var body = CompatibleMethodBody (ec, tic, InternalType.Arglist, delegate_type); + if (body != null) { + if (is_async) { + AsyncInitializer.Create (body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent, null, loc); + } + + am = body.Compatible (ec, body, is_async); + } else { + am = null; + } } if (am == null) @@ -1058,7 +1080,7 @@ namespace Mono.CSharp { // lambda, this also means no variable capturing between this // and parent scope // - am = body.Compatible (ec, ec.CurrentAnonymousMethod); + am = body.Compatible (ec, ec.CurrentAnonymousMethod, is_async); // // Quote nested expression tree @@ -1079,6 +1101,10 @@ namespace Mono.CSharp { am = CreateExpressionTree (ec, delegate_type); } } else { + if (is_async) { + AsyncInitializer.Create (body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent, body.ReturnType, loc); + } + am = body.Compatible (ec); } } catch (CompletionResult) { @@ -1204,7 +1230,6 @@ namespace Mono.CSharp { ParametersBlock b = ec.IsInProbingMode ? (ParametersBlock) Block.PerformClone () : Block; return CompatibleMethodFactory (return_type, delegate_type, p, b); - } protected virtual AnonymousMethodBody CompatibleMethodFactory (TypeSpec return_type, TypeSpec delegate_type, ParametersCompiled p, ParametersBlock b) @@ -1228,7 +1253,7 @@ namespace Mono.CSharp { // // Abstract expression for any block which requires variables hoisting // - public abstract class AnonymousExpression : Expression + public abstract class AnonymousExpression : ExpressionStatement { protected class AnonymousMethodMethod : Method { @@ -1320,10 +1345,10 @@ namespace Mono.CSharp { public AnonymousExpression Compatible (ResolveContext ec) { - return Compatible (ec, this); + return Compatible (ec, this, false); } - public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) + public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae, bool isAsync) { if (block.Resolved) return this; @@ -1362,6 +1387,14 @@ namespace Mono.CSharp { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; + + // + // If e is synchronous the inferred return type is T + // If e is asynchronous the inferred return type is Task + // + if (isAsync && ReturnType != null) { + ReturnType = ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType }); + } } if (res && errors != ec.Report.Errors) @@ -1421,7 +1454,15 @@ namespace Mono.CSharp { } public override bool IsIterator { - get { return false; } + get { + return false; + } + } + + public ParametersCompiled Parameters { + get { + return parameters; + } } public TypeInferenceContext ReturnTypeInference { @@ -1629,6 +1670,11 @@ namespace Mono.CSharp { } } + public override void EmitStatement (EmitContext ec) + { + throw new NotImplementedException (); + } + // // Look for the best storey for this anonymous method // diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs index 050644f06..a24606689 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/argument.cs @@ -158,28 +158,18 @@ namespace Mono.CSharp } } - public class NamedArgument : Argument + public class MovableArgument : Argument { - public readonly string Name; - readonly Location loc; LocalTemporary variable; - public NamedArgument (string name, Location loc, Expression expr) - : this (name, loc, expr, AType.None) + public MovableArgument (Argument arg) + : this (arg.Expr, arg.ArgType) { } - public NamedArgument (string name, Location loc, Expression expr, AType modifier) + protected MovableArgument (Expression expr, AType modifier) : base (expr, modifier) { - this.Name = name; - this.loc = loc; - } - - public override Expression CreateExpressionTree (ResolveContext ec) - { - ec.Report.Error (853, loc, "An expression tree cannot contain named argument"); - return base.CreateExpressionTree (ec); } public override void Emit (EmitContext ec) @@ -208,6 +198,30 @@ namespace Mono.CSharp Expr = variable; } + } + + public class NamedArgument : MovableArgument + { + public readonly string Name; + readonly Location loc; + + public NamedArgument (string name, Location loc, Expression expr) + : this (name, loc, expr, AType.None) + { + } + + public NamedArgument (string name, Location loc, Expression expr, AType modifier) + : base (expr, modifier) + { + this.Name = name; + this.loc = loc; + } + + public override Expression CreateExpressionTree (ResolveContext ec) + { + ec.Report.Error (853, loc, "An expression tree cannot contain named argument"); + return base.CreateExpressionTree (ec); + } public Location Location { get { return loc; } @@ -218,24 +232,25 @@ namespace Mono.CSharp { sealed class ArgumentsOrdered : Arguments { - List ordered; + readonly List ordered; public ArgumentsOrdered (Arguments args) : base (args.Count) { AddRange (args); - ordered = new List (); + ordered = new List (); } - public void AddOrdered (NamedArgument na) + public void AddOrdered (MovableArgument arg) { - ordered.Add (na); + ordered.Add (arg); } public override Expression[] Emit (EmitContext ec, bool dup_args) { - foreach (NamedArgument na in ordered) - na.EmitAssign (ec); + foreach (var a in ordered) { + a.EmitAssign (ec); + } return base.Emit (ec, dup_args); } @@ -488,9 +503,24 @@ namespace Mono.CSharp return this; ArgumentsOrdered ra = this as ArgumentsOrdered; - if (ra == null) + if (ra == null) { ra = new ArgumentsOrdered (this); + for (int i = 0; i < args.Count; ++i) { + var la = args [i]; + if (la == a) + break; + + var ma = la as MovableArgument; + if (ma == null) { + ma = new MovableArgument (la); + ra.args[i] = ma; + } + + ra.AddOrdered (ma); + } + } + ra.AddOrdered (a); return ra; } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/async.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/async.cs new file mode 100644 index 000000000..1a1345013 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/async.cs @@ -0,0 +1,614 @@ +// +// async.cs: Asynchronous functions +// +// Author: +// Marek Safar (marek.safar@gmail.com) +// +// Dual licensed under the terms of the MIT X11 or GNU GPL +// +// Copyright 2011 Novell, Inc. +// + +using System; +using System.Collections.Generic; +using System.Linq; +#if STATIC +using IKVM.Reflection.Emit; +#else +using System.Reflection.Emit; +#endif + +namespace Mono.CSharp +{ + class Await : ExpressionStatement + { + Expression expr; + AwaitStatement stmt; + + public Await (Expression expr, Location loc) + { + this.expr = expr; + this.loc = loc; + } + + protected override void CloneTo (CloneContext clonectx, Expression target) + { + var t = (Await) target; + + t.expr = expr.Clone (clonectx); + } + + public override Expression CreateExpressionTree (ResolveContext ec) + { + throw new NotImplementedException ("ET"); + } + + protected override Expression DoResolve (ResolveContext rc) + { + if (rc.HasSet (ResolveContext.Options.FinallyScope)) { + rc.Report.Error (1984, loc, + "The `await' operator cannot be used in the body of a finally clause"); + } + + if (rc.HasSet (ResolveContext.Options.CatchScope)) { + rc.Report.Error (1985, loc, + "The `await' operator cannot be used in the body of a catch clause"); + } + + if (rc.HasSet (ResolveContext.Options.LockScope)) { + rc.Report.Error (1996, loc, + "The `await' operator cannot be used in the body of a lock statement"); + } + + if (rc.HasSet (ResolveContext.Options.ExpressionTreeConversion)) { + rc.Report.Error (1989, loc, "An expression tree cannot contain an await operator"); + return null; + } + + if (rc.IsUnsafe) { + // TODO: New error code + rc.Report.Error (-1900, loc, + "The `await' operator cannot be used in an unsafe context"); + } + + var bc = (BlockContext) rc; + + if (!bc.CurrentBlock.ParametersBlock.IsAsync) { + // TODO: Should check for existence of await type but + // what to do with it + } + + stmt = new AwaitStatement (expr, loc); + if (!stmt.Resolve (bc)) + return null; + + type = stmt.ResultType; + eclass = ExprClass.Variable; + return this; + } + + public override void Emit (EmitContext ec) + { + stmt.EmitPrologue (ec); + stmt.Emit (ec); + } + + public void EmitAssign (EmitContext ec, FieldExpr field) + { + stmt.EmitPrologue (ec); + field.InstanceExpression.Emit (ec); + stmt.Emit (ec); + } + + public override void EmitStatement (EmitContext ec) + { + stmt.EmitStatement (ec); + } + } + + class AwaitStatement : YieldStatement + { + sealed class AwaitableMemberAccess : MemberAccess + { + public AwaitableMemberAccess (Expression expr) + : base (expr, "GetAwaiter") + { + } + + protected override void Error_TypeDoesNotContainDefinition (ResolveContext rc, TypeSpec type, string name) + { + Error_WrongGetAwaiter (rc, loc, type); + } + + protected override void Error_OperatorCannotBeApplied (ResolveContext rc, TypeSpec type) + { + rc.Report.Error (1991, loc, "Cannot await `{0}' expression", type.GetSignatureForError ()); + } + } + + Field awaiter; + PropertyExpr is_completed; + MethodSpec on_completed; + MethodSpec get_result; + TypeSpec type; + + public AwaitStatement (Expression expr, Location loc) + : base (expr, loc) + { + } + + #region Properties + + public TypeSpec Type { + get { + return type; + } + } + + public TypeSpec ResultType { + get { + return get_result.ReturnType; + } + } + + #endregion + + protected override void DoEmit (EmitContext ec) + { + var fe_awaiter = new FieldExpr (awaiter, loc); + fe_awaiter.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); + + // + // result = awaiter.GetResult (); + // + var mg_result = MethodGroupExpr.CreatePredefined (get_result, fe_awaiter.Type, loc); + mg_result.InstanceExpression = fe_awaiter; + + mg_result.EmitCall (ec, new Arguments (0)); + } + + public void EmitPrologue (EmitContext ec) + { + var fe_awaiter = new FieldExpr (awaiter, loc); + fe_awaiter.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); + + // + // awaiter = expr.GetAwaiter (); + // + fe_awaiter.EmitAssign (ec, expr, false, false); + + is_completed.InstanceExpression = fe_awaiter; + is_completed.EmitBranchable (ec, resume_point, true); + + var mg_completed = MethodGroupExpr.CreatePredefined (on_completed, fe_awaiter.Type, loc); + mg_completed.InstanceExpression = fe_awaiter; + + var args = new Arguments (1); + var storey = (AsyncTaskStorey) machine_initializer.Storey; + var fe_cont = new FieldExpr (storey.Continuation, loc); + fe_cont.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); + + args.Add (new Argument (fe_cont)); + + // + // awaiter.OnCompleted (continuation); + // + mg_completed.EmitCall (ec, args); + + base.DoEmit (ec); + } + + public void EmitStatement (EmitContext ec) + { + EmitPrologue (ec); + Emit (ec); + + if (ResultType.Kind != MemberKind.Void) { + var storey = (AsyncTaskStorey) machine_initializer.Storey; + + if (storey.HoistedReturn != null) + storey.HoistedReturn.EmitAssign (ec); + else + ec.Emit (OpCodes.Pop); + } + } + + static void Error_WrongGetAwaiter (ResolveContext rc, Location loc, TypeSpec type) + { + rc.Report.Error (1986, loc, + "The `await' operand type `{0}' must have suitable GetAwaiter method", + type.GetSignatureForError ()); + } + + void Error_WrongAwaiterPattern (ResolveContext rc, TypeSpec awaiter) + { + rc.Report.Error (1999, loc, "The awaiter type `{0}' must have suitable IsCompleted, OnCompleted, and GetResult members", + awaiter.GetSignatureForError ()); + } + + public override bool Resolve (BlockContext bc) + { + if (!base.Resolve (bc)) + return false; + + type = expr.Type; + + // + // The task result is of dynamic type + // + if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) + throw new NotImplementedException ("dynamic await"); + + // + // Check whether the expression is awaitable + // + Expression ama = new AwaitableMemberAccess (expr).Resolve (bc); + if (ama == null) + return false; + + Arguments args = new Arguments (0); + + var errors_printer = new SessionReportPrinter (); + var old = bc.Report.SetPrinter (errors_printer); + ama = new Invocation (ama, args).Resolve (bc); + + if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression (ama.Type)) { + bc.Report.SetPrinter (old); + Error_WrongGetAwaiter (bc, loc, expr.Type); + return false; + } + + var awaiter_type = ama.Type; + awaiter = ((AsyncTaskStorey) machine_initializer.Storey).AddAwaiter (awaiter_type, loc); + expr = ama; + + // + // Predefined: bool IsCompleted { get; } + // + var is_completed_ma = new MemberAccess (expr, "IsCompleted").Resolve (bc); + if (is_completed_ma != null) { + is_completed = is_completed_ma as PropertyExpr; + if (is_completed != null && is_completed.Type.BuiltinType == BuiltinTypeSpec.Type.Bool && is_completed.IsInstance && is_completed.Getter != null) { + // valid + } else { + bc.Report.SetPrinter (old); + Error_WrongAwaiterPattern (bc, awaiter_type); + return false; + } + } + + bc.Report.SetPrinter (old); + + if (errors_printer.ErrorsCount > 0) { + Error_WrongAwaiterPattern (bc, awaiter_type); + return false; + } + + // + // Predefined: OnCompleted (Action) + // + if (bc.Module.PredefinedTypes.Action.Define ()) { + on_completed = MemberCache.FindMember (awaiter_type, MemberFilter.Method ("OnCompleted", 0, + ParametersCompiled.CreateFullyResolved (bc.Module.PredefinedTypes.Action.TypeSpec), bc.Module.Compiler.BuiltinTypes.Void), + BindingRestriction.InstanceOnly) as MethodSpec; + + if (on_completed == null) { + Error_WrongAwaiterPattern (bc, awaiter_type); + return false; + } + } + + // + // Predefined: GetResult () + // + // The method return type is also result type of await expression + // + get_result = MemberCache.FindMember (awaiter_type, MemberFilter.Method ("GetResult", 0, + ParametersCompiled.EmptyReadOnlyParameters, null), + BindingRestriction.InstanceOnly) as MethodSpec; + + if (get_result == null) { + Error_WrongAwaiterPattern (bc, awaiter_type); + return false; + } + + return true; + } + } + + public class AsyncInitializer : StateMachineInitializer + { + TypeInferenceContext return_inference; + + public AsyncInitializer (ParametersBlock block, TypeContainer host, TypeSpec returnType) + : base (block, host, returnType) + { + } + + #region Properties + + public override string ContainerType { + get { + return "async state machine block"; + } + } + + public override bool IsIterator { + get { + return false; + } + } + + public Block OriginalBlock { + get { + return block.Parent; + } + } + + public TypeInferenceContext ReturnTypeInference { + get { + return return_inference; + } + } + + #endregion + + public static void Create (ParametersBlock block, ParametersCompiled parameters, TypeContainer host, TypeSpec returnType, Location loc) + { + if (returnType != null && returnType.Kind != MemberKind.Void && + returnType != host.Module.PredefinedTypes.Task.TypeSpec && + !returnType.IsGenericTask) { + host.Compiler.Report.Error (1983, loc, "The return type of an async method must be void, Task, or Task"); + } + + for (int i = 0; i < parameters.Count; i++) { + Parameter p = parameters[i]; + Parameter.Modifier mod = p.ModFlags; + if ((mod & Parameter.Modifier.ISBYREF) != 0) { + host.Compiler.Report.Error (1988, p.Location, + "Async methods cannot have ref or out parameters"); + return; + } + + // TODO: + if (p is ArglistParameter) { + host.Compiler.Report.Error (1636, p.Location, + "__arglist is not allowed in parameter list of iterators"); + return; + } + + // TODO: + if (parameters.Types[i].IsPointer) { + host.Compiler.Report.Error (1637, p.Location, + "Iterators cannot have unsafe parameters or yield types"); + return; + } + } + + // TODO: Warning + //if (!block.HasAwait) { + //} + + block.WrapIntoAsyncTask (host, returnType); + } + + protected override BlockContext CreateBlockContext (ResolveContext rc) + { + var ctx = base.CreateBlockContext (rc); + var lambda = rc.CurrentAnonymousMethod as LambdaMethod; + if (lambda != null) + return_inference = lambda.ReturnTypeInference; + + return ctx; + } + + public override Expression CreateExpressionTree (ResolveContext ec) + { + return base.CreateExpressionTree (ec); + } + + public override void Emit (EmitContext ec) + { + throw new NotImplementedException (); + } + + protected override void EmitMoveNextEpilogue (EmitContext ec) + { + var storey = (AsyncTaskStorey) Storey; + storey.EmitSetResult (ec); + } + + public override void EmitStatement (EmitContext ec) + { + var storey = (AsyncTaskStorey) Storey; + storey.Instance.Emit (ec); + ec.Emit (OpCodes.Call, storey.StateMachineMethod.Spec); + + if (storey.Task != null) { + // + // async.$builder.Task; + // + var pe_task = new PropertyExpr (storey.Task, loc) { + InstanceExpression = new FieldExpr (storey.Builder, loc) { + InstanceExpression = storey.Instance + }, + Getter = storey.Task.Get + }; + + pe_task.Emit (ec); + } + + ec.Emit (OpCodes.Ret); + } + + public override void InjectYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point) + { + base.InjectYield (ec, expr, resume_pc, unwind_protect, resume_point); + } + } + + class AsyncTaskStorey : StateMachine + { + int awaiters; + Field builder, continuation; + readonly TypeSpec return_type; + MethodSpec set_result; + PropertySpec task; + LocalVariable hoisted_return; + + public AsyncTaskStorey (AsyncInitializer initializer, TypeSpec type) + : base (initializer.OriginalBlock, initializer.Host, null, null, "async") + { + return_type = type; + } + + public Field AddAwaiter (TypeSpec type, Location loc) + { + return AddCompilerGeneratedField ("$awaiter" + awaiters++.ToString ("X"), new TypeExpression (type, loc)); + } + + #region Properties + + public Field Builder { + get { + return builder; + } + } + + public Field Continuation { + get { + return continuation; + } + } + + public LocalVariable HoistedReturn { + get { + return hoisted_return; + } + } + + public TypeSpec ReturnType { + get { + return return_type; + } + } + + public PropertySpec Task { + get { + return task; + } + } + + #endregion + + protected override bool DoDefineMembers () + { + var action = Module.PredefinedTypes.Action.Resolve (); + if (action != null) { + continuation = AddCompilerGeneratedField ("$continuation", new TypeExpression (action, Location)); + continuation.ModFlags |= Modifiers.READONLY; + } + + PredefinedType builder_type; + PredefinedMember bf; + PredefinedMember sr; + bool has_task_return_type = false; + var pred_members = Module.PredefinedMembers; + + if (return_type.Kind == MemberKind.Void) { + builder_type = Module.PredefinedTypes.AsyncVoidMethodBuilder; + bf = pred_members.AsyncVoidMethodBuilderCreate; + sr = pred_members.AsyncVoidMethodBuilderSetResult; + } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { + builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilder; + bf = pred_members.AsyncTaskMethodBuilderCreate; + sr = pred_members.AsyncTaskMethodBuilderSetResult; + task = pred_members.AsyncTaskMethodBuilderTask.Resolve (Location); + } else { + builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilderGeneric; + bf = pred_members.AsyncTaskMethodBuilderGenericCreate; + sr = pred_members.AsyncTaskMethodBuilderGenericSetResult; + task = pred_members.AsyncTaskMethodBuilderGenericTask.Resolve (Location); + has_task_return_type = true; + } + + set_result = sr.Resolve (Location); + var builder_factory = bf.Resolve (Location); + var bt = builder_type.Resolve (); + if (bt == null || set_result == null || builder_factory == null) + return false; + + // + // Inflate generic Task types + // + if (has_task_return_type) { + bt = bt.MakeGenericType (Module, return_type.TypeArguments); + builder_factory = MemberCache.GetMember (bt, builder_factory); + set_result = MemberCache.GetMember (bt, set_result); + + if (task != null) + task = MemberCache.GetMember (bt, task); + } + + builder = AddCompilerGeneratedField ("$builder", new TypeExpression (bt, Location)); + builder.ModFlags |= Modifiers.READONLY; + + if (!base.DoDefineMembers ()) + return false; + + MethodGroupExpr mg; + var block = instance_constructors[0].Block; + + // + // Initialize continuation with state machine method + // + if (continuation != null) { + var args = new Arguments (1); + mg = MethodGroupExpr.CreatePredefined (StateMachineMethod.Spec, spec, Location); + args.Add (new Argument (mg)); + + block.AddStatement ( + new StatementExpression (new SimpleAssign ( + new FieldExpr (continuation, Location), + new NewDelegate (action, args, Location), + Location + ))); + } + + mg = MethodGroupExpr.CreatePredefined (builder_factory, bt, Location); + block.AddStatement ( + new StatementExpression (new SimpleAssign ( + new FieldExpr (builder, Location), + new Invocation (mg, new Arguments (0)), + Location))); + + if (has_task_return_type) { + hoisted_return = LocalVariable.CreateCompilerGenerated (bt.TypeArguments[0], block, Location); + } + + return true; + } + + public void EmitSetResult (EmitContext ec) + { + // + // $builder.SetResult (); + // $builder.SetResult (value); + // + var mg = MethodGroupExpr.CreatePredefined (set_result, set_result.DeclaringType, Location); + mg.InstanceExpression = new FieldExpr (Builder, Location) { + InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location) + }; + + Arguments args; + if (hoisted_return == null) { + args = new Arguments (0); + } else { + args = new Arguments (1); + args.Add (new Argument (new LocalVariableReference (hoisted_return, Location))); + } + + mg.EmitCall (ec, args); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs index bfce7f92b..b58a81351 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/attribute.cs @@ -46,12 +46,11 @@ namespace Mono.CSharp { { if (attrs == null) return; - + if (attributes == null) attributes = attrs; else attributes.AddAttributes (attrs.Attrs); - attrs.AttachTo (this, context); } @@ -1108,16 +1107,26 @@ namespace Mono.CSharp { public class Attributes { public readonly List Attrs; +#if FULL_AST + public readonly List> Sections = new List> (); +#endif public Attributes (Attribute a) { Attrs = new List (); Attrs.Add (a); + +#if FULL_AST + Sections.Add (Attrs); +#endif } public Attributes (List attrs) { Attrs = attrs; +#if FULL_AST + Sections.Add (attrs); +#endif } public void AddAttribute (Attribute attr) @@ -1127,7 +1136,11 @@ namespace Mono.CSharp { public void AddAttributes (List attrs) { +#if FULL_AST + Sections.Add (attrs); +#else Attrs.AddRange (attrs); +#endif } public void AttachTo (Attributable attributable, IMemberContext context) diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs index 01cad1f2e..316968454 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/context.cs @@ -159,7 +159,7 @@ namespace Mono.CSharp return branching; } - public FlowBranchingIterator StartFlowBranching (Iterator iterator, FlowBranching parent) + public FlowBranchingIterator StartFlowBranching (StateMachineInitializer iterator, FlowBranching parent) { FlowBranchingIterator branching = new FlowBranchingIterator (parent, iterator); current_flow_branching = branching; @@ -267,6 +267,8 @@ namespace Mono.CSharp UsingInitializerScope = 1 << 12, + LockScope = 1 << 13, + /// /// Whether control flow analysis is enabled /// diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs index 3283e58b3..020c84275 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/convert.cs @@ -194,6 +194,11 @@ namespace Mono.CSharp { // Implicit reference conversions // public static bool ImplicitReferenceConversionExists (TypeSpec expr_type, TypeSpec target_type) + { + return ImplicitReferenceConversionExists (expr_type, target_type, true); + } + + static bool ImplicitReferenceConversionExists (TypeSpec expr_type, TypeSpec target_type, bool refOnlyTypeParameter) { // It's here only to speed things up if (target_type.IsStruct) @@ -201,7 +206,8 @@ namespace Mono.CSharp { switch (expr_type.Kind) { case MemberKind.TypeParameter: - return ImplicitTypeParameterConversion (null, (TypeParameterSpec) expr_type, target_type) != null; + return ImplicitTypeParameterConversion (null, (TypeParameterSpec) expr_type, target_type) != null && + (!refOnlyTypeParameter || TypeSpec.IsReferenceType (expr_type)); case MemberKind.Class: // @@ -698,7 +704,7 @@ namespace Mono.CSharp { if (ImplicitNumericConversion (null, expr_type, target_type) != null) return true; - if (ImplicitReferenceConversionExists (expr_type, target_type)) + if (ImplicitReferenceConversionExists (expr_type, target_type, false)) return true; if (ImplicitBoxingConversion (null, expr_type, target_type) != null) diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs index 0d28d9d2b..0cee24dd0 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs @@ -145,6 +145,21 @@ namespace Mono.CSharp UsingsBag ubag; List> mod_locations; Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; + Location savedAttrParenOpenLocation, savedAttrParenCloseLocation; + Stack> locationListStack = new Stack> (); // used for type parameters + + object lastYYVal; + + // Can be used for code completion to get the last valid expression before an error. + // needs a hack in yyparse to make it work add + // lastYYVal = yyVal; + // after the big switch/case (somewhere around line 3915) + public object LastYYVal { + get { + return lastYYVal; + } + } + #line default /** error output stream. @@ -350,7 +365,8 @@ namespace Mono.CSharp //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 "$$25 :", +//t "method_header : opt_attributes opt_modifiers PARTIAL VOID $$23 method_declaration_name OPEN_PARENS $$24 opt_formal_parameter_list CLOSE_PARENS $$25 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", @@ -371,8 +387,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 "$$25 :", -//t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER ASSIGN $$25 constant_expression", +//t "$$26 :", +//t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER ASSIGN $$26 constant_expression", //t "opt_parameter_modifier :", //t "opt_parameter_modifier : parameter_modifiers", //t "parameter_modifiers : parameter_modifier", @@ -387,31 +403,31 @@ namespace Mono.CSharp //t "params_modifier : PARAMS parameter_modifier", //t "params_modifier : PARAMS params_modifier", //t "arglist_modifier : ARGLIST", -//t "$$26 :", //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 "property_declaration : opt_attributes opt_modifiers member_type member_declaration_name $$27 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 "$$32 :", +//t "indexer_declaration : opt_attributes opt_modifiers member_type indexer_declaration_name OPEN_BRACKET $$30 opt_formal_parameter_list CLOSE_BRACKET OPEN_BRACE $$31 accessor_declarations $$32 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 "$$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 "get_accessor_declaration : opt_attributes opt_modifiers GET $$33 accessor_body", +//t "$$34 :", +//t "set_accessor_declaration : opt_attributes opt_modifiers SET $$34 accessor_body", //t "accessor_body : block", //t "accessor_body : SEMICOLON", //t "accessor_body : error", -//t "$$34 :", //t "$$35 :", //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 "$$38 :", +//t "interface_declaration : opt_attributes opt_modifiers opt_partial INTERFACE $$35 type_declaration_name $$36 opt_class_base opt_type_parameter_constraints_clauses $$37 OPEN_BRACE opt_interface_member_declarations CLOSE_BRACE $$38 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", @@ -426,14 +442,14 @@ namespace Mono.CSharp //t "interface_member_declaration : operator_declaration", //t "interface_member_declaration : constructor_declaration", //t "interface_member_declaration : type_declaration", -//t "$$38 :", -//t "operator_declaration : opt_attributes opt_modifiers operator_declarator $$38 operator_body", +//t "$$39 :", +//t "operator_declaration : opt_attributes opt_modifiers operator_declarator $$39 operator_body", //t "operator_body : block", //t "operator_body : SEMICOLON", //t "operator_type : type_expression_or_array", //t "operator_type : VOID", -//t "$$39 :", -//t "operator_declarator : operator_type OPERATOR overloadable_operator OPEN_PARENS $$39 opt_formal_parameter_list CLOSE_PARENS", +//t "$$40 :", +//t "operator_declarator : operator_type OPERATOR overloadable_operator OPEN_PARENS $$40 opt_formal_parameter_list CLOSE_PARENS", //t "operator_declarator : conversion_operator_declarator", //t "overloadable_operator : BANG", //t "overloadable_operator : TILDE", @@ -457,59 +473,59 @@ namespace Mono.CSharp //t "overloadable_operator : OP_LT", //t "overloadable_operator : OP_GE", //t "overloadable_operator : OP_LE", -//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 OPERATOR type OPEN_PARENS $$41 opt_formal_parameter_list CLOSE_PARENS", +//t "$$42 :", +//t "conversion_operator_declarator : EXPLICIT OPERATOR type OPEN_PARENS $$42 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 "$$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 "$$44 :", +//t "constructor_declarator : opt_attributes opt_modifiers IDENTIFIER $$43 OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS $$44 opt_constructor_initializer", //t "constructor_body : block_prepared", //t "constructor_body : SEMICOLON", //t "opt_constructor_initializer :", //t "opt_constructor_initializer : constructor_initializer", -//t "$$44 :", -//t "constructor_initializer : COLON BASE OPEN_PARENS $$44 opt_argument_list CLOSE_PARENS", //t "$$45 :", -//t "constructor_initializer : COLON THIS OPEN_PARENS $$45 opt_argument_list CLOSE_PARENS", -//t "constructor_initializer : error", +//t "constructor_initializer : COLON BASE OPEN_PARENS $$45 opt_argument_list CLOSE_PARENS", //t "$$46 :", -//t "destructor_declaration : opt_attributes opt_modifiers TILDE $$46 IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body", +//t "constructor_initializer : COLON THIS OPEN_PARENS $$46 opt_argument_list CLOSE_PARENS", +//t "constructor_initializer : error", //t "$$47 :", -//t "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name $$47 opt_event_initializer opt_event_declarators SEMICOLON", +//t "destructor_declaration : opt_attributes opt_modifiers TILDE $$47 IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body", //t "$$48 :", +//t "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name $$48 opt_event_initializer opt_event_declarators SEMICOLON", //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 "event_declaration : opt_attributes opt_modifiers EVENT type member_declaration_name OPEN_BRACE $$49 event_accessor_declarations $$50 CLOSE_BRACE", +//t "opt_event_initializer :", +//t "$$51 :", +//t "opt_event_initializer : ASSIGN $$51 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 "$$51 :", -//t "event_declarator : COMMA IDENTIFIER ASSIGN $$51 event_variable_initializer", //t "$$52 :", -//t "event_variable_initializer : $$52 variable_initializer", +//t "event_declarator : COMMA IDENTIFIER ASSIGN $$52 event_variable_initializer", +//t "$$53 :", +//t "event_variable_initializer : $$53 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 "$$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 "add_accessor_declaration : opt_attributes opt_modifiers ADD $$54 event_accessor_block", +//t "$$55 :", +//t "remove_accessor_declaration : opt_attributes opt_modifiers REMOVE $$55 event_accessor_block", //t "event_accessor_block : opt_semicolon", //t "event_accessor_block : block", -//t "$$55 :", //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 "$$58 :", +//t "enum_declaration : opt_attributes opt_modifiers ENUM type_declaration_name opt_enum_base $$56 OPEN_BRACE $$57 opt_enum_member_declarations $$58 CLOSE_BRACE opt_semicolon", //t "opt_enum_base :", //t "opt_enum_base : COLON type", //t "opt_enum_base : COLON error", @@ -519,12 +535,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 "$$58 :", -//t "enum_member_declaration : opt_attributes IDENTIFIER $$58 ASSIGN constant_expression", //t "$$59 :", +//t "enum_member_declaration : opt_attributes IDENTIFIER $$59 ASSIGN constant_expression", //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 "$$62 :", +//t "delegate_declaration : opt_attributes opt_modifiers DELEGATE member_type type_declaration_name OPEN_PARENS $$60 opt_formal_parameter_list CLOSE_PARENS $$61 opt_type_parameter_constraints_clauses $$62 SEMICOLON", //t "opt_nullable :", //t "opt_nullable : INTERR_NULLABLE", //t "namespace_or_type_name : member_name", @@ -537,8 +553,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 "$$62 :", -//t "type_declaration_name : IDENTIFIER $$62 opt_type_parameter_list", +//t "$$63 :", +//t "type_declaration_name : IDENTIFIER $$63 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", @@ -684,8 +700,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 "$$63 :", -//t "new_expr_type : $$63 simple_type", +//t "$$64 :", +//t "new_expr_type : $$64 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", @@ -711,8 +727,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 "$$64 :", -//t "typeof_expression : TYPEOF $$64 open_parens_any typeof_type_expression CLOSE_PARENS", +//t "$$65 :", +//t "typeof_expression : TYPEOF $$65 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", @@ -727,12 +743,14 @@ 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 opt_type_argument_list", -//t "$$65 :", -//t "anonymous_method_expression : DELEGATE opt_anonymous_method_signature $$65 block", +//t "$$66 :", +//t "anonymous_method_expression : DELEGATE opt_anonymous_method_signature $$66 block", +//t "$$67 :", +//t "anonymous_method_expression : ASYNC DELEGATE opt_anonymous_method_signature $$67 block", //t "opt_anonymous_method_signature :", //t "opt_anonymous_method_signature : anonymous_method_signature", -//t "$$66 :", -//t "anonymous_method_signature : OPEN_PARENS $$66 opt_formal_parameter_list CLOSE_PARENS", +//t "$$68 :", +//t "anonymous_method_signature : OPEN_PARENS $$68 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", @@ -803,15 +821,20 @@ 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 "$$67 :", -//t "lambda_expression_body_simple : $$67 expression_or_error", +//t "$$69 :", +//t "lambda_expression_body_simple : $$69 expression_or_error", //t "expression_or_error : expression", //t "expression_or_error : error", -//t "$$68 :", -//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 "lambda_expression : IDENTIFIER ARROW $$70 lambda_expression_body", +//t "$$71 :", +//t "lambda_expression : ASYNC IDENTIFIER ARROW $$71 lambda_expression_body", +//t "$$72 :", +//t "$$73 :", +//t "lambda_expression : OPEN_PARENS_LAMBDA $$72 opt_lambda_parameter_list CLOSE_PARENS ARROW $$73 lambda_expression_body", +//t "$$74 :", +//t "$$75 :", +//t "lambda_expression : ASYNC OPEN_PARENS_LAMBDA $$74 opt_lambda_parameter_list CLOSE_PARENS ARROW $$75 lambda_expression_body", //t "expression : assignment_expression", //t "expression : non_assignment_expression", //t "non_assignment_expression : conditional_expression", @@ -823,11 +846,11 @@ namespace Mono.CSharp //t "undocumented_expressions : MAKEREF open_parens_any expression CLOSE_PARENS", //t "constant_expression : expression", //t "boolean_expression : expression", -//t "$$71 :", -//t "$$72 :", -//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 "$$76 :", +//t "$$77 :", +//t "$$78 :", +//t "$$79 :", +//t "class_declaration : opt_attributes opt_modifiers opt_partial CLASS $$76 type_declaration_name $$77 opt_class_base opt_type_parameter_constraints_clauses $$78 OPEN_BRACE opt_class_member_declarations CLOSE_BRACE $$79 opt_semicolon", //t "opt_partial :", //t "opt_partial : PARTIAL", //t "opt_modifiers :", @@ -867,12 +890,12 @@ namespace Mono.CSharp //t "opt_type_parameter_variance : type_parameter_variance", //t "type_parameter_variance : OUT", //t "type_parameter_variance : IN", -//t "$$75 :", -//t "block : OPEN_BRACE $$75 opt_statement_list block_end", +//t "$$80 :", +//t "block : OPEN_BRACE $$80 opt_statement_list block_end", //t "block_end : CLOSE_BRACE", //t "block_end : COMPLETE_COMPLETION", -//t "$$76 :", -//t "block_prepared : OPEN_BRACE $$76 opt_statement_list CLOSE_BRACE", +//t "$$81 :", +//t "block_prepared : OPEN_BRACE $$81 opt_statement_list CLOSE_BRACE", //t "opt_statement_list :", //t "opt_statement_list : statement_list", //t "statement_list : statement", @@ -917,8 +940,8 @@ namespace Mono.CSharp //t "embedded_statement : labeled_statement", //t "embedded_statement : error", //t "empty_statement : SEMICOLON", -//t "$$77 :", -//t "labeled_statement : IDENTIFIER COLON $$77 statement", +//t "$$82 :", +//t "labeled_statement : IDENTIFIER COLON $$82 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 +953,10 @@ namespace Mono.CSharp //t "pointer_stars : pointer_star", //t "pointer_stars : pointer_star pointer_stars", //t "pointer_star : STAR", -//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 "$$83 :", +//t "block_variable_declaration : variable_type IDENTIFIER $$83 opt_local_variable_initializer opt_variable_declarators SEMICOLON", +//t "$$84 :", +//t "block_variable_declaration : CONST variable_type IDENTIFIER $$84 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 +987,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 "$$80 :", -//t "switch_statement : SWITCH open_parens_any expression CLOSE_PARENS OPEN_BRACE $$80 opt_switch_sections CLOSE_BRACE", +//t "$$85 :", +//t "switch_statement : SWITCH open_parens_any expression CLOSE_PARENS OPEN_BRACE $$85 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 "$$81 :", -//t "switch_section : switch_labels $$81 statement_list", +//t "$$86 :", +//t "switch_section : switch_labels $$86 statement_list", //t "switch_labels : switch_label", //t "switch_labels : switch_labels switch_label", //t "switch_label : CASE constant_expression COLON", @@ -983,14 +1006,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 "$$82 :", -//t "for_statement : FOR open_parens_any $$82 for_statement_cont", +//t "$$87 :", +//t "for_statement : FOR open_parens_any $$87 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 "$$83 :", -//t "for_initializer : variable_type IDENTIFIER $$83 opt_local_variable_initializer opt_variable_declarators", +//t "$$88 :", +//t "for_initializer : variable_type IDENTIFIER $$88 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 +1023,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 "$$84 :", -//t "foreach_statement : FOREACH open_parens_any type IDENTIFIER IN expression CLOSE_PARENS $$84 embedded_statement", +//t "$$89 :", +//t "foreach_statement : FOREACH open_parens_any type IDENTIFIER IN expression CLOSE_PARENS $$89 embedded_statement", //t "jump_statement : break_statement", //t "jump_statement : continue_statement", //t "jump_statement : goto_statement", @@ -1028,20 +1051,20 @@ namespace Mono.CSharp //t "opt_identifier :", //t "opt_identifier : IDENTIFIER", //t "catch_clause : CATCH block", -//t "$$85 :", -//t "catch_clause : CATCH open_parens_any type opt_identifier CLOSE_PARENS $$85 block_prepared", +//t "$$90 :", +//t "catch_clause : CATCH open_parens_any type opt_identifier CLOSE_PARENS $$90 block_prepared", //t "catch_clause : CATCH open_parens_any error", //t "checked_statement : CHECKED block", //t "unchecked_statement : UNCHECKED block", -//t "$$86 :", -//t "unsafe_statement : UNSAFE $$86 block", +//t "$$91 :", +//t "unsafe_statement : UNSAFE $$91 block", //t "lock_statement : LOCK open_parens_any expression CLOSE_PARENS embedded_statement", -//t "$$87 :", -//t "$$88 :", -//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 "$$92 :", +//t "$$93 :", +//t "fixed_statement : FIXED open_parens_any variable_type IDENTIFIER $$92 using_or_fixed_variable_initializer opt_variable_declarators CLOSE_PARENS $$93 embedded_statement", +//t "$$94 :", +//t "$$95 :", +//t "using_statement : USING open_parens_any variable_type IDENTIFIER $$94 using_or_fixed_variable_initializer opt_variable_declarators CLOSE_PARENS $$95 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 +1076,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 "$$91 :", -//t "from_clause : FROM IDENTIFIER IN $$91 expression", -//t "$$92 :", -//t "from_clause : FROM type IDENTIFIER IN $$92 expression", +//t "$$96 :", +//t "from_clause : FROM IDENTIFIER IN $$96 expression", +//t "$$97 :", +//t "from_clause : FROM type IDENTIFIER IN $$97 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 "$$93 :", -//t "select_or_group_clause : SELECT $$93 expression", -//t "$$94 :", -//t "$$95 :", -//t "select_or_group_clause : GROUP $$94 expression $$95 BY expression", +//t "$$98 :", +//t "select_or_group_clause : SELECT $$98 expression", +//t "$$99 :", +//t "$$100 :", +//t "select_or_group_clause : GROUP $$99 expression $$100 BY expression", //t "opt_query_body_clauses :", //t "opt_query_body_clauses : query_body_clauses", //t "query_body_clauses : query_body_clause", @@ -1074,28 +1097,28 @@ namespace Mono.CSharp //t "query_body_clause : where_clause", //t "query_body_clause : join_clause", //t "query_body_clause : orderby_clause", -//t "$$96 :", -//t "let_clause : LET IDENTIFIER ASSIGN $$96 expression", -//t "$$97 :", -//t "where_clause : WHERE $$97 expression", -//t "$$98 :", -//t "$$99 :", -//t "$$100 :", -//t "join_clause : JOIN IDENTIFIER IN $$98 expression ON $$99 expression EQUALS $$100 expression opt_join_into", //t "$$101 :", +//t "let_clause : LET IDENTIFIER ASSIGN $$101 expression", //t "$$102 :", +//t "where_clause : WHERE $$102 expression", //t "$$103 :", -//t "join_clause : JOIN type IDENTIFIER IN $$101 expression ON $$102 expression EQUALS $$103 expression opt_join_into", +//t "$$104 :", +//t "$$105 :", +//t "join_clause : JOIN IDENTIFIER IN $$103 expression ON $$104 expression EQUALS $$105 expression opt_join_into", +//t "$$106 :", +//t "$$107 :", +//t "$$108 :", +//t "join_clause : JOIN type IDENTIFIER IN $$106 expression ON $$107 expression EQUALS $$108 expression opt_join_into", //t "opt_join_into :", //t "opt_join_into : INTO IDENTIFIER", -//t "$$104 :", -//t "orderby_clause : ORDERBY $$104 orderings", +//t "$$109 :", +//t "orderby_clause : ORDERBY $$109 orderings", //t "orderings : order_by", -//t "$$105 :", -//t "orderings : order_by COMMA $$105 orderings_then_by", +//t "$$110 :", +//t "orderings : order_by COMMA $$110 orderings_then_by", //t "orderings_then_by : then_by", -//t "$$106 :", -//t "orderings_then_by : orderings_then_by COMMA $$106 then_by", +//t "$$111 :", +//t "orderings_then_by : orderings_then_by COMMA $$111 then_by", //t "order_by : expression", //t "order_by : expression ASCENDING", //t "order_by : expression DESCENDING", @@ -1103,12 +1126,12 @@ namespace Mono.CSharp //t "then_by : expression ASCENDING", //t "then_by : expression DESCENDING", //t "opt_query_continuation :", -//t "$$107 :", -//t "opt_query_continuation : INTO IDENTIFIER $$107 query_body", +//t "$$112 :", +//t "opt_query_continuation : INTO IDENTIFIER $$112 query_body", //t "interactive_parsing : EVAL_STATEMENT_PARSER EOF", //t "interactive_parsing : EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives opt_COMPLETE_COMPLETION", -//t "$$108 :", -//t "interactive_parsing : EVAL_STATEMENT_PARSER $$108 interactive_statement_list opt_COMPLETE_COMPLETION", +//t "$$113 :", +//t "interactive_parsing : EVAL_STATEMENT_PARSER $$113 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", @@ -1121,16 +1144,16 @@ namespace Mono.CSharp //t "doc_cref : builtin_types opt_doc_method_sig", //t "doc_cref : builtin_types DOT IDENTIFIER opt_doc_method_sig", //t "doc_cref : doc_type_declaration_name DOT THIS", -//t "$$109 :", -//t "doc_cref : doc_type_declaration_name DOT THIS OPEN_BRACKET $$109 opt_doc_parameters CLOSE_BRACKET", +//t "$$114 :", +//t "doc_cref : doc_type_declaration_name DOT THIS OPEN_BRACKET $$114 opt_doc_parameters CLOSE_BRACKET", //t "doc_cref : EXPLICIT OPERATOR type opt_doc_method_sig", //t "doc_cref : IMPLICIT OPERATOR type opt_doc_method_sig", //t "doc_cref : OPERATOR overloadable_operator opt_doc_method_sig", //t "doc_type_declaration_name : type_declaration_name", //t "doc_type_declaration_name : doc_type_declaration_name DOT type_declaration_name", //t "opt_doc_method_sig :", -//t "$$110 :", -//t "opt_doc_method_sig : OPEN_PARENS $$110 opt_doc_parameters CLOSE_PARENS", +//t "$$115 :", +//t "opt_doc_method_sig : OPEN_PARENS $$115 opt_doc_parameters CLOSE_PARENS", //t "opt_doc_parameters :", //t "opt_doc_parameters : doc_parameters", //t "doc_parameters : doc_parameter", @@ -1375,20 +1398,20 @@ namespace Mono.CSharp yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { case 1: -#line 380 "cs-parser.jay" +#line 395 "cs-parser.jay" { Lexer.check_incorrect_doc_comment (); } break; case 2: -#line 381 "cs-parser.jay" +#line 396 "cs-parser.jay" { Lexer.CompleteOnEOF = false; } break; case 6: case_6(); break; case 7: -#line 398 "cs-parser.jay" +#line 413 "cs-parser.jay" { module.AddAttributes ((Attributes) yyVals[0+yyTop], current_namespace); } @@ -1400,7 +1423,7 @@ case 13: case_13(); break; case 14: -#line 436 "cs-parser.jay" +#line 451 "cs-parser.jay" { syntax_error (GetLocation (yyVals[-1+yyTop]), "`alias' expected"); /* TODO: better*/ } @@ -1445,7 +1468,7 @@ case 41: case_41(); break; case 42: -#line 625 "cs-parser.jay" +#line 640 "cs-parser.jay" { current_namespace.DeclarationFound = true; } @@ -1475,18 +1498,18 @@ case 57: case_57(); break; case 58: -#line 717 "cs-parser.jay" +#line 733 "cs-parser.jay" { yyVal = "event"; } break; case 59: -#line 718 "cs-parser.jay" +#line 734 "cs-parser.jay" { yyVal = "return"; } break; case 60: case_60(); break; case 61: -#line 735 "cs-parser.jay" +#line 751 "cs-parser.jay" { yyVal = new List (4) { (Attribute) yyVals[0+yyTop] }; } @@ -1495,7 +1518,7 @@ case 62: case_62(); break; case 63: -#line 749 "cs-parser.jay" +#line 765 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1504,17 +1527,14 @@ case 64: case_64(); break; case 66: -#line 770 "cs-parser.jay" +#line 789 "cs-parser.jay" { yyVal = null; } break; case 67: -#line 774 "cs-parser.jay" - { - yyVal = yyVals[-1+yyTop]; - } + case_67(); break; case 68: -#line 779 "cs-parser.jay" +#line 800 "cs-parser.jay" { yyVal = null; } break; case 69: @@ -1530,13 +1550,13 @@ case 72: case_72(); break; case 73: -#line 823 "cs-parser.jay" +#line 844 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 75: -#line 831 "cs-parser.jay" +#line 852 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1548,17 +1568,17 @@ case 77: case_77(); break; case 78: -#line 856 "cs-parser.jay" +#line 877 "cs-parser.jay" { yyVal = null; } break; case 79: -#line 860 "cs-parser.jay" +#line 881 "cs-parser.jay" { yyVal = Argument.AType.Ref; } break; case 80: -#line 864 "cs-parser.jay" +#line 885 "cs-parser.jay" { yyVal = Argument.AType.Out; } @@ -1567,7 +1587,7 @@ case 95: case_95(); break; case 96: -#line 905 "cs-parser.jay" +#line 926 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1585,7 +1605,7 @@ case 100: case_100(); break; case 101: -#line 937 "cs-parser.jay" +#line 958 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1594,7 +1614,7 @@ case 102: case_102(); break; case 103: -#line 949 "cs-parser.jay" +#line 970 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } @@ -1606,13 +1626,13 @@ case 119: case_119(); break; case 122: -#line 1018 "cs-parser.jay" +#line 1039 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 123: -#line 1022 "cs-parser.jay" +#line 1043 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1621,7 +1641,7 @@ case 124: case_124(); break; case 125: -#line 1038 "cs-parser.jay" +#line 1059 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1645,7 +1665,7 @@ case 133: case_133(); break; case 134: -#line 1117 "cs-parser.jay" +#line 1138 "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"); } @@ -1657,13 +1677,13 @@ case 137: case_137(); break; case 140: -#line 1147 "cs-parser.jay" +#line 1168 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 141: -#line 1151 "cs-parser.jay" +#line 1172 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1672,7 +1692,7 @@ case 142: case_142(); break; case 143: -#line 1164 "cs-parser.jay" +#line 1185 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1681,13 +1701,13 @@ case 144: case_144(); break; case 147: -#line 1183 "cs-parser.jay" +#line 1204 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 148: -#line 1187 "cs-parser.jay" +#line 1208 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1696,7 +1716,7 @@ case 149: case_149(); break; case 150: -#line 1203 "cs-parser.jay" +#line 1224 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1717,13 +1737,13 @@ case 157: case_157(); break; case 158: -#line 1260 "cs-parser.jay" +#line 1291 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; case 159: -#line 1264 "cs-parser.jay" +#line 1295 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1732,33 +1752,33 @@ case 160: case_160(); break; case 161: -#line 1305 "cs-parser.jay" +#line 1335 "cs-parser.jay" { - valid_param_mod = ParameterModifierType.All; + lexer.parsing_generic_declaration = true; } break; case 162: -#line 1309 "cs-parser.jay" + case_162(); + break; +case 163: +#line 1345 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 163: - case_163(); - break; case 164: case_164(); break; -case 166: -#line 1385 "cs-parser.jay" - { yyVal = null; } +case 165: + case_165(); break; case 167: -#line 1389 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } +#line 1419 "cs-parser.jay" + { yyVal = null; } break; -case 169: - case_169(); +case 168: +#line 1423 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 170: case_170(); @@ -1779,20 +1799,20 @@ case 175: case_175(); break; case 176: -#line 1448 "cs-parser.jay" + case_176(); + break; +case 177: +#line 1482 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); } break; -case 177: -#line 1452 "cs-parser.jay" +case 178: +#line 1486 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); } break; -case 178: - case_178(); - break; case 179: case_179(); break; @@ -1809,20 +1829,20 @@ case 183: case_183(); break; case 184: -#line 1527 "cs-parser.jay" + case_184(); + break; +case 185: +#line 1561 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 185: - case_185(); - break; case 186: -#line 1568 "cs-parser.jay" - { yyVal = Parameter.Modifier.NONE; } + case_186(); break; -case 188: - case_188(); +case 187: +#line 1602 "cs-parser.jay" + { yyVal = Parameter.Modifier.NONE; } break; case 189: case_189(); @@ -1852,14 +1872,14 @@ case 197: case_197(); break; case 198: -#line 1666 "cs-parser.jay" + case_198(); + break; +case 199: +#line 1700 "cs-parser.jay" { Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); } break; -case 199: - case_199(); - break; case 200: case_200(); break; @@ -1873,25 +1893,25 @@ case 203: case_203(); break; case 204: -#line 1720 "cs-parser.jay" + case_204(); + break; +case 205: +#line 1754 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; } break; -case 205: - case_205(); - break; case 206: -#line 1750 "cs-parser.jay" - { - lexer.PropertyParsing = false; - } + case_206(); break; case 207: - case_207(); +#line 1783 "cs-parser.jay" + { + lexer.PropertyParsing = false; + } break; -case 212: - case_212(); +case 208: + case_208(); break; case 213: case_213(); @@ -1905,21 +1925,21 @@ case 215: case 216: case_216(); break; -case 218: - case_218(); +case 217: + case_217(); break; case 219: case_219(); break; case 220: -#line 1892 "cs-parser.jay" + case_220(); + break; +case 221: +#line 1928 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 221: - case_221(); - break; case 222: case_222(); break; @@ -1930,171 +1950,171 @@ case 224: case_224(); break; case 225: -#line 1925 "cs-parser.jay" + case_225(); + break; +case 226: +#line 1961 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; -case 230: -#line 1942 "cs-parser.jay" +case 231: +#line 1978 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; -case 231: -#line 1946 "cs-parser.jay" +case 232: +#line 1982 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; -case 236: -#line 1954 "cs-parser.jay" +case 237: +#line 1990 "cs-parser.jay" { report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators"); } break; -case 237: -#line 1958 "cs-parser.jay" +case 238: +#line 1994 "cs-parser.jay" { report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors"); } break; -case 238: -#line 1962 "cs-parser.jay" +case 239: +#line 1998 "cs-parser.jay" { report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); } break; -case 239: -#line 1968 "cs-parser.jay" +case 240: +#line 2004 "cs-parser.jay" { } break; -case 240: - case_240(); +case 241: + case_241(); break; -case 242: -#line 1995 "cs-parser.jay" +case 243: +#line 2034 "cs-parser.jay" { yyVal = null; } break; -case 244: - case_244(); - break; case 245: -#line 2011 "cs-parser.jay" + case_245(); + break; +case 246: +#line 2050 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; -case 246: - case_246(); +case 247: + case_247(); break; -case 248: -#line 2057 "cs-parser.jay" +case 249: +#line 2096 "cs-parser.jay" { yyVal = Operator.OpType.LogicalNot; } break; -case 249: -#line 2058 "cs-parser.jay" +case 250: +#line 2097 "cs-parser.jay" { yyVal = Operator.OpType.OnesComplement; } break; -case 250: -#line 2059 "cs-parser.jay" +case 251: +#line 2098 "cs-parser.jay" { yyVal = Operator.OpType.Increment; } break; -case 251: -#line 2060 "cs-parser.jay" +case 252: +#line 2099 "cs-parser.jay" { yyVal = Operator.OpType.Decrement; } break; -case 252: -#line 2061 "cs-parser.jay" +case 253: +#line 2100 "cs-parser.jay" { yyVal = Operator.OpType.True; } break; -case 253: -#line 2062 "cs-parser.jay" +case 254: +#line 2101 "cs-parser.jay" { yyVal = Operator.OpType.False; } break; -case 254: -#line 2064 "cs-parser.jay" +case 255: +#line 2103 "cs-parser.jay" { yyVal = Operator.OpType.Addition; } break; -case 255: -#line 2065 "cs-parser.jay" +case 256: +#line 2104 "cs-parser.jay" { yyVal = Operator.OpType.Subtraction; } break; -case 256: -#line 2067 "cs-parser.jay" +case 257: +#line 2106 "cs-parser.jay" { yyVal = Operator.OpType.Multiply; } break; -case 257: -#line 2068 "cs-parser.jay" +case 258: +#line 2107 "cs-parser.jay" { yyVal = Operator.OpType.Division; } break; -case 258: -#line 2069 "cs-parser.jay" +case 259: +#line 2108 "cs-parser.jay" { yyVal = Operator.OpType.Modulus; } break; -case 259: -#line 2070 "cs-parser.jay" +case 260: +#line 2109 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseAnd; } break; -case 260: -#line 2071 "cs-parser.jay" +case 261: +#line 2110 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseOr; } break; -case 261: -#line 2072 "cs-parser.jay" +case 262: +#line 2111 "cs-parser.jay" { yyVal = Operator.OpType.ExclusiveOr; } break; -case 262: -#line 2073 "cs-parser.jay" +case 263: +#line 2112 "cs-parser.jay" { yyVal = Operator.OpType.LeftShift; } break; -case 263: -#line 2074 "cs-parser.jay" +case 264: +#line 2113 "cs-parser.jay" { yyVal = Operator.OpType.RightShift; } break; -case 264: -#line 2075 "cs-parser.jay" +case 265: +#line 2114 "cs-parser.jay" { yyVal = Operator.OpType.Equality; } break; -case 265: -#line 2076 "cs-parser.jay" +case 266: +#line 2115 "cs-parser.jay" { yyVal = Operator.OpType.Inequality; } break; -case 266: -#line 2077 "cs-parser.jay" +case 267: +#line 2116 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThan; } break; -case 267: -#line 2078 "cs-parser.jay" +case 268: +#line 2117 "cs-parser.jay" { yyVal = Operator.OpType.LessThan; } break; -case 268: -#line 2079 "cs-parser.jay" +case 269: +#line 2118 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThanOrEqual; } break; -case 269: -#line 2080 "cs-parser.jay" +case 270: +#line 2119 "cs-parser.jay" { yyVal = Operator.OpType.LessThanOrEqual; } break; -case 270: -#line 2087 "cs-parser.jay" +case 271: +#line 2126 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; -case 271: - case_271(); - break; case 272: -#line 2106 "cs-parser.jay" + case_272(); + break; +case 273: +#line 2145 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; -case 273: - case_273(); - break; case 274: case_274(); break; @@ -2113,28 +2133,28 @@ case 278: case 279: case_279(); break; -case 281: -#line 2209 "cs-parser.jay" +case 280: + case_280(); + break; +case 282: +#line 2248 "cs-parser.jay" { current_block = null; yyVal = null; } break; -case 284: -#line 2221 "cs-parser.jay" +case 285: +#line 2260 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 285: - case_285(); - break; case 286: -#line 2231 "cs-parser.jay" + case_286(); + break; +case 287: +#line 2270 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 287: - case_287(); - break; case 288: case_288(); break; @@ -2159,51 +2179,51 @@ case 294: case 295: case_295(); break; -case 297: -#line 2340 "cs-parser.jay" +case 296: + case_296(); + break; +case 298: +#line 2379 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 298: - case_298(); +case 299: + case_299(); break; -case 301: -#line 2357 "cs-parser.jay" +case 302: +#line 2396 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 302: -#line 2361 "cs-parser.jay" +case 303: +#line 2400 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 303: - case_303(); - break; case 304: -#line 2374 "cs-parser.jay" + case_304(); + break; +case 305: +#line 2413 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 305: - case_305(); - break; case 306: case_306(); break; case 307: -#line 2399 "cs-parser.jay" + case_307(); + break; +case 308: +#line 2438 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 310: - case_310(); - break; case 311: case_311(); break; @@ -2225,8 +2245,8 @@ case 316: case 317: case_317(); break; -case 319: - case_319(); +case 318: + case_318(); break; case 320: case_320(); @@ -2237,21 +2257,21 @@ case 321: case 322: case_322(); break; -case 324: - case_324(); +case 323: + case_323(); break; case 325: case_325(); break; -case 328: -#line 2554 "cs-parser.jay" +case 326: + case_326(); + break; +case 329: +#line 2593 "cs-parser.jay" { lbag.AddLocation (yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; -case 330: - case_330(); - break; case 331: case_331(); break; @@ -2262,37 +2282,37 @@ case 333: case_333(); break; case 334: -#line 2612 "cs-parser.jay" + case_334(); + break; +case 335: +#line 2651 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; } break; -case 335: - case_335(); - break; case 336: -#line 2632 "cs-parser.jay" + case_336(); + break; +case 337: +#line 2673 "cs-parser.jay" { lexer.ConstraintsParsing = false; } break; -case 337: - case_337(); - break; -case 339: - case_339(); +case 338: + case_338(); break; -case 341: - case_341(); +case 340: + case_340(); break; -case 343: - case_343(); +case 342: + case_342(); break; case 344: case_344(); break; -case 346: - case_346(); +case 345: + case_345(); break; case 347: case_347(); @@ -2304,19 +2324,19 @@ case 349: case_349(); break; case 350: -#line 2730 "cs-parser.jay" + case_350(); + break; +case 351: +#line 2777 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } break; -case 351: - case_351(); - break; case 352: case_352(); break; -case 354: - case_354(); +case 353: + case_353(); break; case 355: case_355(); @@ -2333,8 +2353,8 @@ case 358: case 359: case_359(); break; -case 361: - case_361(); +case 360: + case_360(); break; case 362: case_362(); @@ -2348,60 +2368,60 @@ case 364: case 365: case_365(); break; -case 367: -#line 2848 "cs-parser.jay" +case 366: + case_366(); + break; +case 368: +#line 2895 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } break; -case 368: -#line 2855 "cs-parser.jay" +case 369: +#line 2902 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } break; -case 370: - case_370(); +case 371: + case_371(); break; -case 372: - case_372(); +case 373: + case_373(); break; -case 374: - case_374(); +case 375: + case_375(); break; -case 376: -#line 2893 "cs-parser.jay" +case 377: +#line 2940 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 377: - case_377(); - break; case 378: -#line 2913 "cs-parser.jay" + case_378(); + break; +case 379: +#line 2960 "cs-parser.jay" { yyVal = new ComposedCast (((MemberName) yyVals[-1+yyTop]).GetTypeExpression (), (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 379: - case_379(); - break; case 380: -#line 2922 "cs-parser.jay" + case_380(); + break; +case 381: +#line 2969 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 381: -#line 2926 "cs-parser.jay" +case 382: +#line 2973 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 382: - case_382(); - break; case 383: case_383(); break; @@ -2412,95 +2432,95 @@ case 385: case_385(); break; case 386: -#line 2964 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } + case_386(); break; case 387: -#line 2965 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } +#line 3011 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } break; case 388: -#line 2966 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } +#line 3012 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } break; case 389: -#line 2967 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } +#line 3013 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } break; case 390: -#line 2968 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } +#line 3014 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } break; case 391: -#line 2969 "cs-parser.jay" +#line 3015 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } + break; +case 392: +#line 3016 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } break; -case 393: -#line 2974 "cs-parser.jay" +case 394: +#line 3021 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); } break; -case 394: -#line 2975 "cs-parser.jay" +case 395: +#line 3022 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); } break; -case 395: -#line 2976 "cs-parser.jay" +case 396: +#line 3023 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); } break; -case 396: -#line 2977 "cs-parser.jay" +case 397: +#line 3024 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); } break; -case 397: -#line 2978 "cs-parser.jay" +case 398: +#line 3025 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); } break; -case 398: -#line 2979 "cs-parser.jay" +case 399: +#line 3026 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); } break; -case 399: -#line 2980 "cs-parser.jay" +case 400: +#line 3027 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); } break; -case 400: -#line 2981 "cs-parser.jay" +case 401: +#line 3028 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); } break; -case 401: -#line 2982 "cs-parser.jay" +case 402: +#line 3029 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); } break; -case 422: - case_422(); - break; case 423: case_423(); break; -case 427: -#line 3029 "cs-parser.jay" - { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } +case 424: + case_424(); break; case 428: -#line 3033 "cs-parser.jay" - { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } +#line 3076 "cs-parser.jay" + { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } break; case 429: -#line 3034 "cs-parser.jay" - { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } +#line 3080 "cs-parser.jay" + { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } break; -case 434: - case_434(); +case 430: +#line 3081 "cs-parser.jay" + { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } break; case 435: -#line 3067 "cs-parser.jay" + case_435(); + break; +case 436: +#line 3114 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); } break; -case 436: - case_436(); - break; case 437: case_437(); break; @@ -2511,49 +2531,49 @@ case 439: case_439(); break; case 440: -#line 3099 "cs-parser.jay" + case_440(); + break; +case 441: +#line 3146 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); } break; -case 441: - case_441(); - break; case 442: -#line 3107 "cs-parser.jay" + case_442(); + break; +case 443: +#line 3154 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); } break; -case 443: - case_443(); - break; case 444: case_444(); break; case 445: -#line 3123 "cs-parser.jay" - { yyVal = null; } + case_445(); break; -case 447: - case_447(); +case 446: +#line 3170 "cs-parser.jay" + { yyVal = null; } break; case 448: case_448(); break; case 449: -#line 3146 "cs-parser.jay" - { yyVal = null; } + case_449(); break; case 450: -#line 3150 "cs-parser.jay" +#line 3193 "cs-parser.jay" + { yyVal = null; } + break; +case 451: +#line 3197 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 451: - case_451(); - break; case 452: case_452(); break; @@ -2564,26 +2584,26 @@ case 454: case_454(); break; case 455: -#line 3182 "cs-parser.jay" + case_455(); + break; +case 456: +#line 3229 "cs-parser.jay" { yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); } break; -case 456: - case_456(); - break; case 457: case_457(); break; case 458: case_458(); break; -case 461: -#line 3210 "cs-parser.jay" - { yyVal = null; } +case 459: + case_459(); break; -case 463: - case_463(); +case 462: +#line 3257 "cs-parser.jay" + { yyVal = null; } break; case 464: case_464(); @@ -2598,14 +2618,14 @@ case 467: case_467(); break; case 468: -#line 3262 "cs-parser.jay" + case_468(); + break; +case 469: +#line 3309 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; -case 472: - case_472(); - break; case 473: case_473(); break; @@ -2615,8 +2635,8 @@ case 474: case 475: case_475(); break; -case 477: - case_477(); +case 476: + case_476(); break; case 478: case_478(); @@ -2634,38 +2654,38 @@ case 482: case_482(); break; case 483: -#line 3349 "cs-parser.jay" + case_483(); + break; +case 484: +#line 3396 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; -case 485: -#line 3357 "cs-parser.jay" +case 486: +#line 3404 "cs-parser.jay" { yyVal = new This (GetLocation (yyVals[0+yyTop])); } break; -case 486: - case_486(); - break; case 487: case_487(); break; case 488: -#line 3377 "cs-parser.jay" + case_488(); + break; +case 489: +#line 3424 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; -case 489: -#line 3384 "cs-parser.jay" +case 490: +#line 3431 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; -case 490: - case_490(); - break; case 491: case_491(); break; @@ -2685,23 +2705,23 @@ case 496: case_496(); break; case 497: -#line 3450 "cs-parser.jay" + case_497(); + break; +case 498: +#line 3497 "cs-parser.jay" { ++lexer.parsing_type; } break; -case 498: - case_498(); - break; case 499: case_499(); break; -case 502: -#line 3477 "cs-parser.jay" - { yyVal = null; } +case 500: + case_500(); break; -case 504: - case_504(); +case 503: +#line 3524 "cs-parser.jay" + { yyVal = null; } break; case 505: case_505(); @@ -2718,8 +2738,8 @@ case 508: case 509: case_509(); break; -case 513: - case_513(); +case 510: + case_510(); break; case 514: case_514(); @@ -2728,32 +2748,32 @@ case 515: case_515(); break; case 516: -#line 3553 "cs-parser.jay" + case_516(); + break; +case 517: +#line 3600 "cs-parser.jay" { yyVal = 2; } break; -case 517: -#line 3557 "cs-parser.jay" +case 518: +#line 3604 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; -case 518: -#line 3564 "cs-parser.jay" +case 519: +#line 3611 "cs-parser.jay" { yyVal = null; } break; -case 519: -#line 3568 "cs-parser.jay" +case 520: +#line 3615 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 520: - case_520(); - break; case 521: case_521(); break; @@ -2764,16 +2784,16 @@ case 523: case_523(); break; case 524: -#line 3612 "cs-parser.jay" + case_524(); + break; +case 525: +#line 3659 "cs-parser.jay" { lexer.TypeOfParsing = true; } break; -case 525: - case_525(); - break; -case 528: - case_528(); +case 526: + case_526(); break; case 529: case_529(); @@ -2809,140 +2829,146 @@ case 539: case_539(); break; case 540: -#line 3726 "cs-parser.jay" - { - start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_540(); break; case 541: - case_541(); +#line 3773 "cs-parser.jay" + { + start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); + } break; case 542: -#line 3742 "cs-parser.jay" + case_542(); + break; +case 543: +#line 3786 "cs-parser.jay" { - yyVal = ParametersCompiled.Undefined; + start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); } break; case 544: -#line 3750 "cs-parser.jay" +#line 3790 "cs-parser.jay" { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); } break; case 545: - case_545(); +#line 3797 "cs-parser.jay" + { + yyVal = ParametersCompiled.Undefined; + } break; -case 546: - case_546(); +case 547: +#line 3805 "cs-parser.jay" + { + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + } break; case 548: -#line 3776 "cs-parser.jay" + case_548(); + break; +case 549: + case_549(); + break; +case 551: +#line 3831 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 549: -#line 3780 "cs-parser.jay" +case 552: +#line 3835 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 552: - case_552(); +case 555: + case_555(); break; -case 553: -#line 3797 "cs-parser.jay" - { - yyVal = new Await ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } +case 556: + case_556(); break; -case 555: -#line 3809 "cs-parser.jay" +case 558: +#line 3865 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 556: -#line 3813 "cs-parser.jay" +case 559: +#line 3869 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 557: -#line 3817 "cs-parser.jay" +case 560: +#line 3873 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 558: -#line 3821 "cs-parser.jay" +case 561: +#line 3877 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 559: -#line 3825 "cs-parser.jay" +case 562: +#line 3881 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 560: -#line 3829 "cs-parser.jay" +case 563: +#line 3885 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 562: - case_562(); - break; -case 563: - case_563(); - break; -case 564: - case_564(); +case 565: + case_565(); break; case 566: case_566(); break; case 567: -#line 3861 "cs-parser.jay" + case_567(); + break; +case 569: + case_569(); + break; +case 570: +#line 3917 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 568: - case_568(); +case 571: + case_571(); break; -case 569: -#line 3870 "cs-parser.jay" +case 572: +#line 3926 "cs-parser.jay" { yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 570: -#line 3874 "cs-parser.jay" +case 573: +#line 3930 "cs-parser.jay" { yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 572: - case_572(); - break; -case 573: - case_573(); - break; case 575: case_575(); break; case 576: case_576(); break; -case 577: - case_577(); - break; case 578: case_578(); break; +case 579: + case_579(); + break; case 580: case_580(); break; @@ -2952,38 +2978,35 @@ case 581: case 583: case_583(); break; -case 585: - case_585(); +case 584: + case_584(); break; -case 587: - case_587(); +case 586: + case_586(); break; -case 589: - case_589(); +case 588: + case_588(); break; -case 591: - case_591(); +case 590: + case_590(); break; -case 593: - case_593(); +case 592: + case_592(); break; -case 595: - case_595(); +case 594: + case_594(); break; case 596: -#line 3998 "cs-parser.jay" - { - yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } - break; -case 597: - case_597(); + case_596(); break; case 598: case_598(); break; case 599: - case_599(); +#line 4054 "cs-parser.jay" + { + yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 600: case_600(); @@ -3022,30 +3045,30 @@ case 611: case_611(); break; case 612: -#line 4093 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + case_612(); break; case 613: case_613(); break; +case 614: + case_614(); + break; +case 615: +#line 4149 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + break; case 616: -#line 4108 "cs-parser.jay" + case_616(); + break; +case 619: +#line 4164 "cs-parser.jay" { start_block (lexer.Location); } break; -case 617: - case_617(); - break; -case 619: - case_619(); - break; case 620: case_620(); break; -case 621: - case_621(); - break; case 622: case_622(); break; @@ -3055,10 +3078,28 @@ case 623: case 624: case_624(); break; +case 625: + case_625(); + break; +case 626: + case_626(); + break; +case 627: +#line 4209 "cs-parser.jay" + { + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + } + break; +case 628: + case_628(); + break; +case 629: + case_629(); + break; case 630: -#line 4170 "cs-parser.jay" +#line 4223 "cs-parser.jay" { - yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; case 631: @@ -3067,27 +3108,12 @@ case 631: case 632: case_632(); break; -case 633: - case_633(); - break; -case 635: -#line 4199 "cs-parser.jay" - { - yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); - } - break; -case 636: -#line 4212 "cs-parser.jay" +case 638: +#line 4248 "cs-parser.jay" { - lexer.ConstraintsParsing = true; + yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); } break; -case 637: - case_637(); - break; -case 638: - case_638(); - break; case 639: case_639(); break; @@ -3095,15 +3121,22 @@ case 640: case_640(); break; case 641: -#line 4251 "cs-parser.jay" - { yyVal = null; } - break; -case 642: -#line 4253 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } + case_641(); break; case 643: - case_643(); +#line 4277 "cs-parser.jay" + { + yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); + } + break; +case 644: +#line 4290 "cs-parser.jay" + { + lexer.ConstraintsParsing = true; + } + break; +case 645: + case_645(); break; case 646: case_646(); @@ -3115,20 +3148,16 @@ case 648: case_648(); break; case 649: - case_649(); +#line 4329 "cs-parser.jay" + { yyVal = null; } break; case 650: - case_650(); +#line 4331 "cs-parser.jay" + { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } break; case 651: case_651(); break; -case 652: - case_652(); - break; -case 653: - case_653(); - break; case 654: case_654(); break; @@ -3153,17 +3182,17 @@ case 660: case 661: case_661(); break; +case 662: + case_662(); + break; case 663: -#line 4373 "cs-parser.jay" - { - current_container.AddBasesForPart (current_class, (List) yyVals[0+yyTop]); - } + case_663(); + break; +case 664: + case_664(); break; case 665: -#line 4381 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_665(); break; case 666: case_666(); @@ -3177,117 +3206,123 @@ case 668: case 669: case_669(); break; -case 670: - case_670(); - break; case 671: - case_671(); - break; -case 672: - case_672(); +#line 4451 "cs-parser.jay" + { + current_container.AddBasesForPart (current_class, (List) yyVals[0+yyTop]); + } break; case 673: - case_673(); +#line 4459 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 674: -#line 4470 "cs-parser.jay" + case_674(); + break; +case 675: + case_675(); + break; +case 676: + case_676(); + break; +case 677: + case_677(); + break; +case 678: + case_678(); + break; +case 679: + case_679(); + break; +case 680: + case_680(); + break; +case 681: + case_681(); + break; +case 682: +#line 4548 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; -case 675: -#line 4474 "cs-parser.jay" +case 683: +#line 4552 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; -case 676: -#line 4481 "cs-parser.jay" +case 684: +#line 4559 "cs-parser.jay" { yyVal = Variance.None; } break; -case 677: - case_677(); +case 685: + case_685(); break; -case 678: -#line 4495 "cs-parser.jay" +case 686: +#line 4573 "cs-parser.jay" { yyVal = Variance.Covariant; } break; -case 679: -#line 4499 "cs-parser.jay" +case 687: +#line 4577 "cs-parser.jay" { yyVal = Variance.Contravariant; } break; -case 680: - case_680(); +case 688: + case_688(); break; -case 681: -#line 4524 "cs-parser.jay" +case 689: +#line 4602 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 682: - case_682(); +case 690: + case_690(); break; -case 683: - case_683(); +case 691: + case_691(); break; -case 684: - case_684(); +case 692: + case_692(); break; -case 685: - case_685(); +case 693: + case_693(); break; -case 690: -#line 4568 "cs-parser.jay" +case 698: +#line 4646 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 691: -#line 4572 "cs-parser.jay" +case 699: +#line 4650 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 693: - case_693(); +case 701: + case_701(); break; -case 696: -#line 4596 "cs-parser.jay" +case 704: +#line 4674 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 697: -#line 4600 "cs-parser.jay" +case 705: +#line 4678 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 726: - case_726(); - break; -case 727: - case_727(); - break; -case 728: - case_728(); - break; -case 729: - case_729(); - break; -case 730: - case_730(); - break; -case 733: - case_733(); - break; case 734: case_734(); break; @@ -3298,28 +3333,16 @@ case 736: case_736(); break; case 737: -#line 4744 "cs-parser.jay" - { - yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_737(); break; case 738: -#line 4748 "cs-parser.jay" - { - yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); - } - break; -case 739: - case_739(); + case_738(); break; case 741: case_741(); break; case 742: -#line 4769 "cs-parser.jay" - { - yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); - } + case_742(); break; case 743: case_743(); @@ -3328,28 +3351,43 @@ case 744: case_744(); break; case 745: - case_745(); +#line 4822 "cs-parser.jay" + { + yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; case 746: - case_746(); +#line 4826 "cs-parser.jay" + { + yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; -case 748: - case_748(); +case 747: + case_747(); break; case 749: case_749(); break; +case 750: +#line 4847 "cs-parser.jay" + { + yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); + } + break; +case 751: + case_751(); + break; +case 752: + case_752(); + break; +case 753: + case_753(); + break; case 754: case_754(); break; -case 755: - case_755(); - break; case 756: -#line 4858 "cs-parser.jay" - { - report.Error (145, lexer.Location, "A const field requires a value to be provided"); - } + case_756(); break; case 757: case_757(); @@ -3357,47 +3395,41 @@ case 757: case 762: case_762(); break; +case 763: + case_763(); + break; case 764: - case_764(); +#line 4936 "cs-parser.jay" + { + report.Error (145, lexer.Location, "A const field requires a value to be provided"); + } break; case 765: case_765(); break; -case 766: - case_766(); - break; -case 767: -#line 4908 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } - break; -case 768: -#line 4912 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } - break; -case 769: -#line 4913 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } - break; case 770: case_770(); break; -case 771: - case_771(); - break; case 772: case_772(); break; +case 773: + case_773(); + break; +case 774: + case_774(); + break; case 775: - case_775(); +#line 4986 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 776: - case_776(); +#line 4990 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 777: -#line 4981 "cs-parser.jay" - { - start_block (GetLocation (yyVals[0+yyTop])); - } +#line 4991 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 778: case_778(); @@ -3405,25 +3437,19 @@ case 778: case 779: case_779(); break; -case 781: - case_781(); - break; -case 782: - case_782(); +case 780: + case_780(); break; case 783: case_783(); break; case 784: -#line 5025 "cs-parser.jay" - { - current_block = current_block.CreateSwitchBlock (lexer.Location); - } + case_784(); break; case 785: -#line 5029 "cs-parser.jay" +#line 5059 "cs-parser.jay" { - yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); + start_block (GetLocation (yyVals[0+yyTop])); } break; case 786: @@ -3432,13 +3458,25 @@ case 786: case 787: case_787(); break; -case 788: - case_788(); - break; case 789: -#line 5058 "cs-parser.jay" + case_789(); + break; +case 790: + case_790(); + break; +case 791: + case_791(); + break; +case 792: +#line 5103 "cs-parser.jay" { - yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); + current_block = current_block.CreateSwitchBlock (lexer.Location); + } + break; +case 793: +#line 5107 "cs-parser.jay" + { + yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); } break; case 794: @@ -3451,46 +3489,55 @@ case 796: case_796(); break; case 797: -#line 5097 "cs-parser.jay" +#line 5136 "cs-parser.jay" { - yyVal = yyVals[0+yyTop]; + yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } break; -case 798: - case_798(); - break; -case 799: - case_799(); - break; -case 800: -#line 5125 "cs-parser.jay" - { yyVal = new EmptyStatement (lexer.Location); } - break; case 802: case_802(); break; case 803: case_803(); break; +case 804: + case_804(); + break; case 805: -#line 5146 "cs-parser.jay" - { yyVal = null; } +#line 5175 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } + break; +case 806: + case_806(); break; case 807: -#line 5151 "cs-parser.jay" + case_807(); + break; +case 808: +#line 5203 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; +case 810: + case_810(); + break; case 811: case_811(); break; -case 812: - case_812(); - break; case 813: - case_813(); +#line 5224 "cs-parser.jay" + { yyVal = null; } break; -case 814: - case_814(); +case 815: +#line 5229 "cs-parser.jay" + { yyVal = new EmptyStatement (lexer.Location); } + break; +case 819: + case_819(); + break; +case 820: + case_820(); break; case 821: case_821(); @@ -3498,32 +3545,17 @@ case 821: case 822: case_822(); break; -case 823: - case_823(); - break; -case 824: - case_824(); - break; -case 825: - case_825(); - break; -case 826: - case_826(); - break; -case 827: - case_827(); - break; -case 828: - case_828(); - break; case 829: case_829(); break; +case 830: + case_830(); + break; +case 831: + case_831(); + break; case 832: -#line 5306 "cs-parser.jay" - { - yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); - } + case_832(); break; case 833: case_833(); @@ -3541,74 +3573,68 @@ case 837: case_837(); break; case 840: -#line 5359 "cs-parser.jay" +#line 5384 "cs-parser.jay" { - yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); } break; case 841: case_841(); break; case 842: -#line 5378 "cs-parser.jay" - { - yyVal = yyVals[-1+yyTop]; - } + case_842(); break; case 843: case_843(); break; case 844: -#line 5396 "cs-parser.jay" - { - yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_844(); break; case 845: -#line 5403 "cs-parser.jay" - { - yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } - break; -case 846: - case_846(); + case_845(); break; -case 847: -#line 5413 "cs-parser.jay" +case 848: +#line 5437 "cs-parser.jay" { - yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); + yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 848: - case_848(); - break; case 849: case_849(); break; case 850: - case_850(); +#line 5456 "cs-parser.jay" + { + yyVal = yyVals[-1+yyTop]; + } break; case 851: case_851(); break; case 852: - case_852(); +#line 5474 "cs-parser.jay" + { + yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 853: - case_853(); +#line 5481 "cs-parser.jay" + { + yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 854: case_854(); break; case 855: - case_855(); - break; -case 856: -#line 5496 "cs-parser.jay" +#line 5491 "cs-parser.jay" { - report.Error (210, lexer.Location, "You must provide an initializer in a fixed or using statement declaration"); + yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } break; +case 856: + case_856(); + break; case 857: case_857(); break; @@ -3631,25 +3657,22 @@ case 863: case_863(); break; case 864: - case_864(); +#line 5574 "cs-parser.jay" + { + report.Error (210, lexer.Location, "You must provide an initializer in a fixed or using statement declaration"); + } break; case 865: case_865(); break; case 866: -#line 5596 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_866(); break; case 867: case_867(); break; case 868: -#line 5611 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_868(); break; case 869: case_869(); @@ -3657,209 +3680,239 @@ case 869: case 870: case_870(); break; +case 871: + case_871(); + break; case 872: case_872(); break; case 873: -#line 5656 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_873(); break; case 874: - case_874(); +#line 5674 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; case 875: case_875(); break; case 876: - case_876(); +#line 5689 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; case 877: case_877(); break; -case 881: - case_881(); - break; -case 887: -#line 5715 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } +case 878: + case_878(); break; -case 888: - case_888(); +case 880: + case_880(); break; -case 889: +case 881: #line 5734 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 890: - case_890(); +case 882: + case_882(); break; -case 891: - case_891(); +case 883: + case_883(); break; -case 892: - case_892(); +case 884: + case_884(); break; -case 893: - case_893(); +case 885: + case_885(); break; -case 894: - case_894(); +case 889: + case_889(); break; case 895: - case_895(); +#line 5793 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; case 896: case_896(); break; case 897: - case_897(); +#line 5812 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; case 898: case_898(); break; +case 899: + case_899(); + break; case 900: -#line 5878 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_900(); break; case 901: -#line 5885 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_901(); break; case 902: case_902(); break; +case 903: + case_903(); + break; case 904: case_904(); break; case 905: case_905(); break; -case 907: - case_907(); +case 906: + case_906(); break; case 908: - case_908(); +#line 5956 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 909: -#line 5931 "cs-parser.jay" +#line 5963 "cs-parser.jay" { - yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; case 910: case_910(); break; -case 911: - case_911(); - break; case 912: -#line 5948 "cs-parser.jay" - { - yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); - } + case_912(); break; case 913: case_913(); break; -case 914: - case_914(); +case 915: + case_915(); break; case 916: case_916(); break; case 917: - case_917(); +#line 6009 "cs-parser.jay" + { + yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + } + break; +case 918: + case_918(); + break; +case 919: + case_919(); break; case 920: - case_920(); +#line 6026 "cs-parser.jay" + { + yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + } break; case 921: case_921(); break; +case 922: + case_922(); + break; +case 924: + case_924(); + break; +case 925: + case_925(); + break; +case 928: + case_928(); + break; case 929: -#line 6072 "cs-parser.jay" + case_929(); + break; +case 937: +#line 6150 "cs-parser.jay" { module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; } break; -case 930: -#line 6079 "cs-parser.jay" +case 938: +#line 6157 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; } break; -case 931: - case_931(); +case 939: + case_939(); break; -case 932: - case_932(); +case 940: + case_940(); break; -case 933: -#line 6096 "cs-parser.jay" +case 941: +#line 6174 "cs-parser.jay" { yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], new MemberName (MemberCache.IndexerNameAlias)); } break; -case 934: -#line 6100 "cs-parser.jay" +case 942: +#line 6178 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 935: - case_935(); +case 943: + case_943(); break; -case 936: - case_936(); +case 944: + case_944(); break; -case 937: - case_937(); +case 945: + case_945(); break; -case 938: - case_938(); +case 946: + case_946(); break; -case 940: -#line 6136 "cs-parser.jay" +case 948: +#line 6214 "cs-parser.jay" { yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); } break; -case 942: -#line 6144 "cs-parser.jay" +case 950: +#line 6222 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 943: -#line 6148 "cs-parser.jay" +case 951: +#line 6226 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; -case 944: -#line 6155 "cs-parser.jay" +case 952: +#line 6233 "cs-parser.jay" { yyVal = new List (0); } break; -case 946: - case_946(); +case 954: + case_954(); break; -case 947: - case_947(); +case 955: + case_955(); break; -case 948: - case_948(); +case 956: + case_956(); break; #line default } @@ -3897,7 +3950,7 @@ case 948: All more than 3 lines long rules are wrapped into a method */ void case_6() -#line 388 "cs-parser.jay" +#line 403 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { Attributes attrs = (Attributes) yyVals[0+yyTop]; @@ -3907,7 +3960,7 @@ void case_6() } void case_8() -#line 400 "cs-parser.jay" +#line 415 "cs-parser.jay" { if (yyToken == Token.EXTERN_ALIAS) report.Error (439, lexer.Location, "An extern alias declaration must precede all other elements"); @@ -3916,7 +3969,7 @@ void case_8() } void case_13() -#line 420 "cs-parser.jay" +#line 435 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -3932,21 +3985,21 @@ void case_13() } void case_17() -#line 446 "cs-parser.jay" +#line 461 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_18() -#line 451 "cs-parser.jay" +#line 466 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_19() -#line 459 "cs-parser.jay" +#line 474 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") { @@ -3959,21 +4012,21 @@ void case_19() } void case_20() -#line 470 "cs-parser.jay" +#line 485 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_21() -#line 478 "cs-parser.jay" +#line 493 "cs-parser.jay" { current_namespace.AddUsing ((MemberName) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); ubag.AddUsing (GetLocation (yyVals[-2+yyTop]), (MemberName) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } void case_22() -#line 491 "cs-parser.jay" +#line 506 "cs-parser.jay" { Attributes attrs = (Attributes) yyVals[-2+yyTop]; MemberName name = (MemberName) yyVals[0+yyTop]; @@ -4006,7 +4059,7 @@ void case_22() } void case_23() -#line 522 "cs-parser.jay" +#line 537 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -4014,7 +4067,7 @@ void case_23() } void case_24() -#line 528 "cs-parser.jay" +#line 543 "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])); @@ -4029,28 +4082,28 @@ void case_24() } void case_25() -#line 544 "cs-parser.jay" +#line 559 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName (lt.Value, lt.Location); } void case_26() -#line 549 "cs-parser.jay" +#line 564 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, lt.Location); } void case_27() -#line 554 "cs-parser.jay" +#line 569 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new MemberName ("", lexer.Location); } void case_32() -#line 572 "cs-parser.jay" +#line 587 "cs-parser.jay" { MemberName name = (MemberName) yyVals[0+yyTop]; @@ -4061,7 +4114,7 @@ void case_32() } void case_41() -#line 604 "cs-parser.jay" +#line 619 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { TypeContainer ds = (TypeContainer)yyVals[0+yyTop]; @@ -4082,15 +4135,15 @@ void case_41() } void case_50() -#line 654 "cs-parser.jay" +#line 669 "cs-parser.jay" { var sect = (List) yyVals[0+yyTop]; yyVal = new Attributes (sect); - lbag.AddLocation (yyVal, savedOpenLocation, savedCloseLocation); + lbag.AddLocation (sect, savedOpenLocation, savedCloseLocation); } void case_51() -#line 660 "cs-parser.jay" +#line 675 "cs-parser.jay" { Attributes attrs = yyVals[-1+yyTop] as Attributes; var sect = (List) yyVals[0+yyTop]; @@ -4098,25 +4151,26 @@ void case_51() attrs = new Attributes (sect); else attrs.AddAttributes (sect); + lbag.AddLocation (sect, savedOpenLocation, savedCloseLocation); yyVal = attrs; } void case_52() -#line 673 "cs-parser.jay" +#line 689 "cs-parser.jay" { lexer.parsing_attribute_section = true; savedOpenLocation = GetLocation (yyVals[0+yyTop]); } void case_53() -#line 678 "cs-parser.jay" +#line 694 "cs-parser.jay" { lexer.parsing_attribute_section = false; yyVal = yyVals[0+yyTop]; } void case_54() -#line 686 "cs-parser.jay" +#line 702 "cs-parser.jay" { current_attr_target = (string) yyVals[-1+yyTop]; if (current_attr_target == "assembly" || current_attr_target == "module") { @@ -4125,7 +4179,7 @@ void case_54() } void case_55() -#line 693 "cs-parser.jay" +#line 709 "cs-parser.jay" { /* when attribute target is invalid*/ if (current_attr_target == string.Empty) @@ -4139,21 +4193,21 @@ void case_55() } void case_56() -#line 705 "cs-parser.jay" +#line 721 "cs-parser.jay" { yyVal = yyVals[-2+yyTop]; savedCloseLocation = GetLocation (yyVals[0+yyTop]); } void case_57() -#line 713 "cs-parser.jay" +#line 729 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = CheckAttributeTarget (lt.Value, lt.Location); } void case_60() -#line 720 "cs-parser.jay" +#line 736 "cs-parser.jay" { if (yyToken == Token.IDENTIFIER) { Error_SyntaxError (yyToken); @@ -4165,7 +4219,7 @@ void case_60() } void case_62() -#line 737 "cs-parser.jay" +#line 753 "cs-parser.jay" { var attrs = (List) yyVals[-2+yyTop]; attrs.Add ((Attribute) yyVals[0+yyTop]); @@ -4174,7 +4228,7 @@ void case_62() } void case_64() -#line 751 "cs-parser.jay" +#line 767 "cs-parser.jay" { --lexer.parsing_block; MemberName mname = (MemberName) yyVals[-2+yyTop]; @@ -4186,10 +4240,21 @@ void case_64() Arguments [] arguments = (Arguments []) yyVals[0+yyTop]; ATypeNameExpression expr = mname.GetTypeExpression (); yyVal = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); + if (arguments != null) { + lbag.AddLocation (yyVal, savedAttrParenOpenLocation, savedAttrParenCloseLocation); + } + } + +void case_67() +#line 791 "cs-parser.jay" +{ + savedAttrParenOpenLocation = GetLocation (yyVals[-2+yyTop]); + savedAttrParenCloseLocation = GetLocation (yyVals[0+yyTop]); + yyVal = yyVals[-1+yyTop]; } void case_69() -#line 781 "cs-parser.jay" +#line 802 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4197,7 +4262,7 @@ void case_69() } void case_70() -#line 787 "cs-parser.jay" +#line 808 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4205,7 +4270,7 @@ void case_70() } void case_71() -#line 793 "cs-parser.jay" +#line 814 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] != null) { @@ -4222,7 +4287,7 @@ void case_71() } void case_72() -#line 808 "cs-parser.jay" +#line 829 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] == null) { @@ -4234,7 +4299,7 @@ void case_72() } void case_76() -#line 833 "cs-parser.jay" +#line 854 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4243,7 +4308,7 @@ void case_76() } void case_77() -#line 843 "cs-parser.jay" +#line 864 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument"); @@ -4256,7 +4321,7 @@ void case_77() } void case_95() -#line 890 "cs-parser.jay" +#line 911 "cs-parser.jay" { report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName (yyToken)); @@ -4265,14 +4330,14 @@ void case_95() } void case_97() -#line 907 "cs-parser.jay" +#line 928 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); push_current_class (new Struct (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); } void case_98() -#line 913 "cs-parser.jay" +#line 934 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -4285,7 +4350,7 @@ void case_98() } void case_99() -#line 924 "cs-parser.jay" +#line 945 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -4293,21 +4358,21 @@ void case_99() } void case_100() -#line 930 "cs-parser.jay" +#line 951 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[0+yyTop])); yyVal = pop_current_class (); } void case_102() -#line 942 "cs-parser.jay" +#line 963 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_118() -#line 984 "cs-parser.jay" +#line 1005 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var mod = (Modifiers) yyVals[-3+yyTop]; @@ -4322,7 +4387,7 @@ void case_118() } void case_119() -#line 997 "cs-parser.jay" +#line 1018 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4335,7 +4400,7 @@ void case_119() } void case_124() -#line 1027 "cs-parser.jay" +#line 1048 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4343,7 +4408,7 @@ void case_124() } void case_126() -#line 1040 "cs-parser.jay" +#line 1061 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -4351,14 +4416,14 @@ void case_126() } void case_127() -#line 1046 "cs-parser.jay" +#line 1067 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } void case_130() -#line 1061 "cs-parser.jay" +#line 1082 "cs-parser.jay" { lexer.parsing_generic_declaration = false; @@ -4373,7 +4438,7 @@ void case_130() } void case_131() -#line 1076 "cs-parser.jay" +#line 1097 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4386,7 +4451,7 @@ void case_131() } void case_132() -#line 1089 "cs-parser.jay" +#line 1110 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); @@ -4399,7 +4464,7 @@ void case_132() } void case_133() -#line 1100 "cs-parser.jay" +#line 1121 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4413,7 +4478,7 @@ void case_133() } void case_136() -#line 1123 "cs-parser.jay" +#line 1144 "cs-parser.jay" { ++lexer.parsing_block; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -4421,7 +4486,7 @@ void case_136() } void case_137() -#line 1129 "cs-parser.jay" +#line 1150 "cs-parser.jay" { --lexer.parsing_block; current_field.Initializer = (Expression) yyVals[0+yyTop]; @@ -4431,7 +4496,7 @@ void case_137() } void case_142() -#line 1156 "cs-parser.jay" +#line 1177 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -4439,7 +4504,7 @@ void case_142() } void case_144() -#line 1166 "cs-parser.jay" +#line 1187 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4448,7 +4513,7 @@ void case_144() } void case_149() -#line 1192 "cs-parser.jay" +#line 1213 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4456,7 +4521,7 @@ void case_149() } void case_151() -#line 1205 "cs-parser.jay" +#line 1226 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -4464,14 +4529,14 @@ void case_151() } void case_152() -#line 1211 "cs-parser.jay" +#line 1232 "cs-parser.jay" { report.Error (443, lexer.Location, "Value or constant expected"); yyVal = null; } void case_155() -#line 1221 "cs-parser.jay" +#line 1242 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); @@ -4479,7 +4544,7 @@ void case_155() } void case_156() -#line 1230 "cs-parser.jay" +#line 1251 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; @@ -4489,13 +4554,23 @@ void case_156() } void case_157() -#line 1238 "cs-parser.jay" +#line 1259 "cs-parser.jay" { Method method = (Method) yyVals[-2+yyTop]; method.Block = (ToplevelBlock) yyVals[0+yyTop]; - if (current_container.Kind == MemberKind.Interface && method.Block != null) { - report.Error (531, method.Location, "`{0}': interface members cannot have a definition", method.GetSignatureForError ()); + if (method.Block == null) { + method.ParameterInfo.CheckParameters (method); + + if ((method.ModFlags & Modifiers.ASYNC) != 0) { + report.Error (1994, method.Location, "`{0}': The async modifier can only be used with methods that have a body", + method.GetSignatureForError ()); + } + } else { + if (current_container.Kind == MemberKind.Interface) { + report.Error (531, method.Location, "`{0}': interface members cannot have a definition", + method.GetSignatureForError ()); + } } current_local_parameters = null; @@ -4505,7 +4580,7 @@ void case_157() } void case_160() -#line 1266 "cs-parser.jay" +#line 1297 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4539,8 +4614,15 @@ void case_160() yyVal = method; } -void case_163() -#line 1311 "cs-parser.jay" +void case_162() +#line 1338 "cs-parser.jay" +{ + lexer.parsing_generic_declaration = false; + valid_param_mod = ParameterModifierType.All; + } + +void case_164() +#line 1347 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4556,14 +4638,13 @@ void case_163() GenericMethod generic = null; if (name.TypeArguments != null) { generic = new GenericMethod (current_namespace, current_class, name, - new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-7+yyTop])), + new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])), current_local_parameters); - generic.SetParameterInfo ((List) yyVals[0+yyTop]); + generic.SetParameterInfo ((List) yyVals[-1+yyTop]); } - var modifiers = (Modifiers) yyVals[-9+yyTop]; - + var modifiers = (Modifiers) yyVals[-10+yyTop]; const Modifiers invalid_partial_mod = Modifiers.AccessibilityMask | Modifiers.ABSTRACT | Modifiers.EXTERN | Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.SEALED | Modifiers.VIRTUAL; @@ -4581,20 +4662,19 @@ void case_163() modifiers |= Modifiers.PARTIAL | Modifiers.PRIVATE; - method = new Method (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-7+yyTop])), - modifiers, name, current_local_parameters, (Attributes) yyVals[-10+yyTop]); + method = new Method (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])), + modifiers, name, current_local_parameters, (Attributes) yyVals[-11+yyTop]); if (doc_support) method.DocComment = Lexer.consume_doc_comment (); - /* TODO: lbag, push void*/ - StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[-8+yyTop])); - lbag.AddMember (method, GetModifierLocations (), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop])); + StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[-9+yyTop])); + lbag.AddMember (method, mod_locations, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop])); yyVal = method; } -void case_164() -#line 1366 "cs-parser.jay" +void case_165() +#line 1400 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-3+yyTop]; report.Error (1585, name.Location, @@ -4611,16 +4691,16 @@ void case_164() yyVal = method; } -void case_169() -#line 1395 "cs-parser.jay" +void case_170() +#line 1429 "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_170() -#line 1401 "cs-parser.jay" +void case_171() +#line 1435 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add ((Parameter) yyVals[0+yyTop]); @@ -4628,16 +4708,16 @@ void case_170() yyVal = new ParametersCompiled (pars_list.ToArray ()); } -void case_171() -#line 1408 "cs-parser.jay" +void case_172() +#line 1442 "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_172() -#line 1414 "cs-parser.jay" +void case_173() +#line 1448 "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"); @@ -4645,8 +4725,8 @@ void case_172() yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[-2+yyTop] } ); } -void case_173() -#line 1421 "cs-parser.jay" +void case_174() +#line 1455 "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"); @@ -4657,16 +4737,16 @@ void case_173() yyVal = new ParametersCompiled (pars_list.ToArray (), true); } -void case_174() -#line 1431 "cs-parser.jay" +void case_175() +#line 1465 "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_175() -#line 1437 "cs-parser.jay" +void case_176() +#line 1471 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4676,15 +4756,15 @@ void case_175() yyVal = new ParametersCompiled (pars_list.ToArray (), true); } -void case_178() -#line 1454 "cs-parser.jay" +void case_179() +#line 1488 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } -void case_179() -#line 1462 "cs-parser.jay" +void case_180() +#line 1496 "cs-parser.jay" { parameters_bucket.Clear (); Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4694,8 +4774,8 @@ void case_179() yyVal = parameters_bucket; } -void case_180() -#line 1471 "cs-parser.jay" +void case_181() +#line 1505 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4714,16 +4794,16 @@ void case_180() yyVal = yyVals[-2+yyTop]; } -void case_181() -#line 1495 "cs-parser.jay" +void case_182() +#line 1529 "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_182() -#line 1504 "cs-parser.jay" +void case_183() +#line 1538 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name"); @@ -4731,8 +4811,8 @@ void case_182() lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_183() -#line 1514 "cs-parser.jay" +void case_184() +#line 1548 "cs-parser.jay" { Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); @@ -4740,8 +4820,8 @@ void case_183() lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_185() -#line 1529 "cs-parser.jay" +void case_186() +#line 1563 "cs-parser.jay" { --lexer.parsing_block; if (lang_version <= LanguageVersion.V_3) { @@ -4779,15 +4859,15 @@ void case_185() ((Parameter) yyVal).DefaultValue = new DefaultParameterValueExpression ((Expression) yyVals[0+yyTop]); } -void case_188() -#line 1574 "cs-parser.jay" +void case_189() +#line 1608 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; parameterModifierLocation = GetLocation (yyVals[0+yyTop]); } -void case_189() -#line 1579 "cs-parser.jay" +void case_190() +#line 1613 "cs-parser.jay" { Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop]; Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2; @@ -4809,8 +4889,8 @@ void case_189() yyVal = mod; } -void case_190() -#line 1603 "cs-parser.jay" +void case_191() +#line 1637 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Ref) == 0) Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop])); @@ -4818,8 +4898,8 @@ void case_190() yyVal = Parameter.Modifier.REF; } -void case_191() -#line 1610 "cs-parser.jay" +void case_192() +#line 1644 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Out) == 0) Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop])); @@ -4827,8 +4907,8 @@ void case_191() yyVal = Parameter.Modifier.OUT; } -void case_192() -#line 1617 "cs-parser.jay" +void case_193() +#line 1651 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop])); @@ -4839,15 +4919,15 @@ void case_192() yyVal = Parameter.Modifier.This; } -void case_193() -#line 1630 "cs-parser.jay" +void case_194() +#line 1664 "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_194() -#line 1635 "cs-parser.jay" +void case_195() +#line 1669 "cs-parser.jay" { report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array"); @@ -4855,22 +4935,22 @@ void case_194() yyVal = new ParamsParameter ((FullNamedExpression) yyVals[-3+yyTop], lt.Value, (Attributes) yyVals[-5+yyTop], lt.Location); } -void case_195() -#line 1642 "cs-parser.jay" +void case_196() +#line 1676 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_196() -#line 1650 "cs-parser.jay" +void case_197() +#line 1684 "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_197() -#line 1655 "cs-parser.jay" +void case_198() +#line 1689 "cs-parser.jay" { Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop]; if ((mod & Parameter.Modifier.This) != 0) { @@ -4880,22 +4960,22 @@ void case_197() } } -void case_199() -#line 1671 "cs-parser.jay" +void case_200() +#line 1705 "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_200() -#line 1682 "cs-parser.jay" +void case_201() +#line 1716 "cs-parser.jay" { if (doc_support) tmpComment = Lexer.consume_doc_comment (); } -void case_201() -#line 1687 "cs-parser.jay" +void case_202() +#line 1721 "cs-parser.jay" { var type = (FullNamedExpression) yyVals[-3+yyTop]; current_property = new Property (current_class, type, (Modifiers) yyVals[-4+yyTop], @@ -4910,8 +4990,8 @@ void case_201() lexer.PropertyParsing = true; } -void case_202() -#line 1701 "cs-parser.jay" +void case_203() +#line 1735 "cs-parser.jay" { lexer.PropertyParsing = false; @@ -4919,20 +4999,19 @@ void case_202() current_property.DocComment = ConsumeStoredComment (); } -void case_203() -#line 1708 "cs-parser.jay" +void case_204() +#line 1742 "cs-parser.jay" { lbag.AppendToMember (current_property, GetLocation (yyVals[0+yyTop])); current_property = null; } -void case_205() -#line 1722 "cs-parser.jay" +void case_206() +#line 1756 "cs-parser.jay" { valid_param_mod = 0; 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]); + 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; @@ -4954,9 +5033,12 @@ void case_205() lexer.PropertyParsing = true; } -void case_207() -#line 1752 "cs-parser.jay" -{ +void case_208() +#line 1785 "cs-parser.jay" +{ + if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) + ((Indexer) current_property).ParameterInfo.CheckParameters (current_property); + if (doc_support) current_property.DocComment = ConsumeStoredComment (); @@ -4964,8 +5046,8 @@ void case_207() current_property = null; } -void case_212() -#line 1768 "cs-parser.jay" +void case_213() +#line 1804 "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 ()); @@ -4977,8 +5059,8 @@ void case_212() } } -void case_213() -#line 1782 "cs-parser.jay" +void case_214() +#line 1818 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5001,8 +5083,8 @@ void case_213() lexer.PropertyParsing = false; } -void case_214() -#line 1804 "cs-parser.jay" +void case_215() +#line 1840 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Get.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5021,8 +5103,8 @@ void case_214() Lexer.doc_state = XmlCommentState.NotAllowed; } -void case_215() -#line 1825 "cs-parser.jay" +void case_216() +#line 1861 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5050,8 +5132,8 @@ void case_215() lexer.PropertyParsing = false; } -void case_216() -#line 1852 "cs-parser.jay" +void case_217() +#line 1888 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Set.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5070,30 +5152,30 @@ void case_216() Lexer.doc_state = XmlCommentState.NotAllowed; } -void case_218() -#line 1874 "cs-parser.jay" +void case_219() +#line 1910 "cs-parser.jay" { lbag.AppendToMember (lbag.LastMember, GetLocation (yyVals[0+yyTop])); yyVal = null; } -void case_219() -#line 1879 "cs-parser.jay" +void case_220() +#line 1915 "cs-parser.jay" { Error_SyntaxError (1043, yyToken, "Invalid accessor body"); yyVal = null; } -void case_221() -#line 1894 "cs-parser.jay" +void case_222() +#line 1930 "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_222() -#line 1901 "cs-parser.jay" +void case_223() +#line 1937 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -5105,23 +5187,23 @@ void case_222() } } -void case_223() -#line 1912 "cs-parser.jay" +void case_224() +#line 1948 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_224() -#line 1918 "cs-parser.jay" +void case_225() +#line 1954 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); yyVal = pop_current_class (); } -void case_240() -#line 1970 "cs-parser.jay" +void case_241() +#line 2006 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { @@ -5129,6 +5211,9 @@ void case_240() current_class, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], current_local_parameters, (ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location); + + if (op.Block == null) + op.ParameterInfo.CheckParameters (op); if (doc_support) { op.DocComment = tmpComment; @@ -5144,15 +5229,15 @@ void case_240() current_local_parameters = null; } -void case_244() -#line 2001 "cs-parser.jay" +void case_245() +#line 2040 "cs-parser.jay" { report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void"); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_246() -#line 2013 "cs-parser.jay" +void case_247() +#line 2052 "cs-parser.jay" { valid_param_mod = 0; @@ -5193,8 +5278,8 @@ void case_246() lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_271() -#line 2089 "cs-parser.jay" +void case_272() +#line 2128 "cs-parser.jay" { valid_param_mod = 0; @@ -5210,8 +5295,8 @@ void case_271() lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_273() -#line 2108 "cs-parser.jay" +void case_274() +#line 2147 "cs-parser.jay" { valid_param_mod = 0; @@ -5227,24 +5312,24 @@ void case_273() lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_274() -#line 2123 "cs-parser.jay" +void case_275() +#line 2162 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration (Operator.OpType.Implicit, null, GetLocation (yyVals[-1+yyTop])); } -void case_275() -#line 2129 "cs-parser.jay" +void case_276() +#line 2168 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration (Operator.OpType.Explicit, null, GetLocation (yyVals[-1+yyTop])); } -void case_276() -#line 2139 "cs-parser.jay" +void case_277() +#line 2178 "cs-parser.jay" { Constructor c = (Constructor) yyVals[-1+yyTop]; c.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5259,8 +5344,8 @@ void case_276() Lexer.doc_state = XmlCommentState.Allowed; } -void case_277() -#line 2158 "cs-parser.jay" +void case_278() +#line 2197 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5270,8 +5355,8 @@ void case_277() valid_param_mod = ParameterModifierType.All; } -void case_278() -#line 2167 "cs-parser.jay" +void case_279() +#line 2206 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -5283,8 +5368,8 @@ void case_278() start_block (lexer.Location); } -void case_279() -#line 2178 "cs-parser.jay" +void case_280() +#line 2217 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-6+yyTop]; var mods = (Modifiers) yyVals[-7+yyTop]; @@ -5313,31 +5398,31 @@ void case_279() yyVal = c; } -void case_285() -#line 2223 "cs-parser.jay" +void case_286() +#line 2262 "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_287() -#line 2233 "cs-parser.jay" +void case_288() +#line 2272 "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_288() -#line 2239 "cs-parser.jay" +void case_289() +#line 2278 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_289() -#line 2247 "cs-parser.jay" +void case_290() +#line 2286 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5347,8 +5432,8 @@ void case_289() current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } -void case_290() -#line 2256 "cs-parser.jay" +void case_291() +#line 2295 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ @@ -5369,8 +5454,8 @@ void case_290() current_local_parameters = null; } -void case_291() -#line 2281 "cs-parser.jay" +void case_292() +#line 2320 "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); @@ -5383,8 +5468,8 @@ void case_291() yyVal = current_event_field; } -void case_292() -#line 2295 "cs-parser.jay" +void case_293() +#line 2334 "cs-parser.jay" { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); @@ -5395,8 +5480,8 @@ void case_292() current_event_field = null; } -void case_293() -#line 2308 "cs-parser.jay" +void case_294() +#line 2347 "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); @@ -5405,8 +5490,8 @@ void case_293() lexer.EventParsing = true; } -void case_294() -#line 2316 "cs-parser.jay" +void case_295() +#line 2355 "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"); @@ -5414,8 +5499,8 @@ void case_294() lexer.EventParsing = false; } -void case_295() -#line 2323 "cs-parser.jay" +void case_296() +#line 2362 "cs-parser.jay" { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); @@ -5427,23 +5512,23 @@ void case_295() current_local_parameters = null; } -void case_298() -#line 2342 "cs-parser.jay" +void case_299() +#line 2381 "cs-parser.jay" { --lexer.parsing_block; current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } -void case_303() -#line 2366 "cs-parser.jay" +void case_304() +#line 2405 "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_305() -#line 2376 "cs-parser.jay" +void case_306() +#line 2415 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -5451,8 +5536,8 @@ void case_305() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_306() -#line 2385 "cs-parser.jay" +void case_307() +#line 2424 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", @@ -5465,29 +5550,29 @@ void case_306() } } -void case_310() -#line 2406 "cs-parser.jay" +void case_311() +#line 2445 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } -void case_311() -#line 2411 "cs-parser.jay" +void case_312() +#line 2450 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } -void case_312() -#line 2416 "cs-parser.jay" +void case_313() +#line 2455 "cs-parser.jay" { report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } -void case_313() -#line 2424 "cs-parser.jay" +void case_314() +#line 2463 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5500,8 +5585,8 @@ void case_313() lexer.EventParsing = false; } -void case_314() -#line 2436 "cs-parser.jay" +void case_315() +#line 2475 "cs-parser.jay" { lexer.EventParsing = true; @@ -5515,8 +5600,8 @@ void case_314() current_local_parameters = null; } -void case_315() -#line 2452 "cs-parser.jay" +void case_316() +#line 2491 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5529,8 +5614,8 @@ void case_315() lexer.EventParsing = false; } -void case_316() -#line 2464 "cs-parser.jay" +void case_317() +#line 2503 "cs-parser.jay" { lexer.EventParsing = true; @@ -5544,22 +5629,22 @@ void case_316() current_local_parameters = null; } -void case_317() -#line 2480 "cs-parser.jay" +void case_318() +#line 2519 "cs-parser.jay" { report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } -void case_319() -#line 2492 "cs-parser.jay" +void case_320() +#line 2531 "cs-parser.jay" { if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } -void case_320() -#line 2497 "cs-parser.jay" +void case_321() +#line 2536 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -5572,16 +5657,16 @@ void case_320() 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_321() -#line 2509 "cs-parser.jay" +void case_322() +#line 2548 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_322() -#line 2515 "cs-parser.jay" +void case_323() +#line 2554 "cs-parser.jay" { if (doc_support) current_class.DocComment = enumTypeComment; @@ -5595,8 +5680,8 @@ void case_322() yyVal = pop_current_class (); } -void case_324() -#line 2532 "cs-parser.jay" +void case_325() +#line 2571 "cs-parser.jay" { var te = yyVals[0+yyTop] as TypeExpression; if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { @@ -5607,22 +5692,22 @@ void case_324() } } -void case_325() -#line 2542 "cs-parser.jay" +void case_326() +#line 2581 "cs-parser.jay" { Error_TypeExpected (GetLocation (yyVals[-1+yyTop])); yyVal = null; } -void case_330() -#line 2560 "cs-parser.jay" +void case_331() +#line 2599 "cs-parser.jay" { lbag.AddLocation (yyVals[-2+yyTop], GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } -void case_331() -#line 2568 "cs-parser.jay" +void case_332() +#line 2607 "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]); @@ -5636,8 +5721,8 @@ void case_331() yyVal = em; } -void case_332() -#line 2581 "cs-parser.jay" +void case_333() +#line 2620 "cs-parser.jay" { ++lexer.parsing_block; if (doc_support) { @@ -5646,8 +5731,8 @@ void case_332() } } -void case_333() -#line 2589 "cs-parser.jay" +void case_334() +#line 2628 "cs-parser.jay" { --lexer.parsing_block; @@ -5662,8 +5747,8 @@ void case_333() yyVal = em; } -void case_335() -#line 2614 "cs-parser.jay" +void case_336() +#line 2653 "cs-parser.jay" { valid_param_mod = 0; @@ -5672,16 +5757,18 @@ void case_335() Delegate del = new Delegate (current_namespace, current_class, (FullNamedExpression) yyVals[-5+yyTop], (Modifiers) yyVals[-7+yyTop], name, p, (Attributes) yyVals[-8+yyTop]); + p.CheckParameters (del); ubag.PushTypeDeclaration (del); ubag.PopTypeDeclaration (); + current_container.AddDelegate (del); current_delegate = del; lexer.ConstraintsParsing = true; } -void case_337() -#line 2634 "cs-parser.jay" +void case_338() +#line 2675 "cs-parser.jay" { if (doc_support) { current_delegate.DocComment = Lexer.consume_doc_comment (); @@ -5696,8 +5783,8 @@ void case_337() current_delegate = null; } -void case_339() -#line 2652 "cs-parser.jay" +void case_340() +#line 2693 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); @@ -5705,8 +5792,8 @@ void case_339() yyVal = ComposedTypeSpecifier.CreateNullable (GetLocation (yyVals[0+yyTop])); } -void case_341() -#line 2663 "cs-parser.jay" +void case_342() +#line 2704 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5714,63 +5801,69 @@ void case_341() yyVal = new MemberName (lt1.Value, lt2.Value, (TypeArguments) yyVals[0+yyTop], lt1.Location); } -void case_343() -#line 2674 "cs-parser.jay" +void case_344() +#line 2715 "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_344() -#line 2683 "cs-parser.jay" +void case_345() +#line 2724 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_346() -#line 2695 "cs-parser.jay" +void case_347() +#line 2736 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) - FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); - - yyVal = yyVals[-1+yyTop]; + FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); + var list = locationListStack.Pop (); + list.Add (GetLocation (yyVals[-2+yyTop])); + list.Add (GetLocation (yyVals[-1+yyTop])); + lbag.AddLocation (yyVals[-1+yyTop], list); + + yyVal = yyVals[-1+yyTop];; } -void case_347() -#line 2702 "cs-parser.jay" +void case_348() +#line 2747 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = new TypeArguments (); } -void case_348() -#line 2710 "cs-parser.jay" +void case_349() +#line 2755 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = type_args; + locationListStack.Push (new List ()); } -void case_349() -#line 2716 "cs-parser.jay" +void case_350() +#line 2762 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = type_args; + locationListStack.Peek ().Add (GetLocation (yyVals[-1+yyTop])); } -void case_351() -#line 2732 "cs-parser.jay" +void case_352() +#line 2779 "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_352() -#line 2741 "cs-parser.jay" +void case_353() +#line 2788 "cs-parser.jay" { MemberName mn = (MemberName)yyVals[0+yyTop]; if (mn.TypeArguments != null) @@ -5778,38 +5871,38 @@ void case_352() mn.GetSignatureForError ())); } -void case_354() -#line 2752 "cs-parser.jay" +void case_355() +#line 2799 "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_355() -#line 2761 "cs-parser.jay" +void case_356() +#line 2808 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeContainer.DefaultIndexerName, GetLocation (yyVals[0+yyTop])); } -void case_356() -#line 2766 "cs-parser.jay" +void case_357() +#line 2813 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName ((MemberName) yyVals[-1+yyTop], TypeContainer.DefaultIndexerName, null, GetLocation (yyVals[-1+yyTop])); } -void case_357() -#line 2774 "cs-parser.jay" +void case_358() +#line 2821 "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_358() -#line 2780 "cs-parser.jay" +void case_359() +#line 2827 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -5818,16 +5911,16 @@ void case_358() lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_359() -#line 2788 "cs-parser.jay" +void case_360() +#line 2835 "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_361() -#line 2798 "cs-parser.jay" +void case_362() +#line 2845 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -5836,16 +5929,16 @@ void case_361() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_362() -#line 2809 "cs-parser.jay" +void case_363() +#line 2856 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression)yyVals[0+yyTop]); yyVal = type_args; } -void case_363() -#line 2815 "cs-parser.jay" +void case_364() +#line 2862 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression)yyVals[0+yyTop]); @@ -5853,15 +5946,15 @@ void case_363() lbag.AddLocation (yyVals[0+yyTop], GetLocation (yyVals[0+yyTop])); } -void case_364() -#line 2825 "cs-parser.jay" +void case_365() +#line 2872 "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_365() -#line 2830 "cs-parser.jay" +void case_366() +#line 2877 "cs-parser.jay" { if (GetTokenName (yyToken) == "type") report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type"); @@ -5871,29 +5964,29 @@ void case_365() yyVal = new TypeParameterName ("", null, lexer.Location); } -void case_370() -#line 2864 "cs-parser.jay" +void case_371() +#line 2911 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_372() -#line 2873 "cs-parser.jay" +void case_373() +#line 2920 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_374() -#line 2882 "cs-parser.jay" +void case_375() +#line 2929 "cs-parser.jay" { report.Error (1536, GetLocation (yyVals[0+yyTop]), "Invalid parameter type `void'"); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_377() -#line 2898 "cs-parser.jay" +void case_378() +#line 2945 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-1+yyTop]; @@ -5907,31 +6000,31 @@ void case_377() } } -void case_379() -#line 2915 "cs-parser.jay" +void case_380() +#line 2962 "cs-parser.jay" { if (yyVals[0+yyTop] != null) yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_382() -#line 2931 "cs-parser.jay" +void case_383() +#line 2978 "cs-parser.jay" { var types = new List (2); types.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = types; } -void case_383() -#line 2937 "cs-parser.jay" +void case_384() +#line 2984 "cs-parser.jay" { var types = (List) yyVals[-2+yyTop]; types.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = types; } -void case_384() -#line 2946 "cs-parser.jay" +void case_385() +#line 2993 "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 ()); @@ -5939,60 +6032,60 @@ void case_384() yyVal = yyVals[0+yyTop]; } -void case_385() -#line 2953 "cs-parser.jay" +void case_386() +#line 3000 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } -void case_422() -#line 3015 "cs-parser.jay" +void case_423() +#line 3062 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_423() -#line 3019 "cs-parser.jay" +void case_424() +#line 3066 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location); } -void case_434() -#line 3060 "cs-parser.jay" +void case_435() +#line 3107 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_436() -#line 3072 "cs-parser.jay" +void case_437() +#line 3119 "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_437() -#line 3078 "cs-parser.jay" +void case_438() +#line 3125 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_438() -#line 3084 "cs-parser.jay" +void case_439() +#line 3131 "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_439() -#line 3090 "cs-parser.jay" +void case_440() +#line 3137 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6001,29 +6094,29 @@ void case_439() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_441() -#line 3100 "cs-parser.jay" +void case_442() +#line 3147 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_443() -#line 3108 "cs-parser.jay" +void case_444() +#line 3155 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_444() -#line 3116 "cs-parser.jay" +void case_445() +#line 3163 "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_447() -#line 3129 "cs-parser.jay" +void case_448() +#line 3176 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) { yyVal = CollectionOrObjectInitializers.Empty; @@ -6034,46 +6127,46 @@ void case_447() } } -void case_448() -#line 3139 "cs-parser.jay" +void case_449() +#line 3186 "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_451() -#line 3155 "cs-parser.jay" +void case_452() +#line 3202 "cs-parser.jay" { var a = new List (); a.Add ((Expression) yyVals[0+yyTop]); yyVal = a; } -void case_452() -#line 3161 "cs-parser.jay" +void case_453() +#line 3208 "cs-parser.jay" { var a = (List)yyVals[-2+yyTop]; a.Add ((Expression) yyVals[0+yyTop]); yyVal = a; } -void case_453() -#line 3166 "cs-parser.jay" +void case_454() +#line 3213 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_454() -#line 3174 "cs-parser.jay" +void case_455() +#line 3221 "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_456() -#line 3183 "cs-parser.jay" +void case_457() +#line 3230 "cs-parser.jay" { CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName; if (csn == null) @@ -6082,8 +6175,8 @@ void case_456() yyVal = new CompletionElementInitializer (csn.Prefix, csn.Location); } -void case_457() -#line 3191 "cs-parser.jay" +void case_458() +#line 3238 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) yyVal = null; @@ -6091,23 +6184,23 @@ void case_457() yyVal = new CollectionElementInitializer ((List)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_458() -#line 3198 "cs-parser.jay" +void case_459() +#line 3245 "cs-parser.jay" { report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty"); yyVal = null; } -void case_463() -#line 3216 "cs-parser.jay" +void case_464() +#line 3263 "cs-parser.jay" { Arguments list = new Arguments (4); list.Add ((Argument) yyVals[0+yyTop]); yyVal = list; } -void case_464() -#line 3222 "cs-parser.jay" +void case_465() +#line 3269 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; if (list [list.Count - 1] is NamedArgument) @@ -6118,8 +6211,8 @@ void case_464() yyVal = list; } -void case_465() -#line 3232 "cs-parser.jay" +void case_466() +#line 3279 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; NamedArgument a = (NamedArgument) yyVals[0+yyTop]; @@ -6135,65 +6228,65 @@ void case_465() yyVal = list; } -void case_466() -#line 3247 "cs-parser.jay" +void case_467() +#line 3294 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[0+yyTop]), "An argument is missing"); yyVal = yyVals[-1+yyTop]; } -void case_467() -#line 3252 "cs-parser.jay" +void case_468() +#line 3299 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } -void case_472() -#line 3273 "cs-parser.jay" +void case_473() +#line 3320 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_473() -#line 3278 "cs-parser.jay" +void case_474() +#line 3325 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_474() -#line 3283 "cs-parser.jay" +void case_475() +#line 3330 "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_475() -#line 3288 "cs-parser.jay" +void case_476() +#line 3335 "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_477() -#line 3300 "cs-parser.jay" +void case_478() +#line 3347 "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_478() -#line 3308 "cs-parser.jay" +void case_479() +#line 3355 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_479() -#line 3314 "cs-parser.jay" +void case_480() +#line 3361 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6201,23 +6294,23 @@ void case_479() yyVal = list; } -void case_480() -#line 3320 "cs-parser.jay" +void case_481() +#line 3367 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_481() -#line 3328 "cs-parser.jay" +void case_482() +#line 3375 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); yyVal = args; } -void case_482() -#line 3334 "cs-parser.jay" +void case_483() +#line 3381 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6228,22 +6321,22 @@ void case_482() yyVal = args; } -void case_486() -#line 3362 "cs-parser.jay" +void case_487() +#line 3409 "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_487() -#line 3367 "cs-parser.jay" +void case_488() +#line 3414 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } -void case_490() -#line 3389 "cs-parser.jay" +void case_491() +#line 3436 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) @@ -6257,8 +6350,8 @@ void case_490() lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_491() -#line 3402 "cs-parser.jay" +void case_492() +#line 3449 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); @@ -6266,8 +6359,8 @@ void case_491() yyVal = new NewInitialize ((FullNamedExpression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_492() -#line 3414 "cs-parser.jay" +void case_493() +#line 3461 "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])) { @@ -6276,8 +6369,8 @@ void case_492() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_493() -#line 3422 "cs-parser.jay" +void case_494() +#line 3469 "cs-parser.jay" { if (yyVals[0+yyTop] == null) report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6285,8 +6378,8 @@ void case_493() yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); } -void case_494() -#line 3429 "cs-parser.jay" +void case_495() +#line 3476 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); @@ -6294,29 +6387,29 @@ void case_494() yyVal = new ImplicitlyTypedArrayCreation ((ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_495() -#line 3436 "cs-parser.jay" +void case_496() +#line 3483 "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_496() -#line 3441 "cs-parser.jay" +void case_497() +#line 3488 "cs-parser.jay" { Error_SyntaxError (1526, yyToken, "Unexpected symbol"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } -void case_498() -#line 3452 "cs-parser.jay" +void case_499() +#line 3499 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } -void case_499() -#line 3460 "cs-parser.jay" +void case_500() +#line 3507 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); @@ -6327,76 +6420,76 @@ void case_499() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_504() -#line 3483 "cs-parser.jay" +void case_505() +#line 3530 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); yyVal = a; } -void case_505() -#line 3489 "cs-parser.jay" +void case_506() +#line 3536 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); yyVal = a; } -void case_506() -#line 3498 "cs-parser.jay" +void case_507() +#line 3545 "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_507() -#line 3504 "cs-parser.jay" +void case_508() +#line 3551 "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_508() -#line 3510 "cs-parser.jay" +void case_509() +#line 3557 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } -void case_509() -#line 3515 "cs-parser.jay" +void case_510() +#line 3562 "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_513() -#line 3530 "cs-parser.jay" +void case_514() +#line 3577 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_514() -#line 3538 "cs-parser.jay" +void case_515() +#line 3585 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_515() -#line 3543 "cs-parser.jay" +void case_516() +#line 3590 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_520() -#line 3573 "cs-parser.jay" +void case_521() +#line 3620 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6404,8 +6497,8 @@ void case_520() yyVal = ai; } -void case_521() -#line 3580 "cs-parser.jay" +void case_522() +#line 3627 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6417,16 +6510,16 @@ void case_521() yyVal = ai; } -void case_522() -#line 3594 "cs-parser.jay" +void case_523() +#line 3641 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_523() -#line 3600 "cs-parser.jay" +void case_524() +#line 3647 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6434,31 +6527,31 @@ void case_523() yyVal = list; } -void case_525() -#line 3614 "cs-parser.jay" +void case_526() +#line 3661 "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_528() -#line 3625 "cs-parser.jay" +void case_529() +#line 3672 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } -void case_529() -#line 3633 "cs-parser.jay" +void case_530() +#line 3680 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_530() -#line 3639 "cs-parser.jay" +void case_531() +#line 3686 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6467,24 +6560,24 @@ void case_530() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_531() -#line 3647 "cs-parser.jay" +void case_532() +#line 3694 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-2+yyTop], lt.Value, lt.Location); } -void case_532() -#line 3653 "cs-parser.jay" +void case_533() +#line 3700 "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_533() -#line 3659 "cs-parser.jay" +void case_534() +#line 3706 "cs-parser.jay" { var te = ((MemberName) yyVals[-3+yyTop]).GetTypeExpression (); if (te.HasTypeArguments) @@ -6494,8 +6587,8 @@ void case_533() yyVal = new MemberAccess (te, lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_534() -#line 3671 "cs-parser.jay" +void case_535() +#line 3718 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); @@ -6503,8 +6596,8 @@ void case_534() yyVal = yyVals[0+yyTop]; } -void case_535() -#line 3681 "cs-parser.jay" +void case_536() +#line 3728 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; if (lang_version == LanguageVersion.ISO_1) @@ -6513,36 +6606,36 @@ void case_535() yyVal = lt; } -void case_536() -#line 3692 "cs-parser.jay" +void case_537() +#line 3739 "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_537() -#line 3700 "cs-parser.jay" +void case_538() +#line 3747 "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_538() -#line 3708 "cs-parser.jay" +void case_539() +#line 3755 "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_539() -#line 3716 "cs-parser.jay" +void case_540() +#line 3763 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-3+yyTop], GetLocation (yyVals[-2+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); } -void case_541() -#line 3728 "cs-parser.jay" +void case_542() +#line 3775 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); if ((ParametersCompiled) yyVals[-2+yyTop] != ParametersCompiled.Undefined) { @@ -6552,8 +6645,8 @@ void case_541() } } -void case_545() -#line 3752 "cs-parser.jay" +void case_548() +#line 3807 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; @@ -6561,8 +6654,8 @@ void case_545() savedCloseLocation = GetLocation (yyVals[-2+yyTop]); } -void case_546() -#line 3762 "cs-parser.jay" +void case_549() +#line 3817 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); @@ -6571,141 +6664,148 @@ void case_546() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_552() -#line 3787 "cs-parser.jay" +void case_555() +#line 3842 "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_562() -#line 3835 "cs-parser.jay" +void case_556() +#line 3850 "cs-parser.jay" +{ + current_block.ParametersBlock.IsAsync = true; + yyVal = new Await ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } + +void case_565() +#line 3891 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_563() -#line 3840 "cs-parser.jay" +void case_566() +#line 3896 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_564() -#line 3845 "cs-parser.jay" +void case_567() +#line 3901 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_566() -#line 3854 "cs-parser.jay" +void case_569() +#line 3910 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_568() -#line 3863 "cs-parser.jay" +void case_571() +#line 3919 "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_572() -#line 3880 "cs-parser.jay" +void case_575() +#line 3936 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_573() -#line 3885 "cs-parser.jay" +void case_576() +#line 3941 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_575() -#line 3894 "cs-parser.jay" +void case_578() +#line 3950 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_576() -#line 3899 "cs-parser.jay" +void case_579() +#line 3955 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_577() -#line 3904 "cs-parser.jay" +void case_580() +#line 3960 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_578() -#line 3909 "cs-parser.jay" +void case_581() +#line 3965 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_580() -#line 3918 "cs-parser.jay" +void case_583() +#line 3974 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_581() -#line 3923 "cs-parser.jay" +void case_584() +#line 3979 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_583() -#line 3932 "cs-parser.jay" +void case_586() +#line 3988 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_585() -#line 3941 "cs-parser.jay" +void case_588() +#line 3997 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_587() -#line 3950 "cs-parser.jay" +void case_590() +#line 4006 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_589() -#line 3959 "cs-parser.jay" +void case_592() +#line 4015 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_591() -#line 3968 "cs-parser.jay" +void case_594() +#line 4024 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_593() -#line 3977 "cs-parser.jay" +void case_596() +#line 4033 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); @@ -6713,85 +6813,85 @@ void case_593() yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_595() -#line 3988 "cs-parser.jay" +void case_598() +#line 4044 "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_597() -#line 4000 "cs-parser.jay" +void case_600() +#line 4056 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_598() -#line 4005 "cs-parser.jay" +void case_601() +#line 4061 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_599() -#line 4010 "cs-parser.jay" +void case_602() +#line 4066 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_600() -#line 4015 "cs-parser.jay" +void case_603() +#line 4071 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_601() -#line 4020 "cs-parser.jay" +void case_604() +#line 4076 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_602() -#line 4025 "cs-parser.jay" +void case_605() +#line 4081 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_603() -#line 4030 "cs-parser.jay" +void case_606() +#line 4086 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_604() -#line 4035 "cs-parser.jay" +void case_607() +#line 4091 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_605() -#line 4040 "cs-parser.jay" +void case_608() +#line 4096 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_606() -#line 4045 "cs-parser.jay" +void case_609() +#line 4101 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_607() -#line 4053 "cs-parser.jay" +void case_610() +#line 4109 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -6799,8 +6899,8 @@ void case_607() yyVal = pars; } -void case_608() -#line 4060 "cs-parser.jay" +void case_611() +#line 4116 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -6812,38 +6912,38 @@ void case_608() yyVal = pars; } -void case_609() -#line 4074 "cs-parser.jay" +void case_612() +#line 4130 "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_610() -#line 4080 "cs-parser.jay" +void case_613() +#line 4136 "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_611() -#line 4086 "cs-parser.jay" +void case_614() +#line 4142 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } -void case_613() -#line 4094 "cs-parser.jay" +void case_616() +#line 4150 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); } -void case_617() -#line 4110 "cs-parser.jay" +void case_620() +#line 4166 "cs-parser.jay" { Block b = end_block (lexer.Location); b.IsCompilerGenerated = true; @@ -6851,74 +6951,94 @@ void case_617() yyVal = b; } -void case_619() -#line 4121 "cs-parser.jay" +void case_622() +#line 4177 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } -void case_620() -#line 4129 "cs-parser.jay" +void case_623() +#line 4185 "cs-parser.jay" { - var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; + 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])); + start_anonymous (true, new ParametersCompiled (p), false, lt.Location); } -void case_621() -#line 4135 "cs-parser.jay" +void case_624() +#line 4191 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_622() -#line 4140 "cs-parser.jay" +void case_625() +#line 4196 "cs-parser.jay" { - if (lang_version <= LanguageVersion.ISO_2) - FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "lambda expressions"); - - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; + Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); + start_anonymous (true, new ParametersCompiled (p), true, lt.Location); } -void case_623() -#line 4147 "cs-parser.jay" +void case_626() +#line 4202 "cs-parser.jay" +{ + yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); + } + +void case_628() +#line 4211 "cs-parser.jay" { valid_param_mod = 0; - start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop])); + start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], false, GetLocation (yyVals[-4+yyTop])); } -void case_624() -#line 4152 "cs-parser.jay" +void case_629() +#line 4216 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_631() -#line 4175 "cs-parser.jay" +#line 4225 "cs-parser.jay" +{ + valid_param_mod = 0; + start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], true, GetLocation (yyVals[-5+yyTop])); + } + +void case_632() +#line 4230 "cs-parser.jay" +{ + yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); + } + +void case_639() +#line 4253 "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_632() -#line 4180 "cs-parser.jay" +void case_640() +#line 4258 "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_633() -#line 4185 "cs-parser.jay" +void case_641() +#line 4263 "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_637() -#line 4214 "cs-parser.jay" +void case_645() +#line 4292 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); Class c = new Class (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]); @@ -6929,8 +7049,8 @@ void case_637() push_current_class (c, yyVals[-3+yyTop]); } -void case_638() -#line 4225 "cs-parser.jay" +void case_646() +#line 4303 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -6943,30 +7063,30 @@ void case_638() } } -void case_639() -#line 4237 "cs-parser.jay" +void case_647() +#line 4315 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_640() -#line 4243 "cs-parser.jay" +void case_648() +#line 4321 "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_643() -#line 4258 "cs-parser.jay" +void case_651() +#line 4336 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; } -void case_646() -#line 4268 "cs-parser.jay" +void case_654() +#line 4346 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -6983,8 +7103,8 @@ void case_646() yyVal = m1 | m2; } -void case_647() -#line 4287 "cs-parser.jay" +void case_655() +#line 4365 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -6993,92 +7113,92 @@ void case_647() report.Error (1530, GetLocation (yyVals[0+yyTop]), "Keyword `new' is not allowed on namespace elements"); } -void case_648() -#line 4295 "cs-parser.jay" +void case_656() +#line 4373 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_649() -#line 4300 "cs-parser.jay" +void case_657() +#line 4378 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_650() -#line 4305 "cs-parser.jay" +void case_658() +#line 4383 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_651() -#line 4310 "cs-parser.jay" +void case_659() +#line 4388 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_652() -#line 4315 "cs-parser.jay" +void case_660() +#line 4393 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_653() -#line 4320 "cs-parser.jay" +void case_661() +#line 4398 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_654() -#line 4325 "cs-parser.jay" +void case_662() +#line 4403 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_655() -#line 4330 "cs-parser.jay" +void case_663() +#line 4408 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_656() -#line 4335 "cs-parser.jay" +void case_664() +#line 4413 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_657() -#line 4340 "cs-parser.jay" +void case_665() +#line 4418 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_658() -#line 4345 "cs-parser.jay" +void case_666() +#line 4423 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_659() -#line 4350 "cs-parser.jay" +void case_667() +#line 4428 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_660() -#line 4355 "cs-parser.jay" +void case_668() +#line 4433 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7086,30 +7206,30 @@ void case_660() Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_661() -#line 4362 "cs-parser.jay" +void case_669() +#line 4440 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_666() -#line 4383 "cs-parser.jay" +void case_674() +#line 4461 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_667() -#line 4391 "cs-parser.jay" +void case_675() +#line 4469 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); yyVal = constraints; } -void case_668() -#line 4397 "cs-parser.jay" +void case_676() +#line 4475 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7126,23 +7246,23 @@ void case_668() yyVal = constraints; } -void case_669() -#line 4416 "cs-parser.jay" +void case_677() +#line 4494 "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_670() -#line 4424 "cs-parser.jay" +void case_678() +#line 4502 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = constraints; } -void case_671() -#line 4430 "cs-parser.jay" +void case_679() +#line 4508 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7166,8 +7286,8 @@ void case_671() yyVal = constraints; } -void case_672() -#line 4456 "cs-parser.jay" +void case_680() +#line 4534 "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 ()); @@ -7175,15 +7295,15 @@ void case_672() yyVal = yyVals[0+yyTop]; } -void case_673() -#line 4463 "cs-parser.jay" +void case_681() +#line 4541 "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_677() -#line 4483 "cs-parser.jay" +void case_685() +#line 4561 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); @@ -7191,78 +7311,78 @@ void case_677() yyVal = yyVals[0+yyTop]; } -void case_680() -#line 4517 "cs-parser.jay" +void case_688() +#line 4595 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } -void case_682() -#line 4529 "cs-parser.jay" +void case_690() +#line 4607 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_683() -#line 4534 "cs-parser.jay" +void case_691() +#line 4612 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } -void case_684() -#line 4543 "cs-parser.jay" +void case_692() +#line 4621 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } -void case_685() -#line 4548 "cs-parser.jay" +void case_693() +#line 4626 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_693() -#line 4575 "cs-parser.jay" +void case_701() +#line 4653 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_726() -#line 4639 "cs-parser.jay" +void case_734() +#line 4717 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } -void case_727() -#line 4644 "cs-parser.jay" +void case_735() +#line 4722 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } -void case_728() -#line 4649 "cs-parser.jay" +void case_736() +#line 4727 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_729() -#line 4657 "cs-parser.jay" +void case_737() +#line 4735 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } -void case_730() -#line 4665 "cs-parser.jay" +void case_738() +#line 4743 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7271,8 +7391,8 @@ void case_730() current_block.AddStatement (labeled); } -void case_733() -#line 4678 "cs-parser.jay" +void case_741() +#line 4756 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7280,8 +7400,8 @@ void case_733() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_734() -#line 4694 "cs-parser.jay" +void case_742() +#line 4772 "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*/ @@ -7312,8 +7432,8 @@ void case_734() } } -void case_735() -#line 4724 "cs-parser.jay" +void case_743() +#line 4802 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7325,8 +7445,8 @@ void case_735() } } -void case_736() -#line 4735 "cs-parser.jay" +void case_744() +#line 4813 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7334,22 +7454,22 @@ void case_736() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_739() -#line 4750 "cs-parser.jay" +void case_747() +#line 4828 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_741() -#line 4759 "cs-parser.jay" +void case_749() +#line 4837 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_743() -#line 4774 "cs-parser.jay" +void case_751() +#line 4852 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7357,16 +7477,16 @@ void case_743() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_744() -#line 4781 "cs-parser.jay" +void case_752() +#line 4859 "cs-parser.jay" { yyVal = current_variable; current_variable = null; lbag.AppendTo (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_745() -#line 4787 "cs-parser.jay" +void case_753() +#line 4865 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7374,8 +7494,8 @@ void case_745() current_variable = new BlockConstantDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_746() -#line 4794 "cs-parser.jay" +void case_754() +#line 4872 "cs-parser.jay" { if (current_variable.Initializer != null) { lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); @@ -7386,15 +7506,15 @@ void case_746() current_variable = null; } -void case_748() -#line 4808 "cs-parser.jay" +void case_756() +#line 4886 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } -void case_749() -#line 4813 "cs-parser.jay" +void case_757() +#line 4891 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7404,8 +7524,8 @@ void case_749() } } -void case_754() -#line 4835 "cs-parser.jay" +void case_762() +#line 4913 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7415,8 +7535,8 @@ void case_754() lbag.AddLocation (d, GetLocation (yyVals[-1+yyTop])); } -void case_755() -#line 4844 "cs-parser.jay" +void case_763() +#line 4922 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7426,15 +7546,15 @@ void case_755() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_757() -#line 4860 "cs-parser.jay" +void case_765() +#line 4938 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); current_variable.Initializer = (Expression) yyVals[0+yyTop]; } -void case_762() -#line 4878 "cs-parser.jay" +void case_770() +#line 4956 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7444,41 +7564,41 @@ void case_762() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_764() -#line 4891 "cs-parser.jay" +void case_772() +#line 4969 "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_765() -#line 4896 "cs-parser.jay" +void case_773() +#line 4974 "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_766() -#line 4904 "cs-parser.jay" +void case_774() +#line 4982 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_770() -#line 4922 "cs-parser.jay" +void case_778() +#line 5000 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { Expression.Error_InvalidExpressionStatement (report, GetLocation (yyVals[0+yyTop])); - s = EmptyExpressionStatement.Instance; + yyVal = new StatementExpression (EmptyExpressionStatement.Instance); + } else { + yyVal = new StatementExpression (s); } - - yyVal = new StatementExpression (s); } -void case_771() -#line 4935 "cs-parser.jay" +void case_779() +#line 5013 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7487,15 +7607,15 @@ void case_771() yyVal = new StatementExpression (s); } -void case_772() -#line 4943 "cs-parser.jay" +void case_780() +#line 5021 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_775() -#line 4957 "cs-parser.jay" +void case_783() +#line 5035 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7504,8 +7624,8 @@ void case_775() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_776() -#line 4966 "cs-parser.jay" +void case_784() +#line 5044 "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])); @@ -7516,23 +7636,23 @@ void case_776() Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_778() -#line 4983 "cs-parser.jay" +void case_786() +#line 5061 "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_779() -#line 4992 "cs-parser.jay" +void case_787() +#line 5070 "cs-parser.jay" { report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } -void case_781() -#line 5001 "cs-parser.jay" +void case_789() +#line 5079 "cs-parser.jay" { var sections = new List (4); @@ -7540,8 +7660,8 @@ void case_781() yyVal = sections; } -void case_782() -#line 5008 "cs-parser.jay" +void case_790() +#line 5086 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -7549,15 +7669,15 @@ void case_782() yyVal = sections; } -void case_783() -#line 5015 "cs-parser.jay" +void case_791() +#line 5093 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } -void case_786() -#line 5034 "cs-parser.jay" +void case_794() +#line 5112 "cs-parser.jay" { var labels = new List (2); @@ -7565,8 +7685,8 @@ void case_786() yyVal = labels; } -void case_787() -#line 5041 "cs-parser.jay" +void case_795() +#line 5119 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -7574,15 +7694,15 @@ void case_787() yyVal = labels; } -void case_788() -#line 5051 "cs-parser.jay" +void case_796() +#line 5129 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_794() -#line 5070 "cs-parser.jay" +void case_802() +#line 5148 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7591,22 +7711,22 @@ void case_794() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_795() -#line 5082 "cs-parser.jay" +void case_803() +#line 5160 "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_796() -#line 5090 "cs-parser.jay" +void case_804() +#line 5168 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; } -void case_798() -#line 5106 "cs-parser.jay" +void case_806() +#line 5184 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7619,15 +7739,15 @@ void case_798() yyVal = end_block (GetLocation (yyVals[-5+yyTop])); } -void case_799() -#line 5118 "cs-parser.jay" +void case_807() +#line 5196 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } -void case_802() -#line 5131 "cs-parser.jay" +void case_810() +#line 5209 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7635,15 +7755,15 @@ void case_802() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_803() -#line 5138 "cs-parser.jay" +void case_811() +#line 5216 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_811() -#line 5162 "cs-parser.jay" +void case_819() +#line 5240 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -7657,15 +7777,15 @@ void case_811() yyVal = sl; } -void case_812() -#line 5178 "cs-parser.jay" +void case_820() +#line 5256 "cs-parser.jay" { report.Error (230, GetLocation (yyVals[-5+yyTop]), "Type and identifier are both required in a foreach statement"); yyVal = null; } -void case_813() -#line 5183 "cs-parser.jay" +void case_821() +#line 5261 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -7675,8 +7795,8 @@ void case_813() yyVal = li; } -void case_814() -#line 5192 "cs-parser.jay" +void case_822() +#line 5270 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7688,58 +7808,58 @@ void case_814() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_821() -#line 5215 "cs-parser.jay" +void case_829() +#line 5293 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_822() -#line 5223 "cs-parser.jay" +void case_830() +#line 5301 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_823() -#line 5231 "cs-parser.jay" +void case_831() +#line 5309 "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_824() -#line 5237 "cs-parser.jay" +void case_832() +#line 5315 "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_825() -#line 5242 "cs-parser.jay" +void case_833() +#line 5320 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_826() -#line 5250 "cs-parser.jay" +void case_834() +#line 5328 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_827() -#line 5258 "cs-parser.jay" +void case_835() +#line 5336 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_828() -#line 5266 "cs-parser.jay" +void case_836() +#line 5344 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -7756,8 +7876,8 @@ void case_828() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_829() -#line 5282 "cs-parser.jay" +void case_837() +#line 5360 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -7772,29 +7892,29 @@ void case_829() lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_833() -#line 5308 "cs-parser.jay" +void case_841() +#line 5386 "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_834() -#line 5313 "cs-parser.jay" +void case_842() +#line 5391 "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_835() -#line 5318 "cs-parser.jay" +void case_843() +#line 5396 "cs-parser.jay" { report.Error (1524, GetLocation (yyVals[-2+yyTop]), "Expected catch or finally"); yyVal = null; } -void case_836() -#line 5326 "cs-parser.jay" +void case_844() +#line 5404 "cs-parser.jay" { var l = new List (2); @@ -7802,8 +7922,8 @@ void case_836() yyVal = l; } -void case_837() -#line 5333 "cs-parser.jay" +void case_845() +#line 5411 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -7820,8 +7940,8 @@ void case_837() yyVal = l; } -void case_841() -#line 5361 "cs-parser.jay" +void case_849() +#line 5439 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -7837,8 +7957,8 @@ void case_841() yyVal = c; } -void case_843() -#line 5380 "cs-parser.jay" +void case_851() +#line 5458 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { report.Error (1015, lexer.Location, @@ -7850,15 +7970,15 @@ void case_843() yyVal = new Catch (null, GetLocation (yyVals[-2+yyTop])); } -void case_846() -#line 5408 "cs-parser.jay" +void case_854() +#line 5486 "cs-parser.jay" { if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_848() -#line 5418 "cs-parser.jay" +void case_856() +#line 5496 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7867,8 +7987,8 @@ void case_848() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_849() -#line 5429 "cs-parser.jay" +void case_857() +#line 5507 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -7879,15 +7999,15 @@ void case_849() current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_850() -#line 5439 "cs-parser.jay" +void case_858() +#line 5517 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_851() -#line 5444 "cs-parser.jay" +void case_859() +#line 5522 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7898,8 +8018,8 @@ void case_851() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_852() -#line 5457 "cs-parser.jay" +void case_860() +#line 5535 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -7910,15 +8030,15 @@ void case_852() current_variable = new Using.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_853() -#line 5467 "cs-parser.jay" +void case_861() +#line 5545 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_854() -#line 5472 "cs-parser.jay" +void case_862() +#line 5550 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7929,8 +8049,8 @@ void case_854() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_855() -#line 5482 "cs-parser.jay" +void case_863() +#line 5560 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7940,15 +8060,15 @@ void case_855() yyVal = u; } -void case_857() -#line 5498 "cs-parser.jay" +void case_865() +#line 5576 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; yyVal = current_variable; } -void case_858() -#line 5509 "cs-parser.jay" +void case_866() +#line 5587 "cs-parser.jay" { lexer.query_parsing = false; @@ -7961,8 +8081,8 @@ void case_858() current_block = current_block.Parent; } -void case_859() -#line 5521 "cs-parser.jay" +void case_867() +#line 5599 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -7973,8 +8093,8 @@ void case_859() current_block = current_block.Parent; } -void case_860() -#line 5532 "cs-parser.jay" +void case_868() +#line 5610 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -7983,16 +8103,16 @@ void case_860() current_block = current_block.Parent; } -void case_861() -#line 5539 "cs-parser.jay" +void case_869() +#line 5617 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; } -void case_862() -#line 5548 "cs-parser.jay" +void case_870() +#line 5626 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8001,8 +8121,8 @@ void case_862() yyVal = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop]))); } -void case_863() -#line 5556 "cs-parser.jay" +void case_871() +#line 5634 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8015,8 +8135,8 @@ void case_863() ); } -void case_864() -#line 5571 "cs-parser.jay" +void case_872() +#line 5649 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8025,8 +8145,8 @@ void case_864() yyVal = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop]))); } -void case_865() -#line 5579 "cs-parser.jay" +void case_873() +#line 5657 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8039,8 +8159,8 @@ void case_865() ); } -void case_867() -#line 5598 "cs-parser.jay" +void case_875() +#line 5676 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8052,8 +8172,8 @@ void case_867() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_869() -#line 5613 "cs-parser.jay" +void case_877() +#line 5691 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8068,8 +8188,8 @@ void case_869() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_870() -#line 5630 "cs-parser.jay" +void case_878() +#line 5708 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -8085,15 +8205,15 @@ void case_870() yyVal = head; } -void case_872() -#line 5646 "cs-parser.jay" +void case_880() +#line 5724 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_874() -#line 5658 "cs-parser.jay" +void case_882() +#line 5736 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8101,8 +8221,8 @@ void case_874() current_block = current_block.Parent; } -void case_875() -#line 5665 "cs-parser.jay" +void case_883() +#line 5743 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8111,8 +8231,8 @@ void case_875() linq_clause_blocks.Push ((Linq.QueryBlock)current_block); } -void case_876() -#line 5673 "cs-parser.jay" +void case_884() +#line 5751 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8120,8 +8240,8 @@ void case_876() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_877() -#line 5680 "cs-parser.jay" +void case_885() +#line 5758 "cs-parser.jay" { yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-3+yyTop], linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); @@ -8130,15 +8250,15 @@ void case_877() current_block = current_block.Parent; } -void case_881() -#line 5697 "cs-parser.jay" +void case_889() +#line 5775 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_888() -#line 5717 "cs-parser.jay" +void case_896() +#line 5795 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8151,8 +8271,8 @@ void case_888() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_890() -#line 5736 "cs-parser.jay" +void case_898() +#line 5814 "cs-parser.jay" { yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8160,8 +8280,8 @@ void case_890() current_block = current_block.Parent; } -void case_891() -#line 5746 "cs-parser.jay" +void case_899() +#line 5824 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8170,8 +8290,8 @@ void case_891() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_892() -#line 5754 "cs-parser.jay" +void case_900() +#line 5832 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8180,8 +8300,8 @@ void case_892() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_893() -#line 5762 "cs-parser.jay" +void case_901() +#line 5840 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8190,8 +8310,8 @@ void case_893() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_894() -#line 5770 "cs-parser.jay" +void case_902() +#line 5848 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8230,8 +8350,8 @@ void case_894() ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_895() -#line 5808 "cs-parser.jay" +void case_903() +#line 5886 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8240,8 +8360,8 @@ void case_895() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_896() -#line 5816 "cs-parser.jay" +void case_904() +#line 5894 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8250,8 +8370,8 @@ void case_896() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_897() -#line 5824 "cs-parser.jay" +void case_905() +#line 5902 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8260,8 +8380,8 @@ void case_897() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_898() -#line 5832 "cs-parser.jay" +void case_906() +#line 5910 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8302,8 +8422,8 @@ void case_898() ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_902() -#line 5887 "cs-parser.jay" +void case_910() +#line 5965 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8311,8 +8431,8 @@ void case_902() yyVal = yyVals[0+yyTop]; } -void case_904() -#line 5898 "cs-parser.jay" +void case_912() +#line 5976 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8320,15 +8440,15 @@ void case_904() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_905() -#line 5905 "cs-parser.jay" +void case_913() +#line 5983 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_907() -#line 5914 "cs-parser.jay" +void case_915() +#line 5992 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8336,43 +8456,43 @@ void case_907() current_block = new Linq.QueryBlock ((Linq.QueryBlock) current_block, lexer.Location); } -void case_908() -#line 5921 "cs-parser.jay" +void case_916() +#line 5999 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_910() -#line 5933 "cs-parser.jay" +void case_918() +#line 6011 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_911() -#line 5938 "cs-parser.jay" +void case_919() +#line 6016 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_913() -#line 5950 "cs-parser.jay" +void case_921() +#line 6028 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_914() -#line 5955 "cs-parser.jay" +void case_922() +#line 6033 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_916() -#line 5965 "cs-parser.jay" +void case_924() +#line 6043 "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*/ @@ -8389,8 +8509,8 @@ void case_916() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_917() -#line 5981 "cs-parser.jay" +void case_925() +#line 6059 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -8400,8 +8520,8 @@ void case_917() }; } -void case_920() -#line 6008 "cs-parser.jay" +void case_928() +#line 6086 "cs-parser.jay" { current_container = new Class (current_namespace, current_class, new MemberName (""), Modifiers.PUBLIC, null); current_class = current_container; @@ -8432,8 +8552,8 @@ void case_920() start_block (lexer.Location); } -void case_921() -#line 6038 "cs-parser.jay" +void case_929() +#line 6116 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); @@ -8444,16 +8564,16 @@ void case_921() current_local_parameters = null; } -void case_931() -#line 6081 "cs-parser.jay" +void case_939() +#line 6159 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; yyVal = null; } -void case_932() -#line 6087 "cs-parser.jay" +void case_940() +#line 6165 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -8461,15 +8581,15 @@ void case_932() yyVal = new MemberName (lt.Value); } -void case_935() -#line 6102 "cs-parser.jay" +void case_943() +#line 6180 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], new MemberName (MemberCache.IndexerNameAlias)); } -void case_936() -#line 6107 "cs-parser.jay" +void case_944() +#line 6185 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8478,8 +8598,8 @@ void case_936() yyVal = null; } -void case_937() -#line 6115 "cs-parser.jay" +void case_945() +#line 6193 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8488,8 +8608,8 @@ void case_937() yyVal = null; } -void case_938() -#line 6123 "cs-parser.jay" +void case_946() +#line 6201 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); module.DocumentationBuilder.ParsedParameters = p; @@ -8497,24 +8617,24 @@ void case_938() yyVal = null; } -void case_946() -#line 6161 "cs-parser.jay" +void case_954() +#line 6239 "cs-parser.jay" { var parameters = new List (); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); yyVal = parameters; } -void case_947() -#line 6167 "cs-parser.jay" +void case_955() +#line 6245 "cs-parser.jay" { var parameters = yyVals[-2+yyTop] as List; parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); yyVal = parameters; } -void case_948() -#line 6176 "cs-parser.jay" +void case_956() +#line 6254 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); @@ -8540,85 +8660,86 @@ void case_948() 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, 30, 30, 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, 31, 183, 183, 183, 185, 185, 185, 188, 188, - 189, 190, 189, 191, 192, 193, 32, 194, 194, 17, - 17, 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, - 214, 215, 215, 215, 216, 216, 216, 236, 236, 237, - 237, 238, 238, 218, 218, 235, 235, 235, 235, 235, - 235, 235, 235, 220, 239, 239, 240, 240, 241, 241, - 243, 243, 243, 244, 244, 244, 244, 244, 245, 245, - 162, 162, 249, 249, 249, 249, 249, 251, 251, 250, - 250, 252, 252, 252, 252, 253, 221, 248, 248, 248, - 254, 254, 255, 255, 222, 223, 223, 224, 225, 226, - 226, 217, 217, 217, 217, 217, 260, 256, 227, 261, - 261, 262, 262, 263, 263, 264, 264, 264, 264, 257, - 257, 208, 208, 259, 259, 265, 265, 258, 258, 85, - 85, 266, 266, 267, 228, 268, 268, 268, 269, 269, - 269, 269, 269, 270, 196, 229, 230, 231, 232, 272, - 233, 271, 271, 274, 273, 219, 275, 275, 275, 275, - 275, 277, 278, 276, 276, 276, 276, 276, 276, 276, - 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, - 281, 281, 281, 282, 282, 282, 282, 282, 283, 283, - 283, 284, 284, 285, 285, 286, 286, 287, 287, 288, - 288, 289, 289, 290, 290, 291, 291, 291, 291, 291, - 291, 291, 291, 291, 291, 291, 292, 292, 293, 293, - 293, 294, 294, 295, 295, 298, 296, 297, 297, 300, - 299, 301, 302, 299, 46, 46, 246, 246, 246, 246, - 234, 234, 234, 84, 304, 305, 306, 307, 308, 28, - 63, 63, 62, 62, 111, 111, 309, 309, 309, 309, - 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, - 309, 66, 66, 68, 68, 68, 310, 310, 311, 312, - 312, 313, 313, 313, 313, 205, 205, 314, 314, 316, - 112, 317, 317, 318, 160, 315, 315, 319, 319, 320, - 320, 320, 320, 324, 324, 325, 325, 325, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, - 322, 326, 326, 326, 326, 326, 326, 326, 326, 326, - 326, 326, 326, 326, 340, 340, 340, 340, 327, 341, - 323, 342, 342, 343, 343, 343, 343, 343, 343, 209, - 209, 344, 346, 321, 349, 321, 345, 345, 345, 347, - 347, 352, 352, 353, 353, 348, 348, 350, 350, 354, - 354, 355, 351, 351, 351, 328, 328, 339, 339, 356, - 357, 357, 329, 329, 358, 358, 361, 359, 360, 360, - 362, 362, 362, 365, 363, 364, 364, 366, 366, 330, - 330, 330, 330, 367, 368, 372, 369, 371, 371, 373, - 373, 377, 376, 376, 374, 374, 375, 375, 379, 378, - 378, 370, 380, 370, 331, 331, 331, 331, 331, 331, - 381, 382, 383, 383, 383, 384, 385, 386, 386, 387, - 387, 332, 332, 332, 332, 388, 388, 390, 390, 389, - 391, 389, 389, 333, 334, 392, 337, 335, 394, 395, - 338, 396, 397, 336, 336, 393, 393, 303, 303, 303, - 303, 398, 398, 400, 400, 402, 401, 403, 401, 399, - 399, 399, 407, 405, 408, 409, 405, 404, 404, 410, - 410, 411, 411, 411, 411, 411, 416, 412, 417, 413, - 418, 419, 420, 414, 422, 423, 424, 414, 421, 421, - 426, 415, 425, 429, 425, 428, 431, 428, 427, 427, - 427, 430, 430, 430, 406, 432, 406, 3, 3, 433, - 3, 3, 434, 434, 247, 247, 242, 242, 5, 435, - 435, 435, 435, 439, 435, 435, 435, 435, 436, 436, - 437, 440, 437, 438, 438, 441, 441, 442, + 109, 110, 111, 102, 102, 103, 103, 106, 106, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 115, + 115, 118, 118, 118, 121, 118, 119, 119, 122, 122, + 123, 123, 123, 116, 116, 116, 124, 124, 124, 117, + 126, 128, 129, 56, 131, 132, 133, 58, 127, 127, + 127, 127, 127, 137, 134, 138, 135, 136, 136, 136, + 139, 140, 141, 143, 30, 30, 142, 142, 144, 144, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 148, + 59, 147, 147, 149, 149, 152, 146, 146, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 154, 153, 155, 153, 153, 153, 60, 158, 160, 156, + 157, 157, 159, 159, 164, 162, 165, 162, 162, 166, + 61, 168, 57, 171, 172, 57, 167, 174, 167, 169, + 169, 175, 175, 176, 177, 176, 178, 173, 170, 170, + 170, 170, 170, 182, 179, 183, 180, 181, 181, 185, + 187, 188, 31, 184, 184, 184, 186, 186, 186, 189, + 189, 190, 191, 190, 192, 193, 194, 32, 195, 195, + 17, 17, 196, 196, 199, 198, 198, 198, 200, 200, + 202, 64, 125, 105, 105, 130, 130, 203, 203, 203, + 201, 201, 204, 204, 205, 205, 207, 207, 86, 76, + 76, 90, 90, 120, 120, 150, 150, 208, 208, 208, + 208, 208, 212, 212, 213, 213, 211, 211, 211, 211, + 211, 211, 211, 214, 214, 214, 214, 214, 214, 214, + 214, 214, 215, 215, 215, 215, 215, 215, 215, 215, + 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, + 215, 215, 216, 216, 216, 217, 217, 217, 237, 237, + 238, 238, 239, 239, 219, 219, 236, 236, 236, 236, + 236, 236, 236, 236, 221, 240, 240, 241, 241, 242, + 242, 244, 244, 244, 245, 245, 245, 245, 245, 246, + 246, 163, 163, 250, 250, 250, 250, 250, 252, 252, + 251, 251, 253, 253, 253, 253, 254, 222, 249, 249, + 249, 255, 255, 256, 256, 223, 224, 224, 225, 226, + 227, 227, 218, 218, 218, 218, 218, 261, 257, 228, + 262, 262, 263, 263, 264, 264, 265, 265, 265, 265, + 258, 258, 209, 209, 260, 260, 266, 266, 259, 259, + 85, 85, 267, 267, 268, 229, 269, 269, 269, 270, + 270, 270, 270, 270, 271, 197, 230, 231, 232, 233, + 273, 234, 274, 234, 272, 272, 276, 275, 220, 277, + 277, 277, 277, 277, 279, 280, 278, 278, 278, 278, + 278, 278, 278, 281, 281, 281, 281, 282, 282, 282, + 282, 282, 282, 283, 283, 283, 284, 284, 284, 284, + 284, 285, 285, 285, 286, 286, 287, 287, 288, 288, + 289, 289, 290, 290, 291, 291, 292, 292, 293, 293, + 293, 293, 293, 293, 293, 293, 293, 293, 293, 294, + 294, 295, 295, 295, 296, 296, 297, 297, 300, 298, + 299, 299, 302, 301, 303, 301, 304, 305, 301, 306, + 307, 301, 46, 46, 247, 247, 247, 247, 235, 235, + 235, 84, 309, 310, 311, 312, 313, 28, 63, 63, + 62, 62, 112, 112, 314, 314, 314, 314, 314, 314, + 314, 314, 314, 314, 314, 314, 314, 314, 314, 66, + 66, 68, 68, 68, 315, 315, 316, 317, 317, 318, + 318, 318, 318, 206, 206, 319, 319, 321, 113, 322, + 322, 323, 161, 320, 320, 324, 324, 325, 325, 325, + 325, 329, 329, 330, 330, 330, 327, 327, 327, 327, + 327, 327, 327, 327, 327, 327, 327, 327, 327, 331, + 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, + 331, 331, 345, 345, 345, 345, 332, 346, 328, 347, + 347, 348, 348, 348, 348, 348, 348, 210, 210, 349, + 351, 326, 354, 326, 350, 350, 350, 352, 352, 357, + 357, 358, 358, 353, 353, 355, 355, 359, 359, 360, + 356, 356, 356, 333, 333, 344, 344, 361, 362, 362, + 334, 334, 363, 363, 366, 364, 365, 365, 367, 367, + 367, 370, 368, 369, 369, 371, 371, 335, 335, 335, + 335, 372, 373, 377, 374, 376, 376, 378, 378, 382, + 381, 381, 379, 379, 380, 380, 384, 383, 383, 375, + 385, 375, 336, 336, 336, 336, 336, 336, 386, 387, + 388, 388, 388, 389, 390, 391, 391, 392, 392, 337, + 337, 337, 337, 393, 393, 395, 395, 394, 396, 394, + 394, 338, 339, 397, 342, 340, 399, 400, 343, 401, + 402, 341, 341, 398, 398, 308, 308, 308, 308, 403, + 403, 405, 405, 407, 406, 408, 406, 404, 404, 404, + 412, 410, 413, 414, 410, 409, 409, 415, 415, 416, + 416, 416, 416, 416, 421, 417, 422, 418, 423, 424, + 425, 419, 427, 428, 429, 419, 426, 426, 431, 420, + 430, 434, 430, 433, 436, 433, 432, 432, 432, 435, + 435, 435, 411, 437, 411, 3, 3, 438, 3, 3, + 439, 439, 248, 248, 243, 243, 5, 440, 440, 440, + 440, 444, 440, 440, 440, 440, 441, 441, 442, 445, + 442, 443, 443, 446, 446, 447, }; static readonly short [] yyLen = { 2, 2, 0, 3, 1, 2, 4, 3, 1, 0, 1, @@ -8637,1334 +8758,1330 @@ void case_948() 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, + 0, 0, 0, 12, 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, - 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, + 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, 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, 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, 4, 0, - 4, 0, 1, 0, 4, 4, 1, 2, 2, 1, - 1, 4, 2, 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, 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, 4, + 0, 4, 0, 5, 0, 1, 0, 4, 4, 1, + 2, 2, 1, 1, 4, 2, 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, 5, 0, 0, 7, 0, + 0, 8, 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, - 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, 2, 2, - 2, 4, 3, 0, 7, 4, 4, 3, 1, 3, - 0, 0, 4, 0, 1, 1, 3, 2, + 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, 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, 2, 2, 2, 4, + 3, 0, 7, 4, 4, 3, 1, 3, 0, 0, + 4, 0, 1, 1, 3, 2, }; static readonly short [] yyDefRed = { 0, 8, 0, 0, 0, 0, 0, 0, 0, 2, 4, - 0, 0, 11, 14, 0, 918, 0, 0, 922, 0, - 0, 15, 17, 18, 388, 394, 401, 389, 391, 0, - 390, 0, 397, 399, 386, 0, 393, 395, 387, 398, - 400, 396, 350, 939, 0, 392, 929, 0, 10, 1, - 0, 0, 0, 12, 0, 772, 0, 0, 0, 0, - 0, 0, 0, 0, 429, 0, 0, 0, 0, 0, - 0, 0, 427, 0, 0, 0, 485, 0, 428, 0, - 524, 0, 846, 0, 0, 0, 630, 0, 0, 0, - 0, 0, 0, 680, 0, 729, 0, 0, 0, 0, - 0, 0, 0, 0, 426, 0, 622, 0, 771, 712, - 0, 0, 0, 0, 403, 404, 0, 406, 407, 408, + 0, 0, 11, 14, 0, 926, 0, 0, 930, 0, + 0, 15, 17, 18, 389, 395, 402, 390, 392, 0, + 391, 0, 398, 400, 387, 0, 394, 396, 388, 399, + 401, 397, 351, 947, 0, 393, 937, 0, 10, 1, + 0, 0, 0, 12, 0, 780, 0, 0, 0, 0, + 0, 0, 0, 0, 430, 0, 0, 0, 0, 0, + 0, 0, 428, 0, 0, 0, 486, 0, 429, 0, + 525, 0, 854, 0, 0, 0, 638, 0, 0, 0, + 0, 0, 0, 0, 688, 0, 737, 0, 0, 0, + 0, 0, 0, 0, 0, 427, 0, 627, 0, 779, + 720, 0, 0, 0, 0, 404, 405, 0, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, - 419, 420, 421, 424, 425, 626, 554, 0, 550, 551, + 419, 420, 421, 422, 425, 426, 634, 557, 0, 553, + 554, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 635, 633, 636, 637, 704, 706, 0, 702, + 705, 721, 723, 724, 725, 726, 727, 728, 729, 730, + 731, 732, 722, 0, 0, 0, 781, 782, 798, 799, + 800, 801, 823, 824, 825, 826, 827, 828, 0, 0, + 0, 20, 0, 0, 0, 341, 0, 343, 934, 16, + 927, 0, 0, 254, 253, 250, 255, 256, 249, 268, + 267, 260, 261, 257, 259, 258, 262, 251, 252, 263, + 264, 270, 269, 265, 266, 0, 0, 950, 0, 939, + 0, 938, 3, 52, 0, 0, 0, 42, 39, 41, + 43, 44, 45, 46, 47, 50, 13, 0, 0, 0, + 829, 431, 432, 852, 0, 0, 0, 0, 0, 0, + 406, 0, 830, 0, 547, 541, 546, 736, 778, 707, + 734, 733, 735, 708, 709, 710, 711, 712, 713, 714, + 715, 716, 717, 718, 719, 0, 0, 0, 804, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 839, 0, 403, 0, 0, 0, 0, 0, 0, + 853, 0, 0, 0, 750, 746, 0, 0, 0, 0, + 0, 0, 370, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 630, 556, 0, 0, 552, 558, 559, 551, + 563, 562, 560, 561, 0, 0, 623, 738, 536, 0, + 424, 423, 0, 0, 0, 0, 340, 0, 744, 745, + 0, 489, 490, 0, 0, 0, 742, 743, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 627, 625, 628, 629, 696, 698, 0, 694, 697, - 713, 715, 716, 717, 718, 719, 720, 721, 722, 723, - 724, 714, 0, 0, 0, 773, 774, 790, 791, 792, - 793, 815, 816, 817, 818, 819, 820, 0, 0, 0, - 20, 0, 0, 0, 340, 0, 342, 926, 16, 919, - 0, 0, 253, 252, 249, 254, 255, 248, 267, 266, - 259, 260, 256, 258, 257, 261, 250, 251, 262, 263, - 269, 268, 264, 265, 0, 0, 942, 0, 931, 0, - 930, 3, 52, 0, 0, 0, 42, 39, 41, 43, - 44, 45, 46, 47, 50, 13, 0, 0, 0, 821, - 430, 431, 844, 0, 0, 0, 0, 0, 405, 0, - 822, 0, 544, 540, 543, 728, 770, 699, 726, 725, - 727, 700, 701, 702, 703, 704, 705, 706, 707, 708, - 709, 710, 711, 0, 0, 0, 796, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 831, - 0, 402, 0, 0, 0, 0, 0, 0, 845, 0, - 0, 0, 742, 738, 0, 0, 0, 0, 0, 0, - 369, 0, 0, 0, 0, 0, 0, 0, 553, 0, - 0, 549, 555, 556, 548, 560, 559, 557, 558, 0, - 0, 620, 730, 535, 0, 423, 422, 0, 0, 0, - 0, 339, 0, 736, 737, 0, 488, 489, 0, 0, - 0, 734, 735, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 929, 703, 751, 741, 0, 776, 777, 880, + 897, 0, 0, 0, 909, 868, 866, 890, 0, 0, + 888, 891, 892, 893, 894, 869, 867, 0, 0, 0, + 345, 0, 21, 0, 0, 0, 946, 0, 352, 0, + 0, 0, 948, 0, 0, 40, 660, 666, 658, 0, + 655, 665, 659, 657, 656, 663, 661, 662, 668, 664, + 667, 669, 0, 0, 653, 51, 488, 0, 0, 484, + 485, 0, 482, 0, 753, 0, 0, 0, 0, 774, + 775, 0, 0, 0, 642, 0, 833, 831, 643, 0, + 0, 510, 0, 0, 0, 501, 0, 505, 515, 517, + 0, 497, 0, 0, 0, 0, 0, 492, 0, 495, + 0, 499, 372, 834, 0, 0, 835, 843, 0, 0, + 0, 844, 0, 0, 855, 0, 0, 749, 0, 382, + 0, 378, 379, 0, 377, 380, 381, 0, 0, 0, + 564, 0, 0, 543, 625, 0, 701, 0, 0, 696, + 698, 699, 700, 435, 436, 837, 0, 0, 0, 348, + 349, 0, 192, 191, 193, 0, 0, 0, 0, 374, + 0, 610, 0, 0, 440, 0, 443, 0, 441, 0, + 0, 0, 0, 0, 0, 469, 472, 0, 0, 464, + 471, 470, 0, 599, 600, 601, 602, 603, 604, 605, + 606, 607, 609, 608, 565, 567, 566, 572, 573, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 921, 695, 743, - 733, 0, 768, 769, 872, 889, 0, 0, 0, 901, - 860, 858, 882, 0, 0, 880, 883, 884, 885, 886, - 861, 859, 0, 0, 0, 344, 0, 21, 0, 0, - 0, 938, 0, 351, 0, 0, 0, 940, 0, 0, - 40, 652, 658, 650, 0, 647, 657, 651, 649, 648, - 655, 653, 654, 660, 656, 659, 661, 0, 0, 645, - 51, 487, 0, 0, 483, 484, 0, 481, 0, 745, - 0, 0, 0, 0, 766, 767, 0, 0, 0, 634, - 0, 825, 823, 635, 0, 0, 509, 0, 0, 0, - 500, 0, 504, 514, 516, 0, 496, 0, 0, 0, - 0, 0, 491, 0, 494, 0, 498, 371, 826, 0, - 0, 827, 835, 0, 0, 0, 836, 0, 0, 847, - 0, 0, 741, 0, 381, 0, 377, 378, 0, 376, - 379, 380, 0, 0, 0, 561, 0, 0, 693, 0, - 0, 688, 690, 691, 692, 434, 435, 829, 0, 0, - 0, 347, 348, 0, 191, 190, 192, 0, 0, 0, - 0, 373, 0, 607, 0, 0, 439, 0, 442, 0, - 440, 0, 0, 0, 0, 0, 0, 468, 471, 0, - 0, 463, 470, 469, 0, 596, 597, 598, 599, 600, - 601, 602, 603, 604, 606, 605, 562, 564, 563, 569, - 570, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 593, 0, 0, 513, - 0, 0, 0, 0, 0, 0, 0, 873, 875, 871, - 0, 881, 0, 0, 341, 936, 937, 365, 0, 0, - 362, 0, 0, 188, 0, 0, 946, 932, 934, 60, - 58, 59, 0, 0, 53, 0, 0, 61, 63, 27, - 25, 0, 0, 0, 642, 0, 646, 438, 0, 486, - 0, 537, 0, 546, 178, 199, 0, 0, 168, 0, - 0, 0, 179, 541, 0, 849, 799, 0, 810, 797, - 0, 801, 0, 0, 0, 824, 0, 0, 0, 499, - 0, 515, 517, 0, 0, 455, 0, 0, 451, 0, - 0, 478, 0, 519, 493, 0, 155, 520, 153, 154, - 522, 0, 536, 0, 840, 0, 833, 0, 837, 528, - 0, 0, 0, 366, 0, 526, 0, 0, 538, 0, - 852, 0, 864, 0, 862, 0, 0, 632, 633, 682, - 683, 681, 689, 828, 615, 621, 614, 0, 731, 0, - 346, 610, 0, 0, 0, 552, 443, 437, 441, 436, - 539, 477, 476, 473, 472, 0, 467, 432, 433, 444, - 0, 0, 749, 0, 0, 890, 866, 0, 891, 0, - 887, 0, 902, 0, 0, 0, 0, 870, 19, 343, - 679, 678, 0, 677, 0, 361, 948, 189, 943, 0, - 0, 54, 0, 0, 0, 0, 0, 0, 368, 0, - 636, 0, 0, 80, 79, 0, 482, 0, 0, 0, - 0, 0, 545, 0, 0, 0, 0, 0, 802, 0, - 0, 0, 0, 0, 848, 506, 505, 458, 0, 0, - 927, 928, 447, 453, 0, 456, 0, 480, 0, 0, - 0, 0, 0, 777, 843, 0, 834, 534, 529, 0, - 0, 525, 0, 855, 0, 794, 865, 863, 0, 619, - 618, 617, 349, 609, 608, 623, 475, 0, 465, 464, - 595, 0, 763, 748, 0, 0, 0, 752, 0, 868, - 0, 895, 0, 910, 911, 904, 874, 876, 916, 364, - 363, 947, 0, 0, 62, 56, 0, 64, 26, 23, - 0, 0, 319, 0, 225, 0, 101, 0, 77, 757, - 128, 129, 0, 0, 0, 760, 197, 198, 0, 0, - 0, 0, 171, 180, 172, 174, 0, 0, 0, 0, - 806, 0, 811, 812, 0, 0, 457, 459, 460, 454, - 448, 452, 0, 511, 0, 479, 490, 446, 523, 521, - 0, 839, 0, 0, 530, 0, 0, 631, 0, 474, - 0, 0, 744, 753, 867, 0, 0, 0, 888, 0, - 0, 0, 935, 0, 0, 0, 69, 70, 73, 74, - 0, 334, 325, 324, 0, 637, 221, 97, 0, 746, - 761, 183, 0, 195, 0, 0, 0, 795, 857, 0, - 0, 0, 813, 776, 495, 492, 783, 0, 789, 0, - 0, 781, 0, 786, 841, 533, 532, 0, 624, 0, - 0, 869, 892, 0, 0, 0, 906, 0, 917, 0, - 75, 67, 0, 0, 0, 320, 0, 0, 0, 0, - 0, 184, 0, 175, 173, 850, 803, 0, 0, 808, - 0, 0, 778, 782, 0, 787, 0, 853, 0, 755, - 0, 896, 913, 914, 907, 877, 55, 0, 71, 72, - 0, 0, 0, 0, 0, 0, 0, 762, 182, 0, - 194, 0, 0, 814, 788, 0, 684, 842, 0, 764, - 0, 0, 0, 76, 0, 0, 335, 0, 321, 0, - 329, 385, 384, 0, 382, 666, 0, 638, 0, 667, - 222, 98, 185, 851, 798, 0, 854, 893, 0, 908, - 0, 0, 0, 0, 0, 0, 0, 0, 668, 0, - 0, 0, 0, 897, 29, 24, 336, 0, 0, 330, - 383, 0, 0, 0, 102, 99, 685, 0, 0, 0, - 0, 322, 674, 0, 675, 672, 0, 670, 95, 0, - 94, 0, 0, 83, 85, 86, 87, 88, 89, 90, - 91, 92, 93, 156, 0, 0, 238, 230, 231, 232, - 233, 234, 235, 236, 237, 0, 0, 228, 0, 0, - 0, 894, 0, 337, 333, 0, 0, 0, 639, 84, - 0, 281, 276, 280, 0, 223, 229, 116, 108, 109, - 110, 111, 112, 113, 114, 115, 117, 0, 0, 106, - 100, 900, 898, 673, 671, 0, 0, 0, 0, 0, - 0, 0, 289, 0, 0, 239, 0, 0, 247, 0, - 166, 157, 165, 0, 103, 107, 0, 0, 275, 0, - 0, 274, 0, 0, 0, 0, 355, 0, 353, 0, - 0, 200, 0, 0, 0, 0, 0, 640, 224, 118, - 0, 352, 0, 0, 0, 0, 132, 0, 0, 0, - 0, 0, 0, 158, 0, 0, 204, 0, 356, 0, - 242, 241, 240, 0, 0, 293, 0, 272, 134, 0, - 270, 161, 0, 0, 136, 0, 357, 0, 0, 201, - 0, 0, 0, 354, 245, 127, 125, 0, 0, 297, - 0, 0, 0, 0, 0, 0, 0, 278, 0, 0, - 0, 0, 140, 0, 0, 0, 0, 358, 359, 0, - 0, 0, 0, 0, 122, 312, 0, 294, 0, 0, - 306, 0, 0, 0, 301, 0, 152, 0, 0, 0, - 0, 147, 0, 0, 290, 0, 137, 0, 131, 141, - 159, 164, 212, 0, 202, 0, 0, 0, 0, 126, - 0, 119, 123, 0, 0, 0, 308, 0, 309, 298, - 0, 0, 292, 302, 273, 0, 0, 133, 148, 271, - 162, 288, 0, 279, 283, 143, 0, 0, 0, 209, - 211, 205, 246, 124, 313, 315, 295, 0, 0, 307, - 304, 151, 149, 0, 0, 0, 0, 160, 213, 215, - 203, 0, 0, 0, 306, 163, 284, 286, 144, 0, - 0, 206, 317, 318, 314, 316, 305, 0, 0, 219, - 218, 217, 214, 216, 0, 0, 0, 207, 285, 287, + 0, 0, 0, 0, 596, 0, 0, 514, 0, 0, + 0, 0, 0, 0, 0, 881, 883, 879, 0, 889, + 0, 0, 342, 944, 945, 366, 0, 0, 363, 0, + 0, 189, 0, 0, 954, 940, 942, 60, 58, 59, + 0, 0, 53, 0, 0, 61, 63, 27, 25, 0, + 0, 0, 650, 0, 654, 439, 0, 487, 0, 538, + 0, 549, 179, 200, 0, 0, 169, 0, 0, 0, + 180, 542, 0, 857, 807, 0, 818, 805, 0, 809, + 0, 0, 0, 832, 0, 0, 0, 500, 0, 516, + 518, 0, 0, 456, 0, 0, 452, 0, 0, 479, + 0, 520, 494, 0, 155, 521, 153, 154, 523, 0, + 537, 0, 848, 0, 841, 0, 845, 529, 0, 0, + 0, 367, 0, 527, 0, 0, 539, 0, 860, 0, + 872, 0, 870, 0, 0, 640, 641, 0, 0, 0, + 690, 691, 689, 697, 836, 618, 624, 617, 0, 739, + 0, 347, 613, 0, 0, 0, 555, 444, 438, 442, + 437, 540, 478, 477, 474, 473, 0, 468, 433, 434, + 445, 0, 0, 757, 0, 0, 898, 874, 0, 899, + 0, 895, 0, 910, 0, 0, 0, 0, 878, 19, + 344, 687, 686, 0, 685, 0, 362, 956, 190, 951, + 0, 0, 54, 0, 0, 0, 0, 0, 0, 369, + 0, 644, 0, 0, 80, 79, 0, 483, 0, 0, + 0, 0, 0, 548, 0, 0, 0, 0, 0, 810, + 0, 0, 0, 0, 0, 856, 507, 506, 459, 0, + 0, 935, 936, 448, 454, 0, 457, 0, 481, 0, + 0, 0, 0, 0, 785, 851, 0, 842, 535, 530, + 0, 0, 526, 0, 863, 0, 802, 873, 871, 0, + 544, 626, 0, 622, 621, 620, 350, 612, 611, 628, + 476, 0, 466, 465, 598, 0, 771, 756, 0, 0, + 0, 760, 0, 876, 0, 903, 0, 918, 919, 912, + 882, 884, 924, 365, 364, 955, 0, 0, 62, 56, + 0, 64, 26, 23, 0, 0, 320, 0, 226, 0, + 101, 0, 77, 765, 128, 129, 0, 0, 0, 768, + 198, 199, 0, 0, 0, 0, 172, 181, 173, 175, + 0, 0, 0, 0, 814, 0, 819, 820, 0, 0, + 458, 460, 461, 455, 449, 453, 0, 512, 0, 480, + 491, 447, 524, 522, 0, 847, 0, 0, 531, 0, + 0, 639, 631, 0, 475, 0, 0, 752, 761, 875, + 0, 0, 0, 896, 0, 0, 0, 943, 0, 0, + 0, 69, 70, 73, 74, 0, 335, 326, 325, 0, + 645, 222, 97, 0, 754, 769, 184, 0, 196, 0, + 0, 0, 803, 865, 0, 0, 0, 821, 784, 496, + 493, 791, 0, 797, 0, 0, 789, 0, 794, 849, + 534, 533, 0, 0, 629, 0, 0, 877, 900, 0, + 0, 0, 914, 0, 925, 0, 75, 67, 0, 0, + 0, 321, 0, 0, 0, 0, 0, 185, 0, 176, + 174, 858, 811, 0, 0, 816, 0, 0, 786, 790, + 0, 795, 0, 861, 632, 0, 763, 0, 904, 921, + 922, 915, 885, 55, 0, 71, 72, 0, 0, 0, + 0, 0, 0, 0, 770, 183, 0, 195, 0, 0, + 822, 796, 0, 692, 850, 0, 772, 0, 0, 0, + 76, 0, 0, 336, 0, 322, 0, 330, 386, 385, + 0, 383, 674, 0, 646, 0, 675, 223, 98, 186, + 859, 806, 0, 862, 901, 0, 916, 0, 0, 0, + 0, 0, 0, 0, 0, 676, 0, 0, 0, 0, + 905, 29, 24, 337, 0, 0, 331, 384, 0, 0, + 0, 102, 99, 693, 0, 0, 0, 0, 323, 682, + 0, 683, 680, 0, 678, 95, 0, 94, 0, 0, + 83, 85, 86, 87, 88, 89, 90, 91, 92, 93, + 156, 0, 0, 239, 231, 232, 233, 234, 235, 236, + 237, 238, 0, 0, 229, 0, 0, 0, 902, 0, + 338, 334, 0, 0, 0, 647, 84, 0, 282, 277, + 281, 0, 224, 230, 116, 108, 109, 110, 111, 112, + 113, 114, 115, 117, 0, 0, 106, 100, 908, 906, + 681, 679, 0, 0, 0, 0, 0, 0, 0, 290, + 0, 0, 240, 0, 0, 248, 0, 167, 157, 166, + 0, 103, 107, 0, 0, 276, 0, 0, 275, 0, + 161, 0, 0, 356, 0, 354, 0, 0, 201, 0, + 0, 0, 0, 0, 648, 225, 118, 0, 353, 0, + 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, + 158, 0, 0, 205, 0, 357, 0, 243, 242, 241, + 0, 0, 294, 0, 273, 134, 0, 271, 0, 0, + 0, 136, 0, 358, 0, 0, 202, 0, 0, 0, + 355, 246, 127, 125, 0, 0, 298, 0, 0, 0, + 0, 0, 162, 0, 279, 0, 0, 0, 0, 140, + 0, 0, 0, 0, 359, 360, 0, 0, 0, 0, + 0, 122, 313, 0, 295, 0, 0, 307, 0, 0, + 0, 302, 0, 152, 0, 0, 0, 0, 147, 0, + 0, 291, 0, 137, 0, 131, 141, 159, 165, 213, + 0, 203, 0, 0, 0, 0, 126, 0, 119, 123, + 0, 0, 0, 309, 0, 310, 299, 0, 0, 293, + 303, 274, 0, 0, 133, 148, 272, 0, 289, 0, + 280, 284, 143, 0, 0, 0, 210, 212, 206, 247, + 124, 314, 316, 296, 0, 0, 308, 305, 151, 149, + 163, 0, 0, 0, 160, 214, 216, 204, 0, 0, + 0, 307, 0, 285, 287, 144, 0, 0, 207, 318, + 319, 315, 317, 306, 164, 0, 0, 220, 219, 218, + 215, 217, 0, 0, 0, 208, 286, 288, }; protected static readonly short [] yyDgoto = { 7, - 8, 50, 9, 51, 10, 11, 52, 234, 677, 424, - 12, 13, 53, 22, 23, 24, 319, 194, 237, 662, - 817, 1001, 1116, 1463, 814, 238, 239, 240, 241, 242, - 243, 244, 245, 655, 439, 656, 657, 914, 658, 659, - 918, 815, 996, 997, 998, 267, 579, 1088, 826, 1182, - 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, - 1193, 458, 666, 1279, 928, 1095, 1059, 1128, 1166, 1151, - 1210, 1238, 1209, 1239, 1240, 1123, 1338, 1315, 1363, 1364, - 1365, 930, 1361, 931, 720, 1255, 1326, 1302, 1351, 507, - 1344, 1320, 1380, 893, 1349, 1352, 1353, 1447, 1381, 1382, - 1378, 1194, 1262, 1221, 1280, 678, 1328, 1427, 1346, 1444, - 459, 268, 679, 680, 681, 682, 683, 642, 560, 1100, - 643, 644, 832, 1282, 1306, 1395, 1356, 1429, 1283, 1331, - 1452, 1475, 1396, 1397, 1473, 1460, 1461, 926, 1058, 1150, - 1206, 1264, 1207, 1208, 1256, 1313, 1286, 1257, 321, 225, - 1360, 1259, 1345, 1342, 1195, 1223, 1276, 1424, 1386, 1108, - 1425, 580, 1468, 1469, 1275, 1341, 1317, 1373, 1368, 1339, - 1405, 1410, 1371, 1374, 1375, 1455, 1411, 1369, 1370, 1465, - 1453, 1454, 923, 1005, 1119, 1093, 1144, 1120, 1121, 1158, - 1055, 1142, 1170, 527, 195, 111, 426, 197, 554, 434, - 226, 1294, 640, 641, 803, 819, 322, 401, 525, 301, - 1124, 1125, 46, 113, 302, 115, 116, 117, 118, 119, + 8, 50, 9, 51, 10, 11, 52, 235, 685, 429, + 12, 13, 53, 22, 23, 24, 321, 195, 238, 670, + 828, 1016, 1133, 1480, 825, 239, 240, 241, 242, 243, + 244, 245, 246, 663, 444, 664, 665, 928, 666, 667, + 932, 826, 1011, 1012, 1013, 269, 587, 1105, 837, 1199, + 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, + 1210, 463, 674, 1296, 942, 1112, 1075, 1145, 1183, 1168, + 1227, 1255, 1226, 1256, 1257, 1140, 1355, 1332, 1380, 1381, + 1382, 944, 1378, 945, 728, 1272, 1343, 1319, 1368, 512, + 1361, 1337, 1397, 907, 1366, 1369, 1370, 1464, 1398, 1399, + 1395, 1211, 1279, 1238, 1297, 686, 1345, 1444, 1316, 1401, + 1473, 464, 270, 687, 688, 689, 690, 691, 650, 568, + 1117, 651, 652, 843, 1299, 1323, 1412, 1373, 1446, 1300, + 1348, 1469, 1493, 1413, 1414, 1491, 1477, 1478, 940, 1074, + 1167, 1223, 1281, 1224, 1225, 1273, 1330, 1303, 1274, 323, + 226, 1377, 1276, 1362, 1359, 1212, 1240, 1293, 1441, 1403, + 1125, 1442, 588, 1486, 1487, 1292, 1358, 1334, 1390, 1385, + 1356, 1422, 1427, 1388, 1391, 1392, 1472, 1428, 1386, 1387, + 1482, 1470, 1471, 937, 1020, 1136, 1110, 1161, 1137, 1138, + 1175, 1071, 1159, 1187, 532, 196, 112, 431, 198, 562, + 439, 227, 1311, 648, 649, 814, 830, 324, 406, 530, + 303, 1141, 1142, 46, 114, 304, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 254, 780, 967, 503, - 707, 853, 708, 709, 960, 136, 200, 713, 581, 582, - 583, 584, 774, 467, 468, 296, 965, 715, 402, 298, - 490, 491, 492, 493, 496, 722, 308, 737, 738, 869, - 264, 473, 265, 472, 137, 138, 139, 140, 141, 142, - 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, - 153, 563, 564, 565, 756, 757, 882, 758, 154, 550, - 348, 979, 155, 485, 924, 1057, 1148, 1260, 460, 1129, - 1130, 1177, 1178, 804, 540, 330, 752, 1136, 541, 542, - 269, 270, 271, 158, 159, 160, 272, 273, 274, 275, - 276, 277, 278, 279, 280, 281, 282, 283, 172, 284, - 551, 173, 174, 315, 785, 619, 896, 829, 673, 934, - 894, 897, 898, 935, 936, 285, 175, 176, 177, 1030, - 971, 1031, 1032, 1033, 1075, 1034, 178, 179, 180, 181, - 690, 478, 691, 952, 1068, 692, 950, 693, 1070, 1071, - 182, 183, 184, 185, 186, 187, 303, 516, 517, 973, - 1077, 311, 949, 838, 1102, 875, 1109, 188, 412, 189, - 413, 899, 986, 414, 631, 798, 795, 796, 991, 415, - 416, 417, 418, 419, 420, 903, 621, 901, 1081, 1153, - 1212, 988, 1112, 1169, 793, 627, 794, 1046, 990, 1047, - 1113, 992, 17, 19, 47, 48, 229, 645, 811, 435, - 646, 647, - }; - protected static readonly short [] yySindex = { -140, - 0, -179, -122, -206, -107,11604, 0, -77, 0, 0, - -107, -206, 0, 0, -106, 0, 6451, -107, 0, -173, - -255, 0, 0, 0, 0, 0, 0, 0, 0, 22, - 0, 41, 0, 0, 0, 4973, 0, 0, 0, 0, - 0, 0, 0, 0, 125, 0, 0, 160, 0, 0, - -77, 70, -107, 0, 114, 0, 130, 248, 124,11086, - 283, 180, 82, 6608, 0, 180, 180, 180, -159, 180, - 180, 227, 0,10105, 180, 180, 0,10105, 0, 297, - 0, 124, 0, 180, 463, 180, 0, 8157,11654, 299, - 180, 180,10909, 0,10105, 0,10785,10785,10785,10785, -10785,10785,10785,10785, 0, 294, 0,11678, 0, 0, - 260, 375, 308, 118, 0, 0, 565, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1011, 0, 0, - 669, 98, 289, 605, 382, 567, 569, 594, 590, 439, - 619, 0, 0, 0, 0, 0, 0, 3339, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 603, 670, -270, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -189, -186, 70, - 0, 396, 652, 666, 0, 629, 0, 0, 0, 0, -11678,11678, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 704, 672, 0, 680, 0, -160, - 0, 0, 0, 70,12518, 70, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 845, 701,10241, 0, - 0, 0, 0,10105, 180, 180, 281, 308, 0, 709, - 0,11678, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 784, 117,11086, 0,11678,10105, 759, - 779,10105,10105, 4541, 429, -196, 799,11732, 40, 0, - 788, 0, 812,11678,10105, 825, 461, 180, 0,10105, - 297, 9561, 0, 0, 463,10105, 463, -205, 416, 728, - 0, 670, 118, -69, 757,10105,10105,10105, 0, 6765, - -299, 0, 0, 0, 0, 0, 0, 0, 0, 827, -10105, 0, 0, 0, 682, 0, 0,11509, 197, 839, - 807, 0, 317, 0, 0, 354, 0, 0, 806,10241, - 9289, 0, 0,10785,10105,10105,10105,10105,10105,10105, -10105,10105,10105,10105,10105,10785,10785,10785,11678,11678, -10785,10785,10785,10785,10785,10785,10785,10785,10785,10785, -10785,10785,10785,10785,10785,10785,10105, 0, 0, 0, - 0, 670, 0, 0, 0, 0,11749,11803, 808, 0, - 0, 0, 0, -24, 714, 0, 0, 0, 0, 0, - 0, 0, 70, 70, 811, 0, 816, 0, 807, 704, - 704, 0, -146, 0, 528, 704, 869, 0, -180,12518, - 0, 0, 0, 0, -156, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 101,12548, 0, - 0, 0, 807, 206, 0, 0, 592, 0, 873, 0, - 876, -100, 297, 180, 0, 0, 834, 7688, -246, 0, - 878, 0, 0, 0, 895, 901, 0, 369, 0, 910, - 0, 906, 0, 0, 0, 598, 0, 7824, 610,10105, - 799, 9289, 0, 7236, 0, 463, 0, 0, 0, 913, - 921, 0, 0, 124, 297, 61, 0, 4222, 922, 0, - 923, 858, 0, 924, 0,10105, 0, 0, 1005, 0, - 0, 0,10105, 1006, 928, 0, 931, 932, 0, -283, - 6765, 0, 0, 0, 0, 0, 0, 0, 929, 297, - 6765, 0, 0, -262, 0, 0, 0, 463, 197, 889, -11827, 0, 935, 0, 939,10785, 0, -96, 0, 247, - 0, 807, 615,10105,10105, 941, 1059, 0, 0, 50, - 942, 0, 0, 0, 669, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 669, 669, 98, 98, 289, 289, 289, 289, 605, - 605, 382, 567, 569, 594, 590, 0, 944, -197, 0, -10105, -26, 899, 13, 903, 948,10105, 0, 0, 0, - 964, 0, 481, 807, 0, 0, 0, 0, 586, 274, - 0,11827, 528, 0, 950, 960, 0, 0, 0, 0, - 0, 0, 197, 652, 0, 962, 961, 0, 0, 0, - 0, 969,11877, 925, 0, 233, 0, 0, 110, 0, -10241, 0, 966, 0, 0, 0, 628, 973, 0, 974, - 975, 977, 0, 0,10105, 0, 0, 938, 0, 0, - 981, 0, 979,10105, 1064, 0, 6608, 6608, 7983, 0, - 4541, 0, 0, 9697, -252, 0, -282, -184, 0, 930, - 937, 0, -141, 0, 0, 991, 0, 0, 0, 0, - 0, 992, 0, 1001, 0, 4381, 0, 297, 0, 0, - 463, 394, 427, 0, 951, 0, 998, 999, 0, 6608, - 0, 6608, 0,10105, 0,10105,11678, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 8140, 0,11678, - 0, 0, 955,11509, 1031, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9153, 0, 0, 0, 0, - 9425,10105, 0, 7393, 1002, 0, 0, 1081, 0, 1083, - 0, 761, 0, 1004,10105,10105, 963, 0, 0, 0, - 0, 0, 965, 0, -146, 0, 0, 0, 0, 528, - 528, 0, 811, 1012, 1013, 967, 1019, 925, 0, 1014, - 0, 1132, 1134, 0, 0,10105, 0, 9833, 1021, 628, -11827,11678, 0, -50, 1137, 1140, 1027, 1022, 0,10105, -10105, 1028,10105, 1122, 0, 0, 0, 0, 60, 9969, - 0, 0, 0, 0, 7529, 0, 1149, 0, 670,10105, - 1056, 7983, 1060, 0, 0, 1009, 0, 0, 0, 1015, - 489, 0, 1018, 0, 1022, 0, 0, 0, 1052, 0, - 0, 0, 0, 0, 0, 0, 0, 561, 0, 0, - 0,11732, 0, 0, 1020, 1053, 1002, 0,10105, 0, -10105, 0,10105, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1061, 811, 0, 0,10377, 0, 0, 0, - 1066, 7253, 0, 925, 0, 925, 0, 925, 0, 0, - 0, 0, 1024, 1067, 1021, 0, 0, 0, -155, -152, - 1070, 1074, 0, 0, 0, 0, 1073, 7983, 1002, -197, - 0, 1078, 0, 0, 1085, 6608, 0, 0, 0, 0, - 0, 0, 1080, 0, 799, 0, 0, 0, 0, 0, - -187, 0, 1086, 489, 0, 1034, 1002, 0, 297, 0, - 1036, 1079, 0, 0, 0,10105, 1114,10105, 0,10105, - 1111, 292, 0, 961, 184, 623, 0, 0, 0, 0, - -206, 0, 0, 0, 1096, 0, 0, 0, 1084, 0, - 0, 0, 547, 0, 1087, 1210, 1211, 0, 0, 1097, - 1002,10105, 0, 0, 0, 0, 0,10105, 0, 1102, - -203, 0, -203, 0, 0, 0, 0, 1099, 0,10105, - 7393, 0, 0, 1125, 896, 1100, 0,10105, 0, 1103, - 0, 0,10377, -107, -100, 0, 1101, 1101, 1101, 9833, - 1105, 0,10105, 0, 0, 0, 0, 1106, 979, 0, - 6608, 1107, 0, 0, 6765, 0, 1110, 0, 1113, 0, -10105, 0, 0, 0, 0, 0, 0,10105, 0, 0, - 70, 1109, 70, 7410, -145, -145, -145, 0, 0,10105, - 0, 6608, 6608, 0, 0, 6765, 0, 0, 6608, 0, - 1136,10105,10105, 0, 70, 1117, 0, 1069, 0, 1116, - 0, 0, 0, 1120, 0, 0, 1071, 0, 1156, 0, - 0, 0, 0, 0, 0, 6765, 0, 0, 1164, 0, - 1112, -145, 0, 1145, 70, 7410, 1139, 1148, 0, 1151, - 1152, 1153,10105, 0, 0, 0, 0, 1135, 1112, 0, - 0,11580, -79, 70, 0, 0, 0, 1167,10105, 1144, -10105, 0, 0, 1166, 0, 0, 1165, 0, 0,12548, - 0, 1170, -79, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 462,12548, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1172, 70, 0, 70, 1112, - 1123, 0, 1167, 0, 0, 1173,11580,11325, 0, 0, - 479, 0, 0, 0,11357, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1174, 70, 0, - 0, 0, 0, 0, 0,11678,11678, 336,11732, 337, - 463, 1207, 0, 197, 9089, 0, 1242, 0, 0, 1112, - 0, 0, 0, 1112, 0, 0, 1131, 1133, 0,11678, - -151, 0,11678, 1133, 1138, 1184, 0, 197, 0, 1186, - 9021, 0, 1189, 1141, -76, 509, 4973, 0, 0, 0, - 197, 0, 1193, 1143, 1191, 1187, 0, 1195, 1198, 1199, - -100, 1190, 1202, 0, 1201, 1209, 0, 807, 0, 654, - 0, 0, 0, 1206, -192, 0, 1197, 0, 0, 1212, - 0, 0, 1213, 1215, 0, 1208, 0, -100, -100, 0, - -100, 1216, 1217, 0, 0, 0, 0, 1219, -48, 0, - 1220, -100, 1327, 1221, -100, -100, 479, 0, 7983, 1179, - 1222, 1208, 0, 1224, 1228, 26, 1214, 0, 0, -100, - 9833, 1183, 1227, 1219, 0, 0,12548, 0, 70, 70, - 0, 1188, 1229, 1220, 0, 1232, 0,10105, 1192, 1233, - 1221, 0, 1236, 1239, 0, -182, 0, 1237, 0, 0, - 0, 0, 0,12548, 0, 26, 26, 1247, 1245, 0, - -192, 0, 0, 20, 1251,12548, 0,12548, 0, 0, - 7983, 1240, 0, 0, 0, 1252, 1212, 0, 0, 0, - 0, 0, -144, 0, 0, 0, -145, 844, 1256, 0, - 0, 0, 0, 0, 0, 0, 0, 1311, 1368, 0, - 0, 0, 0, -145, 1261, 1262, 7983, 0, 0, 0, - 0, 26, 529, 529, 0, 0, 0, 0, 0, -198, - -198, 0, 0, 0, 0, 0, 0, 9289, 9289, 0, - 0, 0, 0, 0, 1266, 1264, 1265, 0, 0, 0, + 130, 131, 132, 133, 134, 135, 136, 255, 791, 981, + 508, 715, 864, 716, 717, 974, 137, 201, 721, 589, + 590, 591, 592, 785, 472, 473, 298, 979, 723, 407, + 300, 495, 496, 497, 498, 501, 730, 310, 745, 746, + 880, 266, 478, 758, 267, 477, 138, 139, 140, 141, + 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 154, 571, 572, 573, 767, 768, 896, 769, + 155, 558, 759, 353, 994, 546, 1054, 156, 490, 938, + 1073, 1165, 1277, 465, 1146, 1147, 1194, 1195, 815, 548, + 335, 763, 1153, 549, 550, 271, 272, 273, 159, 160, + 161, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 173, 286, 559, 174, 175, 317, 796, + 627, 910, 840, 681, 948, 908, 911, 912, 949, 950, + 287, 176, 177, 178, 1045, 985, 1046, 1047, 1048, 1091, + 1049, 179, 180, 181, 182, 698, 483, 699, 966, 1084, + 700, 964, 701, 1086, 1087, 183, 184, 185, 186, 187, + 188, 305, 521, 522, 987, 1093, 313, 963, 849, 1119, + 886, 1126, 189, 417, 190, 418, 913, 1001, 419, 639, + 809, 806, 807, 1006, 420, 421, 422, 423, 424, 425, + 917, 629, 915, 1098, 1170, 1229, 1003, 1129, 1186, 804, + 635, 805, 1062, 1005, 1063, 1130, 1007, 17, 19, 47, + 48, 230, 653, 822, 440, 654, 655, }; - protected static readonly short [] yyRindex = { 2824, - 0, 0, 6922, 2824, 0, 0, 0, 1638, 0, 0, - 2977, 1029, 0, 0, 0, 0, 0, 2977, 0, 0, - 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, + protected static readonly short [] yySindex = { -157, + 0, -201, -137, -18, 44,11653, 0, 248, 0, 0, + 44, -18, 0, 0, 104, 0, 6498, 44, 0, -196, + -237, 0, 0, 0, 0, 0, 0, 0, 0, 99, + 0, 223, 0, 0, 0, 1006, 0, 0, 0, 0, + 0, 0, 0, 0, 93, 0, 0, 544, 0, 0, + 248, 259, 44, 0, 258, 0, 87, 294, 353,11153, + 318, -29, 328, 6655, 0, -29, -29, -29, -175, -29, + -29, 587, 0,10172, -29, -29, 0,10172, 0, 388, + 0, 353, 0, -29, 330, -29, 0, 8204,11672, 390, + -29, -29, -162,10976, 0,10172, 0,10852,10852,10852, +10852,10852,10852,10852,10852, 0, -103, 0,11726, 0, + 0, 363, -260, 795, 302, 0, 0, 447, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1640, 0, 0, 1640, 0, 0, - 1638, 3020, 2871, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1274, 0, 0, 0, 0, 0, 0, 0, - 0,11901, 0, 1268, 0, 0, 0, 1268, 0, 0, - 0, 0, 0, 0, 249, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1069, 0, + 0, 685, 66, 498, 616, 597, 456, 462, 480, 505, + 137, 548, 0, 0, 0, 0, 0, 0, 3318, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3651, 0, 0, 0, 0, - 0, 288, 4539, 3810, 0, 0, 4380, 0, 0, 0, + 0, 0, 0, 571, 600, -285, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -105, 95, + 259, 0, 401, 606, 627, 0, 615, 0, 0, 0, + 0,11726,11726, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4695, 0, 0, - 4763, 5107, 5311, 5651, 5855, 5991, 6127, 758, 6263, 1178, - 519, 0, 0, 0, 0, 0, 0, 43, 0, 0, + 0, 0, 0, 0, 0, 674, 633, 0, 646, 0, + -249, 0, 0, 0, 259,12475, 259, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 830, 688,10308, + 0, 0, 0, 0,10172, -29, -29, 834, 512, 795, + 0, 698, 0,11726, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1230, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 911, 911, 3087, - 0, 505, 1269, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 801, 74,11153, 0,11726, +10172, 757, 776,10172,10172, 4520, 326, 109, 779,11743, + 264, 0, 782, 0, 822,11726,10172, 840, 516, -29, + 0,10172, 388, 9628, 0, 0, 330,10172, 330, -205, + 547, 803, 0, 600, 302, -1, 810,10172,10172,10172, + 328, 892, 0, 0, 6812, -56, 0, 0, 0, 0, + 0, 0, 0, 0, 870,10172, 0, 0, 0, 1324, + 0, 0,11582, -289, 860, 839, 0, -84, 0, 0, + 263, 0, 0, 842,10308, 9356, 0, 0,10852,10172, +10172,10172,10172,10172,10172,10172,10172,10172,10172,10172, +10852,10852,10852,11726,11726,10852,10852,10852,10852,10852, +10852,10852,10852,10852,10852,10852,10852,10852,10852,10852, +10852,10172, 0, 0, 0, 0, 600, 0, 0, 0, + 0,11797,11821, 849, 0, 0, 0, 0, 33, 856, + 0, 0, 0, 0, 0, 0, 0, 259, 259, 853, + 0, 867, 0, 839, 674, 674, 0, -86, 0, -206, + 674, 909, 0, -198,12475, 0, 0, 0, 0, -192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 235,12518, 0, 0, 0, 839, 419, 0, + 0, 561, 0, 886, 0, 920, 67, 388, -29, 0, + 0, 881, 7735, -147, 0, 940, 0, 0, 0, 945, + 946, 0, 417, 0, 951, 0, 947, 0, 0, 0, + 680, 0, 7871, 681,10172, 779, 9356, 0, 7283, 0, + 330, 0, 0, 0, 948, 950, 0, 0, 353, 388, + 267, 0, 4201, 952, 0, 953, 908, 0, 956, 0, +10172, 0, 0, 1035, 0, 0, 0,10172, 1036, 972, + 0, 975, 976, 0, 0,11582, 0, -288, 6812, 0, + 0, 0, 0, 0, 0, 0, 974, 388, 6812, 0, + 0, -286, 0, 0, 0, 330, -289, 935,11871, 0, + 980, 0, 987,10852, 0, 275, 0, 349, 0, 839, + 793,10172,10172, 994, 1110, 0, 0, -36, 993, 0, + 0, 0, 685, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 685, + 685, 66, 66, 498, 498, 498, 498, 616, 616, 597, + 456, 462, 480, 505, 0, 995, -186, 0,10172, 80, + 955, 113, 957, 996,10172, 0, 0, 0, 1012, 0, + 200, 839, 0, 0, 0, 0, 517, 242, 0,11871, + -206, 0, 997, 1000, 0, 0, 0, 0, 0, 0, + -289, 606, 0, 1001, 1005, 0, 0, 0, 0, 1007, +11895, 963, 0, 361, 0, 0, 542, 0,10308, 0, + 1016, 0, 0, 0, 711, 1010, 0, 1041, 1042, 1044, + 0, 0,10172, 0, 0, 1002, 0, 0, 1043, 0, + 1049,10172, 1130, 0, 6655, 6655, 8030, 0, 4520, 0, + 0, 9764, 236, 0, -281, 58, 0, 999, 1003, 0, + -185, 0, 0, 1053, 0, 0, 0, 0, 0, 1055, + 0, 1063, 0, 4360, 0, 388, 0, 0, 330, 428, + 573, 0, 1013, 0, 1060, 1061, 0, 6655, 0, 6655, + 0,10172, 0,10172,11726, 0, 0, 388, 388, 1066, + 0, 0, 0, 0, 0, 0, 0, 0, 8187, 0, +11726, 0, 0, 1015,11582, 1092, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9220, 0, 0, 0, + 0, 9492,10172, 0, 7440, 1065, 0, 0, 1146, 0, + 1147, 0, 667, 0, 1068,10172,10172, 1025, 0, 0, + 0, 0, 0, 1028, 0, -86, 0, 0, 0, 0, + -206, -206, 0, 853, 1075, 1078, 1033, 1085, 963, 0, + 1079, 0, 1197, 1199, 0, 0,10172, 0, 9900, 1082, + 711,11871,11726, 0, 128, 1203, 1205, 1090, 1086, 0, +10172,10172, 1094,10172, 1188, 0, 0, 0, 0, 31, +10036, 0, 0, 0, 0, 7576, 0, 1225, 0, 600, +10172, 1115, 8030, 1116, 0, 0, 1067, 0, 0, 0, + 1072, 556, 0, 1073, 0, 1086, 0, 0, 0, 1111, + 0, 0, 1143, 0, 0, 0, 0, 0, 0, 0, + 0, 637, 0, 0, 0,11743, 0, 0, 1074, 1117, + 1065, 0,10172, 0,10172, 0,10172, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1125, 853, 0, 0, +10444, 0, 0, 0, 1136, 7300, 0, 963, 0, 963, + 0, 963, 0, 0, 0, 0, 1091, 1132, 1082, 0, + 0, 0, -188, -181, 1113, 1137, 0, 0, 0, 0, + 1134, 8030, 1065, -186, 0, 1138, 0, 0, 1140, 6655, + 0, 0, 0, 0, 0, 0, 1145, 0, 779, 0, + 0, 0, 0, 0, -203, 0, 1141, 556, 0, 1095, + 1065, 0, 0, 388, 0, 1096, 1142, 0, 0, 0, +10172, 1180,10172, 0,10172, 1179, 461, 0, 1005, 238, + 762, 0, 0, 0, 0, -18, 0, 0, 0, 1164, + 0, 0, 0, 1155, 0, 0, 0, 481, 0, 1156, + 1285, 1287, 0, 0, 1181, 1065,10172, 0, 0, 0, + 0, 0,10172, 0, 1184, -191, 0, -191, 0, 0, + 0, 0, 1182, 388, 0,10172, 7440, 0, 0, 1208, + 702, 1183, 0,10172, 0, 1186, 0, 0,10444, 44, + 67, 0, 1185, 1185, 1185, 9900, 1189, 0,10172, 0, + 0, 0, 0, 1192, 1049, 0, 6655, 1190, 0, 0, + 6812, 0, 1191, 0, 0, 1202, 0,10172, 0, 0, + 0, 0, 0, 0,10172, 0, 0, 259, 1195, 259, + 7457, 71, 71, 71, 0, 0,10172, 0, 6655, 6655, + 0, 0, 6812, 0, 0, 6655, 0, 1213,10172,10172, + 0, 259, 1201, 0, 1157, 0, 1204, 0, 0, 0, + 1207, 0, 0, 1158, 0, 1234, 0, 0, 0, 0, + 0, 0, 6812, 0, 0, 1235, 0, 1206, 71, 0, + 1216, 259, 7457, 1210, 1219, 0, 1220, 1221, 1224,10172, + 0, 0, 0, 0, 1212, 1206, 0, 0,11232, -65, + 259, 0, 0, 0, 1239,10172, 1222,10172, 0, 0, + 1226, 0, 0, 1228, 0, 0,12518, 0, 1232, -65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1640, 252, 0, 0, 0, 0, - 0, 0, 0, 3150, 290, 3197, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3426, 0, 0, 0, + 0, -262,12518, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1238, 259, 0, 259, 1206, 1178, 0, 1239, + 0, 0, 1236,11232,11398, 0, 0, -255, 0, 0, + 0,11430, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1242, 259, 0, 0, 0, 0, + 0, 0,11726,11726, 225,11743, 316, 330, 1270, 0, + -289, 640, 0, 1306, 0, 0, 1206, 0, 0, 0, + 1206, 0, 0, 1198, 1200, 0,11726, -164, 0,11726, + 0, 1209, 1244, 0, -289, 0, 1246, 9112, 0, 1251, + 1211, -46, 351, 1006, 0, 0, 0, -289, 0, 1254, + 1214, 1252, 1237, 0, 1255, 1200, 1260, 67, 1241, 1261, + 0, 1262, 1258, 0, 839, 0, 678, 0, 0, 0, + 1264, -184, 0, 1266, 0, 0, 1267, 0, 1268, 1271, + 1273, 0, 1274, 0, 67, 67, 0, 67, 1276, 1277, + 0, 0, 0, 0, 1278, 62, 0, 1282, 67, 1401, + 1286, 67, 0, -255, 0, 8030, 1245, 1283, 1274, 0, + 1290, 1292, 77, 1295, 0, 0, 67, 9900, 1248, 1291, + 1278, 0, 0,12518, 0, 259, 259, 0, 1250, 1293, + 1282, 0, 1298, 0,10172, 1257, 1296, 1286, 0, 1301, + 67, 0, -77, 0, 1299, 0, 0, 0, 0, 0, +12518, 0, 77, 77, 1309, 1305, 0, -184, 0, 0, + 219, 1311,12518, 0,12518, 0, 0, 8030, 1300, 0, + 0, 0, 1312, 1267, 0, 0, 0, 1316, 0, 20, + 0, 0, 0, 71, 848, 1321, 0, 0, 0, 0, + 0, 0, 0, 0, 1375, 1428, 0, 0, 0, 0, + 0, 1323, 1325, 8030, 0, 0, 0, 0, 77, 412, + 412, 0, 71, 0, 0, 0, 110, 110, 0, 0, + 0, 0, 0, 0, 0, 9356, 9356, 0, 0, 0, + 0, 0, 1327, 1326, 1331, 0, 0, 0, + }; + protected static readonly short [] yyRindex = { 2851, + 0, 0, 6969, 2851, 0, 0, 0, 1704, 0, 0, + 3004, 2782, 0, 0, 0, 0, 0, 3004, 0, 0, + 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1708, 0, 0, 1708, 0, 0, + 1704, 3047, 2898, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1342, 0, 0, 0, 0, 0, 0, 0, + 0,11949, 0, 1334, 0, 0, 0, 1334, 0, 0, + 0, 0, 0, 0, 206, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3630, 0, 0, 0, + 0, 0, 313, 4518, 3789, 0, 0, 4359, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1278, 0, 0, 0, 0, 3426, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4674, 0, + 0, 4742, 5086, 5290, 5630, 358, 5902, 6038, 6174, 6310, + -194, 293, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1935, 0, 2484, 380, 2065, 0, - 0, 2212, 2065, 380, 0, 0, 0, 0, 0, -242, + 0, 0, 0, 0, 1294, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 939, 939, + 3090, 0, 595, 1337, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1268, 0, 0, 0, 0, 0, 0, 1270, 2337, 0, - 3426, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1708, 228, 0, 0, 0, + 0, 0, 0, 0, 3133, 402, 3176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3405, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1318, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, - 0, 0, 3260, 2642, 0, 0, 0, 0, 1782, 1640, - 1640, 0, -124, 0, 7705, 1640, 1647, 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 278,11018, 0, - 0, 0, 3426, 3969, 0, 0, 0, 0, 0, 0, - 0,11401, 0, 0, 0, 0, 0, 1273, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 854, 1033, 0, - 0, 1282, 0, 0, 0, 0, 0, -40, 0, 0, - 3903, 1280, 0, 0, 0, 284, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1486, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1350, 0, 0, 0, 0, + 3405, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2039, 0, 1150, 692, + 2169, 0, 0, 2316, 2169, 692, 0, 0, 0, 0, + 1342, 0, 0, 0, 145, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1334, 0, 0, 0, 0, + 0, 0, 1349, 2441, 0, 3405, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 8297, - 0, 0, 0, 0, 0, 0, 0, 47, 419, 0, - 0, 0, 1283, 0, 0, 0, 0, 3426, 0, 3426, - 0, 4062, 0, 0, 0, -35, 0, 0, 0, 0, - 92, 0, 0, 0, 4867, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4935, 5039, 5175, 5243, 5379, 5447, 5515, 5583, 5719, - 5787, 5923, 6059, 6195, 830, 6319, 0, 0, 632, 0, - 0, 380, 0, 380, 0, 0, 0, 0, 0, 0, - 2299, 0, 0, 1782, 0, 0, 0, 0, 1241, 0, - 0, 0,11955, 0, 0, 645, 0, 0, 0, 0, - 0, 0, 706, -249, 0, 0, 1288, 0, 0, 0, - 0, 1293, 0, 0, 0, 0, 0, 0,10513, 0, - 0, 0, 644, 0, 0, 0,11972, 0, 0, 663, - 691, 702, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1285, 0, 0, 0, 0, 0, 0, 0, - 1295, 0, 0, 0, 3492, 0, 0, 18, 0, 67, - 3585, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1307, 0, 0, 0, 0, 0, 0, 0, 0, - 258, 478, 551, 0, 0, 0, 0, 1304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1422, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 169, + 0, 0, 0, 0, 0, 0, 0, 3239, 2606, 0, + 0, 0, 0, 1886, 1708, 1708, 0, -122, 0, 7752, + 1708, 1722, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 364,11085, 0, 0, 0, 3405, 3948, 0, + 0, 0, 0, 0, 0, 0,11474, 0, 0, 0, + 0, 0, 1354, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 731, 818, 0, 0, 1357, 0, 0, 0, + 0, 0, 191, 0, 0, 3882, 1363, 0, 0, 0, + 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1590, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1349, 0, 0, 201, 0, + 0, 0, 0, 0, 0, 0, 0, 8344, 0, 0, + 0, 0, 0, 0, 0, -197, 537, 0, 0, 0, + 1365, 0, 0, 0, 0, 3405, 0, 3405, 0, 4041, + 0, 0, 0, 127, 0, 0, 0, 0, -20, 0, + 0, 0, 4846, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 4914, + 5018, 5154, 5222, 5358, 5426, 5494, 5562, 5698, 5766, 5834, + 5970, 6106, 6242, 6366, 0, 0, 786, 0, 0, 692, + 0, 692, 0, 0, 0, 0, 0, 0, 988, 0, + 0, 1886, 0, 0, 0, 0, 1322, 0, 0, 0, +11966, 0, 0, 800, 0, 0, 0, 0, 0, 0, + 744, 664, 0, 0, 1374, 0, 0, 0, 0, 1378, + 0, 0, 0, 0, 0, 0,10580, 0, 0, 0, + 807, 0, 0, 0,12020, 0, 0, 808, 824, 833, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 97, 0, 0, 0, 1301, 0, 0, 0, 0, 0, - 0, 366, 0, 562, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -124, 0, 0, 0, 0,11972, - 8000, 0, 1308, 0, 622, 0, 0, 0, 0, 1312, - 0, 1277, 1291, 0, 0, 0, 0, 0, 1306,12026, - 0, 0, 0,11477, 0, 0, 0, 770, 0, 1322, - 0, 0, 0, 1653, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 3744, 0, - 4221, 1315, 0, 0, 0, 1360, 0, 0, 0, 0, - 478, 0, 0, 0, 770, 0, 0, 0, 0, 0, + 1370, 0, 0, 0, 0, 0, 0, 0, 1380, 0, + 0, 0, 3471, 0, 0, 202, 0, 49, 3564, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1381, + 0, 0, 0, 0, 0, 0, 0, 0, 254, 804, + 658, 0, 0, 0, 0, 1379, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 8344, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 591, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 773, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1357, 0, 0, 0, 0, 0, - 781, 792, 0, 0, 0, 0, 0, 0, 1363, 632, + 0, 251, 0, 0, 0, 1377, 0, 0, 0, 0, + 0, 0, 641, 0, 614, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -122, 0, 0, 0, 0, +12020, 8047, 0, 1384, 0, 805, 0, 0, 0, 0, + 1383, 0, 1338, 1341, 0, 0, 0, 0, 0, 1386, +12044, 0, 0, 0,11550, 0, 0, 0, 857, 0, + 1387, 0, 0, 0, 1757, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3723, + 0, 4200, 1396, 0, 0, 0, 1393, 0, 0, 0, + 0, 804, 0, 0, 0, 857, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3903, 0, 0, 0, 0, 0, - 1316, 0, 0, 478, 0, 885, 1363, 0, 8297, 0, - 456, 631, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 139, 0, 1288, 2402, 0, 0, 0, 0, 0, -12068, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 656, 0, 678, 0, 0, 0, 0, 0, - 1301, 1365, 0, 0, 0, 0, 0, 0, 0, 0, - 1319, 0, 7079, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 468, 593, 0, 0, 0, 0, - 0, 0, 0,12144,11401, 0, 73, 73, 73, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 950, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 821, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -12249, 0, -278, 0, 1372, 1372, 1372, 0, 0, 0, - 0, 0, 0, 0, 0, -219, 0, 0, 0, 0, - 0, 0, 0, 0,12292, 0, 0, 0, 0, 1376, - 0, 0, 0, 147, 0, 0, 0, 0, 554, 0, - 0, 0, 0, 0, 0, 1377, 0, 0, 0, 0, - 2934, 1364, 365, 0, 217, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 2761, 0, - 0, 0, 8457, 8853, 0, 0, 0, 688, 0, 0, - 0, 0, 0, 0, 0, 0, 395, 0, 0,11183, - 0, 0, 8556, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0,11251, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 8947, 0, 8655, 2761, - 0, 0, 688, 0, 0, 0, 0, 278, 0, 0, - 0, 0, 0, 0, 278, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 8754, 0, + 871, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1391, 0, + 0, 0, 0, 0, 880, 884, 0, 0, 0, 0, + 0, 0, 1407, 786, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3882, 0, + 0, 0, 0, 0, 1412, 0, 0, 804, 0, 932, + 1407, 0, 0, 8344, 0, 632, 670, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 176, 0, 1374, 8394, + 0, 0, 0, 0, 0,12092, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 770, 0, 775, + 0, 0, 0, 0, 0, 1377, 1409, 0, 0, 0, + 0, 0, 0, 0, 0, 1414, 0, 7126, 0, 0, + 0, 0, 0, 8344, 0, 0, 0, 0, 0, 0, + 679, 730, 0, 0, 0, 0, 0, 0, 0,12135, +11474, 0, 170, 170, 170, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1411, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4669, 306, 0, 8989, 0, 0, 0, 9059, 0, 2761, - 0, 0, 0, 2761, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 868, 0, 1379, + 0, 0, 0, 0, 0, 0, 0,12246, 0, -290, + 0, 1418, 1418, 1418, 0, 0, 0, 0, 0, 0, + 0, 0, -178, 0, 0, 0, 0, 0, 0, 0, + 0,12289, 0, 0, 0, 0, 1419, 0, 0, 0, + 216, 0, 0, 0, 0, 445, 0, 0, 0, 0, + 0, 0, 1420, 0, 0, 0, 0, 2961, 1410, -257, + 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2719, 0, 0, 0, 8548, + 8944, 0, 0, 0, 745, 0, 0, 0, 0, 0, + 0, 0, 0, -244, 0, 0,11256, 0, 0, 8647, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 908, 0, 602, 0, 0, 0, 0, 0, 0, 0, -11401, 794, 0, 0, 0, 0, 0, 1375, 0, 718, - 0, 0, 0, 0, 0, 0, 815, 0, 0, 0, - 0, 0, 0, 0, 0, 1373, 0,11401,11401, 0, -11433, 0, 0, 0, 0, 0, 0, 1382,12478, 0, - 1391,11401,10649, 1392,11401,11401, 0, 0, 0, 0, - 0, 1393, 0, 0, 0,12448, 0, 0, 0,11401, - 0, 0, 0, 1394, 0, 0, 105, 0,10940,12410, - 0, 0, 0, 1396, 0, 0, 0, 0, 0, 0, - 1403, 0, 0, 0, 0, 583, 0, 818, 0, 0, - 0, 0, 0, 898, 0,12334,12372, 0, 0, 0, - 0, 0, 0, 0, 0, 1440, 0, 1517, 0, 0, - 0, 819, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 588, 0, 0, 0, + 0, 0,11324, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9038, 0, 8746, 2719, 0, 0, 745, + 0, 0, 0, 0, 364, 0, 0, 0, 0, 0, + 0, 364, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 8845, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4648, 457, 0, + 9080, 0, 0, 0, 9150, 0, 2719, 0, 0, 0, + 2719, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 866, 0, 1424, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 888, 0, 551, + 0, 0, 0, 0, 0, 0, 0,11474, 889, 0, + 0, 0, 0, 0, 1426, 0, 906, 0, 0, 0, + 0, 0, 0, 900, 0, 0, 0, 0, 0, 0, + 0, 0, 1437, 0,11474,11474, 0,11506, 0, 0, + 0, 0, 0, 0, 1460, 1390, 0, 1461,11474,10716, + 1463,11474, 0, 0, 0, 0, 0, 0, 1465, 0, + 0, 0,12445, 0, 0, 0,11474, 0, 0, 0, + 1467, 0, 0, 285, 0,11007,12407, 0, 0, 0, + 1468, 0, 0, 0, 0, 0, 0, 1472, 0, 0, +11474, 0, 490, 0, 910, 0, 0, 0, 0, 0, + 942, 0,12331,12369, 0, 0, 0, 0, 0, 0, + 0, 0, 1487, 0, 1586, 0, 0, 0, 926, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 588, 0, 0, 0, 0, 0, 0, - 0,12448,10821,12186, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1280, 1280, 0, + 0, 0, 0, 492, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,12445,10888, +12203, 0, 492, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1363, 1363, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; protected static readonly short [] yyGindex = { 0, - 0, 1732, 0, 0, 0, -2, -9, -178, -42, 1735, - 0, 1772, 1786, 568, 0, 0, -7, 0, 0, 0, - 0, 0, 0, -780, -685, -216, -600, 0, 0, 0, - 0, 0, -190, 0, 0, 0, 879, 0, 982, 0, - 0, 0, 0, 739, 741, -17, -229, 0, 0, 0, - 0, 613, -662, -625, -592, -518, -515, -471, -465, -453, --1096,-1093, 0, 1, 0, 211, 0,-1034, 0, 0, - 0, 0, 0, 0, 558, -74, 397, 0, 0, 0, - 435,-1025, 0, -273, -291, 1146, 0, 0, 0, -859, - 384, 0, 0, -493, 0, 0, 451, 0, 0, 425, - 0, 0, 460, 0, -391, -931, 0, 0, 0, 0, - 570, -14, 0, 0, 988, 990, 994, 1155, -523, 0, - 0, -312, 1003, 566, 0, -940, 0, 0, 0, 0, - 0, 0, 0, 0, 368, 0, 0, 0, 0, 0, - 0, 0, 0, 630, 0, 0, 0, 0, -301, 548, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 641, - 0, -494, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 383, 0, 0, 465, 0, 0, 470, 472, 388, - 0, 0, 0, 0, 0, 0, 0, 0, 698, 0, - 0, 0, 0, -58, 0, 318, -55, 0, 0, 534, - 0, 595, 0, 1043, 0, 1333, -293, -269, -62, 162, - 0, 710, 0, -39, 54, 0, 0, -5, 0, 0, + 0, 1799, 0, 0, 0, -2, -10, -179, -42, 1800, + 0, 1841, 1854, 83, 0, 0, -6, 0, 0, 0, + 0, 0, 0, -826, -694, -224, -431, 0, 0, 0, + 0, 0, -193, 0, 0, 0, 934, 0, 1047, 0, + 0, 0, 0, 814, 815, -17, -230, 0, 0, 0, + 0, 672,-1118, -618, -488, -460, -427, -357, -308, -219, +-1116,-1131, 0, 1, 0, 234, 0,-1073, 0, 0, + 0, 0, 0, 0, 617, 173, 458, 0, 0, 0, + 493,-1039, 0, -276, -293, 1217, 0, 0, 0, -863, + 453, 0, 0, -492, 0, 0, 522, 0, 0, 497, + 0, 0, 532, 0,-1189, -934, 0, 0, 0, 0, + 0, 625, -13, 0, 0, 1054, 1056, 1057, 1215, -521, + 0, 0, -321, 1062, 613, 0, -995, 0, 0, 0, + 0, 0, 0, 0, 0, 427, 0, 0, 0, 0, + 0, 0, 0, 0, 683, 0, 0, 0, 0, -340, + 607, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 701, 0, -504, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 438, 0, 0, 535, 0, 0, 541, 543, + 465, 0, 0, 0, 0, 0, 0, 0, 0, 771, + 0, 0, 0, 0, -59, 0, -15, -91, 0, 0, + 605, 0, 665, 0, 1122, 0, 1416, -291, -274, -66, + 451, 0, 777, 0, -38, 518, 0, 0, 1027, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -263, 0, 129, 0, 0, -327, - 0, 0, 0, 997, 0, -300, -134, 1154, 1091, 0, - 1088, 0, 1284, 1495, 1200, 0, 0, 909, 1788, 0, - 0, 0, 0, 1160, 0, 0, 0, 0, 0, -504, - 0, 0, 0, 0, 1775, 1115, 0, 0, 480, 904, - 752, 902, 1482, 1483, 1484, 1487, 1481, 0, 1488, 0, - 0, 0, 1118, 0, 907, 0, 0, 0, 0, 0, - 0, 0, 0, -286, 0, 0, 0, 0, -442, 0, - 751, 0, 668, 0, 747, 0, 0, 0, 813, -519, - -16, -305, -13, 0, 1729, 0, 25, 0, 27, 58, - 90, 106, 115, 119, 120, 121, 134, 144, 0, -658, - 0, -32, 0, 0, 940, 0, -455, 0, 0, 0, - 848, 0, 995, 0, 956, -449, 0, 0, 0, 0, - 0, 0, 862, 0, 0, 861, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 874, 0, 0, - 0, 0, 0, 0, 0, 0, -37, 0, 1381, 0, - 0, 0, 1023, 0, 0, 0, 0, 0, -170, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1480, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 686, 0, 0, 0, 0, 0, 0, 0, 0, 787, - 0, 0, 0, 0, 0, 0, 31, 1090, 0, 0, - 0, 1092, + 0, 0, 0, 0, 0, -269, 0, 132, 0, 0, + -320, 0, 0, 0, 1076, 0, -298, -134, 1229, 1159, + 0, 1151, 0, 1361, 1580, 1269, 0, 0, 968, 1882, + 0, 0, 0, 0, 1247, 0, 0, 0, 0, 0, + -515, 1624, 0, 0, 0, 0, 1865, 489, 0, 0, + 474, 922, 905, 918, 1564, 1565, 1566, 1572, 1563, 0, + 1571, 0, 0, 0, 1218, 1427, -708, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -287, 0, + 0, 0, 0, -446, 0, 819, 0, 741, 0, 825, + 0, 0, 0, 890, -526, -16, -307, 12, 0, 1818, + 0, 68, 0, 86, 101, 105, 114, 117, 122, 147, + 148, 149, 150, 0, -667, 0, -25, 0, 0, 1020, + 0, -575, 0, 0, 0, 923, 0, 1077, 0, 1030, + -457, 0, 0, 0, 0, 0, 0, 941, 0, 0, + 937, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 949, 0, 0, 0, 0, 0, 0, 0, + 0, -26, 0, 1469, 0, 0, 0, 1103, 0, 0, + 0, 0, 0, -169, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1574, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 761, 0, 0, 0, 0, + 0, 0, 0, 0, 862, 0, 0, 0, 0, 0, + 0, -14, 1173, 0, 0, 0, 1175, }; - protected static readonly short [] yyTable = { 109, - 156, 18, 110, 157, 508, 505, 44, 716, 190, 235, - 721, 423, 193, 320, 325, 481, 667, 441, 422, 466, - 258, 753, 314, 398, 544, 535, 501, 260, 689, 524, - 489, 759, 981, 350, 1098, 561, 863, 763, 844, 845, - 306, 161, 925, 162, 253, 461, 562, 694, 785, 355, - 347, 363, 530, 354, 259, 362, 300, 1470, 783, 497, - 300, 1131, 1132, 1336, 1028, 307, 405, 309, 1027, 405, - 114, 854, 546, 1422, 163, 650, 14, 331, 231, 20, - 1028, 874, 191, 876, 750, 851, 1218, 259, 526, 326, - 342, 259, 259, 259, 259, 259, 259, 259, 259, 660, - 1012, 651, 1225, 1014, 1296, 403, 164, 1157, 289, 638, - 1126, 760, 1237, 114, 858, 1, 290, 114, 807, 1445, - 65, 65, 165, 1092, 65, 686, 430, 431, 850, 547, - 466, 166, 620, 652, 16, 167, 168, 169, 344, 48, - 109, 156, 1237, 110, 157, 751, 852, 235, 785, 406, - 170, 2, 406, 761, 407, 675, 408, 407, 404, 408, - 171, 345, 409, 410, 437, 409, 410, 45, 94, 48, - 498, 695, 499, 198, 251, 346, 1179, 1471, 112, 49, - 1446, 48, 161, 784, 162, 344, 686, 471, 1337, 855, - 262, 440, 1423, 1127, 286, 287, 288, 710, 292, 293, - 6, 347, 785, 304, 305, 846, 441, 1366, 345, 714, - 310, 114, 312, 479, 316, 163, 734, 2, 1029, 327, - 328, 112, 233, 252, 533, 112, 500, 20, 859, 510, - 438, 465, 860, 461, 1029, 544, 469, 653, 15, 411, - 676, 361, 421, 347, 192, 544, 258, 164, 1309, 323, - 323, 360, 523, 477, 258, 432, 528, 43, 291, 562, - 532, 661, 1013, 165, 531, 1015, 1297, 787, 233, 323, - 553, 480, 166, 1404, 484, 486, 167, 168, 169, 522, - 259, 1393, 1435, 3, 4, 5, 6, 511, 259, 233, - 941, 170, 519, 48, 521, 567, 520, 1024, 484, 925, - 1428, 171, 374, 549, 600, 601, 789, 939, 1050, 537, - 538, 55, 1438, 543, 1439, 858, 545, 345, 233, 112, - 233, 344, 925, 300, 628, 629, 201, 449, 662, 514, - 808, 767, 623, 625, 1436, 1400, 630, 196, 630, 114, - 562, 1310, 465, 578, 345, 202, 728, 586, 587, 588, - 589, 590, 591, 592, 593, 594, 595, 596, 259, 379, - 1156, 734, 323, 323, 344, 114, 975, 643, 969, 1324, - 259, 259, 259, 635, 687, 259, 259, 663, 1172, 618, - 235, 664, 342, 114, 310, 450, 361, 345, 449, 1271, - 639, 953, 1448, 630, 233, 380, 1354, 1355, 837, 1357, - 879, 879, 663, 344, 630, 196, 196, 668, 347, 1456, - 1376, 662, 1104, 1383, 1384, 824, 374, 633, 374, 643, - 374, 778, 825, 323, 502, 196, 345, 957, 1399, 1241, - 344, 654, 347, 860, 925, 687, 518, 489, 233, 662, - 925, 466, 665, 1134, 1135, 688, 450, 112, 461, 323, - 1137, 561, 263, 345, 1019, 1430, 1431, 6, 684, 323, - 636, 637, 562, 462, 374, 323, 648, 346, 466, 1036, - 466, 1037, 643, 112, 352, 381, 382, 643, 779, 1288, - 879, 643, 712, 1289, 578, 663, 719, 878, 878, 246, - 94, 112, 475, 1020, 251, 227, 643, 228, 247, 725, - 727, 1198, 248, 313, 821, 461, 323, 360, 743, 323, - 733, 1462, 768, 663, 770, 745, 771, 937, 196, 196, - 462, 1038, 959, 643, 543, 466, 342, 545, 822, 562, - 227, 114, 230, 968, 543, 755, 932, 545, 1199, 372, - 323, 323, 643, 252, 1198, 476, 1229, 405, 342, 641, - 251, 889, 249, 951, 710, 823, 773, 773, 669, 340, - 259, 643, 1181, 1197, 1051, 1067, 643, 878, 323, 323, - 643, 1200, 689, 641, 344, 856, 1229, 642, 800, 196, - 669, 1199, 1181, 1230, 328, 643, 753, 344, 199, 964, - 360, 1269, 1272, 294, 114, 295, 344, 345, 508, 252, - 641, 642, 685, 786, 114, 196, 1197, 341, 1228, 792, - 345, 346, 643, 1230, 1200, 196, 1231, 739, 360, 345, - 199, 196, 360, 250, 360, 360, 360, 360, 642, 367, - 406, 643, 360, 346, 48, 407, 342, 408, 1228, 112, - 1270, 1273, 726, 409, 410, 1201, 1231, 805, 1202, 347, - 372, 866, 372, 465, 372, 372, 338, 372, 261, 372, - 345, 258, 196, 94, 820, 196, 739, 484, 343, 326, - 528, 344, 879, 714, 769, 367, 842, 351, 251, 323, - 356, 719, 383, 384, 344, 883, 712, 1000, 1201, 806, - 1232, 1202, 1203, 1233, 345, 259, 196, 196, 1204, 357, - 358, 372, 112, 372, 909, 338, 372, 345, 346, 909, - 1205, 909, 112, 867, 909, 909, 513, 909, 909, 359, - 1232, 346, 323, 1233, 196, 196, 877, 252, 878, 514, - 360, 352, 331, 669, 568, 1203, 345, 1234, 331, 909, - 881, 1204, 196, 1235, 569, 332, 515, 353, 345, 699, - 114, 114, 345, 1205, 1072, 1236, 196, 940, 578, 344, - 313, 669, 639, 578, 891, 345, 719, 1234, 932, 544, - 669, 570, 352, 1235, 594, 345, 425, 907, 908, 389, - 390, 571, 345, 352, 344, 1236, 344, 345, 427, 1101, - 611, 345, 611, 114, 909, 114, 346, 345, 494, 870, - 544, 313, 495, 323, 345, 654, 912, 345, 929, 345, - 480, 912, 313, 912, 868, 635, 912, 912, 921, 912, - 912, 1049, 484, 1000, 323, 955, 1133, 765, 1107, 765, - 544, 765, 958, 555, 345, 735, 345, 1222, 667, 395, - 556, 912, 966, 585, 719, 94, 345, 1004, 313, 345, - 345, 396, 557, 427, 1261, 1387, 799, 594, 112, 112, - 602, 603, 594, 345, 594, 594, 594, 594, 594, 594, - 594, 594, 594, 594, 594, 94, 1292, 345, 196, 801, - 345, 985, 1299, 987, 1311, 989, 594, 323, 594, 1305, - 594, 802, 594, 594, 594, 94, 912, 1215, 441, 999, - 903, 112, 345, 112, 1155, 903, 654, 903, 323, 868, - 903, 903, 1115, 903, 903, 1061, 1258, 1440, 800, 338, - 665, 323, 338, 1258, 1006, 323, 1007, 1062, 1008, 665, - 719, 905, 980, 555, 781, 830, 905, 552, 905, 347, - 556, 905, 905, 364, 905, 905, 25, 594, 26, 282, - 391, 27, 557, 1459, 664, 508, 28, 392, 282, 196, - 29, 670, 751, 664, 755, 671, 751, 702, 1042, 31, - 1044, 703, 1045, 1476, 1477, 291, 33, 291, 393, 711, - 196, 34, 291, 495, 772, 35, 385, 386, 671, 394, - 903, 66, 323, 323, 1052, 66, 1053, 37, 1054, 38, - 387, 388, 754, 39, 754, 747, 754, 747, 397, 114, - 480, 40, 41, 588, 945, 42, 945, 756, 317, 756, - 400, 905, 1079, 719, 427, 181, 899, 181, 36, 181, - 1086, 899, 169, 899, 169, 999, 899, 899, 295, 899, - 899, 428, 480, 196, 1091, 480, 429, 193, 235, 193, - 1118, 193, 406, 323, 376, 377, 378, 407, 543, 408, - 176, 545, 176, 1111, 196, 409, 410, 345, 433, 932, - 1114, 177, 235, 177, 227, 345, 345, 196, 345, 345, - 57, 196, 480, 323, 360, 589, 433, 1176, 360, 543, - 345, 360, 545, 360, 1139, 1045, 588, 436, 360, 349, - 462, 588, 1118, 588, 588, 588, 588, 588, 588, 588, - 588, 588, 588, 588, 904, 905, 899, 112, 463, 543, - 1180, 1196, 545, 474, 114, 588, 470, 588, 114, 588, - 196, 588, 588, 588, 482, 1168, 606, 607, 608, 609, - 1180, 856, 1176, 856, 68, 529, 68, 588, 196, 196, - 199, 1213, 199, 480, 483, 114, 114, 588, 588, 114, - 353, 170, 114, 170, 1196, 504, 1180, 135, 589, 135, - 588, 1267, 1268, 589, 534, 589, 589, 589, 589, 589, - 589, 589, 589, 589, 589, 589, 588, 509, 296, 114, - 296, 142, 303, 142, 303, 1295, 1180, 589, 1298, 589, - 512, 589, 548, 589, 589, 589, 1263, 1449, 1450, 196, - 566, 332, 333, 334, 335, 336, 337, 338, 339, 589, - 345, 507, 1303, 572, 345, 626, 345, 507, 349, 589, - 589, 196, 112, 634, 350, 1303, 112, 649, 350, 196, - 345, 130, 589, 130, 672, 345, 345, 674, 130, 1083, - 1084, 686, 1332, 696, 1333, 323, 531, 531, 589, 878, - 878, 643, 643, 112, 112, 345, 697, 112, 1096, 1097, - 112, 1312, 698, 345, 350, 741, 345, 700, 350, 701, - 345, 350, 350, 350, 723, 36, 604, 605, 350, 36, - 610, 611, 724, 739, 740, 742, 1367, 112, 744, 746, - 36, 747, 748, 749, 754, 36, 762, 323, 764, 36, - 765, 776, 36, 1394, 777, 781, 788, 512, 782, 797, - 790, 809, 350, 323, 36, 36, 1406, 1408, 791, 36, - 36, 719, 1263, 810, 813, 36, 812, 36, 36, 36, - 36, 816, 43, 480, 833, 36, 828, 834, 835, 36, - 836, 36, 841, 1394, 1394, 839, 840, 843, 198, 857, - 1416, 36, 861, 36, 36, 862, 36, 864, 871, 872, - 36, 873, 884, 886, 900, 895, 902, 906, 323, 323, - 909, 916, 910, 917, 919, 920, 323, 925, 922, 927, - 36, 365, 945, 719, 933, 946, 36, 36, 947, 954, - 508, 956, 948, 424, 963, 424, 508, 323, 323, 1394, - 323, 196, 366, 367, 368, 369, 370, 371, 372, 373, - 374, 375, 498, 978, 424, 424, 972, 970, 983, 719, - 993, 323, 974, 592, 323, 976, 1002, 982, 1464, 1464, - 536, 1009, 1010, 1016, 424, 1472, 1472, 1017, 1018, 1025, - 578, 578, 424, 1022, 868, 424, 1023, 1035, 1040, 1041, - 1043, 1048, 1056, 196, 1060, 1064, 1065, 1063, 1066, 1073, - 1078, 1082, 1087, 1085, 1099, 1094, 1107, 1103, 536, 196, - 1117, 1105, 1110, 1138, 1141, 832, 1143, 1155, 1147, 1145, - 597, 598, 599, 1146, 1127, 536, 536, 536, 536, 536, - 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, - 536, 1154, 1159, 1162, 1163, 1171, 592, 1164, 1165, 1214, - 1167, 592, 1211, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 196, 196, 1216, 1219, 1217, 1226, - 1242, 1265, 196, 1274, 1244, 592, 1287, 592, 1290, 592, - 1291, 592, 592, 592, 1301, 1300, 1304, 1307, 1308, 1316, - 1310, 1318, 1319, 196, 196, 1321, 196, 592, 1322, 1323, - 1325, 1329, 1284, 512, 1327, 1330, 1335, 1340, 512, 512, - 1343, 1350, 1377, 1398, 1347, 1284, 1348, 196, 1358, 1359, - 196, 1284, 1362, 1372, 1379, 1391, 1388, 1389, 1284, 1392, - 1401, 512, 1402, 1415, 1413, 1412, 592, 1420, 1418, 1417, - 1421, 512, 536, 1432, 512, 512, 1433, 1426, 1437, 512, - 1441, 1442, 512, 1451, 512, 1436, 512, 512, 512, 512, - 1435, 1457, 1458, 1478, 512, 1479, 1480, 9, 512, 941, - 542, 612, 512, 830, 32, 502, 933, 732, 800, 503, - 512, 461, 775, 512, 613, 512, 512, 30, 676, 22, - 804, 512, 501, 512, 512, 512, 512, 512, 512, 512, - 512, 512, 512, 512, 30, 527, 750, 31, 323, 512, - 766, 758, 31, 779, 512, 512, 780, 512, 512, 512, - 512, 512, 512, 512, 220, 512, 512, 805, 512, 512, - 512, 512, 512, 512, 512, 512, 512, 512, 96, 512, - 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - 512, 838, 759, 512, 750, 512, 807, 512, 664, 664, - 512, 832, 832, 327, 686, 352, 512, 345, 138, 832, - 832, 832, 832, 832, 643, 832, 832, 120, 832, 832, - 832, 832, 832, 832, 832, 832, 299, 145, 139, 121, - 832, 300, 832, 832, 832, 832, 832, 832, 146, 643, - 832, 345, 232, 54, 832, 832, 236, 832, 832, 832, - 21, 1089, 994, 1090, 915, 1220, 1266, 1434, 1403, 832, - 1443, 832, 1390, 832, 832, 1419, 1385, 832, 818, 832, - 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - 832, 942, 832, 943, 1281, 832, 832, 944, 1474, 832, - 832, 831, 938, 1293, 1314, 1224, 1227, 1467, 1414, 1409, - 1407, 1466, 1160, 1334, 832, 832, 832, 911, 832, 1285, - 736, 962, 832, 832, 573, 1161, 832, 849, 775, 297, - 847, 832, 832, 832, 832, 832, 888, 329, 890, 832, - 827, 832, 612, 1026, 613, 616, 614, 832, 832, 1149, - 615, 885, 1152, 617, 1245, 1039, 399, 1106, 1080, 1021, - 1011, 984, 1074, 1076, 632, 1069, 729, 977, 1243, 1140, - 913, 912, 832, 832, 832, 832, 0, 832, 775, 775, - 0, 0, 0, 0, 832, 0, 775, 775, 775, 775, - 775, 0, 775, 775, 0, 775, 775, 775, 775, 775, - 775, 775, 0, 0, 740, 0, 0, 775, 0, 775, - 775, 775, 775, 775, 775, 0, 0, 775, 0, 0, - 0, 775, 775, 0, 775, 775, 775, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 775, 0, 775, 536, - 775, 775, 0, 0, 775, 0, 775, 775, 775, 775, - 775, 775, 775, 775, 775, 775, 775, 775, 0, 775, - 0, 0, 775, 775, 0, 0, 775, 775, 0, 0, + protected static readonly short [] yyTable = { 110, + 157, 18, 724, 111, 197, 510, 44, 191, 513, 236, + 446, 428, 570, 194, 486, 352, 729, 675, 316, 471, + 427, 260, 764, 506, 403, 697, 494, 552, 158, 540, + 529, 569, 770, 232, 262, 874, 1115, 855, 856, 1148, + 1149, 933, 996, 466, 6, 254, 360, 774, 368, 535, + 892, 308, 1042, 359, 14, 367, 302, 658, 375, 192, + 302, 595, 1215, 668, 1043, 1235, 309, 1027, 311, 794, + 869, 1353, 197, 197, 1029, 442, 1043, 327, 336, 761, + 885, 1242, 887, 659, 162, 1174, 862, 771, 531, 793, + 408, 1313, 291, 197, 677, 1309, 357, 20, 1, 563, + 292, 349, 163, 200, 1124, 1215, 564, 1246, 1322, 1254, + 332, 95, 358, 1239, 331, 660, 332, 164, 565, 16, + 1278, 165, 677, 333, 350, 315, 1339, 48, 818, 772, + 166, 677, 628, 167, 471, 200, 1109, 1246, 168, 1254, + 762, 110, 157, 409, 595, 111, 702, 863, 236, 595, + 410, 595, 595, 595, 595, 595, 595, 595, 595, 595, + 595, 595, 345, 169, 170, 171, 172, 352, 43, 646, + 158, 48, 375, 595, 375, 595, 375, 595, 1439, 595, + 595, 595, 742, 48, 870, 349, 197, 197, 871, 793, + 1196, 199, 445, 264, 795, 595, 1354, 288, 289, 290, + 2, 294, 295, 446, 718, 570, 306, 307, 350, 352, + 346, 437, 722, 312, 857, 314, 15, 318, 1044, 661, + 375, 193, 329, 330, 569, 669, 162, 361, 570, 1028, + 1044, 443, 470, 411, 595, 466, 1030, 474, 412, 347, + 413, 552, 293, 793, 163, 366, 414, 415, 197, 260, + 528, 552, 1421, 1314, 533, 332, 333, 260, 537, 164, + 322, 327, 482, 165, 575, 536, 3, 4, 5, 6, + 703, 348, 166, 485, 197, 167, 489, 491, 1326, 1445, + 168, 355, 234, 1462, 197, 1055, 869, 349, 527, 516, + 197, 1455, 538, 1456, 524, 48, 526, 1440, 933, 525, + 489, 6, 1039, 234, 933, 169, 170, 171, 172, 570, + 350, 542, 543, 865, 1066, 554, 651, 1383, 551, 557, + 953, 651, 683, 416, 351, 651, 1143, 384, 302, 819, + 742, 1173, 1410, 576, 197, 789, 462, 197, 1417, 2, + 651, 252, 643, 577, 1463, 1095, 553, 470, 586, 1189, + 410, 463, 594, 595, 596, 597, 598, 599, 600, 601, + 602, 603, 604, 385, 502, 1488, 989, 651, 197, 197, + 1465, 1327, 555, 798, 435, 436, 676, 352, 20, 373, + 983, 636, 637, 1341, 626, 236, 651, 1035, 312, 349, + 253, 366, 790, 462, 967, 647, 197, 197, 971, 1485, + 1258, 352, 1288, 202, 871, 848, 800, 684, 463, 1144, + 1371, 1372, 350, 1374, 197, 1053, 933, 1447, 1448, 1121, + 644, 645, 933, 641, 1393, 670, 656, 1400, 197, 507, + 234, 866, 329, 411, 570, 234, 476, 662, 412, 494, + 413, 523, 1416, 386, 387, 234, 414, 415, 471, 480, + 1305, 1151, 1152, 569, 1306, 248, 45, 696, 1154, 249, + 1083, 638, 484, 228, 692, 229, 1438, 113, 955, 1034, + 349, 671, 1051, 1479, 1052, 503, 95, 504, 515, 252, + 1286, 1452, 48, 361, 779, 1489, 781, 720, 782, 586, + 373, 727, 373, 350, 373, 373, 234, 373, 638, 373, + 638, 570, 481, 349, 49, 733, 735, 743, 670, 250, + 113, 671, 694, 751, 113, 672, 741, 887, 887, 951, + 753, 55, 561, 426, 886, 886, 350, 203, 253, 1287, + 197, 505, 551, 1453, 115, 519, 670, 400, 325, 325, + 973, 373, 551, 373, 766, 946, 373, 651, 597, 401, + 811, 982, 736, 197, 671, 638, 608, 609, 450, 325, + 553, 903, 1216, 965, 784, 784, 361, 718, 695, 451, + 553, 1289, 432, 694, 747, 810, 673, 115, 347, 697, + 347, 115, 671, 867, 631, 633, 337, 338, 339, 340, + 341, 342, 343, 344, 361, 978, 764, 887, 361, 651, + 361, 361, 361, 361, 886, 1216, 347, 1247, 361, 113, + 693, 797, 677, 585, 513, 816, 861, 803, 1067, 450, + 1290, 352, 467, 747, 467, 368, 349, 234, 349, 695, + 451, 597, 832, 247, 197, 649, 597, 1247, 597, 597, + 597, 597, 597, 597, 597, 597, 597, 597, 597, 350, + 734, 350, 325, 325, 349, 197, 833, 817, 357, 649, + 597, 470, 597, 351, 597, 351, 597, 597, 597, 251, + 260, 368, 831, 651, 533, 489, 115, 350, 651, 467, + 578, 339, 651, 834, 853, 722, 649, 315, 350, 727, + 579, 351, 1217, 263, 720, 499, 585, 651, 265, 500, + 1015, 585, 778, 585, 585, 585, 585, 585, 585, 585, + 585, 585, 585, 585, 325, 315, 410, 95, 197, 95, + 1218, 597, 878, 252, 651, 585, 1328, 585, 650, 585, + 339, 585, 585, 585, 888, 1217, 889, 1248, 113, 197, + 325, 585, 585, 651, 891, 766, 585, 585, 1198, 1214, + 325, 895, 650, 1219, 95, 197, 325, 585, 585, 197, + 328, 347, 350, 1218, 113, 1249, 1088, 1248, 1198, 586, + 585, 518, 253, 647, 586, 905, 780, 727, 95, 650, + 356, 430, 946, 552, 519, 113, 585, 1172, 921, 922, + 643, 349, 1214, 677, 1245, 1249, 1219, 707, 1250, 411, + 325, 520, 1118, 325, 412, 115, 413, 349, 197, 349, + 812, 673, 414, 415, 350, 552, 541, 662, 349, 943, + 673, 485, 813, 1220, 1245, 369, 197, 197, 1250, 935, + 350, 115, 350, 489, 325, 325, 969, 1065, 1015, 396, + 1150, 350, 593, 972, 351, 552, 351, 835, 879, 1077, + 397, 675, 115, 980, 836, 727, 283, 541, 672, 610, + 611, 1078, 325, 325, 398, 283, 1220, 672, 1251, 605, + 606, 607, 1221, 1404, 541, 541, 541, 541, 541, 541, + 541, 541, 541, 541, 541, 541, 541, 541, 541, 541, + 197, 388, 389, 346, 1275, 1000, 811, 1002, 1251, 1004, + 447, 1275, 349, 357, 399, 346, 877, 446, 614, 346, + 614, 1232, 197, 1014, 228, 1221, 231, 1252, 352, 432, + 197, 662, 346, 448, 292, 350, 292, 890, 1132, 357, + 678, 292, 315, 113, 679, 1457, 449, 402, 1021, 351, + 1022, 451, 1023, 897, 727, 881, 452, 1252, 453, 454, + 455, 456, 911, 296, 346, 297, 457, 911, 315, 911, + 458, 1222, 911, 911, 1294, 911, 911, 346, 297, 350, + 346, 1476, 459, 325, 513, 460, 879, 461, 432, 917, + 766, 1494, 1495, 1058, 917, 1060, 917, 1061, 405, 917, + 917, 541, 917, 917, 394, 395, 325, 390, 391, 113, + 115, 462, 433, 773, 1222, 773, 1253, 773, 995, 113, + 792, 392, 393, 1070, 917, 954, 563, 920, 841, 325, + 918, 919, 920, 564, 920, 485, 339, 920, 920, 339, + 920, 920, 434, 65, 65, 565, 1253, 65, 1096, 727, + 766, 762, 911, 762, 228, 762, 1103, 438, 346, 710, + 719, 1014, 920, 711, 500, 1100, 1101, 1295, 485, 1108, + 346, 485, 777, 441, 346, 236, 115, 1135, 913, 917, + 381, 382, 383, 913, 551, 913, 115, 346, 913, 913, + 1128, 913, 913, 907, 946, 467, 261, 1131, 907, 236, + 907, 350, 438, 907, 907, 197, 907, 907, 508, 485, + 325, 346, 553, 346, 508, 468, 551, 920, 1019, 346, + 331, 1156, 1061, 346, 346, 475, 346, 346, 57, 1135, + 261, 325, 346, 346, 261, 261, 261, 261, 261, 261, + 261, 261, 487, 1068, 553, 1069, 551, 1197, 1213, 182, + 479, 182, 346, 182, 194, 509, 194, 197, 194, 371, + 346, 488, 1185, 346, 358, 113, 113, 1197, 913, 755, + 346, 755, 783, 197, 553, 252, 679, 361, 1230, 953, + 485, 953, 346, 907, 66, 346, 346, 170, 66, 170, + 764, 1213, 764, 1197, 325, 509, 362, 363, 425, 346, + 425, 509, 759, 177, 411, 177, 759, 514, 113, 412, + 113, 413, 178, 1320, 178, 325, 364, 414, 415, 425, + 425, 1466, 1467, 1197, 253, 517, 1320, 365, 197, 197, + 534, 325, 115, 115, 1280, 325, 197, 539, 864, 425, + 864, 574, 351, 1349, 545, 1350, 351, 425, 346, 130, + 425, 130, 68, 923, 68, 556, 130, 197, 197, 200, + 197, 200, 350, 171, 351, 171, 1301, 680, 351, 580, + 346, 351, 135, 351, 135, 115, 634, 115, 351, 1301, + 354, 197, 361, 297, 197, 297, 361, 657, 346, 361, + 351, 361, 1301, 142, 642, 142, 361, 886, 886, 1329, + 204, 682, 325, 325, 614, 615, 616, 617, 694, 304, + 1301, 304, 351, 532, 532, 651, 651, 1113, 1114, 612, + 613, 618, 619, 1384, 261, 704, 705, 706, 708, 731, + 709, 732, 261, 747, 748, 749, 923, 750, 752, 754, + 1411, 923, 205, 923, 923, 923, 923, 923, 923, 923, + 923, 923, 923, 1423, 1425, 755, 756, 757, 727, 765, + 1280, 1193, 773, 775, 541, 923, 325, 923, 776, 923, + 485, 923, 923, 923, 787, 788, 792, 808, 820, 793, + 1411, 1411, 799, 821, 801, 823, 802, 1433, 824, 827, + 43, 844, 206, 207, 208, 209, 325, 210, 211, 212, + 213, 214, 215, 216, 217, 261, 839, 218, 219, 220, + 221, 222, 223, 224, 225, 371, 1193, 261, 261, 261, + 727, 371, 261, 261, 845, 846, 923, 847, 851, 850, + 113, 513, 852, 854, 872, 868, 1411, 199, 873, 875, + 882, 883, 898, 884, 900, 1284, 1285, 893, 909, 914, + 916, 920, 923, 371, 930, 924, 727, 371, 931, 370, + 933, 934, 939, 936, 941, 947, 1481, 1481, 959, 1312, + 960, 961, 1315, 1490, 1490, 968, 962, 970, 586, 586, + 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, + 977, 503, 992, 984, 986, 993, 1031, 115, 371, 988, + 990, 997, 998, 371, 1008, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 1017, 1025, 1024, 1033, + 1032, 1038, 1050, 1037, 1040, 879, 371, 371, 1056, 371, + 371, 371, 1057, 371, 371, 371, 1059, 371, 371, 1064, + 1072, 371, 371, 371, 371, 1076, 1079, 113, 371, 371, + 1080, 113, 1081, 371, 371, 371, 371, 371, 371, 371, + 371, 1089, 1082, 1094, 1099, 1104, 1102, 1124, 1116, 1111, + 1155, 325, 371, 1120, 1122, 371, 1134, 371, 1158, 113, + 113, 1127, 1144, 113, 1160, 1164, 113, 1162, 371, 560, + 1163, 1172, 1171, 1176, 1179, 1180, 1181, 1182, 25, 840, + 26, 1184, 1188, 27, 1228, 1259, 1233, 1231, 28, 1236, + 261, 1234, 29, 113, 115, 1243, 1291, 1261, 115, 1282, + 1304, 31, 1336, 325, 1318, 1307, 1321, 1308, 33, 1324, + 1333, 1342, 1335, 34, 1347, 1338, 1317, 35, 1325, 325, + 1340, 1327, 1346, 1344, 1352, 1360, 115, 115, 1363, 37, + 115, 38, 1364, 115, 1365, 39, 1357, 1367, 1375, 1376, + 48, 1379, 48, 40, 41, 1389, 1394, 42, 1406, 1396, + 319, 1408, 1405, 1409, 1415, 1418, 1419, 1429, 1430, 1432, + 115, 1435, 1437, 48, 1434, 1449, 1450, 513, 1454, 1443, + 1458, 1459, 513, 513, 325, 325, 48, 1461, 1468, 1453, + 1452, 48, 325, 1474, 1496, 1475, 48, 1497, 48, 48, + 48, 48, 1498, 9, 48, 513, 48, 949, 545, 838, + 48, 740, 32, 325, 325, 513, 325, 503, 513, 513, + 615, 941, 48, 513, 504, 48, 513, 48, 513, 808, + 513, 513, 513, 513, 462, 261, 616, 325, 513, 684, + 325, 354, 513, 30, 22, 812, 513, 502, 30, 324, + 528, 48, 758, 31, 513, 221, 783, 513, 96, 513, + 513, 766, 813, 31, 846, 513, 767, 513, 513, 513, + 513, 513, 513, 513, 513, 513, 513, 513, 758, 787, + 815, 788, 817, 513, 672, 672, 328, 694, 513, 513, + 353, 513, 513, 513, 513, 513, 513, 513, 346, 513, + 513, 651, 513, 513, 513, 513, 513, 513, 513, 513, + 513, 513, 138, 513, 513, 513, 513, 513, 513, 513, + 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, + 513, 513, 513, 513, 513, 120, 300, 513, 145, 513, + 139, 513, 121, 301, 513, 840, 840, 146, 651, 233, + 513, 237, 54, 840, 840, 840, 840, 840, 21, 840, + 840, 1009, 840, 840, 840, 840, 840, 840, 840, 840, + 929, 1237, 1283, 1420, 840, 1451, 840, 840, 840, 840, + 840, 840, 1106, 1107, 840, 346, 1460, 829, 840, 840, + 1407, 840, 840, 840, 1436, 1402, 1298, 1310, 956, 842, + 957, 958, 952, 840, 1492, 840, 1244, 840, 840, 1484, + 1331, 840, 1241, 840, 840, 840, 840, 840, 840, 840, + 840, 840, 840, 840, 840, 1431, 840, 1426, 1424, 840, + 840, 1351, 1177, 840, 840, 1483, 1302, 925, 744, 1178, + 860, 976, 904, 786, 581, 902, 1041, 838, 840, 840, + 840, 840, 840, 299, 544, 858, 840, 840, 334, 620, + 840, 621, 624, 622, 1166, 840, 840, 840, 840, 840, + 623, 625, 760, 840, 1262, 840, 404, 1169, 1026, 1097, + 1123, 840, 840, 1036, 1092, 1085, 1090, 999, 991, 737, + 1260, 1157, 899, 640, 927, 926, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 840, 840, 840, 840, + 0, 840, 783, 783, 0, 0, 0, 0, 840, 0, + 783, 783, 783, 783, 783, 0, 783, 783, 0, 783, + 783, 783, 783, 783, 783, 783, 0, 0, 748, 0, + 0, 783, 0, 783, 783, 783, 783, 783, 783, 0, + 0, 783, 0, 0, 0, 783, 783, 0, 783, 783, + 783, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 783, 0, 783, 0, 783, 783, 0, 0, 783, 0, + 783, 783, 783, 783, 783, 783, 783, 783, 783, 783, + 783, 783, 0, 783, 0, 0, 783, 783, 0, 0, + 783, 783, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 783, 783, 783, 783, 783, + 0, 0, 0, 783, 783, 0, 0, 783, 0, 0, + 0, 0, 783, 783, 783, 783, 783, 0, 0, 0, + 783, 346, 783, 0, 0, 0, 346, 346, 783, 783, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 775, 775, 775, 0, 775, 0, 0, 0, 775, - 775, 0, 0, 775, 0, 0, 0, 0, 775, 775, - 775, 775, 775, 0, 0, 0, 775, 345, 775, 0, - 0, 0, 345, 345, 775, 775, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 339, 346, + 0, 0, 0, 783, 783, 783, 783, 0, 783, 346, + 0, 0, 346, 346, 0, 783, 0, 346, 0, 0, + 346, 0, 346, 0, 346, 346, 346, 346, 0, 0, + 0, 0, 346, 0, 0, 0, 346, 0, 0, 0, + 346, 0, 0, 0, 0, 0, 0, 0, 346, 0, + 0, 346, 0, 346, 346, 0, 0, 0, 0, 346, + 0, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 0, 0, 0, 0, 346, 0, 0, + 0, 0, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 0, 346, 346, 0, 0, 346, 346, 346, + 346, 346, 0, 0, 346, 346, 0, 0, 0, 346, + 346, 346, 346, 346, 346, 346, 346, 0, 0, 0, + 0, 0, 0, 0, 748, 0, 0, 0, 346, 748, + 748, 346, 0, 346, 0, 346, 0, 0, 346, 0, + 0, 0, 0, 0, 346, 376, 0, 0, 0, 0, + 0, 0, 748, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 748, 0, 0, 748, 748, 0, 0, 0, + 748, 0, 0, 748, 0, 748, 0, 748, 748, 748, + 748, 0, 0, 0, 0, 748, 0, 0, 0, 748, + 0, 0, 0, 748, 0, 0, 0, 0, 0, 0, + 0, 748, 0, 0, 748, 0, 748, 748, 0, 0, + 0, 0, 748, 0, 748, 748, 748, 748, 748, 748, + 748, 748, 748, 748, 748, 0, 0, 0, 0, 0, + 748, 0, 0, 0, 0, 748, 748, 748, 748, 748, + 748, 0, 748, 748, 748, 0, 748, 748, 0, 0, + 748, 748, 748, 748, 339, 0, 0, 748, 748, 339, + 339, 0, 748, 748, 748, 748, 748, 748, 748, 748, + 346, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 748, 339, 0, 748, 0, 748, 0, 748, 0, + 0, 748, 339, 0, 0, 339, 339, 748, 0, 0, + 339, 0, 0, 339, 0, 339, 0, 339, 339, 339, + 339, 0, 0, 0, 0, 339, 0, 0, 0, 339, + 0, 0, 0, 339, 0, 0, 0, 0, 0, 0, + 0, 339, 0, 0, 339, 0, 339, 339, 0, 0, + 0, 0, 339, 0, 339, 339, 339, 339, 339, 339, + 339, 339, 339, 339, 339, 0, 0, 0, 0, 0, + 339, 0, 0, 0, 0, 339, 339, 339, 339, 339, + 339, 0, 339, 339, 339, 0, 339, 339, 0, 0, + 339, 339, 339, 339, 0, 0, 0, 339, 339, 0, + 0, 0, 339, 339, 339, 339, 339, 339, 339, 339, + 0, 376, 0, 0, 0, 0, 376, 376, 0, 0, + 0, 339, 0, 0, 339, 0, 339, 0, 339, 0, + 0, 339, 0, 0, 0, 0, 0, 339, 0, 376, + 0, 0, 0, 0, 0, 49, 0, 0, 0, 376, + 0, 0, 376, 376, 0, 0, 0, 376, 0, 0, + 376, 0, 376, 0, 376, 376, 376, 376, 0, 0, + 0, 0, 376, 0, 0, 0, 376, 0, 0, 0, + 376, 0, 0, 0, 0, 0, 0, 0, 376, 0, + 0, 376, 0, 376, 376, 0, 0, 0, 0, 376, + 0, 376, 376, 376, 376, 376, 376, 376, 376, 376, + 376, 376, 0, 0, 0, 0, 0, 376, 0, 0, + 0, 0, 376, 376, 0, 376, 376, 376, 0, 376, + 376, 376, 0, 376, 376, 0, 346, 376, 376, 376, + 376, 0, 346, 0, 376, 376, 0, 0, 0, 376, + 376, 376, 376, 376, 376, 376, 376, 0, 28, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 376, 0, + 0, 376, 0, 376, 346, 0, 0, 0, 346, 0, + 0, 0, 0, 0, 376, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 338, 345, 0, 0, 0, 775, - 775, 775, 775, 0, 775, 345, 0, 0, 345, 345, - 0, 775, 0, 345, 0, 0, 345, 0, 345, 0, - 345, 345, 345, 345, 0, 0, 0, 0, 345, 0, - 0, 0, 345, 0, 0, 0, 345, 0, 0, 0, - 0, 0, 0, 0, 345, 0, 0, 345, 0, 345, - 345, 0, 0, 0, 0, 345, 0, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 0, - 0, 0, 0, 345, 0, 0, 0, 0, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 0, 345, - 345, 0, 0, 345, 345, 345, 345, 345, 0, 0, - 345, 345, 0, 0, 0, 345, 345, 345, 345, 345, - 345, 345, 345, 0, 0, 0, 0, 0, 0, 0, - 740, 0, 0, 0, 345, 740, 740, 345, 0, 345, - 0, 345, 0, 0, 345, 0, 0, 0, 0, 0, - 345, 375, 0, 0, 0, 0, 0, 0, 740, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 740, 0, - 0, 740, 740, 0, 0, 0, 740, 0, 0, 740, - 0, 740, 0, 740, 740, 740, 740, 0, 0, 0, - 0, 740, 0, 0, 0, 740, 0, 0, 0, 740, - 0, 0, 0, 0, 0, 0, 0, 740, 0, 0, - 740, 0, 740, 740, 0, 0, 0, 0, 740, 0, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 0, 0, 0, 0, 0, 740, 0, 0, 0, - 0, 740, 740, 740, 740, 740, 740, 0, 740, 740, - 740, 0, 740, 740, 0, 0, 740, 740, 740, 740, - 338, 0, 0, 740, 740, 338, 338, 0, 740, 740, - 740, 740, 740, 740, 740, 740, 345, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 740, 338, 0, - 740, 0, 740, 0, 740, 0, 0, 740, 338, 0, - 0, 338, 338, 740, 0, 0, 338, 0, 0, 338, - 0, 338, 0, 338, 338, 338, 338, 0, 0, 0, - 0, 338, 0, 0, 0, 338, 0, 0, 0, 338, - 0, 0, 0, 0, 0, 0, 0, 338, 0, 0, - 338, 0, 338, 338, 0, 0, 0, 0, 338, 0, - 338, 338, 338, 338, 338, 338, 338, 338, 338, 338, - 338, 0, 0, 0, 0, 0, 338, 0, 0, 0, - 0, 338, 338, 338, 338, 338, 338, 0, 338, 338, - 338, 0, 338, 338, 0, 0, 338, 338, 338, 338, - 0, 0, 0, 338, 338, 0, 0, 0, 338, 338, - 338, 338, 338, 338, 338, 338, 0, 375, 0, 0, - 0, 0, 375, 375, 0, 0, 0, 338, 0, 0, - 338, 0, 338, 370, 338, 0, 0, 338, 0, 0, - 0, 0, 0, 338, 0, 375, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 375, 0, 0, 375, 375, - 0, 0, 0, 375, 0, 0, 375, 0, 375, 0, - 375, 375, 375, 375, 0, 0, 0, 0, 375, 0, - 0, 0, 375, 0, 0, 0, 375, 0, 0, 0, - 0, 0, 0, 0, 375, 0, 0, 375, 0, 375, - 375, 0, 0, 0, 915, 375, 0, 375, 375, 375, - 375, 375, 375, 375, 375, 375, 375, 375, 0, 0, - 0, 0, 0, 375, 0, 0, 0, 0, 375, 375, - 0, 375, 375, 375, 0, 375, 375, 375, 0, 375, - 375, 0, 345, 375, 375, 375, 375, 0, 345, 0, - 375, 375, 0, 0, 0, 375, 375, 375, 375, 375, - 375, 375, 375, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 375, 0, 0, 375, 0, 375, - 345, 0, 0, 0, 345, 0, 0, 915, 0, 0, - 375, 49, 915, 0, 915, 915, 915, 915, 915, 915, - 915, 915, 915, 915, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 345, 0, 0, 915, 0, 915, 0, - 915, 0, 915, 915, 915, 345, 0, 0, 0, 0, - 345, 0, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 0, 0, 0, 0, 0, 345, - 0, 0, 0, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 0, 345, 345, 0, 0, 345, 345, - 345, 345, 345, 0, 0, 345, 345, 915, 0, 0, - 345, 345, 345, 345, 345, 345, 345, 345, 0, 370, - 0, 0, 0, 0, 0, 370, 0, 0, 0, 345, - 0, 0, 345, 0, 345, 0, 345, 0, 0, 345, - 28, 0, 0, 0, 0, 345, 0, 0, 0, 0, - 0, 0, 345, 345, 345, 345, 0, 370, 0, 345, - 345, 370, 0, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 0, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 0, 0, 0, 0, 0, - 0, 345, 370, 35, 345, 0, 0, 370, 0, 370, - 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 370, 370, 0, 370, 370, 370, 0, 370, 370, 370, - 0, 370, 370, 0, 0, 370, 370, 370, 370, 0, - 34, 0, 370, 370, 0, 0, 0, 370, 370, 370, - 370, 370, 370, 370, 370, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 370, 0, 49, 370, - 0, 370, 49, 0, 49, 0, 49, 0, 49, 0, - 0, 49, 370, 49, 49, 0, 49, 0, 49, 0, - 49, 0, 49, 49, 49, 49, 0, 0, 49, 49, - 0, 0, 0, 28, 49, 49, 49, 49, 49, 0, - 0, 49, 49, 49, 0, 49, 0, 49, 49, 49, - 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, - 0, 0, 49, 49, 49, 0, 49, 0, 0, 0, - 0, 49, 49, 0, 49, 49, 33, 49, 49, 49, - 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 346, + 0, 36, 0, 0, 346, 0, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 0, 346, 346, + 0, 0, 346, 346, 346, 346, 346, 0, 0, 346, + 346, 0, 0, 0, 346, 346, 346, 346, 346, 346, + 346, 346, 0, 0, 0, 0, 0, 0, 0, 0, + 35, 0, 0, 346, 0, 0, 346, 0, 346, 0, + 346, 0, 49, 346, 0, 0, 49, 0, 49, 346, + 49, 0, 49, 0, 0, 49, 0, 49, 49, 0, + 49, 0, 49, 0, 49, 0, 49, 49, 49, 49, + 0, 0, 49, 49, 0, 0, 0, 34, 49, 49, + 49, 49, 49, 0, 0, 49, 49, 49, 0, 49, + 0, 49, 49, 49, 49, 49, 49, 49, 49, 0, + 49, 49, 49, 49, 0, 0, 49, 49, 49, 0, + 49, 0, 0, 0, 0, 49, 49, 0, 49, 49, + 0, 49, 49, 49, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 49, 0, 49, 49, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 28, 28, 49, 5, - 0, 28, 0, 0, 0, 28, 0, 28, 0, 0, - 28, 0, 28, 28, 0, 28, 0, 28, 0, 28, - 0, 28, 28, 28, 28, 0, 0, 28, 28, 0, - 0, 0, 0, 28, 0, 28, 28, 28, 0, 49, - 28, 28, 28, 0, 28, 0, 0, 28, 0, 28, - 28, 28, 28, 0, 0, 0, 28, 28, 28, 0, - 35, 28, 28, 28, 35, 0, 923, 0, 0, 0, - 28, 28, 0, 28, 28, 35, 28, 28, 28, 0, - 35, 0, 28, 0, 35, 0, 0, 35, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, - 35, 0, 28, 0, 35, 35, 0, 34, 28, 28, - 35, 34, 35, 35, 35, 35, 0, 28, 0, 0, - 35, 0, 34, 0, 35, 0, 35, 34, 0, 48, - 0, 34, 0, 0, 34, 0, 35, 0, 35, 35, - 0, 35, 0, 0, 0, 35, 34, 34, 0, 0, - 0, 34, 34, 0, 0, 0, 0, 34, 28, 34, - 34, 34, 34, 0, 0, 35, 0, 34, 0, 0, - 28, 34, 35, 34, 28, 0, 7, 0, 0, 0, - 0, 0, 0, 34, 0, 28, 34, 0, 34, 0, - 28, 0, 34, 0, 28, 0, 0, 28, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, - 28, 0, 34, 33, 28, 28, 0, 33, 34, 34, - 28, 0, 28, 28, 28, 28, 0, 0, 33, 0, - 28, 0, 0, 33, 28, 0, 28, 33, 0, 924, - 33, 0, 0, 0, 0, 0, 28, 0, 0, 28, - 0, 28, 33, 33, 0, 28, 5, 33, 33, 0, - 48, 0, 0, 33, 0, 33, 33, 33, 33, 0, - 0, 48, 0, 33, 0, 28, 48, 33, 0, 33, - 48, 28, 28, 48, 0, 0, 0, 0, 0, 33, - 0, 0, 33, 0, 33, 48, 48, 0, 33, 0, - 48, 48, 0, 0, 0, 0, 48, 0, 48, 48, - 48, 48, 0, 0, 0, 0, 48, 0, 33, 0, - 48, 0, 48, 923, 0, 33, 0, 48, 0, 0, - 0, 0, 48, 0, 0, 48, 0, 48, 48, 0, - 0, 48, 0, 48, 0, 0, 0, 48, 0, 0, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 48, 48, 48, 0, 0, 0, 48, 48, 0, - 0, 0, 0, 48, 0, 48, 48, 48, 48, 0, - 0, 0, 0, 48, 0, 0, 48, 48, 0, 48, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 48, - 0, 48, 48, 0, 48, 0, 48, 0, 48, 0, - 48, 0, 0, 48, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 48, 48, 0, 48, 0, - 48, 48, 0, 7, 0, 0, 48, 49, 48, 48, - 48, 48, 0, 0, 0, 0, 48, 0, 49, 0, - 48, 0, 48, 49, 0, 0, 0, 49, 0, 0, - 49, 0, 48, 0, 0, 48, 0, 48, 0, 0, - 0, 48, 49, 49, 0, 0, 0, 49, 49, 0, - 0, 0, 0, 49, 0, 49, 49, 49, 49, 0, - 0, 48, 0, 49, 0, 0, 924, 49, 0, 49, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 49, - 0, 48, 49, 0, 49, 0, 48, 0, 49, 0, - 48, 0, 0, 48, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 48, 48, 0, 49, 0, - 48, 48, 0, 0, 0, 0, 48, 0, 48, 48, - 48, 48, 0, 0, 0, 0, 48, 0, 0, 0, - 48, 0, 48, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 48, 0, 56, 48, 0, 48, 0, 0, - 0, 48, 57, 25, 58, 26, 0, 0, 27, 59, - 0, 60, 61, 28, 62, 63, 64, 29, 0, 0, - 0, 48, 0, 65, 0, 66, 31, 67, 68, 69, - 70, 0, 0, 33, 0, 0, 0, 71, 34, 0, - 72, 73, 35, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 74, 0, 37, 0, 38, 75, 0, 0, - 39, 0, 76, 77, 78, 79, 80, 81, 40, 41, - 82, 83, 42, 84, 0, 85, 0, 0, 86, 87, - 0, 345, 88, 89, 0, 0, 0, 345, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, - 0, 93, 0, 0, 0, 94, 0, 0, 0, 95, - 0, 0, 0, 0, 96, 97, 98, 99, 100, 0, - 0, 0, 101, 345, 102, 0, 0, 0, 0, 0, - 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 345, 0, 0, - 0, 0, 0, 345, 0, 105, 106, 107, 108, 0, - 0, 0, 0, 0, 345, 0, 0, 198, 0, 345, - 0, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 0, 0, 0, 0, 0, 0, 345, - 0, 0, 0, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 0, 345, 345, 0, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 0, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 0, - 514, 0, 0, 345, 0, 345, 514, 0, 345, 0, - 0, 0, 0, 0, 345, 0, 0, 0, 0, 345, - 0, 0, 345, 0, 345, 345, 0, 0, 0, 345, - 345, 0, 0, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 514, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 345, 345, 0, 0, 0, 0, 0, - 0, 345, 345, 0, 345, 0, 0, 0, 0, 0, - 345, 0, 0, 514, 0, 0, 0, 0, 514, 0, - 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, - 514, 0, 0, 0, 0, 0, 0, 0, 345, 0, - 0, 514, 514, 514, 514, 514, 514, 514, 514, 514, - 514, 0, 514, 514, 0, 514, 514, 514, 514, 514, - 514, 514, 514, 514, 514, 0, 514, 514, 514, 514, - 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, - 514, 514, 514, 514, 514, 514, 514, 514, 0, 510, - 0, 0, 0, 0, 514, 510, 0, 345, 0, 0, - 0, 0, 0, 514, 0, 0, 0, 0, 0, 345, - 0, 345, 0, 345, 0, 0, 345, 0, 345, 345, - 0, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 510, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 0, 0, 0, 0, 345, 0, - 345, 402, 0, 345, 0, 0, 0, 0, 0, 345, - 0, 0, 510, 0, 0, 0, 0, 510, 0, 510, - 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, - 0, 0, 0, 0, 0, 0, 0, 402, 0, 0, - 510, 510, 0, 510, 510, 510, 510, 510, 510, 510, - 0, 510, 510, 0, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 0, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 510, 510, 510, 0, 518, 0, - 0, 0, 0, 510, 518, 0, 510, 0, 0, 0, - 0, 0, 510, 0, 0, 0, 0, 0, 338, 0, - 402, 402, 402, 402, 0, 402, 0, 402, 402, 0, - 402, 402, 402, 402, 402, 0, 402, 402, 402, 402, - 518, 402, 402, 402, 402, 402, 402, 402, 402, 402, - 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, - 402, 402, 402, 0, 0, 0, 0, 338, 0, 402, - 345, 0, 402, 0, 0, 0, 0, 0, 402, 0, - 0, 518, 0, 0, 0, 0, 518, 0, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 0, - 0, 0, 0, 0, 0, 0, 345, 0, 0, 0, - 518, 0, 518, 518, 518, 518, 518, 518, 518, 0, - 518, 518, 0, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 0, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 0, 345, 0, 0, - 0, 0, 518, 345, 0, 518, 0, 0, 0, 0, - 0, 518, 0, 0, 0, 0, 0, 0, 345, 345, - 345, 345, 345, 0, 0, 0, 345, 345, 0, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 0, 0, 0, 0, 0, 0, 345, 0, - 0, 345, 0, 0, 0, 0, 0, 345, 0, 0, - 345, 0, 0, 0, 0, 345, 0, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 345, - 0, 345, 345, 345, 345, 345, 345, 345, 0, 345, - 345, 0, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 0, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 0, 445, 730, 0, 0, - 0, 345, 445, 0, 345, 0, 25, 0, 26, 0, - 345, 27, 0, 0, 0, 0, 28, 0, 0, 0, - 29, 0, 0, 0, 0, 0, 0, 0, 0, 31, - 0, 0, 0, 0, 0, 0, 33, 0, 445, 0, - 0, 34, 0, 0, 0, 35, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 37, 0, 38, - 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, - 0, 40, 41, 0, 0, 42, 0, 0, 731, 445, - 0, 0, 0, 0, 445, 0, 445, 445, 445, 445, - 445, 445, 445, 445, 445, 445, 445, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 445, 0, - 445, 445, 445, 445, 445, 445, 445, 0, 445, 445, - 0, 445, 445, 445, 445, 445, 445, 445, 445, 445, - 445, 0, 445, 445, 445, 445, 445, 445, 445, 445, - 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, - 445, 445, 445, 445, 0, 405, 865, 0, 0, 732, - 445, 405, 0, 445, 0, 25, 0, 26, 0, 445, + 28, 0, 0, 0, 0, 0, 0, 49, 0, 49, + 49, 0, 0, 0, 28, 28, 0, 0, 0, 28, + 0, 0, 49, 28, 0, 28, 0, 0, 28, 0, + 28, 28, 0, 28, 0, 28, 0, 28, 0, 28, + 28, 28, 28, 33, 0, 28, 28, 0, 0, 0, + 0, 28, 0, 28, 28, 28, 0, 0, 28, 28, + 28, 0, 28, 49, 0, 28, 0, 28, 28, 28, + 28, 0, 0, 0, 28, 28, 28, 0, 36, 28, + 28, 28, 36, 0, 0, 0, 5, 0, 28, 28, + 0, 28, 28, 36, 28, 28, 28, 0, 36, 0, + 28, 0, 36, 0, 0, 36, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 36, 36, 0, + 28, 0, 36, 36, 0, 0, 28, 28, 36, 931, + 36, 36, 36, 36, 0, 28, 0, 0, 36, 0, + 0, 0, 36, 0, 36, 0, 0, 35, 0, 0, + 0, 35, 0, 0, 36, 0, 36, 36, 0, 36, + 0, 0, 35, 36, 0, 0, 0, 35, 0, 0, + 0, 35, 48, 0, 35, 0, 28, 0, 0, 0, + 0, 0, 0, 36, 0, 0, 35, 35, 0, 36, + 36, 35, 35, 0, 34, 0, 0, 35, 34, 35, + 35, 35, 35, 0, 0, 0, 0, 35, 0, 34, + 0, 35, 0, 35, 34, 7, 0, 0, 34, 0, + 0, 34, 0, 35, 0, 35, 35, 0, 35, 0, + 0, 0, 35, 34, 34, 0, 0, 0, 34, 34, + 0, 0, 0, 0, 34, 0, 34, 34, 34, 34, + 0, 0, 35, 0, 34, 0, 0, 28, 34, 35, + 34, 28, 0, 0, 0, 0, 0, 0, 0, 0, + 34, 0, 28, 34, 0, 34, 0, 28, 932, 34, + 0, 28, 0, 0, 28, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 28, 28, 0, 34, + 33, 28, 28, 0, 33, 34, 34, 28, 0, 28, + 28, 28, 28, 0, 0, 33, 0, 28, 0, 0, + 33, 28, 0, 28, 33, 0, 0, 33, 0, 0, + 0, 0, 0, 28, 0, 0, 28, 0, 28, 33, + 33, 0, 28, 5, 33, 33, 0, 48, 0, 0, + 33, 0, 33, 33, 33, 33, 0, 0, 48, 0, + 33, 0, 28, 48, 33, 0, 33, 48, 28, 28, + 48, 0, 0, 0, 0, 0, 33, 0, 0, 33, + 0, 33, 48, 48, 0, 33, 931, 48, 48, 0, + 48, 0, 0, 48, 0, 48, 48, 48, 48, 0, + 0, 48, 0, 48, 0, 33, 48, 48, 0, 48, + 48, 0, 33, 48, 0, 0, 0, 0, 0, 48, + 0, 0, 48, 0, 48, 48, 48, 0, 48, 48, + 48, 48, 0, 48, 0, 0, 48, 0, 48, 48, + 48, 48, 0, 0, 48, 0, 48, 0, 48, 48, + 48, 0, 48, 48, 0, 0, 48, 0, 0, 0, + 0, 0, 48, 0, 0, 48, 0, 48, 48, 48, + 0, 48, 7, 48, 48, 0, 49, 0, 0, 48, + 0, 48, 48, 48, 48, 0, 0, 49, 0, 48, + 0, 48, 49, 48, 0, 48, 49, 0, 0, 49, + 0, 0, 0, 0, 0, 48, 0, 0, 48, 0, + 48, 49, 49, 0, 48, 0, 49, 49, 0, 0, + 0, 0, 49, 0, 49, 49, 49, 49, 0, 0, + 0, 0, 49, 0, 48, 932, 49, 0, 49, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 48, 49, 0, 49, 0, 48, 0, 49, 0, 48, + 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 48, 48, 0, 49, 0, 48, + 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, + 48, 0, 0, 0, 0, 48, 0, 0, 0, 48, + 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 48, 0, 56, 48, 0, 48, 0, 0, 0, + 48, 57, 25, 58, 26, 0, 0, 27, 59, 0, + 60, 61, 28, 62, 63, 64, 29, 0, 0, 0, + 48, 0, 65, 0, 66, 31, 67, 68, 69, 70, + 0, 0, 33, 0, 0, 0, 71, 34, 0, 72, + 73, 35, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 74, 0, 37, 0, 38, 75, 0, 0, 39, + 0, 76, 77, 78, 79, 80, 81, 40, 41, 82, + 83, 42, 84, 0, 85, 0, 0, 86, 87, 0, + 346, 88, 89, 0, 0, 0, 346, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, + 94, 0, 0, 0, 95, 0, 0, 0, 96, 0, + 0, 0, 0, 97, 98, 99, 100, 101, 0, 0, + 0, 102, 346, 103, 0, 0, 0, 0, 0, 104, + 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 346, 0, 0, 0, + 0, 0, 346, 0, 106, 107, 108, 109, 0, 0, + 0, 0, 0, 346, 0, 0, 199, 0, 346, 0, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 0, 0, 0, 0, 0, 0, 346, 0, + 0, 0, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 0, 346, 346, 0, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 0, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 0, 515, + 0, 0, 346, 0, 346, 515, 0, 346, 0, 0, + 0, 0, 0, 346, 0, 0, 0, 0, 346, 0, + 0, 346, 0, 346, 346, 0, 0, 0, 346, 346, + 0, 0, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 515, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 346, 346, 0, 0, 0, 0, 0, 0, + 346, 346, 0, 346, 0, 0, 0, 0, 0, 346, + 0, 0, 515, 0, 0, 0, 0, 515, 0, 515, + 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, + 515, 515, 515, 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, 511, 0, + 0, 0, 0, 515, 511, 0, 346, 0, 0, 0, + 0, 0, 515, 0, 0, 0, 0, 0, 346, 0, + 346, 0, 346, 0, 0, 346, 0, 346, 346, 0, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 511, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 0, 0, 0, 0, 346, 0, 346, + 403, 0, 346, 0, 0, 0, 0, 0, 346, 0, + 0, 511, 0, 0, 0, 0, 511, 0, 511, 511, + 511, 511, 511, 511, 511, 511, 511, 511, 511, 0, + 0, 0, 0, 0, 0, 0, 403, 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, 519, 0, 0, + 0, 0, 511, 519, 0, 511, 0, 0, 0, 0, + 0, 511, 0, 0, 0, 0, 0, 339, 0, 403, + 403, 403, 403, 0, 403, 0, 403, 403, 0, 403, + 403, 403, 403, 403, 0, 403, 403, 403, 403, 519, + 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, + 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, + 403, 403, 0, 0, 0, 0, 339, 0, 403, 346, + 0, 403, 0, 0, 0, 0, 0, 403, 0, 0, + 519, 0, 0, 0, 0, 519, 0, 519, 519, 519, + 519, 519, 519, 519, 519, 519, 519, 519, 0, 0, + 0, 0, 0, 0, 0, 346, 0, 0, 0, 519, + 0, 519, 519, 519, 519, 519, 519, 519, 0, 519, + 519, 0, 519, 519, 519, 519, 519, 519, 519, 519, + 519, 519, 0, 519, 519, 519, 519, 519, 519, 519, + 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + 519, 519, 519, 519, 519, 0, 346, 0, 0, 0, + 0, 519, 346, 0, 519, 0, 0, 0, 0, 0, + 519, 0, 0, 0, 0, 0, 0, 346, 346, 346, + 346, 346, 0, 0, 0, 346, 346, 0, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 0, 0, 0, 0, 0, 0, 346, 0, 0, + 346, 0, 0, 0, 0, 0, 346, 0, 0, 346, + 0, 0, 0, 0, 346, 0, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 346, 0, + 346, 346, 346, 346, 346, 346, 346, 0, 346, 346, + 0, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 0, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 0, 446, 738, 0, 0, 0, + 346, 446, 0, 346, 0, 25, 0, 26, 0, 346, 27, 0, 0, 0, 0, 28, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, - 0, 0, 0, 0, 0, 33, 0, 405, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 446, 0, 0, 34, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 38, 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, - 40, 41, 0, 0, 42, 0, 0, 317, 405, 0, - 0, 0, 0, 405, 0, 405, 405, 405, 405, 405, - 405, 405, 405, 405, 405, 405, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 405, 0, 405, - 405, 405, 405, 405, 405, 405, 0, 405, 0, 0, - 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, - 0, 405, 405, 405, 405, 405, 405, 405, 405, 405, - 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, - 405, 405, 405, 0, 547, 0, 487, 0, 349, 405, - 547, 0, 405, 0, 57, 25, 0, 26, 405, 0, - 27, 255, 0, 0, 0, 28, 62, 63, 0, 29, - 0, 0, 0, 0, 0, 65, 0, 0, 31, 0, - 0, 0, 0, 0, 0, 33, 547, 0, 0, 0, - 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 37, 0, 38, 75, - 0, 0, 39, 0, 0, 77, 0, 79, 0, 81, - 40, 41, 256, 0, 42, 0, 0, 547, 0, 0, - 0, 0, 547, 0, 547, 547, 547, 547, 547, 547, - 547, 547, 547, 547, 547, 0, 0, 0, 0, 90, - 91, 92, 0, 0, 0, 0, 547, 0, 547, 0, - 547, 95, 547, 547, 547, 0, 547, 547, 0, 547, - 547, 547, 547, 547, 547, 547, 547, 547, 547, 367, - 0, 0, 547, 547, 547, 547, 547, 547, 547, 547, - 547, 547, 547, 547, 547, 547, 547, 547, 547, 547, - 561, 547, 367, 0, 0, 0, 561, 105, 488, 0, - 0, 0, 0, 0, 0, 367, 0, 547, 0, 0, - 367, 0, 0, 244, 0, 367, 0, 367, 367, 367, - 367, 0, 0, 0, 0, 367, 0, 0, 0, 367, - 0, 0, 561, 367, 0, 0, 0, 0, 0, 0, - 0, 367, 0, 0, 367, 0, 367, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 565, 0, - 0, 0, 0, 0, 565, 0, 0, 0, 0, 0, - 367, 0, 0, 561, 0, 0, 0, 0, 561, 0, - 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, - 561, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 565, 0, 561, 0, 561, 0, 561, 0, 561, 561, - 561, 0, 561, 561, 0, 0, 561, 561, 561, 561, - 561, 561, 561, 561, 561, 0, 367, 0, 561, 561, - 561, 561, 561, 561, 561, 561, 0, 0, 0, 0, - 0, 565, 0, 0, 0, 0, 565, 561, 565, 565, - 565, 565, 565, 565, 565, 565, 565, 565, 565, 0, - 0, 0, 568, 561, 0, 0, 0, 0, 568, 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, 568, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 565, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 566, 565, 0, 0, 0, 0, 566, 0, 0, 0, - 0, 0, 0, 0, 0, 568, 0, 0, 0, 0, - 568, 0, 568, 568, 568, 568, 568, 568, 568, 568, - 568, 568, 568, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 566, 0, 568, 0, 568, 0, 568, 0, - 568, 568, 568, 0, 568, 568, 0, 0, 568, 568, - 568, 568, 0, 0, 0, 568, 568, 203, 0, 0, + 40, 41, 0, 0, 42, 0, 0, 739, 446, 0, + 0, 0, 0, 446, 0, 446, 446, 446, 446, 446, + 446, 446, 446, 446, 446, 446, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 446, 0, 446, + 446, 446, 446, 446, 446, 446, 0, 446, 446, 0, + 446, 446, 446, 446, 446, 446, 446, 446, 446, 446, + 0, 446, 446, 446, 446, 446, 446, 446, 446, 446, + 446, 446, 446, 446, 446, 446, 446, 446, 446, 446, + 446, 446, 446, 0, 406, 876, 0, 0, 740, 446, + 406, 0, 446, 0, 25, 0, 26, 0, 446, 27, + 0, 0, 0, 0, 28, 0, 0, 0, 29, 0, + 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, + 0, 0, 0, 0, 33, 0, 406, 0, 0, 34, + 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 37, 0, 38, 0, 0, + 0, 39, 0, 0, 0, 0, 0, 0, 0, 40, + 41, 0, 0, 42, 0, 0, 319, 406, 0, 0, + 0, 0, 406, 0, 406, 406, 406, 406, 406, 406, + 406, 406, 406, 406, 406, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 406, 0, 406, 406, + 406, 406, 406, 406, 406, 0, 406, 0, 0, 406, + 406, 406, 406, 406, 406, 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, 550, 0, 492, 0, 354, 406, 550, + 0, 406, 0, 57, 25, 0, 26, 406, 0, 27, + 256, 0, 0, 0, 28, 62, 63, 0, 29, 0, + 0, 0, 0, 0, 65, 0, 0, 31, 0, 0, + 0, 0, 0, 0, 33, 550, 0, 0, 0, 34, + 0, 72, 73, 35, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 37, 0, 38, 75, 0, + 0, 39, 0, 0, 77, 0, 79, 0, 81, 40, + 41, 257, 0, 42, 0, 0, 550, 0, 0, 0, + 0, 550, 0, 550, 550, 550, 550, 550, 550, 550, + 550, 550, 550, 550, 0, 0, 0, 0, 90, 91, + 92, 258, 0, 0, 0, 550, 0, 550, 0, 550, + 96, 550, 550, 550, 0, 550, 550, 0, 550, 550, + 550, 550, 550, 550, 550, 550, 550, 550, 368, 0, + 0, 550, 550, 550, 550, 550, 550, 550, 550, 550, + 550, 550, 550, 550, 550, 550, 550, 550, 550, 564, + 550, 368, 0, 0, 0, 564, 106, 493, 0, 0, + 0, 0, 0, 0, 368, 0, 550, 0, 0, 368, + 0, 0, 245, 0, 368, 0, 368, 368, 368, 368, + 0, 0, 0, 0, 368, 0, 0, 0, 368, 0, + 0, 564, 368, 0, 0, 0, 0, 0, 0, 0, + 368, 0, 0, 368, 0, 368, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 568, 0, 0, + 0, 0, 0, 568, 0, 0, 0, 0, 0, 368, + 0, 0, 564, 0, 0, 0, 0, 564, 0, 564, + 564, 564, 564, 564, 564, 564, 564, 564, 564, 564, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 568, + 0, 564, 0, 564, 0, 564, 0, 564, 564, 564, + 0, 564, 564, 0, 0, 564, 564, 564, 564, 564, + 564, 564, 564, 564, 0, 368, 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, 0, 0, 566, 0, 0, 0, 0, 566, 568, - 566, 566, 566, 566, 566, 566, 566, 566, 566, 566, - 566, 0, 0, 0, 567, 568, 0, 0, 0, 204, - 567, 0, 566, 0, 566, 0, 566, 0, 566, 566, - 566, 0, 566, 566, 0, 0, 566, 566, 566, 566, - 0, 0, 0, 566, 566, 0, 0, 0, 566, 566, - 566, 566, 566, 566, 566, 566, 567, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 566, 0, 205, - 206, 207, 208, 0, 209, 210, 211, 212, 213, 214, - 215, 216, 571, 566, 217, 218, 219, 220, 221, 222, - 223, 224, 0, 0, 0, 0, 0, 567, 0, 0, - 0, 0, 567, 0, 567, 567, 567, 567, 567, 567, - 567, 567, 567, 567, 567, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 567, 0, 567, 0, - 567, 0, 567, 567, 567, 0, 567, 567, 0, 0, - 567, 567, 567, 567, 0, 0, 0, 567, 567, 0, - 572, 0, 567, 567, 567, 567, 567, 567, 567, 567, - 0, 0, 0, 0, 0, 571, 0, 0, 0, 0, - 571, 567, 571, 571, 571, 571, 571, 571, 571, 571, - 571, 571, 571, 0, 0, 0, 0, 567, 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, 0, 573, 0, - 571, 571, 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, 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, 0, 574, 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, 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, 0, 575, 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, + 0, 571, 564, 0, 0, 0, 0, 571, 0, 568, + 0, 568, 0, 568, 0, 568, 568, 568, 0, 568, + 568, 0, 0, 568, 568, 568, 568, 0, 0, 0, + 568, 568, 0, 0, 0, 568, 568, 568, 568, 568, + 568, 568, 568, 571, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 568, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 569, + 568, 0, 0, 0, 0, 569, 0, 0, 0, 0, + 0, 0, 0, 0, 571, 0, 0, 0, 0, 571, + 0, 571, 571, 571, 571, 571, 571, 571, 571, 571, + 571, 571, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 569, 0, 571, 0, 571, 0, 571, 0, 571, + 571, 571, 0, 571, 571, 0, 0, 571, 571, 571, + 571, 0, 0, 0, 571, 571, 0, 0, 0, 571, + 571, 571, 571, 571, 571, 571, 571, 0, 0, 0, + 0, 0, 569, 0, 0, 0, 0, 569, 571, 569, + 569, 569, 569, 569, 569, 569, 569, 569, 569, 569, + 0, 0, 0, 570, 571, 0, 0, 0, 0, 570, + 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, 570, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 569, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 574, 569, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 570, 0, 0, 0, + 0, 570, 0, 570, 570, 570, 570, 570, 570, 570, + 570, 570, 570, 570, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 570, 0, 570, 0, 570, + 0, 570, 570, 570, 0, 570, 570, 0, 0, 570, + 570, 570, 570, 0, 0, 0, 570, 570, 0, 575, + 0, 570, 570, 570, 570, 570, 570, 570, 570, 0, + 0, 0, 0, 0, 574, 0, 0, 0, 0, 574, + 570, 574, 574, 574, 574, 574, 574, 574, 574, 574, + 574, 574, 0, 0, 0, 0, 570, 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, 0, 576, 0, 574, 574, 574, 574, 574, 574, 574, 574, 0, 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, 0, 576, 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, 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, 0, - 577, 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, 0, 575, 0, 0, - 0, 0, 0, 0, 576, 0, 576, 0, 576, 0, - 576, 576, 576, 0, 0, 0, 0, 0, 576, 576, - 576, 576, 0, 0, 0, 576, 576, 0, 578, 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, 0, 576, 0, 0, 0, 0, - 0, 0, 577, 0, 577, 0, 577, 0, 577, 577, - 577, 0, 0, 0, 0, 0, 577, 577, 577, 577, - 0, 0, 0, 577, 577, 0, 579, 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, 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, 0, 577, 0, 575, 575, 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, 0, 575, 0, 0, 0, 0, 0, 0, 576, + 0, 576, 0, 576, 0, 576, 576, 576, 0, 0, + 0, 0, 0, 576, 576, 576, 576, 0, 0, 0, + 576, 576, 0, 578, 0, 576, 576, 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, 0, - 0, 578, 0, 0, 0, 0, 578, 577, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 0, - 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, 580, 0, 0, 0, 578, 578, - 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, - 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, 0, 581, 0, 0, 0, 0, 0, 579, 579, - 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, 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, 0, - 582, 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, 0, 580, 0, 0, - 0, 0, 0, 0, 581, 0, 581, 0, 581, 0, - 581, 581, 581, 0, 0, 0, 0, 0, 0, 0, - 581, 581, 0, 0, 0, 581, 581, 0, 583, 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, 0, 581, 0, 0, 0, 0, - 0, 0, 582, 0, 582, 0, 582, 0, 582, 582, - 582, 0, 0, 0, 0, 0, 0, 0, 582, 582, - 0, 0, 0, 582, 582, 0, 584, 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, 0, 582, 0, 0, 0, 0, 0, 0, - 583, 0, 583, 0, 583, 0, 583, 583, 583, 0, - 0, 0, 0, 0, 0, 0, 583, 583, 0, 0, - 0, 583, 583, 0, 585, 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, - 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, 584, - 584, 0, 586, 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, 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, 585, 0, 0, 0, 585, 585, 0, - 587, 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, 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, 0, 0, 586, 0, 590, 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, 0, 586, 0, 0, 0, 0, - 0, 0, 587, 0, 587, 0, 587, 0, 587, 587, - 587, 0, 0, 0, 591, 0, 0, 0, 0, 587, - 0, 0, 0, 0, 587, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 587, 587, 0, 0, 0, 0, - 0, 590, 0, 0, 0, 0, 590, 587, 590, 590, - 590, 590, 590, 590, 590, 590, 590, 590, 590, 0, - 0, 0, 0, 587, 0, 0, 0, 0, 0, 0, - 590, 0, 590, 0, 590, 0, 590, 590, 590, 0, + 576, 0, 0, 0, 0, 0, 0, 577, 0, 577, + 0, 577, 0, 577, 577, 577, 0, 0, 0, 0, + 0, 577, 577, 577, 577, 0, 0, 0, 577, 577, + 0, 579, 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, 0, 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, 580, + 0, 0, 0, 578, 578, 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, 0, 578, 0, 0, 0, + 0, 0, 0, 579, 0, 579, 0, 579, 0, 579, + 579, 579, 0, 0, 0, 0, 0, 579, 579, 579, + 579, 0, 0, 0, 579, 579, 0, 581, 0, 0, + 0, 579, 579, 579, 579, 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, 0, 579, 0, 0, 0, 0, 0, + 0, 580, 0, 580, 0, 580, 0, 580, 580, 580, + 0, 0, 0, 0, 0, 580, 580, 580, 580, 0, + 0, 0, 580, 580, 0, 582, 0, 0, 0, 580, + 580, 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, 0, 580, 0, 0, 0, 0, 0, 0, 581, + 0, 581, 0, 581, 0, 581, 581, 581, 0, 0, + 0, 0, 0, 581, 581, 581, 581, 0, 0, 0, + 581, 581, 0, 583, 0, 0, 0, 581, 581, 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, 0, + 581, 0, 0, 0, 0, 0, 0, 582, 0, 582, + 0, 582, 0, 582, 582, 582, 0, 0, 0, 0, + 0, 0, 0, 582, 582, 0, 0, 0, 582, 582, + 0, 584, 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, 0, 582, 0, + 0, 0, 0, 0, 0, 583, 0, 583, 0, 583, + 0, 583, 583, 583, 0, 0, 0, 0, 0, 0, + 0, 583, 583, 0, 0, 0, 583, 583, 0, 586, + 0, 0, 0, 0, 0, 583, 583, 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, 0, 583, 0, 0, 0, + 0, 0, 0, 584, 0, 584, 0, 584, 0, 584, + 584, 584, 0, 0, 0, 0, 0, 0, 0, 584, + 584, 0, 0, 0, 584, 584, 0, 587, 0, 0, + 0, 0, 0, 584, 584, 584, 584, 0, 0, 0, + 0, 0, 586, 0, 0, 0, 0, 586, 584, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 0, 0, 0, 0, 584, 0, 0, 0, 0, 0, + 0, 586, 0, 586, 0, 586, 0, 586, 586, 586, + 0, 0, 0, 0, 0, 0, 0, 586, 586, 0, + 0, 0, 586, 586, 0, 588, 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, 0, 586, 0, 0, 0, 0, 0, 0, 587, + 0, 587, 0, 587, 0, 587, 587, 587, 0, 0, + 0, 0, 0, 0, 0, 0, 587, 0, 0, 0, + 587, 587, 0, 589, 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, 0, + 587, 0, 0, 0, 0, 0, 0, 588, 0, 588, + 0, 588, 0, 588, 588, 588, 0, 0, 0, 0, + 0, 0, 0, 0, 588, 0, 0, 0, 588, 588, + 0, 590, 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, 0, 588, 0, + 0, 0, 0, 0, 0, 589, 0, 589, 0, 589, + 0, 589, 589, 589, 0, 0, 0, 0, 0, 0, + 0, 0, 589, 0, 0, 0, 0, 589, 0, 591, + 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, 0, 589, 0, 0, 0, + 0, 0, 0, 590, 0, 590, 0, 590, 0, 590, + 590, 590, 0, 0, 0, 0, 0, 0, 0, 0, + 590, 0, 0, 0, 0, 590, 0, 592, 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, 0, 590, 0, 0, 0, 0, 0, + 0, 591, 0, 591, 0, 591, 0, 591, 591, 591, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 590, 0, 0, 0, 0, 591, 0, 0, - 0, 0, 591, 590, 591, 591, 591, 591, 591, 591, - 591, 591, 591, 591, 591, 590, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 591, 0, 591, 0, - 591, 590, 591, 591, 591, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 56, 0, 591, 0, - 0, 0, 0, 0, 57, 25, 58, 26, 0, 591, - 27, 59, 0, 60, 61, 28, 62, 63, 64, 29, - 0, 591, 0, 0, 0, 65, 0, 66, 31, 67, - 68, 69, 70, 0, 0, 33, 0, 591, 0, 71, - 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 74, 0, 37, 0, 38, 75, - 0, 0, 39, 0, 76, 77, 78, 79, 80, 81, - 40, 41, 82, 83, 42, 84, 0, 85, 0, 0, - 86, 87, 0, 0, 88, 89, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, - 91, 92, 0, 93, 0, 0, 0, 94, 0, 0, - 0, 95, 0, 0, 0, 0, 96, 97, 98, 99, - 100, 0, 0, 0, 101, 0, 102, 0, 0, 0, - 0, 0, 103, 104, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 266, 0, 0, 0, 105, 106, 107, - 108, 57, 25, 58, 26, 0, 0, 27, 59, 0, - 60, 61, 28, 62, 63, 64, 29, 0, 0, 0, + 0, 0, 0, 591, 0, 593, 0, 0, 0, 0, + 0, 0, 0, 591, 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, + 0, 0, 591, 0, 0, 0, 0, 0, 0, 592, + 0, 592, 0, 592, 0, 592, 592, 592, 0, 0, + 0, 594, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 592, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 592, 592, 0, 0, 0, 0, 0, 593, 0, + 0, 0, 0, 593, 592, 593, 593, 593, 593, 593, + 593, 593, 593, 593, 593, 593, 0, 0, 0, 0, + 592, 0, 0, 0, 0, 0, 0, 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, 594, 0, 0, 0, 0, 594, + 593, 594, 594, 594, 594, 594, 594, 594, 594, 594, + 594, 594, 593, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 594, 0, 594, 0, 594, 593, 594, + 594, 594, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 56, 0, 594, 0, 0, 0, 0, + 0, 57, 25, 58, 26, 0, 594, 27, 59, 0, + 60, 61, 28, 62, 63, 64, 29, 0, 594, 0, 0, 0, 65, 0, 66, 31, 67, 68, 69, 70, - 0, 0, 33, 0, 0, 0, 71, 34, 0, 72, + 0, 0, 33, 0, 594, 0, 71, 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 0, 37, 0, 38, 75, 0, 0, 39, 0, 76, 77, 78, 79, 80, 81, 40, 41, 82, 83, 42, 84, 0, 85, 0, 0, 86, 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 90, 91, 92, 0, - 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, - 0, 0, 0, 96, 97, 98, 99, 100, 0, 0, - 0, 101, 0, 102, 0, 0, 0, 0, 0, 103, - 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, + 94, 0, 0, 0, 95, 0, 0, 0, 96, 0, + 0, 0, 0, 97, 98, 99, 100, 101, 0, 0, + 0, 102, 0, 103, 0, 0, 0, 0, 0, 104, + 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 539, 0, 0, 0, 105, 106, 107, 108, 57, 25, + 268, 0, 0, 0, 106, 107, 108, 109, 57, 25, 58, 26, 0, 0, 27, 59, 0, 60, 61, 28, 62, 63, 64, 29, 0, 0, 0, 0, 0, 65, 0, 66, 31, 67, 68, 69, 70, 0, 0, 33, @@ -9974,177 +10091,207 @@ void case_948() 78, 79, 80, 81, 40, 41, 82, 83, 42, 84, 0, 85, 0, 0, 86, 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 90, 91, 92, 0, 93, 0, 0, - 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, - 96, 97, 98, 99, 100, 0, 0, 0, 101, 0, - 102, 0, 0, 0, 0, 0, 103, 104, 0, 0, + 0, 0, 0, 90, 91, 92, 93, 94, 0, 0, + 0, 95, 0, 0, 0, 96, 0, 0, 0, 0, + 97, 98, 99, 100, 101, 0, 0, 0, 102, 0, + 103, 0, 0, 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 920, 0, 0, - 0, 105, 106, 107, 108, 920, 920, 920, 920, 0, - 0, 920, 920, 0, 920, 920, 920, 920, 920, 920, - 920, 0, 0, 0, 0, 0, 920, 0, 920, 920, - 920, 920, 920, 920, 0, 0, 920, 0, 0, 0, - 920, 920, 0, 920, 920, 920, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 920, 0, 920, 0, 920, - 920, 0, 0, 920, 0, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 0, 920, 0, - 0, 920, 920, 0, 0, 920, 920, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 547, 0, 0, + 0, 106, 107, 108, 109, 57, 25, 58, 26, 0, + 0, 27, 59, 0, 60, 61, 28, 62, 63, 64, + 29, 0, 0, 0, 0, 0, 65, 0, 66, 31, + 67, 68, 69, 70, 0, 0, 33, 0, 0, 0, + 71, 34, 0, 72, 73, 35, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 74, 0, 37, 0, 38, + 75, 0, 0, 39, 0, 76, 77, 78, 79, 80, + 81, 40, 41, 82, 83, 42, 84, 0, 85, 0, + 0, 86, 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 920, 920, 920, 0, 920, 0, 0, 0, 920, 0, - 0, 0, 920, 0, 0, 0, 0, 920, 920, 920, - 920, 920, 0, 0, 0, 920, 0, 920, 0, 0, - 0, 0, 0, 920, 920, 0, 0, 0, 0, 0, + 90, 91, 92, 93, 94, 0, 0, 0, 95, 0, + 0, 0, 96, 0, 0, 0, 0, 97, 98, 99, + 100, 101, 0, 0, 0, 102, 0, 103, 0, 0, + 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 784, 0, 0, 0, 920, 920, - 920, 920, 784, 784, 784, 784, 0, 0, 784, 784, - 0, 784, 784, 784, 784, 784, 784, 784, 0, 0, - 0, 0, 0, 784, 0, 784, 784, 784, 784, 784, - 784, 0, 0, 784, 0, 0, 0, 784, 784, 0, - 784, 784, 784, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 784, 0, 784, 0, 784, 784, 0, 0, - 784, 0, 784, 784, 784, 784, 784, 784, 784, 784, - 784, 784, 784, 784, 0, 784, 0, 0, 784, 784, - 0, 0, 784, 784, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 784, 784, 784, - 0, 784, 0, 0, 0, 784, 0, 0, 0, 784, - 0, 0, 0, 0, 784, 784, 784, 784, 784, 0, - 0, 0, 784, 0, 784, 0, 0, 0, 0, 0, - 784, 784, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 928, 0, 0, 0, 106, 107, + 108, 109, 928, 928, 928, 928, 0, 0, 928, 928, + 0, 928, 928, 928, 928, 928, 928, 928, 0, 0, + 0, 0, 0, 928, 0, 928, 928, 928, 928, 928, + 928, 0, 0, 928, 0, 0, 0, 928, 928, 0, + 928, 928, 928, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 928, 0, 928, 0, 928, 928, 0, 0, + 928, 0, 928, 928, 928, 928, 928, 928, 928, 928, + 928, 928, 928, 928, 0, 928, 0, 0, 928, 928, + 0, 0, 928, 928, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 928, 928, 928, + 928, 928, 0, 0, 0, 928, 0, 0, 0, 928, + 0, 0, 0, 0, 928, 928, 928, 928, 928, 0, + 0, 0, 928, 0, 928, 0, 0, 0, 0, 0, + 928, 928, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 717, 0, 0, 0, 784, 784, 784, 784, 57, - 25, 0, 26, 0, 0, 27, 255, 0, 1003, 0, - 28, 62, 63, 0, 29, 0, 0, 25, 0, 26, - 65, 0, 27, 31, 0, 0, 0, 28, 0, 0, - 33, 29, 0, 0, 0, 34, 0, 72, 73, 35, - 31, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 37, 34, 38, 75, 0, 35, 39, 0, 0, - 77, 0, 79, 0, 81, 40, 41, 256, 37, 42, - 38, 0, 0, 0, 39, 0, 87, 0, 0, 88, - 89, 0, 40, 41, 0, 0, 42, 0, 0, 317, - 0, 0, 0, 0, 90, 91, 92, 0, 93, 0, - 0, 0, 504, 718, 0, 0, 95, 0, 0, 0, - 0, 0, 97, 98, 99, 100, 0, 0, 0, 101, - 0, 102, 0, 0, 0, 0, 0, 103, 104, 0, + 0, 792, 0, 0, 0, 928, 928, 928, 928, 792, + 792, 792, 792, 0, 0, 792, 792, 0, 792, 792, + 792, 792, 792, 792, 792, 0, 0, 0, 0, 0, + 792, 0, 792, 792, 792, 792, 792, 792, 0, 0, + 792, 0, 0, 0, 792, 792, 0, 792, 792, 792, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 792, + 0, 792, 0, 792, 792, 0, 0, 792, 0, 792, + 792, 792, 792, 792, 792, 792, 792, 792, 792, 792, + 792, 0, 792, 0, 0, 792, 792, 0, 0, 792, + 792, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 792, 792, 792, 792, 792, 0, + 0, 0, 792, 0, 0, 0, 792, 0, 0, 0, + 0, 792, 792, 792, 792, 792, 0, 0, 0, 792, + 0, 792, 0, 0, 0, 0, 0, 792, 792, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 717, 0, - 0, 0, 105, 299, 107, 108, 57, 25, 0, 26, - 0, 0, 27, 255, 0, 1122, 0, 28, 62, 63, - 349, 29, 0, 0, 25, 0, 26, 65, 0, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 725, 0, + 0, 0, 792, 792, 792, 792, 57, 25, 0, 26, + 0, 0, 27, 256, 0, 1018, 0, 28, 62, 63, + 0, 29, 0, 0, 25, 0, 26, 65, 0, 27, 31, 0, 0, 0, 28, 0, 0, 33, 29, 0, 0, 0, 34, 0, 72, 73, 35, 31, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 37, 34, - 38, 75, 892, 35, 39, 0, 0, 77, 0, 79, - 0, 81, 40, 41, 256, 37, 42, 38, 0, 0, + 38, 75, 0, 35, 39, 0, 0, 77, 0, 79, + 0, 81, 40, 41, 257, 37, 42, 38, 0, 0, 0, 39, 0, 87, 0, 0, 88, 89, 0, 40, - 41, 0, 0, 42, 0, 0, 317, 0, 0, 0, - 0, 90, 91, 92, 0, 93, 0, 0, 0, 504, - 0, 0, 0, 95, 0, 0, 0, 0, 0, 97, - 98, 99, 100, 0, 0, 0, 101, 0, 102, 0, - 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, - 0, 0, 57, 25, 0, 26, 0, 0, 27, 255, - 0, 0, 0, 28, 62, 63, 0, 29, 0, 105, - 299, 107, 108, 65, 0, 0, 31, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 349, 34, 0, - 72, 73, 35, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 37, 0, 38, 75, 0, 0, - 39, 0, 0, 77, 0, 79, 0, 81, 40, 41, - 256, 0, 42, 0, 0, 0, 0, 0, 0, 87, - 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, - 0, 93, 0, 0, 0, 704, 961, 0, 0, 95, - 0, 0, 0, 0, 0, 97, 98, 99, 100, 0, - 0, 0, 101, 0, 102, 0, 0, 0, 0, 0, - 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 687, 0, 105, 705, 107, 108, 0, - 0, 57, 25, 0, 26, 0, 706, 27, 255, 0, - 0, 0, 28, 62, 63, 0, 29, 0, 0, 186, - 0, 186, 65, 0, 186, 31, 0, 0, 0, 186, - 0, 0, 33, 186, 0, 0, 0, 34, 0, 72, - 73, 35, 186, 0, 0, 0, 0, 0, 0, 186, - 0, 0, 0, 37, 186, 38, 75, 0, 186, 39, - 0, 0, 77, 0, 79, 0, 81, 40, 41, 256, - 186, 42, 186, 0, 85, 0, 186, 0, 87, 0, - 0, 88, 89, 0, 186, 186, 0, 0, 186, 0, - 0, 186, 0, 0, 0, 0, 90, 91, 92, 0, - 93, 0, 0, 0, 0, 0, 0, 0, 95, 0, - 0, 0, 0, 0, 97, 98, 99, 100, 0, 0, - 0, 101, 0, 102, 0, 0, 944, 0, 0, 103, - 104, 0, 0, 0, 0, 0, 0, 57, 25, 0, - 26, 0, 0, 27, 255, 0, 0, 0, 28, 62, - 63, 0, 29, 0, 105, 299, 107, 108, 65, 0, - 0, 31, 0, 0, 0, 0, 0, 0, 33, 0, - 0, 0, 186, 34, 0, 72, 73, 35, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, - 0, 38, 75, 0, 0, 39, 0, 0, 77, 0, - 79, 0, 81, 40, 41, 256, 0, 42, 0, 0, - 0, 0, 0, 0, 87, 0, 0, 88, 89, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 90, 91, 92, 0, 93, 0, 0, 0, - 704, 0, 0, 0, 95, 0, 0, 0, 0, 0, - 97, 98, 99, 100, 0, 0, 0, 101, 0, 102, - 0, 0, 0, 0, 0, 103, 104, 0, 0, 0, + 41, 0, 0, 42, 0, 0, 319, 0, 0, 0, + 0, 90, 91, 92, 93, 94, 0, 0, 0, 509, + 726, 0, 0, 96, 0, 0, 0, 0, 0, 98, + 99, 100, 101, 0, 0, 0, 102, 0, 103, 0, + 0, 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 717, 0, - 105, 705, 107, 108, 0, 0, 57, 25, 0, 26, - 0, 706, 27, 255, 0, 0, 0, 28, 62, 63, - 0, 29, 0, 0, 186, 0, 186, 65, 0, 186, - 31, 0, 0, 0, 186, 0, 0, 33, 186, 0, - 0, 0, 34, 0, 72, 73, 35, 186, 0, 0, - 0, 0, 0, 0, 186, 0, 0, 0, 37, 186, - 38, 75, 0, 186, 39, 0, 0, 77, 0, 79, - 0, 81, 40, 41, 256, 186, 42, 186, 0, 0, - 0, 186, 0, 87, 0, 0, 88, 89, 0, 186, - 186, 0, 0, 186, 0, 0, 186, 0, 0, 0, - 0, 90, 91, 92, 0, 93, 0, 0, 0, 504, - 0, 0, 0, 95, 0, 0, 0, 0, 0, 97, - 98, 99, 100, 0, 0, 0, 101, 0, 102, 944, - 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 880, 0, 0, 0, 105, - 299, 107, 108, 57, 25, 0, 26, 0, 0, 27, - 255, 0, 0, 0, 28, 62, 63, 186, 29, 0, + 0, 0, 0, 0, 0, 725, 0, 0, 0, 106, + 301, 108, 109, 57, 25, 0, 26, 0, 0, 27, + 256, 0, 1139, 0, 28, 62, 63, 354, 29, 0, 0, 25, 0, 26, 65, 0, 27, 31, 0, 0, 0, 28, 0, 0, 33, 29, 0, 0, 0, 34, 0, 72, 73, 35, 31, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 37, 34, 38, 75, 0, + 0, 33, 0, 0, 0, 37, 34, 38, 75, 906, 35, 39, 0, 0, 77, 0, 79, 0, 81, 40, - 41, 256, 37, 42, 38, 0, 0, 0, 39, 0, + 41, 257, 37, 42, 38, 0, 0, 0, 39, 0, 87, 0, 0, 88, 89, 0, 40, 41, 0, 0, - 42, 0, 0, 317, 0, 0, 0, 0, 90, 91, - 92, 0, 93, 0, 0, 0, 0, 0, 0, 0, - 95, 0, 0, 0, 0, 0, 97, 98, 99, 100, - 0, 0, 0, 101, 0, 102, 0, 0, 0, 0, - 0, 103, 104, 0, 0, 0, 0, 0, 0, 0, + 42, 0, 0, 319, 0, 0, 0, 0, 90, 91, + 92, 93, 94, 0, 0, 0, 509, 0, 0, 0, + 96, 0, 0, 0, 0, 0, 98, 99, 100, 101, + 0, 0, 0, 102, 0, 103, 0, 0, 0, 0, + 0, 104, 105, 0, 0, 0, 0, 0, 0, 57, + 25, 0, 26, 0, 0, 27, 256, 0, 0, 0, + 28, 62, 63, 0, 29, 0, 106, 301, 108, 109, + 65, 0, 0, 31, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 354, 34, 0, 72, 73, 35, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 37, 0, 38, 75, 0, 0, 39, 0, 0, + 77, 0, 79, 0, 81, 40, 41, 257, 0, 42, + 0, 0, 0, 0, 0, 0, 87, 0, 0, 88, + 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 90, 91, 92, 93, 94, 0, + 0, 0, 712, 975, 0, 0, 96, 0, 0, 0, + 0, 0, 98, 99, 100, 101, 0, 0, 0, 102, + 0, 103, 0, 0, 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 616, 0, 0, 0, 105, 299, 107, 108, - 616, 616, 0, 616, 0, 0, 616, 616, 0, 0, - 0, 616, 616, 616, 318, 616, 0, 0, 0, 0, - 0, 616, 0, 0, 616, 0, 0, 0, 0, 0, - 0, 616, 0, 0, 0, 0, 616, 0, 616, 616, - 616, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 616, 0, 616, 616, 0, 0, 616, 0, - 0, 616, 0, 616, 0, 616, 616, 616, 616, 0, - 616, 0, 0, 0, 0, 0, 0, 616, 0, 0, - 616, 616, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 616, 616, 616, 0, 616, - 0, 0, 0, 0, 0, 0, 0, 616, 0, 0, - 0, 0, 0, 616, 616, 616, 616, 0, 0, 0, - 616, 0, 616, 0, 0, 0, 0, 0, 616, 616, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 695, 0, 106, 713, 108, 109, 0, 0, 57, 25, + 0, 26, 0, 714, 27, 256, 0, 0, 0, 28, + 62, 63, 0, 29, 0, 0, 187, 0, 187, 65, + 0, 187, 31, 0, 0, 0, 187, 0, 0, 33, + 187, 0, 0, 0, 34, 0, 72, 73, 35, 187, + 0, 0, 0, 0, 0, 0, 187, 0, 0, 0, + 37, 187, 38, 75, 0, 187, 39, 0, 0, 77, + 0, 79, 0, 81, 40, 41, 257, 187, 42, 187, + 0, 85, 0, 187, 0, 87, 0, 0, 88, 89, + 0, 187, 187, 0, 0, 187, 0, 0, 187, 0, + 0, 0, 0, 90, 91, 92, 93, 94, 0, 0, + 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, + 0, 98, 99, 100, 101, 0, 0, 0, 102, 0, + 103, 0, 0, 952, 0, 0, 104, 105, 0, 0, + 0, 0, 0, 0, 57, 25, 0, 26, 0, 0, + 27, 256, 0, 0, 0, 28, 62, 63, 0, 29, + 0, 106, 301, 108, 109, 65, 0, 0, 31, 0, + 0, 0, 0, 0, 0, 33, 0, 0, 0, 187, + 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 37, 0, 38, 75, + 0, 0, 39, 0, 0, 77, 0, 79, 0, 81, + 40, 41, 257, 0, 42, 0, 0, 0, 0, 0, + 0, 87, 0, 0, 88, 89, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, + 91, 92, 93, 94, 0, 0, 0, 712, 0, 0, + 0, 96, 0, 0, 0, 0, 0, 98, 99, 100, + 101, 0, 0, 0, 102, 0, 103, 0, 0, 0, + 0, 0, 104, 105, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 725, 0, 106, 713, 108, + 109, 0, 0, 57, 25, 0, 26, 0, 714, 27, + 256, 0, 0, 0, 28, 62, 63, 0, 29, 0, + 0, 187, 0, 187, 65, 0, 187, 31, 0, 0, + 0, 187, 0, 0, 33, 187, 0, 0, 0, 34, + 0, 72, 73, 35, 187, 0, 0, 0, 0, 0, + 0, 187, 0, 0, 0, 37, 187, 38, 75, 0, + 187, 39, 0, 0, 77, 0, 79, 0, 81, 40, + 41, 257, 187, 42, 187, 0, 0, 0, 187, 0, + 87, 0, 0, 88, 89, 0, 187, 187, 0, 0, + 187, 0, 0, 187, 0, 0, 0, 0, 90, 91, + 92, 93, 94, 0, 0, 0, 509, 0, 0, 0, + 96, 0, 0, 0, 0, 0, 98, 99, 100, 101, + 0, 0, 0, 102, 0, 103, 952, 0, 0, 0, + 0, 104, 105, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 894, 0, 0, 0, 106, 301, 108, 109, + 57, 25, 0, 26, 0, 0, 27, 256, 0, 0, + 0, 28, 62, 63, 187, 29, 0, 0, 25, 0, + 26, 65, 0, 27, 31, 0, 0, 0, 28, 0, + 0, 33, 29, 0, 0, 0, 34, 0, 72, 73, + 35, 31, 0, 0, 0, 0, 0, 0, 33, 0, + 0, 0, 37, 34, 38, 75, 0, 35, 39, 0, + 0, 77, 0, 79, 0, 81, 40, 41, 257, 37, + 42, 38, 0, 0, 0, 39, 0, 87, 0, 0, + 88, 89, 0, 40, 41, 0, 0, 42, 0, 0, + 319, 0, 0, 0, 0, 90, 91, 92, 93, 94, + 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, + 0, 0, 0, 98, 99, 100, 101, 0, 0, 0, + 102, 0, 103, 0, 0, 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 616, 616, 616, 616, 48, 0, 0, - 0, 48, 0, 48, 0, 0, 48, 0, 48, 48, - 0, 48, 0, 48, 0, 48, 0, 48, 48, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 619, + 0, 0, 0, 106, 301, 108, 109, 619, 619, 0, + 619, 0, 0, 619, 619, 0, 0, 0, 619, 619, + 619, 320, 619, 0, 0, 0, 0, 0, 619, 0, + 0, 619, 0, 0, 0, 0, 0, 0, 619, 0, + 0, 0, 0, 619, 0, 619, 619, 619, 0, 0, + 0, 0, 0, 0, 0, 346, 0, 0, 0, 619, + 0, 619, 619, 0, 0, 619, 0, 0, 619, 0, + 619, 0, 619, 619, 619, 619, 0, 619, 0, 0, + 0, 0, 0, 0, 619, 0, 0, 619, 619, 0, + 0, 346, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 619, 619, 619, 619, 619, 0, 0, 0, + 0, 0, 0, 0, 619, 0, 0, 0, 0, 0, + 619, 619, 619, 619, 0, 0, 0, 619, 0, 619, + 0, 0, 0, 0, 0, 619, 619, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 619, 619, 619, 619, 346, 346, 346, 346, 0, 0, + 0, 346, 346, 0, 0, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 0, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + 346, 346, 346, 346, 346, 346, 346, 0, 48, 0, + 0, 0, 48, 346, 48, 0, 346, 48, 0, 48, + 48, 0, 48, 0, 48, 0, 48, 0, 48, 48, + 48, 48, 0, 0, 48, 48, 0, 0, 0, 0, + 48, 0, 48, 48, 48, 0, 0, 48, 0, 48, + 0, 48, 0, 0, 48, 0, 48, 48, 48, 48, + 0, 0, 0, 48, 48, 48, 0, 0, 48, 48, + 48, 0, 0, 0, 0, 0, 0, 48, 48, 0, + 48, 48, 0, 48, 48, 48, 0, 0, 0, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 48, 0, 48, + 0, 48, 0, 48, 0, 81, 48, 0, 48, 48, + 0, 48, 0, 48, 48, 48, 0, 48, 48, 48, 48, 0, 0, 48, 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, 0, 0, 48, 0, 48, 0, 48, 0, 0, 48, 0, 48, 48, 48, 48, 0, - 0, 0, 48, 48, 48, 0, 0, 48, 48, 48, + 0, 0, 48, 48, 48, 48, 0, 48, 48, 48, 0, 0, 0, 0, 0, 0, 48, 48, 0, 48, 48, 0, 48, 48, 48, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 48, 0, - 48, 0, 48, 0, 81, 48, 0, 48, 48, 0, + 48, 0, 48, 0, 82, 48, 0, 48, 48, 0, 48, 0, 48, 48, 48, 0, 48, 48, 48, 48, 0, 0, 48, 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, 0, 0, 48, 0, 48, 0, 48, @@ -10154,7 +10301,7 @@ void case_948() 0, 48, 48, 48, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 48, 0, 48, - 0, 48, 0, 82, 48, 0, 48, 48, 0, 48, + 0, 48, 0, 104, 48, 0, 48, 48, 0, 48, 0, 48, 48, 48, 0, 48, 48, 48, 48, 0, 0, 48, 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, 0, 0, 48, 0, 48, 0, 48, 0, @@ -10164,7 +10311,7 @@ void case_948() 48, 48, 48, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 48, 0, 48, 0, - 48, 0, 104, 48, 0, 48, 48, 0, 48, 0, + 48, 0, 105, 48, 0, 48, 48, 0, 48, 0, 48, 48, 48, 0, 48, 48, 48, 48, 0, 0, 48, 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, 0, 0, 48, 0, 48, 0, 48, 0, 0, @@ -10172,845 +10319,805 @@ void case_948() 48, 48, 48, 0, 48, 48, 48, 0, 0, 0, 0, 0, 0, 48, 48, 0, 48, 48, 0, 48, 48, 48, 0, 0, 0, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, + 0, 0, 48, 0, 48, 48, 0, 48, 0, 48, + 48, 227, 48, 0, 48, 0, 48, 0, 48, 48, + 48, 48, 0, 0, 48, 48, 0, 0, 0, 0, + 48, 0, 48, 48, 48, 0, 0, 48, 0, 48, + 346, 48, 0, 0, 48, 0, 48, 48, 48, 48, + 0, 0, 0, 48, 48, 48, 0, 0, 48, 48, + 48, 48, 0, 346, 0, 0, 0, 48, 48, 0, + 48, 48, 447, 48, 48, 48, 346, 0, 0, 48, + 0, 346, 0, 0, 346, 0, 346, 0, 346, 346, + 346, 346, 0, 0, 0, 448, 346, 0, 0, 48, + 346, 0, 0, 0, 346, 228, 0, 0, 449, 0, + 367, 0, 346, 451, 0, 346, 0, 346, 452, 0, + 453, 454, 455, 456, 0, 0, 0, 0, 457, 0, + 0, 0, 458, 367, 0, 0, 346, 0, 0, 0, + 0, 346, 0, 0, 459, 0, 367, 460, 346, 461, + 278, 367, 346, 0, 244, 48, 367, 0, 367, 367, + 367, 367, 0, 0, 0, 346, 367, 0, 0, 0, + 367, 0, 0, 462, 367, 0, 0, 0, 0, 0, + 0, 0, 367, 57, 25, 367, 26, 367, 0, 27, + 256, 0, 0, 0, 28, 62, 63, 346, 29, 0, + 0, 0, 0, 0, 65, 0, 0, 31, 0, 0, + 0, 367, 0, 0, 33, 0, 0, 0, 0, 34, + 0, 72, 73, 35, 0, 582, 0, 0, 0, 1308, + 0, 0, 583, 0, 0, 37, 0, 38, 75, 0, + 0, 39, 0, 0, 77, 0, 79, 0, 81, 40, + 41, 257, 0, 42, 0, 0, 0, 0, 0, 0, + 584, 0, 0, 88, 89, 0, 0, 367, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 90, 91, + 92, 93, 94, 0, 0, 0, 0, 0, 0, 0, + 96, 901, 0, 585, 0, 0, 98, 99, 100, 101, + 0, 0, 0, 102, 0, 103, 0, 0, 0, 0, + 0, 104, 105, 0, 0, 0, 0, 0, 0, 57, + 25, 0, 26, 0, 0, 27, 256, 0, 0, 0, + 28, 62, 63, 0, 29, 0, 106, 469, 108, 109, + 65, 0, 0, 31, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 0, 34, 0, 72, 73, 35, + 0, 582, 0, 0, 0, 0, 0, 0, 583, 0, + 0, 37, 0, 38, 75, 0, 0, 39, 0, 0, + 77, 0, 79, 0, 81, 40, 41, 257, 0, 42, + 0, 0, 0, 0, 0, 0, 584, 0, 0, 88, + 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 90, 91, 92, 93, 94, 0, + 0, 0, 0, 0, 0, 0, 96, 0, 0, 585, + 0, 0, 98, 99, 100, 101, 0, 0, 0, 102, + 0, 103, 0, 0, 0, 0, 0, 104, 105, 0, + 0, 0, 0, 0, 0, 57, 25, 0, 26, 0, + 0, 27, 256, 0, 0, 0, 28, 62, 63, 0, + 29, 0, 106, 469, 108, 109, 65, 0, 0, 31, + 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, + 0, 34, 0, 72, 73, 35, 0, 582, 0, 0, + 0, 0, 0, 0, 583, 0, 0, 37, 0, 38, + 75, 0, 0, 39, 0, 0, 77, 0, 79, 0, + 81, 40, 41, 257, 0, 42, 0, 0, 0, 0, + 0, 0, 584, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 48, 0, 48, 0, 48, 0, 48, - 0, 105, 48, 0, 48, 48, 0, 48, 0, 48, - 48, 48, 0, 48, 48, 48, 48, 0, 0, 48, - 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, - 0, 0, 48, 0, 48, 0, 48, 0, 0, 48, - 0, 48, 48, 48, 48, 0, 0, 0, 48, 48, - 48, 48, 0, 48, 48, 48, 0, 0, 0, 0, - 0, 0, 48, 48, 0, 48, 48, 0, 48, 48, - 48, 0, 0, 0, 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, - 0, 48, 0, 48, 48, 0, 48, 0, 48, 48, - 226, 48, 0, 48, 0, 48, 0, 48, 48, 48, - 48, 0, 0, 48, 48, 0, 0, 0, 0, 48, - 0, 48, 48, 48, 0, 0, 48, 0, 48, 345, - 48, 0, 0, 48, 0, 48, 48, 48, 48, 0, - 0, 0, 48, 48, 48, 0, 0, 48, 48, 48, - 48, 0, 345, 0, 0, 0, 48, 48, 0, 48, - 48, 442, 48, 48, 48, 345, 0, 0, 48, 0, - 345, 0, 0, 345, 0, 345, 0, 345, 345, 345, - 345, 0, 0, 0, 443, 345, 0, 0, 48, 345, - 0, 0, 0, 345, 227, 0, 0, 444, 0, 366, - 0, 345, 446, 0, 345, 0, 345, 447, 0, 448, - 449, 450, 451, 0, 0, 0, 0, 452, 0, 0, - 0, 453, 366, 0, 0, 345, 0, 0, 0, 442, - 345, 0, 0, 454, 0, 366, 455, 345, 456, 277, - 366, 345, 0, 243, 48, 366, 0, 366, 366, 366, - 366, 0, 443, 0, 345, 366, 0, 0, 0, 366, - 0, 0, 457, 366, 0, 444, 0, 0, 0, 0, - 446, 366, 0, 0, 366, 447, 366, 448, 449, 450, - 451, 0, 0, 0, 0, 452, 345, 0, 0, 453, - 0, 0, 0, 1277, 0, 0, 57, 25, 0, 26, - 366, 454, 27, 255, 455, 0, 456, 28, 62, 63, - 0, 29, 0, 0, 0, 0, 0, 65, 1291, 0, - 31, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 457, 0, 34, 0, 72, 73, 35, 0, 574, 0, - 0, 0, 0, 0, 0, 575, 0, 0, 37, 0, - 38, 75, 0, 0, 39, 0, 366, 77, 0, 79, - 0, 81, 40, 41, 256, 0, 42, 0, 0, 0, - 0, 0, 0, 576, 0, 0, 88, 89, 0, 0, - 0, 0, 0, 0, 0, 0, 1278, 0, 0, 0, - 0, 90, 91, 92, 0, 93, 0, 0, 0, 0, - 0, 0, 0, 95, 887, 0, 577, 0, 0, 97, - 98, 99, 100, 0, 0, 0, 101, 0, 102, 0, - 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, - 0, 0, 57, 25, 0, 26, 0, 0, 27, 255, - 0, 0, 0, 28, 62, 63, 0, 29, 0, 105, - 464, 107, 108, 65, 0, 0, 31, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 0, 34, 0, - 72, 73, 35, 0, 574, 0, 0, 0, 0, 0, - 0, 575, 0, 0, 37, 0, 38, 75, 0, 0, - 39, 0, 0, 77, 0, 79, 0, 81, 40, 41, - 256, 0, 42, 0, 0, 0, 0, 0, 0, 576, - 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, - 0, 93, 0, 0, 0, 0, 0, 0, 0, 95, - 0, 0, 577, 0, 0, 97, 98, 99, 100, 0, - 0, 0, 101, 0, 102, 0, 0, 0, 0, 0, - 103, 104, 0, 0, 0, 0, 0, 0, 57, 25, - 0, 26, 0, 0, 27, 255, 0, 0, 0, 28, - 62, 63, 0, 29, 0, 105, 464, 107, 108, 65, - 0, 0, 31, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 34, 0, 72, 73, 35, 0, - 574, 0, 0, 0, 0, 0, 0, 575, 0, 0, - 37, 0, 38, 75, 0, 0, 39, 0, 0, 77, - 0, 79, 0, 81, 40, 41, 256, 0, 42, 0, - 0, 0, 0, 0, 0, 576, 0, 0, 88, 89, + 90, 91, 92, 93, 94, 0, 0, 0, 0, 0, + 0, 0, 96, 0, 0, 0, 0, 0, 98, 99, + 100, 101, 0, 0, 0, 102, 0, 103, 0, 0, + 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, + 0, 57, 25, 0, 26, 0, 0, 27, 256, 0, + 0, 0, 28, 62, 63, 0, 29, 0, 106, 469, + 108, 109, 65, 0, 0, 31, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, 0, 34, 0, 72, + 73, 35, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 0, 38, 75, 0, 0, 39, + 0, 0, 77, 0, 79, 0, 81, 40, 41, 257, + 0, 42, 0, 0, 85, 0, 0, 0, 87, 0, + 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, + 94, 0, 0, 0, 0, 0, 0, 0, 96, 0, + 0, 0, 0, 0, 98, 99, 100, 101, 0, 0, + 0, 102, 0, 103, 0, 0, 0, 0, 0, 104, + 105, 0, 0, 0, 0, 0, 0, 57, 25, 0, + 26, 0, 0, 27, 256, 0, 0, 0, 28, 62, + 63, 0, 29, 0, 106, 301, 108, 109, 65, 0, + 0, 31, 0, 0, 0, 0, 0, 0, 33, 0, + 0, 0, 0, 34, 0, 72, 73, 35, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, + 0, 38, 75, 0, 0, 39, 0, 0, 77, 0, + 79, 0, 81, 40, 41, 257, 0, 42, 0, 0, + 0, 0, 0, 0, 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 90, 91, 92, 0, 93, 0, 0, - 0, 0, 0, 0, 0, 95, 0, 0, 0, 0, - 0, 97, 98, 99, 100, 0, 0, 0, 101, 0, - 102, 0, 0, 0, 0, 0, 103, 104, 0, 0, - 0, 0, 0, 0, 57, 25, 0, 26, 0, 0, - 27, 255, 0, 0, 0, 28, 62, 63, 0, 29, - 0, 105, 464, 107, 108, 65, 0, 0, 31, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 37, 0, 38, 75, - 0, 0, 39, 0, 0, 77, 0, 79, 0, 81, - 40, 41, 256, 0, 42, 0, 0, 85, 0, 0, - 0, 87, 0, 0, 88, 89, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, - 91, 92, 0, 93, 0, 0, 0, 0, 0, 0, - 0, 95, 0, 0, 0, 0, 0, 97, 98, 99, - 100, 0, 0, 0, 101, 0, 102, 0, 0, 0, - 0, 0, 103, 104, 0, 0, 0, 0, 0, 0, - 57, 25, 0, 26, 0, 0, 27, 255, 0, 0, - 0, 28, 62, 63, 0, 29, 0, 105, 299, 107, - 108, 65, 0, 0, 31, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 34, 0, 72, 73, - 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 37, 0, 38, 75, 0, 0, 39, 0, - 0, 77, 0, 79, 0, 81, 40, 41, 256, 0, - 42, 0, 0, 0, 0, 0, 0, 87, 0, 0, - 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 90, 91, 92, 0, 93, - 0, 0, 0, 0, 848, 0, 0, 95, 0, 0, - 0, 0, 0, 97, 98, 99, 100, 0, 0, 0, - 101, 0, 102, 0, 0, 0, 0, 0, 103, 104, - 0, 0, 0, 0, 0, 0, 57, 25, 0, 26, - 0, 0, 27, 255, 0, 0, 0, 28, 62, 63, - 0, 29, 0, 105, 299, 107, 108, 65, 0, 0, - 31, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 0, 34, 0, 72, 73, 35, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, - 38, 75, 0, 0, 39, 0, 0, 77, 0, 79, - 0, 81, 40, 41, 256, 0, 42, 0, 0, 0, - 0, 0, 0, 87, 0, 0, 88, 89, 0, 0, + 0, 0, 90, 91, 92, 93, 94, 0, 0, 0, + 0, 859, 0, 0, 96, 0, 0, 0, 0, 0, + 98, 99, 100, 101, 0, 0, 0, 102, 0, 103, + 0, 0, 0, 0, 0, 104, 105, 0, 0, 0, + 0, 0, 0, 57, 25, 0, 26, 0, 0, 27, + 256, 0, 0, 0, 28, 62, 63, 0, 29, 0, + 106, 301, 108, 109, 65, 0, 0, 31, 0, 0, + 0, 0, 0, 0, 33, 0, 0, 0, 0, 34, + 0, 72, 73, 35, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 37, 0, 38, 75, 0, + 0, 39, 0, 0, 77, 0, 79, 0, 81, 40, + 41, 257, 0, 42, 0, 0, 0, 0, 0, 0, + 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 90, 91, + 92, 93, 94, 0, 0, 0, 509, 0, 0, 0, + 96, 0, 0, 0, 0, 0, 98, 99, 100, 101, + 0, 0, 0, 102, 0, 103, 0, 0, 0, 0, + 0, 104, 105, 0, 0, 0, 0, 0, 0, 57, + 25, 0, 26, 0, 0, 27, 256, 0, 0, 0, + 28, 62, 63, 0, 29, 0, 106, 301, 108, 109, + 65, 0, 0, 31, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 0, 34, 0, 72, 73, 35, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 37, 0, 38, 75, 0, 0, 39, 0, 0, + 77, 0, 79, 0, 81, 40, 41, 257, 0, 42, + 0, 0, 0, 0, 0, 0, 87, 0, 0, 88, + 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 90, 91, 92, 93, 94, 0, + 0, 0, 503, 0, 0, 0, 96, 0, 0, 0, + 0, 0, 98, 99, 100, 101, 0, 0, 0, 102, + 0, 103, 0, 0, 0, 0, 0, 104, 105, 0, + 0, 0, 0, 0, 0, 57, 25, 0, 26, 0, + 0, 27, 256, 0, 0, 0, 28, 62, 63, 0, + 29, 0, 106, 301, 108, 109, 65, 0, 0, 31, + 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, + 0, 34, 0, 72, 73, 35, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 37, 0, 38, + 75, 0, 0, 39, 0, 0, 77, 0, 79, 0, + 81, 40, 41, 257, 0, 42, 0, 0, 0, 0, + 0, 0, 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 90, 91, 92, 0, 93, 0, 0, 0, 504, - 0, 0, 0, 95, 0, 0, 0, 0, 0, 97, - 98, 99, 100, 0, 0, 0, 101, 0, 102, 0, - 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, - 0, 0, 57, 25, 0, 26, 0, 0, 27, 255, - 0, 0, 0, 28, 62, 63, 0, 29, 0, 105, - 299, 107, 108, 65, 0, 0, 31, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 0, 34, 0, - 72, 73, 35, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 37, 0, 38, 75, 0, 0, - 39, 0, 0, 77, 0, 79, 0, 81, 40, 41, - 256, 0, 42, 0, 0, 0, 0, 0, 0, 87, - 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, - 0, 93, 0, 0, 0, 498, 0, 0, 0, 95, - 0, 0, 0, 0, 0, 97, 98, 99, 100, 0, - 0, 0, 101, 0, 102, 0, 0, 0, 0, 0, - 103, 104, 0, 0, 0, 0, 0, 0, 57, 25, - 0, 26, 0, 0, 27, 255, 0, 0, 0, 28, - 62, 63, 0, 29, 0, 105, 299, 107, 108, 65, - 0, 0, 31, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 34, 0, 72, 73, 35, 0, + 90, 91, 92, 93, 94, 0, 0, 0, 0, 0, + 0, 0, 96, 0, 0, 0, 0, 0, 98, 99, + 100, 101, 0, 0, 0, 102, 0, 103, 0, 0, + 0, 0, 0, 104, 105, 0, 0, 0, 0, 0, + 0, 57, 25, 0, 26, 0, 0, 27, 256, 0, + 0, 0, 28, 62, 63, 0, 29, 0, 106, 301, + 108, 109, 65, 0, 0, 31, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, 0, 34, 0, 72, + 73, 35, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 0, 38, 75, 0, 0, 39, + 0, 0, 77, 0, 79, 0, 81, 40, 41, 257, + 0, 42, 0, 0, 0, 0, 0, 0, 87, 0, + 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, + 94, 0, 0, 0, 0, 0, 0, 0, 96, 0, + 0, 0, 0, 0, 98, 99, 100, 101, 0, 0, + 0, 102, 0, 103, 0, 0, 0, 0, 0, 104, + 105, 0, 0, 0, 0, 0, 0, 57, 25, 0, + 26, 0, 0, 27, 256, 0, 0, 0, 28, 62, + 63, 0, 29, 0, 106, 469, 108, 109, 65, 0, + 0, 31, 0, 0, 0, 0, 0, 0, 33, 0, + 0, 0, 0, 34, 0, 72, 73, 35, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, + 0, 38, 75, 0, 0, 39, 0, 0, 77, 0, + 79, 0, 81, 40, 41, 257, 0, 42, 0, 0, + 0, 0, 0, 0, 87, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 37, 0, 38, 75, 0, 0, 39, 0, 0, 77, - 0, 79, 0, 81, 40, 41, 256, 0, 42, 0, - 0, 0, 0, 0, 0, 87, 0, 0, 88, 89, + 0, 0, 90, 91, 92, 93, 94, 0, 0, 0, + 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, + 98, 99, 100, 101, 0, 0, 0, 102, 0, 103, + 0, 0, 0, 0, 0, 104, 105, 0, 0, 0, + 0, 0, 0, 78, 78, 0, 78, 0, 0, 78, + 78, 0, 0, 0, 78, 78, 78, 0, 78, 0, + 106, 1010, 108, 109, 78, 0, 0, 78, 0, 0, + 0, 0, 0, 0, 78, 0, 0, 0, 0, 78, + 0, 78, 78, 78, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 78, 0, 78, 78, 0, + 0, 78, 0, 0, 78, 0, 78, 0, 78, 78, + 78, 78, 0, 78, 0, 0, 0, 0, 0, 0, + 78, 0, 0, 78, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 78, 78, + 78, 78, 78, 0, 0, 0, 0, 0, 0, 0, + 78, 0, 0, 0, 0, 0, 78, 78, 78, 78, + 0, 0, 0, 78, 0, 78, 0, 0, 0, 0, + 0, 78, 78, 0, 0, 0, 0, 0, 0, 150, + 150, 0, 150, 0, 0, 150, 150, 0, 0, 0, + 150, 150, 150, 0, 150, 0, 78, 78, 78, 78, + 150, 0, 0, 150, 0, 0, 0, 0, 0, 0, + 150, 0, 0, 0, 0, 150, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 90, 91, 92, 0, 93, 0, 0, - 0, 0, 0, 0, 0, 95, 0, 0, 0, 0, - 0, 97, 98, 99, 100, 0, 0, 0, 101, 0, - 102, 0, 0, 0, 0, 0, 103, 104, 0, 0, - 0, 0, 0, 0, 57, 25, 0, 26, 0, 0, - 27, 255, 0, 0, 0, 28, 62, 63, 0, 29, - 0, 105, 299, 107, 108, 65, 0, 0, 31, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 37, 0, 38, 75, - 0, 0, 39, 0, 0, 77, 0, 79, 0, 81, - 40, 41, 256, 0, 42, 0, 0, 0, 0, 0, - 0, 87, 0, 0, 88, 89, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, - 91, 92, 0, 93, 0, 0, 0, 0, 0, 0, - 0, 95, 0, 0, 0, 0, 0, 97, 98, 99, - 100, 0, 0, 0, 101, 0, 102, 0, 0, 0, - 0, 0, 103, 104, 0, 0, 0, 0, 0, 0, - 57, 25, 0, 26, 0, 0, 27, 255, 0, 0, - 0, 28, 62, 63, 0, 29, 0, 105, 464, 107, - 108, 65, 0, 0, 31, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 34, 0, 72, 73, - 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 37, 0, 38, 75, 0, 0, 39, 0, - 0, 77, 0, 79, 0, 81, 40, 41, 256, 0, - 42, 0, 0, 0, 0, 0, 0, 87, 0, 0, - 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 90, 91, 92, 0, 93, - 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, - 0, 0, 0, 97, 98, 99, 100, 0, 0, 0, - 101, 0, 102, 0, 0, 0, 0, 0, 103, 104, - 0, 0, 0, 0, 0, 0, 78, 78, 0, 78, - 0, 0, 78, 78, 0, 0, 0, 78, 78, 78, - 0, 78, 0, 105, 995, 107, 108, 78, 0, 0, - 78, 0, 0, 0, 0, 0, 0, 78, 0, 0, - 0, 0, 78, 0, 78, 78, 78, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, - 78, 78, 0, 0, 78, 0, 0, 78, 0, 78, - 0, 78, 78, 78, 78, 0, 78, 0, 0, 0, - 0, 0, 0, 78, 0, 0, 78, 78, 0, 0, + 0, 150, 0, 150, 150, 0, 0, 150, 0, 0, + 150, 0, 150, 0, 150, 150, 150, 150, 0, 150, + 0, 0, 0, 0, 0, 0, 150, 0, 0, 150, + 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 150, 150, 150, 150, 150, 0, + 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, + 0, 0, 150, 150, 150, 150, 0, 0, 0, 150, + 0, 150, 0, 0, 0, 0, 0, 150, 150, 0, + 0, 0, 0, 0, 0, 57, 25, 0, 26, 0, + 0, 27, 256, 0, 0, 0, 28, 62, 63, 0, + 29, 0, 150, 150, 150, 150, 65, 0, 0, 31, + 0, 0, 0, 0, 0, 0, 33, 0, 28, 0, + 0, 34, 0, 72, 73, 35, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 37, 0, 38, + 75, 28, 0, 39, 0, 0, 77, 0, 79, 0, + 81, 40, 41, 257, 28, 42, 0, 0, 0, 28, + 0, 0, 0, 0, 28, 0, 28, 28, 28, 28, + 0, 0, 28, 0, 28, 0, 0, 0, 28, 0, + 90, 91, 92, 258, 94, 0, 0, 0, 0, 0, + 28, 0, 96, 28, 0, 28, 0, 0, 98, 99, + 100, 101, 0, 0, 0, 102, 0, 103, 0, 57, + 25, 0, 26, 104, 105, 27, 256, 0, 0, 28, + 28, 62, 63, 0, 29, 28, 28, 0, 0, 0, + 65, 0, 0, 31, 0, 0, 0, 48, 106, 259, + 33, 109, 0, 0, 0, 34, 0, 72, 73, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 78, 78, 78, 0, 78, 0, 0, 0, 0, - 0, 0, 0, 78, 0, 0, 0, 0, 0, 78, - 78, 78, 78, 0, 0, 0, 78, 0, 78, 0, - 0, 0, 0, 0, 78, 78, 0, 0, 0, 0, - 0, 0, 150, 150, 0, 150, 0, 0, 150, 150, - 0, 0, 0, 150, 150, 150, 0, 150, 0, 78, - 78, 78, 78, 150, 0, 0, 150, 0, 0, 0, - 0, 0, 0, 150, 0, 0, 0, 0, 150, 0, - 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 150, 0, 150, 150, 0, 0, - 150, 0, 0, 150, 0, 150, 0, 150, 150, 150, - 150, 0, 150, 0, 0, 0, 0, 0, 0, 150, - 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, - 0, 150, 0, 0, 0, 0, 0, 0, 0, 150, - 0, 0, 0, 0, 0, 150, 150, 150, 150, 0, - 0, 0, 150, 0, 150, 0, 0, 0, 0, 0, - 150, 150, 0, 0, 0, 0, 0, 0, 57, 25, - 0, 26, 0, 0, 27, 255, 0, 0, 0, 28, - 62, 63, 0, 29, 0, 150, 150, 150, 150, 65, - 0, 0, 31, 0, 0, 0, 0, 0, 0, 33, - 0, 28, 0, 0, 34, 0, 72, 73, 35, 0, + 48, 37, 0, 38, 75, 0, 0, 39, 0, 0, + 77, 0, 79, 48, 81, 40, 41, 257, 48, 42, + 0, 0, 0, 48, 0, 48, 48, 48, 48, 0, + 0, 48, 0, 48, 0, 0, 0, 48, 0, 0, + 0, 0, 0, 0, 90, 91, 92, 258, 94, 48, + 0, 0, 48, 0, 48, 0, 96, 652, 0, 652, + 0, 652, 98, 0, 652, 101, 652, 652, 0, 652, + 0, 652, 0, 652, 0, 652, 652, 652, 48, 0, + 0, 652, 652, 0, 311, 0, 0, 652, 0, 652, + 652, 0, 0, 0, 652, 0, 0, 0, 652, 0, + 0, 0, 106, 259, 0, 109, 0, 0, 0, 652, + 652, 0, 652, 0, 0, 0, 652, 652, 0, 0, + 0, 0, 0, 0, 652, 652, 57, 25, 652, 26, + 0, 652, 27, 256, 0, 0, 652, 28, 62, 63, + 0, 29, 0, 0, 0, 0, 0, 65, 0, 0, + 31, 0, 0, 0, 0, 0, 0, 33, 652, 652, + 0, 0, 34, 0, 72, 73, 35, 0, 0, 0, + 0, 652, 0, 0, 0, 0, 0, 0, 37, 0, + 38, 75, 0, 0, 39, 0, 0, 77, 0, 79, + 0, 81, 40, 41, 257, 0, 42, 0, 0, 85, + 0, 0, 0, 0, 0, 0, 25, 0, 26, 0, + 0, 27, 652, 1190, 0, 0, 28, 0, 0, 0, + 29, 90, 91, 92, 258, 0, 0, 0, 0, 31, + 651, 0, 651, 96, 0, 651, 33, 651, 651, 0, + 651, 34, 651, 1191, 651, 35, 651, 651, 651, 0, + 0, 0, 651, 651, 0, 0, 0, 37, 651, 38, + 651, 651, 0, 39, 1192, 651, 0, 0, 0, 651, + 0, 40, 41, 0, 0, 42, 0, 0, 319, 106, + 259, 651, 0, 651, 0, 0, 0, 651, 651, 0, + 0, 0, 0, 0, 0, 651, 651, 0, 651, 651, + 651, 0, 651, 651, 0, 651, 651, 651, 651, 0, + 651, 0, 651, 0, 651, 651, 651, 0, 0, 0, + 651, 651, 0, 0, 0, 0, 651, 0, 651, 651, + 0, 0, 0, 651, 0, 0, 0, 651, 0, 0, + 0, 0, 651, 0, 0, 0, 0, 0, 0, 651, + 0, 651, 0, 0, 0, 651, 651, 0, 0, 354, + 0, 0, 0, 651, 651, 0, 0, 651, 0, 0, + 651, 0, 25, 0, 26, 651, 0, 27, 0, 0, + 1263, 0, 28, 651, 671, 0, 29, 0, 672, 1264, + 1265, 0, 0, 0, 1266, 31, 0, 0, 0, 0, + 1267, 0, 33, 0, 25, 0, 26, 34, 0, 27, + 0, 35, 1263, 0, 28, 0, 671, 0, 29, 0, + 672, 1264, 1265, 37, 0, 38, 1266, 31, 0, 39, + 0, 0, 1267, 0, 33, 0, 0, 40, 41, 34, + 0, 42, 0, 35, 1268, 0, 0, 0, 48, 1269, + 48, 651, 0, 48, 0, 37, 0, 38, 48, 0, + 0, 39, 48, 0, 0, 0, 0, 0, 0, 40, + 41, 48, 0, 42, 0, 0, 1268, 0, 48, 0, + 48, 1269, 48, 48, 1270, 48, 0, 48, 0, 48, + 48, 48, 0, 0, 48, 0, 48, 0, 0, 48, + 0, 48, 0, 48, 0, 48, 0, 0, 48, 0, + 48, 0, 0, 48, 48, 48, 0, 48, 0, 48, + 48, 48, 0, 48, 48, 1271, 48, 0, 48, 48, + 0, 48, 0, 48, 48, 0, 0, 48, 48, 0, + 48, 0, 0, 0, 0, 48, 48, 48, 0, 48, + 0, 0, 48, 0, 48, 168, 25, 1271, 26, 48, + 0, 27, 0, 48, 0, 48, 28, 48, 0, 0, + 29, 0, 48, 0, 0, 48, 0, 48, 0, 31, + 0, 48, 0, 0, 48, 168, 33, 0, 0, 48, + 48, 34, 0, 48, 0, 35, 48, 563, 0, 0, + 0, 48, 0, 0, 564, 0, 0, 37, 0, 38, + 0, 0, 0, 39, 0, 0, 565, 0, 0, 0, + 0, 40, 41, 0, 0, 42, 0, 25, 566, 26, + 0, 0, 27, 48, 0, 0, 0, 28, 0, 0, + 0, 29, 0, 0, 0, 30, 25, 0, 26, 0, + 31, 27, 0, 0, 0, 32, 28, 33, 0, 0, + 29, 0, 34, 0, 0, 0, 35, 36, 0, 31, + 0, 0, 0, 0, 0, 0, 33, 48, 37, 0, + 38, 34, 0, 0, 39, 35, 0, 0, 0, 0, + 0, 0, 40, 41, 0, 0, 42, 37, 0, 38, + 25, 0, 26, 39, 0, 27, 0, 0, 0, 567, + 28, 40, 41, 0, 29, 42, 0, 25, 319, 26, + 0, 0, 27, 31, 0, 0, 0, 28, 0, 0, + 33, 29, 0, 0, 0, 34, 0, 0, 0, 35, + 31, 0, 0, 0, 0, 0, 0, 33, 0, 0, + 0, 37, 34, 38, 0, 0, 35, 39, 0, 0, + 0, 0, 0, 0, 0, 40, 41, 0, 37, 42, + 38, 25, 319, 26, 39, 0, 27, 0, 0, 0, + 43, 28, 40, 41, 0, 29, 42, 0, 0, 511, + 0, 0, 0, 0, 31, 25, 0, 26, 0, 326, + 27, 33, 0, 0, 0, 28, 34, 0, 0, 29, + 35, 0, 0, 0, 0, 0, 0, 0, 31, 0, + 0, 0, 37, 0, 38, 33, 0, 0, 39, 0, + 34, 0, 0, 0, 35, 0, 40, 41, 0, 0, + 42, 0, 0, 319, 0, 25, 37, 26, 38, 0, + 27, 0, 39, 354, 0, 28, 0, 0, 0, 29, + 40, 41, 0, 0, 42, 0, 0, 319, 31, 25, + 354, 26, 0, 0, 27, 33, 0, 0, 0, 28, + 34, 0, 0, 29, 35, 0, 0, 0, 0, 0, + 0, 0, 31, 0, 0, 0, 37, 0, 38, 33, + 0, 0, 39, 0, 34, 0, 0, 0, 35, 0, + 40, 41, 0, 0, 42, 0, 0, 566, 0, 0, + 37, 0, 38, 498, 630, 498, 39, 0, 498, 0, + 0, 0, 0, 498, 40, 41, 0, 498, 42, 0, + 188, 739, 188, 0, 0, 188, 498, 0, 632, 0, + 188, 0, 0, 498, 188, 0, 0, 0, 498, 0, + 0, 0, 498, 188, 0, 0, 0, 0, 0, 0, + 188, 0, 0, 0, 498, 188, 498, 0, 0, 188, + 498, 0, 0, 0, 0, 0, 0, 0, 498, 498, + 0, 188, 498, 188, 187, 498, 187, 188, 354, 187, + 0, 0, 0, 0, 187, 188, 188, 0, 187, 188, + 0, 0, 188, 0, 0, 0, 0, 187, 197, 0, + 197, 0, 354, 197, 187, 0, 0, 0, 197, 187, + 0, 0, 197, 187, 0, 0, 0, 0, 0, 0, + 0, 197, 0, 0, 0, 187, 0, 187, 197, 0, + 0, 187, 0, 197, 0, 0, 0, 197, 0, 187, + 187, 0, 35, 187, 0, 0, 187, 0, 0, 197, + 0, 197, 0, 35, 0, 197, 498, 0, 35, 0, + 0, 0, 35, 197, 197, 35, 0, 197, 0, 0, + 197, 0, 0, 188, 0, 0, 0, 35, 35, 0, + 0, 0, 35, 35, 0, 33, 0, 0, 35, 0, + 35, 35, 35, 35, 0, 0, 33, 0, 35, 0, + 0, 33, 35, 0, 35, 33, 0, 0, 33, 0, + 0, 0, 0, 0, 35, 0, 35, 35, 0, 35, + 33, 33, 0, 35, 0, 33, 33, 187, 0, 0, + 0, 33, 0, 33, 33, 33, 33, 0, 0, 0, + 0, 33, 0, 35, 0, 33, 0, 33, 0, 35, + 35, 197, 0, 28, 0, 28, 0, 33, 0, 0, + 33, 0, 33, 0, 0, 0, 33, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 0, 28, + 0, 0, 33, 33, 28, 0, 48, 0, 0, 28, + 0, 28, 28, 28, 28, 0, 0, 48, 0, 28, + 0, 0, 48, 28, 0, 0, 48, 0, 0, 48, + 0, 0, 0, 0, 0, 28, 0, 0, 28, 0, + 28, 48, 48, 0, 0, 0, 48, 48, 0, 48, + 0, 0, 48, 0, 48, 48, 48, 48, 0, 0, + 48, 0, 48, 0, 28, 48, 48, 0, 48, 48, + 28, 28, 48, 0, 0, 0, 0, 0, 48, 0, + 0, 48, 0, 48, 48, 48, 0, 48, 0, 48, + 48, 48, 0, 0, 0, 48, 0, 48, 48, 48, + 48, 0, 0, 0, 0, 48, 0, 48, 0, 48, + 0, 48, 0, 37, 48, 0, 0, 0, 0, 0, + 0, 48, 0, 0, 48, 0, 48, 48, 0, 48, + 48, 0, 48, 0, 0, 0, 0, 48, 0, 48, + 48, 48, 48, 0, 0, 0, 0, 48, 0, 0, + 48, 48, 48, 0, 0, 0, 38, 0, 0, 0, + 0, 0, 0, 48, 0, 48, 48, 48, 48, 48, + 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, + 48, 0, 0, 0, 0, 48, 0, 0, 0, 48, + 48, 0, 48, 0, 48, 48, 0, 0, 209, 0, + 0, 48, 0, 48, 48, 48, 48, 0, 48, 0, + 0, 0, 0, 48, 0, 48, 48, 48, 48, 0, + 0, 0, 0, 48, 0, 0, 0, 48, 48, 0, + 48, 0, 48, 48, 0, 447, 211, 0, 0, 48, + 0, 48, 48, 0, 48, 0, 48, 0, 0, 0, + 0, 48, 0, 48, 48, 48, 48, 0, 448, 0, + 0, 48, 0, 0, 0, 48, 0, 0, 48, 0, + 0, 449, 0, 0, 312, 450, 451, 48, 447, 0, + 48, 452, 48, 453, 454, 455, 456, 0, 0, 0, + 0, 457, 0, 0, 0, 458, 0, 0, 0, 0, + 0, 448, 0, 0, 0, 0, 48, 459, 48, 48, + 460, 0, 461, 0, 449, 0, 0, 0, 0, 451, + 0, 0, 0, 0, 452, 0, 453, 454, 455, 456, + 0, 0, 0, 0, 457, 0, 462, 0, 458, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 37, 0, 38, 75, 28, 0, 39, 0, 0, 77, - 0, 79, 0, 81, 40, 41, 256, 28, 42, 0, - 0, 0, 28, 0, 0, 0, 0, 28, 0, 28, - 28, 28, 28, 0, 0, 28, 0, 28, 0, 0, - 0, 28, 0, 90, 91, 92, 0, 93, 0, 0, - 0, 0, 0, 28, 0, 95, 28, 0, 28, 0, - 0, 97, 98, 99, 100, 0, 0, 0, 101, 0, - 102, 0, 57, 25, 0, 26, 103, 104, 27, 255, - 0, 0, 28, 28, 62, 63, 0, 29, 28, 28, - 0, 0, 0, 65, 0, 0, 31, 0, 0, 0, - 48, 105, 257, 33, 108, 0, 0, 0, 34, 0, - 72, 73, 35, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 48, 37, 0, 38, 75, 0, 0, - 39, 0, 0, 77, 0, 79, 48, 81, 40, 41, - 256, 48, 42, 0, 0, 0, 48, 0, 48, 48, - 48, 48, 0, 0, 48, 0, 48, 0, 0, 0, - 48, 0, 0, 0, 0, 0, 0, 90, 91, 92, - 0, 93, 48, 0, 0, 48, 0, 48, 0, 95, - 644, 0, 644, 0, 644, 97, 0, 644, 100, 644, - 644, 0, 644, 0, 644, 0, 644, 0, 644, 644, - 644, 48, 0, 0, 644, 644, 0, 310, 0, 0, - 644, 0, 644, 644, 0, 0, 0, 644, 0, 0, - 0, 644, 0, 0, 0, 105, 257, 0, 108, 0, - 0, 0, 644, 644, 0, 644, 0, 0, 0, 644, - 644, 0, 0, 0, 0, 0, 0, 644, 644, 57, - 25, 644, 26, 0, 644, 27, 255, 0, 0, 644, - 28, 62, 63, 0, 29, 0, 0, 0, 0, 0, - 65, 0, 0, 31, 0, 0, 0, 0, 0, 0, - 33, 644, 644, 0, 0, 34, 0, 72, 73, 35, - 0, 0, 0, 0, 644, 0, 0, 0, 0, 0, - 0, 37, 0, 38, 75, 0, 0, 39, 0, 0, - 77, 0, 79, 0, 81, 40, 41, 256, 0, 42, - 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 644, 0, 0, 0, 0, - 0, 0, 0, 0, 90, 91, 92, 643, 0, 643, - 0, 0, 643, 0, 643, 643, 95, 643, 0, 643, - 0, 643, 0, 643, 643, 643, 0, 0, 0, 643, - 643, 0, 0, 0, 0, 643, 0, 643, 643, 0, - 0, 0, 643, 0, 0, 0, 643, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 643, 0, - 643, 0, 105, 257, 643, 643, 0, 0, 0, 0, - 0, 0, 643, 643, 0, 643, 643, 643, 0, 643, - 643, 0, 643, 643, 643, 643, 0, 643, 0, 643, - 0, 643, 643, 643, 0, 0, 0, 643, 643, 0, - 0, 0, 0, 643, 0, 643, 643, 0, 0, 0, - 643, 0, 0, 0, 643, 0, 0, 0, 0, 643, - 0, 0, 0, 0, 0, 0, 643, 0, 643, 0, - 0, 0, 643, 643, 0, 0, 0, 0, 0, 0, - 643, 643, 0, 0, 643, 0, 0, 643, 0, 25, - 0, 26, 643, 0, 27, 0, 0, 1246, 0, 28, - 643, 663, 0, 29, 0, 664, 1247, 1248, 0, 0, - 0, 1249, 31, 0, 0, 0, 0, 1250, 0, 33, - 0, 25, 0, 26, 34, 0, 27, 0, 35, 1246, - 0, 28, 0, 663, 0, 29, 0, 664, 1247, 1248, - 37, 0, 38, 1249, 31, 0, 39, 0, 0, 1250, - 0, 33, 0, 0, 40, 41, 34, 0, 42, 0, - 35, 1251, 0, 0, 0, 48, 1252, 48, 643, 0, - 48, 0, 37, 0, 38, 48, 0, 0, 39, 48, - 0, 0, 0, 0, 0, 0, 40, 41, 48, 0, - 42, 0, 0, 1251, 0, 48, 0, 48, 1252, 48, - 48, 1253, 48, 0, 48, 0, 48, 48, 48, 0, - 0, 48, 0, 48, 0, 0, 48, 0, 48, 0, - 48, 0, 48, 0, 0, 48, 0, 48, 0, 0, - 48, 48, 48, 0, 48, 0, 48, 48, 48, 0, - 48, 48, 1254, 48, 0, 48, 48, 0, 48, 0, - 48, 48, 0, 0, 48, 48, 0, 48, 0, 0, - 0, 0, 48, 48, 48, 0, 48, 0, 0, 48, - 0, 48, 167, 25, 1254, 26, 48, 0, 27, 0, - 48, 0, 48, 28, 48, 0, 0, 29, 0, 48, - 0, 0, 48, 0, 48, 0, 31, 0, 48, 0, - 0, 48, 167, 33, 0, 0, 48, 48, 34, 0, - 48, 0, 35, 48, 555, 0, 0, 0, 48, 0, - 0, 556, 0, 0, 37, 0, 38, 0, 0, 0, - 39, 0, 0, 557, 0, 0, 0, 0, 40, 41, - 0, 0, 42, 0, 25, 558, 26, 0, 0, 27, - 48, 1173, 0, 0, 28, 0, 0, 0, 29, 0, - 0, 0, 0, 0, 0, 0, 0, 31, 25, 0, - 26, 0, 0, 27, 33, 0, 0, 0, 28, 34, - 0, 1174, 29, 35, 0, 0, 30, 0, 0, 0, - 0, 31, 0, 0, 48, 37, 32, 38, 33, 0, - 0, 39, 1175, 34, 0, 0, 0, 35, 36, 40, - 41, 0, 0, 42, 0, 0, 317, 0, 25, 37, - 26, 38, 0, 27, 0, 39, 559, 0, 28, 0, - 0, 0, 29, 40, 41, 0, 0, 42, 0, 0, - 0, 31, 25, 0, 26, 0, 0, 27, 33, 0, - 0, 0, 28, 34, 0, 0, 29, 35, 0, 0, - 0, 0, 0, 0, 0, 31, 0, 0, 0, 37, - 0, 38, 33, 0, 0, 39, 0, 34, 0, 0, - 0, 35, 0, 40, 41, 0, 0, 42, 0, 0, - 317, 0, 0, 37, 0, 38, 25, 349, 26, 39, - 0, 27, 0, 0, 0, 0, 28, 40, 41, 0, - 29, 42, 0, 25, 317, 26, 0, 0, 27, 31, - 0, 43, 0, 28, 0, 0, 33, 29, 0, 0, - 0, 34, 0, 0, 0, 35, 31, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 37, 34, 38, - 0, 0, 35, 39, 0, 0, 0, 0, 0, 0, - 0, 40, 41, 0, 37, 42, 38, 25, 506, 26, - 39, 324, 27, 0, 0, 0, 0, 28, 40, 41, - 0, 29, 42, 0, 0, 317, 0, 0, 0, 0, - 31, 25, 0, 26, 0, 349, 27, 33, 0, 0, - 0, 28, 34, 0, 0, 29, 35, 0, 0, 0, - 0, 0, 0, 0, 31, 0, 0, 0, 37, 0, - 38, 33, 0, 0, 39, 0, 34, 0, 0, 0, - 35, 0, 40, 41, 0, 0, 42, 0, 0, 317, - 0, 25, 37, 26, 38, 0, 27, 0, 39, 349, - 0, 28, 0, 0, 0, 29, 40, 41, 0, 0, - 42, 0, 0, 558, 31, 497, 622, 497, 0, 0, - 497, 33, 0, 0, 0, 497, 34, 0, 0, 497, - 35, 0, 0, 0, 0, 0, 0, 0, 497, 0, - 0, 0, 37, 0, 38, 497, 0, 0, 39, 0, - 497, 0, 0, 0, 497, 0, 40, 41, 0, 0, - 42, 0, 0, 731, 0, 0, 497, 0, 497, 187, - 624, 187, 497, 0, 187, 0, 0, 0, 0, 187, - 497, 497, 0, 187, 497, 0, 186, 497, 186, 0, - 0, 186, 187, 0, 349, 0, 186, 0, 0, 187, - 186, 0, 0, 0, 187, 0, 0, 0, 187, 186, - 0, 0, 0, 0, 0, 0, 186, 0, 0, 0, - 187, 186, 187, 0, 0, 186, 187, 0, 0, 0, - 0, 0, 0, 0, 187, 187, 0, 186, 187, 186, - 196, 187, 196, 186, 349, 196, 0, 0, 0, 0, - 196, 186, 186, 0, 196, 186, 0, 0, 186, 0, - 0, 0, 0, 196, 0, 0, 0, 0, 497, 0, - 196, 0, 0, 0, 0, 196, 0, 0, 35, 196, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, - 0, 196, 0, 196, 35, 0, 0, 196, 35, 0, - 0, 35, 0, 0, 0, 196, 196, 0, 0, 196, - 0, 0, 196, 35, 35, 0, 0, 0, 35, 35, - 0, 0, 187, 0, 35, 0, 35, 35, 35, 35, - 0, 0, 0, 0, 35, 0, 0, 0, 35, 186, - 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 35, 0, 35, 35, 33, 35, 0, 0, 0, 35, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 33, 0, 0, 0, 33, 0, 0, 33, 0, 35, - 0, 0, 0, 0, 0, 35, 35, 0, 0, 33, - 33, 0, 0, 196, 33, 33, 28, 0, 28, 0, - 33, 0, 33, 33, 33, 33, 0, 0, 0, 0, - 33, 0, 0, 0, 33, 0, 33, 0, 0, 28, - 0, 0, 0, 0, 0, 0, 33, 0, 0, 33, - 0, 33, 28, 0, 0, 33, 0, 28, 0, 0, - 0, 0, 28, 0, 28, 28, 28, 28, 0, 0, - 0, 0, 28, 0, 0, 33, 28, 0, 0, 48, - 0, 33, 33, 0, 0, 0, 0, 0, 28, 0, - 48, 28, 0, 28, 0, 48, 0, 0, 0, 48, - 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 48, 48, 0, 28, 0, 48, - 48, 0, 48, 28, 28, 48, 0, 48, 48, 48, - 48, 0, 0, 48, 0, 48, 0, 0, 48, 48, - 0, 48, 48, 0, 0, 48, 0, 0, 0, 0, - 0, 48, 0, 0, 48, 0, 48, 48, 48, 0, - 48, 0, 48, 48, 48, 0, 0, 0, 48, 0, - 48, 48, 48, 48, 0, 0, 0, 0, 48, 0, - 48, 0, 48, 0, 48, 0, 37, 48, 0, 0, - 0, 0, 0, 0, 48, 0, 0, 48, 0, 48, - 48, 0, 48, 48, 0, 48, 0, 0, 0, 0, - 48, 0, 48, 48, 48, 48, 0, 0, 0, 0, - 48, 0, 0, 48, 48, 48, 0, 0, 0, 38, - 0, 0, 0, 0, 0, 0, 48, 0, 48, 48, - 48, 48, 48, 48, 0, 0, 0, 0, 48, 0, - 48, 48, 48, 48, 0, 0, 0, 0, 48, 0, - 0, 0, 48, 48, 0, 48, 0, 48, 48, 0, - 0, 208, 0, 0, 48, 0, 48, 48, 48, 48, - 0, 48, 0, 0, 0, 0, 48, 0, 48, 48, - 48, 48, 0, 0, 0, 0, 48, 0, 0, 0, - 48, 48, 0, 48, 0, 48, 48, 0, 48, 210, - 48, 0, 48, 0, 48, 48, 0, 48, 0, 48, - 0, 0, 0, 0, 48, 0, 48, 48, 48, 48, - 0, 48, 0, 0, 48, 0, 0, 0, 48, 0, - 0, 48, 0, 0, 48, 0, 0, 311, 442, 48, - 48, 0, 0, 48, 48, 48, 48, 48, 48, 48, - 0, 0, 48, 0, 48, 0, 0, 0, 48, 0, - 0, 443, 0, 0, 0, 0, 0, 0, 442, 48, - 48, 48, 48, 48, 444, 48, 0, 0, 445, 446, - 0, 0, 0, 0, 447, 0, 448, 449, 450, 451, - 0, 443, 0, 0, 452, 0, 0, 0, 453, 48, - 0, 0, 0, 0, 444, 0, 0, 0, 0, 446, - 454, 0, 0, 455, 447, 456, 448, 449, 450, 451, - 0, 0, 0, 0, 452, 0, 0, 0, 453, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 457, - 454, 0, 0, 455, 0, 456, 0, 0, 0, 0, + 459, 0, 0, 460, 0, 461, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 457, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 462, }; protected static readonly short [] yyCheck = { 17, - 17, 4, 17, 17, 298, 297, 6, 502, 18, 52, - 504, 190, 20, 88, 89, 289, 459, 234, 189, 249, - 60, 541, 85, 158, 330, 326, 296, 60, 478, 316, - 294, 551, 892, 108, 1060, 348, 722, 561, 697, 698, - 78, 17, 0, 17, 59, 236, 348, 294, 268, 112, - 106, 114, 322, 112, 60, 114, 74, 256, 256, 256, - 78, 1096, 1097, 256, 268, 80, 256, 82, 256, 256, - 17, 256, 372, 256, 17, 256, 256, 95, 48, 335, - 268, 740, 256, 742, 368, 368, 1180, 93, 294, 368, - 343, 97, 98, 99, 100, 101, 102, 103, 104, 256, - 256, 282, 1196, 256, 256, 376, 17, 1142, 268, 256, - 256, 374, 1209, 60, 256, 256, 276, 64, 642, 264, - 370, 371, 17, 1055, 374, 368, 201, 202, 381, 429, - 360, 17, 402, 314, 257, 17, 17, 17, 391, 418, - 158, 158, 1239, 158, 158, 429, 429, 190, 368, 339, - 17, 358, 339, 416, 344, 256, 346, 344, 429, 346, - 17, 414, 352, 353, 325, 352, 353, 6, 367, 294, - 367, 418, 369, 429, 371, 428, 256, 376, 17, 257, - 325, 306, 158, 381, 158, 391, 429, 262, 381, 374, - 62, 234, 375, 339, 66, 67, 68, 498, 70, 71, - 0, 257, 422, 75, 76, 699, 423, 256, 414, 501, - 82, 158, 84, 288, 86, 158, 518, 358, 422, 91, - 92, 60, 369, 420, 294, 64, 423, 335, 370, 304, - 230, 249, 374, 424, 422, 541, 254, 418, 418, 429, - 341, 113, 429, 299, 418, 551, 286, 158, 325, 88, - 89, 0, 315, 286, 294, 225, 319, 418, 418, 561, - 323, 418, 418, 158, 323, 418, 418, 294, 369, 108, - 345, 289, 158, 1367, 292, 293, 158, 158, 158, 312, - 286, 256, 263, 424, 425, 426, 427, 305, 294, 369, - 341, 158, 310, 418, 312, 351, 311, 956, 316, 257, - 1394, 158, 256, 341, 379, 380, 294, 831, 994, 327, - 328, 418, 1406, 330, 1408, 256, 330, 414, 369, 158, - 369, 391, 256, 341, 349, 350, 305, 368, 256, 269, - 643, 428, 407, 408, 315, 1361, 372, 20, 374, 286, - 642, 418, 360, 361, 414, 305, 286, 365, 366, 367, - 368, 369, 370, 371, 372, 373, 374, 375, 364, 262, - 1141, 663, 201, 202, 391, 312, 871, 263, 862, 1301, - 376, 377, 378, 429, 368, 381, 382, 277, 1159, 397, - 423, 281, 343, 330, 256, 368, 258, 414, 429, 1249, - 433, 841, 1427, 429, 369, 298, 1328, 1329, 685, 1331, - 349, 350, 256, 391, 429, 88, 89, 463, 464, 1444, - 1342, 339, 1071, 1345, 1346, 306, 370, 425, 372, 315, - 374, 372, 313, 262, 296, 108, 414, 368, 1360, 1210, - 391, 439, 488, 374, 368, 429, 308, 701, 369, 367, - 374, 671, 342, 1102, 1103, 478, 429, 286, 372, 288, - 1109, 764, 371, 414, 948, 1396, 1397, 257, 473, 298, - 430, 431, 764, 372, 418, 304, 436, 428, 372, 974, - 374, 976, 272, 312, 357, 378, 379, 277, 429, 1260, - 429, 281, 500, 1264, 502, 339, 504, 349, 350, 376, - 367, 330, 376, 949, 371, 371, 296, 373, 369, 514, - 515, 1164, 373, 386, 272, 429, 345, 256, 526, 348, - 518, 1452, 568, 367, 570, 533, 572, 830, 201, 202, - 429, 977, 850, 323, 541, 429, 343, 541, 296, 831, - 371, 478, 373, 861, 551, 550, 828, 551, 1164, 256, - 379, 380, 342, 420, 1207, 429, 1209, 256, 343, 272, - 371, 781, 423, 840, 855, 323, 574, 575, 375, 266, - 566, 272, 1163, 1164, 381, 1021, 277, 429, 407, 408, - 281, 1164, 1022, 296, 391, 710, 1239, 272, 634, 262, - 375, 1207, 1183, 1209, 368, 296, 1106, 391, 21, 859, - 339, 256, 256, 367, 541, 369, 391, 414, 892, 420, - 323, 296, 474, 621, 551, 288, 1207, 314, 1209, 627, - 414, 428, 323, 1239, 1207, 298, 1209, 369, 367, 414, - 53, 304, 371, 376, 373, 374, 375, 376, 323, 372, - 339, 342, 381, 428, 418, 344, 343, 346, 1239, 478, - 305, 305, 514, 352, 353, 1164, 1239, 374, 1164, 705, - 367, 726, 369, 671, 371, 372, 369, 374, 376, 376, - 414, 701, 345, 367, 664, 348, 418, 685, 375, 371, - 733, 391, 747, 965, 428, 418, 694, 418, 371, 518, - 373, 699, 394, 395, 391, 760, 704, 917, 1207, 416, - 1209, 1207, 1164, 1209, 414, 701, 379, 380, 1164, 392, - 393, 418, 541, 420, 339, 418, 423, 414, 428, 344, - 1164, 346, 551, 728, 349, 350, 256, 352, 353, 412, - 1239, 428, 561, 1239, 407, 408, 744, 420, 746, 269, - 423, 357, 368, 339, 418, 1207, 357, 1209, 374, 374, - 758, 1207, 425, 1209, 428, 381, 286, 373, 369, 381, - 697, 698, 373, 1207, 1028, 1209, 439, 832, 776, 391, - 386, 367, 805, 781, 782, 386, 784, 1239, 1060, 1075, - 376, 418, 357, 1239, 256, 357, 381, 795, 796, 398, - 399, 428, 414, 357, 391, 1239, 391, 369, 373, 1063, - 372, 373, 374, 740, 429, 742, 428, 418, 370, 373, - 1106, 386, 374, 642, 386, 813, 339, 414, 826, 414, - 828, 344, 386, 346, 421, 871, 349, 350, 818, 352, - 353, 992, 840, 1053, 663, 843, 1100, 372, 367, 374, - 1136, 376, 850, 306, 357, 518, 418, 376, 1281, 401, - 313, 374, 860, 364, 862, 367, 369, 922, 386, 372, - 373, 413, 325, 373, 376, 1349, 376, 339, 697, 698, - 381, 382, 344, 386, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 367, 1268, 373, 561, 294, - 376, 899, 1274, 901, 376, 903, 368, 726, 370, 1281, - 372, 306, 374, 375, 376, 367, 429, 1171, 1115, 917, - 339, 740, 414, 742, 376, 344, 914, 346, 747, 421, - 349, 350, 1091, 352, 353, 369, 1218, 1411, 974, 369, - 367, 760, 372, 1225, 924, 764, 926, 381, 928, 376, - 948, 339, 372, 306, 374, 308, 344, 256, 346, 995, - 313, 349, 350, 379, 352, 353, 265, 429, 267, 367, - 384, 270, 325, 1447, 367, 1249, 275, 389, 376, 642, - 279, 370, 372, 376, 979, 374, 376, 370, 986, 288, - 988, 374, 990, 1468, 1469, 374, 295, 376, 385, 370, - 663, 300, 381, 374, 370, 304, 382, 383, 374, 400, - 429, 370, 831, 832, 372, 374, 374, 316, 1001, 318, - 396, 397, 372, 322, 374, 374, 376, 376, 390, 956, - 1028, 330, 331, 256, 370, 334, 372, 374, 337, 376, - 418, 429, 1040, 1041, 373, 370, 339, 372, 0, 374, - 1048, 344, 370, 346, 372, 1053, 349, 350, 369, 352, - 353, 376, 1060, 726, 1054, 1063, 418, 370, 1091, 372, - 1093, 374, 339, 892, 386, 387, 388, 344, 1075, 346, - 370, 1075, 372, 1081, 747, 352, 353, 414, 415, 1361, - 1088, 370, 1115, 372, 371, 370, 371, 760, 373, 374, - 375, 764, 1100, 922, 367, 256, 415, 1162, 371, 1106, - 373, 374, 1106, 376, 1112, 1113, 339, 418, 381, 418, - 256, 344, 1145, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 354, 355, 429, 956, 418, 1136, - 1163, 1164, 1136, 340, 1071, 368, 418, 370, 1075, 372, - 813, 374, 375, 376, 376, 1153, 385, 386, 387, 388, - 1183, 372, 1217, 374, 372, 418, 374, 390, 831, 832, - 370, 1169, 372, 1171, 376, 1102, 1103, 400, 401, 1106, - 373, 370, 1109, 372, 1207, 367, 1209, 374, 339, 376, - 413, 1246, 1247, 344, 418, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, 429, 376, 374, 1136, - 376, 374, 374, 376, 376, 1270, 1239, 368, 1273, 370, - 376, 372, 376, 374, 375, 376, 1221, 364, 365, 892, - 372, 97, 98, 99, 100, 101, 102, 103, 104, 390, - 414, 368, 1278, 418, 371, 418, 373, 374, 418, 400, - 401, 914, 1071, 418, 367, 1291, 1075, 369, 371, 922, - 373, 374, 413, 376, 372, 392, 393, 372, 381, 354, - 355, 418, 1308, 376, 1310, 1094, 372, 373, 429, 349, - 350, 364, 365, 1102, 1103, 412, 372, 1106, 1058, 1059, - 1109, 1286, 372, 420, 367, 418, 423, 368, 371, 374, - 373, 374, 415, 376, 372, 257, 383, 384, 381, 261, - 389, 390, 372, 372, 372, 372, 1339, 1136, 294, 294, - 272, 374, 372, 372, 376, 277, 418, 1146, 374, 281, - 372, 371, 284, 1356, 256, 374, 418, 0, 375, 356, - 418, 372, 415, 1162, 296, 297, 1369, 1370, 381, 301, - 302, 1349, 1347, 374, 374, 307, 375, 309, 310, 311, - 312, 373, 418, 1361, 372, 317, 381, 374, 374, 321, - 374, 323, 374, 1396, 1397, 418, 376, 294, 429, 423, - 1378, 333, 372, 335, 336, 374, 338, 367, 418, 372, - 342, 373, 418, 343, 294, 374, 294, 374, 1217, 1218, - 418, 370, 418, 371, 418, 367, 1225, 256, 375, 256, - 362, 381, 256, 1411, 374, 256, 368, 369, 372, 372, - 368, 280, 381, 371, 256, 373, 374, 1246, 1247, 1452, - 1249, 1094, 402, 403, 404, 405, 406, 407, 408, 409, - 410, 411, 367, 372, 392, 393, 418, 368, 376, 1447, - 370, 1270, 418, 256, 1273, 418, 371, 418, 1453, 1454, - 326, 418, 376, 374, 412, 1460, 1461, 374, 376, 370, - 1468, 1469, 420, 376, 421, 423, 372, 372, 423, 381, - 347, 351, 367, 1146, 381, 256, 256, 381, 372, 368, - 372, 347, 370, 374, 370, 375, 367, 372, 364, 1162, - 372, 375, 370, 348, 368, 0, 418, 376, 418, 374, - 376, 377, 378, 374, 339, 381, 382, 383, 384, 385, - 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, - 396, 348, 368, 375, 367, 381, 339, 367, 367, 376, - 368, 344, 356, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 1217, 1218, 371, 368, 374, 368, - 418, 368, 1225, 337, 372, 368, 305, 370, 418, 372, - 418, 374, 375, 376, 371, 418, 371, 369, 418, 367, - 418, 371, 376, 1246, 1247, 371, 1249, 390, 371, 371, - 381, 371, 1255, 256, 373, 367, 371, 381, 261, 262, - 369, 374, 256, 370, 372, 1268, 372, 1270, 373, 373, - 1273, 1274, 374, 374, 374, 372, 418, 376, 1281, 372, - 418, 284, 376, 372, 376, 418, 429, 372, 376, 418, - 372, 294, 498, 367, 297, 298, 372, 381, 368, 302, - 381, 370, 305, 368, 307, 315, 309, 310, 311, 312, - 263, 371, 371, 368, 317, 372, 372, 0, 321, 0, - 367, 372, 325, 376, 376, 368, 0, 418, 376, 368, - 333, 372, 0, 336, 372, 338, 339, 370, 418, 367, - 376, 344, 368, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 368, 372, 376, 370, 367, 362, - 566, 376, 368, 368, 367, 368, 368, 370, 371, 372, - 373, 374, 375, 376, 418, 378, 379, 376, 381, 382, - 383, 384, 385, 386, 387, 388, 389, 390, 418, 392, - 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, - 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, - 413, 372, 376, 416, 372, 418, 372, 420, 367, 376, - 423, 256, 257, 368, 368, 367, 429, 373, 376, 264, - 265, 266, 267, 268, 315, 270, 271, 376, 273, 274, - 275, 276, 277, 278, 279, 280, 376, 376, 376, 376, - 285, 376, 287, 288, 289, 290, 291, 292, 376, 263, - 295, 0, 51, 12, 299, 300, 52, 302, 303, 304, - 5, 1053, 914, 1053, 813, 1183, 1239, 1401, 1364, 314, - 1417, 316, 1352, 318, 319, 1381, 1347, 322, 663, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 834, 337, 834, 1255, 340, 341, 834, 1461, 344, - 345, 677, 830, 1268, 1287, 1195, 1207, 1455, 1374, 1370, - 1369, 1454, 1145, 1310, 359, 360, 361, 805, 363, 1255, - 518, 855, 367, 368, 360, 1146, 371, 704, 575, 72, - 701, 376, 377, 378, 379, 380, 776, 93, 781, 384, - 671, 386, 391, 965, 392, 395, 393, 392, 393, 1129, - 394, 764, 1136, 396, 1217, 979, 158, 1075, 1041, 950, - 935, 897, 1031, 1033, 415, 1022, 516, 875, 1213, 1113, - 811, 810, 417, 418, 419, 420, -1, 422, 256, 257, - -1, -1, -1, -1, 429, -1, 264, 265, 266, 267, - 268, -1, 270, 271, -1, 273, 274, 275, 276, 277, - 278, 279, -1, -1, 0, -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, 855, - 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, + 17, 4, 507, 17, 20, 299, 6, 18, 300, 52, + 235, 191, 353, 20, 291, 107, 509, 464, 85, 250, + 190, 60, 549, 298, 159, 483, 296, 335, 17, 328, + 318, 353, 559, 48, 60, 730, 1076, 705, 706, 1113, + 1114, 0, 906, 237, 0, 59, 113, 569, 115, 324, + 759, 78, 256, 113, 256, 115, 74, 256, 256, 256, + 78, 256, 1181, 256, 268, 1197, 80, 256, 82, 256, + 256, 256, 88, 89, 256, 325, 268, 368, 96, 368, + 748, 1213, 750, 282, 17, 1159, 368, 374, 294, 268, + 376, 256, 268, 109, 339, 1285, 357, 335, 256, 306, + 276, 391, 17, 21, 367, 1224, 313, 1226, 1298, 1226, + 368, 367, 373, 376, 277, 314, 374, 17, 325, 257, + 376, 17, 367, 381, 414, 386, 1316, 418, 650, 416, + 17, 376, 407, 17, 365, 53, 1071, 1256, 17, 1256, + 429, 159, 159, 429, 339, 159, 294, 429, 191, 344, + 256, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 266, 17, 17, 17, 17, 259, 418, 256, + 159, 294, 370, 368, 372, 370, 374, 372, 256, 374, + 375, 376, 523, 306, 370, 391, 202, 203, 374, 368, + 256, 429, 235, 62, 381, 390, 381, 66, 67, 68, + 358, 70, 71, 428, 503, 546, 75, 76, 414, 301, + 314, 226, 506, 82, 707, 84, 418, 86, 422, 418, + 418, 418, 91, 92, 546, 418, 159, 0, 569, 418, + 422, 231, 250, 339, 429, 429, 418, 255, 344, 343, + 346, 549, 418, 422, 159, 114, 352, 353, 264, 288, + 317, 559, 1384, 418, 321, 418, 419, 296, 325, 159, + 88, 89, 288, 159, 356, 325, 424, 425, 426, 427, + 418, 375, 159, 291, 290, 159, 294, 295, 325, 1411, + 159, 109, 369, 264, 300, 994, 256, 391, 314, 307, + 306, 1423, 294, 1425, 312, 418, 314, 375, 257, 313, + 318, 257, 970, 369, 256, 159, 159, 159, 159, 650, + 414, 329, 330, 256, 1009, 372, 272, 256, 335, 346, + 842, 277, 256, 429, 428, 281, 256, 262, 346, 651, + 671, 1158, 256, 418, 350, 372, 372, 353, 1378, 358, + 296, 371, 434, 428, 325, 1054, 335, 365, 366, 1176, + 256, 372, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 380, 298, 256, 256, 882, 323, 384, 385, + 1444, 418, 429, 294, 202, 203, 468, 469, 335, 256, + 873, 349, 350, 1318, 402, 428, 342, 963, 257, 391, + 420, 260, 429, 429, 852, 438, 412, 413, 368, 1473, + 1227, 493, 1266, 305, 374, 693, 294, 341, 429, 339, + 1345, 1346, 414, 1348, 430, 991, 368, 1413, 1414, 1087, + 435, 436, 374, 430, 1359, 256, 441, 1362, 444, 298, + 369, 374, 368, 339, 775, 369, 264, 444, 344, 709, + 346, 310, 1377, 378, 379, 369, 352, 353, 679, 376, + 1277, 1119, 1120, 775, 1281, 369, 6, 483, 1126, 373, + 1036, 429, 290, 371, 478, 373, 1401, 17, 341, 962, + 391, 256, 988, 1469, 990, 367, 367, 369, 306, 371, + 256, 263, 418, 256, 576, 376, 578, 505, 580, 507, + 367, 509, 369, 414, 371, 372, 369, 374, 372, 376, + 374, 842, 429, 391, 257, 519, 520, 523, 339, 423, + 60, 277, 368, 531, 64, 281, 523, 349, 350, 841, + 538, 418, 350, 429, 349, 350, 414, 305, 420, 305, + 546, 423, 549, 315, 17, 269, 367, 401, 88, 89, + 861, 418, 559, 420, 558, 839, 423, 263, 256, 413, + 642, 872, 286, 569, 339, 429, 384, 385, 368, 109, + 549, 792, 1181, 851, 582, 583, 339, 866, 368, 368, + 559, 256, 373, 429, 369, 376, 342, 60, 343, 1037, + 343, 64, 367, 718, 412, 413, 98, 99, 100, 101, + 102, 103, 104, 105, 367, 870, 1123, 429, 371, 315, + 373, 374, 375, 376, 429, 1224, 343, 1226, 381, 159, + 479, 629, 375, 256, 906, 374, 381, 635, 381, 429, + 305, 713, 372, 418, 374, 372, 391, 369, 391, 429, + 429, 339, 272, 376, 650, 272, 344, 1256, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 414, + 519, 414, 202, 203, 391, 671, 296, 416, 357, 296, + 368, 679, 370, 428, 372, 428, 374, 375, 376, 376, + 709, 418, 672, 272, 741, 693, 159, 414, 277, 429, + 418, 369, 281, 323, 702, 979, 323, 386, 414, 707, + 428, 428, 1181, 376, 712, 370, 339, 296, 371, 374, + 931, 344, 428, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 264, 386, 256, 367, 734, 367, + 1181, 429, 736, 371, 323, 368, 376, 370, 272, 372, + 418, 374, 375, 376, 752, 1224, 754, 1226, 288, 755, + 290, 384, 385, 342, 758, 759, 389, 390, 1180, 1181, + 300, 769, 296, 1181, 367, 771, 306, 400, 401, 775, + 371, 343, 414, 1224, 314, 1226, 1043, 1256, 1200, 787, + 413, 256, 420, 816, 792, 793, 428, 795, 367, 323, + 418, 381, 1076, 1091, 269, 335, 429, 376, 806, 807, + 882, 391, 1224, 375, 1226, 1256, 1224, 381, 1226, 339, + 350, 286, 1079, 353, 344, 288, 346, 391, 824, 391, + 294, 367, 352, 353, 414, 1123, 328, 824, 391, 837, + 376, 839, 306, 1181, 1256, 379, 842, 843, 1256, 829, + 414, 314, 414, 851, 384, 385, 854, 1007, 1069, 384, + 1117, 414, 369, 861, 428, 1153, 428, 306, 421, 369, + 389, 1298, 335, 871, 313, 873, 367, 369, 367, 386, + 387, 381, 412, 413, 385, 376, 1224, 376, 1226, 381, + 382, 383, 1181, 1366, 386, 387, 388, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, + 906, 394, 395, 357, 1235, 913, 988, 915, 1256, 917, + 261, 1242, 391, 357, 400, 369, 734, 1132, 372, 373, + 374, 1188, 928, 931, 371, 1224, 373, 1226, 1010, 373, + 936, 928, 386, 284, 374, 414, 376, 755, 1108, 357, + 370, 381, 386, 483, 374, 1428, 297, 390, 938, 428, + 940, 302, 942, 771, 962, 373, 307, 1256, 309, 310, + 311, 312, 339, 367, 418, 369, 317, 344, 386, 346, + 321, 1181, 349, 350, 325, 352, 353, 373, 369, 414, + 376, 1464, 333, 523, 1266, 336, 421, 338, 373, 339, + 994, 1486, 1487, 1001, 344, 1003, 346, 1005, 418, 349, + 350, 503, 352, 353, 398, 399, 546, 382, 383, 549, + 483, 362, 376, 372, 1224, 374, 1226, 376, 372, 559, + 374, 396, 397, 1016, 374, 843, 306, 339, 308, 569, + 354, 355, 344, 313, 346, 1043, 369, 349, 350, 372, + 352, 353, 418, 370, 371, 325, 1256, 374, 1056, 1057, + 1054, 372, 429, 374, 371, 376, 1064, 415, 357, 370, + 370, 1069, 374, 374, 374, 354, 355, 418, 1076, 1070, + 369, 1079, 574, 418, 373, 1108, 549, 1110, 339, 429, + 386, 387, 388, 344, 1091, 346, 559, 386, 349, 350, + 1098, 352, 353, 339, 1378, 256, 60, 1105, 344, 1132, + 346, 414, 415, 349, 350, 1111, 352, 353, 368, 1117, + 650, 371, 1091, 373, 374, 418, 1123, 429, 936, 418, + 277, 1129, 1130, 370, 371, 418, 373, 374, 375, 1162, + 94, 671, 392, 393, 98, 99, 100, 101, 102, 103, + 104, 105, 376, 372, 1123, 374, 1153, 1180, 1181, 370, + 340, 372, 412, 374, 370, 367, 372, 1163, 374, 0, + 420, 376, 1170, 423, 373, 705, 706, 1200, 429, 374, + 357, 376, 370, 1179, 1153, 371, 374, 373, 1186, 370, + 1188, 372, 369, 429, 370, 372, 373, 370, 374, 372, + 374, 1224, 376, 1226, 734, 368, 392, 393, 371, 386, + 373, 374, 372, 370, 339, 372, 376, 376, 748, 344, + 750, 346, 370, 1295, 372, 755, 412, 352, 353, 392, + 393, 364, 365, 1256, 420, 376, 1308, 423, 1234, 1235, + 418, 771, 705, 706, 1238, 775, 1242, 418, 372, 412, + 374, 372, 367, 1325, 343, 1327, 371, 420, 373, 374, + 423, 376, 372, 256, 374, 376, 381, 1263, 1264, 370, + 1266, 372, 414, 370, 367, 372, 1272, 372, 371, 418, + 373, 374, 374, 376, 376, 748, 418, 750, 381, 1285, + 418, 1287, 367, 374, 1290, 376, 371, 369, 373, 374, + 415, 376, 1298, 374, 418, 376, 381, 349, 350, 1303, + 285, 372, 842, 843, 390, 391, 392, 393, 418, 374, + 1316, 376, 415, 372, 373, 364, 365, 1074, 1075, 388, + 389, 394, 395, 1356, 288, 376, 372, 372, 368, 372, + 374, 372, 296, 372, 372, 418, 339, 372, 294, 294, + 1373, 344, 327, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 1386, 1387, 374, 372, 372, 1366, 376, + 1364, 1179, 418, 374, 866, 368, 906, 370, 372, 372, + 1378, 374, 375, 376, 371, 256, 374, 356, 372, 375, + 1413, 1414, 418, 374, 418, 375, 381, 1395, 374, 373, + 418, 372, 377, 378, 379, 380, 936, 382, 383, 384, + 385, 386, 387, 388, 389, 369, 381, 392, 393, 394, + 395, 396, 397, 398, 399, 256, 1234, 381, 382, 383, + 1428, 262, 386, 387, 374, 374, 429, 374, 376, 418, + 970, 0, 374, 294, 372, 423, 1469, 429, 374, 367, + 418, 372, 418, 373, 343, 1263, 1264, 372, 374, 294, + 294, 374, 418, 294, 370, 418, 1464, 298, 371, 381, + 418, 367, 256, 375, 256, 374, 1470, 1471, 256, 1287, + 256, 372, 1290, 1477, 1478, 372, 381, 280, 1486, 1487, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, + 256, 367, 372, 368, 418, 343, 374, 970, 339, 418, + 418, 418, 376, 344, 370, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 371, 376, 418, 376, + 374, 372, 372, 376, 370, 421, 367, 368, 423, 370, + 371, 372, 381, 374, 375, 376, 347, 378, 379, 351, + 367, 382, 383, 384, 385, 381, 381, 1087, 389, 390, + 256, 1091, 256, 394, 395, 396, 397, 398, 399, 400, + 401, 368, 372, 372, 347, 370, 374, 367, 370, 375, + 348, 1111, 413, 372, 375, 416, 372, 418, 368, 1119, + 1120, 370, 339, 1123, 418, 418, 1126, 374, 429, 256, + 374, 376, 348, 368, 375, 367, 367, 367, 265, 0, + 267, 368, 381, 270, 356, 418, 371, 376, 275, 368, + 574, 374, 279, 1153, 1087, 368, 337, 372, 1091, 368, + 305, 288, 376, 1163, 371, 418, 371, 418, 295, 369, + 367, 381, 371, 300, 367, 371, 418, 304, 418, 1179, + 371, 418, 371, 373, 371, 369, 1119, 1120, 371, 316, + 1123, 318, 372, 1126, 372, 322, 381, 374, 373, 373, + 261, 374, 263, 330, 331, 374, 256, 334, 376, 374, + 337, 372, 418, 372, 370, 418, 376, 418, 376, 372, + 1153, 376, 372, 284, 418, 367, 372, 256, 368, 381, + 381, 370, 261, 262, 1234, 1235, 297, 372, 368, 315, + 263, 302, 1242, 371, 368, 371, 307, 372, 309, 310, + 311, 312, 372, 0, 315, 284, 317, 0, 367, 376, + 321, 418, 376, 1263, 1264, 294, 1266, 368, 297, 298, + 372, 0, 333, 302, 368, 336, 305, 338, 307, 376, + 309, 310, 311, 312, 372, 709, 372, 1287, 317, 418, + 1290, 418, 321, 370, 367, 376, 325, 368, 368, 367, + 372, 362, 376, 370, 333, 418, 0, 336, 418, 338, + 339, 376, 376, 368, 372, 344, 376, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 372, 368, + 372, 368, 372, 362, 367, 376, 368, 368, 367, 368, + 367, 370, 371, 372, 373, 374, 375, 376, 373, 378, + 379, 315, 381, 382, 383, 384, 385, 386, 387, 388, + 389, 390, 376, 392, 393, 394, 395, 396, 397, 398, + 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, + 409, 410, 411, 412, 413, 376, 376, 416, 376, 418, + 376, 420, 376, 376, 423, 256, 257, 376, 263, 51, + 429, 52, 12, 264, 265, 266, 267, 268, 5, 270, + 271, 928, 273, 274, 275, 276, 277, 278, 279, 280, + 824, 1200, 1256, 1381, 285, 1418, 287, 288, 289, 290, + 291, 292, 1069, 1069, 295, 0, 1434, 671, 299, 300, + 1369, 302, 303, 304, 1398, 1364, 1272, 1285, 845, 685, + 845, 845, 841, 314, 1478, 316, 1224, 318, 319, 1472, + 1304, 322, 1212, 324, 325, 326, 327, 328, 329, 330, + 331, 332, 333, 334, 335, 1391, 337, 1387, 1386, 340, + 341, 1327, 1162, 344, 345, 1471, 1272, 816, 523, 1163, + 712, 866, 792, 583, 365, 787, 979, 679, 359, 360, + 361, 362, 363, 72, 331, 709, 367, 368, 94, 396, + 371, 397, 400, 398, 1146, 376, 377, 378, 379, 380, + 399, 401, 546, 384, 1234, 386, 159, 1153, 949, 1057, + 1091, 392, 393, 964, 1048, 1037, 1046, 911, 886, 521, + 1230, 1130, 775, 420, 822, 821, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 417, 418, 419, 420, + -1, 422, 256, 257, -1, -1, -1, -1, 429, -1, + 264, 265, 266, 267, 268, -1, 270, 271, -1, 273, + 274, 275, 276, 277, 278, 279, -1, -1, 0, -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, 359, 360, 361, 362, 363, + -1, -1, -1, 367, 368, -1, -1, 371, -1, -1, + -1, -1, 376, 377, 378, 379, 380, -1, -1, -1, + 384, 256, 386, -1, -1, -1, 261, 262, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 359, 360, 361, -1, 363, -1, -1, -1, 367, - 368, -1, -1, 371, -1, -1, -1, -1, 376, 377, - 378, 379, 380, -1, -1, -1, 384, 256, 386, -1, - -1, -1, 261, 262, 392, 393, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0, 284, + -1, -1, -1, 417, 418, 419, 420, -1, 422, 294, + -1, -1, 297, 298, -1, 429, -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, -1, -1, -1, 362, -1, -1, + -1, -1, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, -1, 378, 379, -1, -1, 382, 383, 384, + 385, 386, -1, -1, 389, 390, -1, -1, -1, 394, + 395, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, -1, -1, 256, -1, -1, -1, 413, 261, + 262, 416, -1, 418, -1, 420, -1, -1, 423, -1, + -1, -1, -1, -1, 429, 0, -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, -1, -1, -1, + 362, -1, -1, -1, -1, 367, 368, 369, 370, 371, + 372, -1, 374, 375, 376, -1, 378, 379, -1, -1, + 382, 383, 384, 385, 256, -1, -1, 389, 390, 261, + 262, -1, 394, 395, 396, 397, 398, 399, 400, 401, + 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 413, 284, -1, 416, -1, 418, -1, 420, -1, + -1, 423, 294, -1, -1, 297, 298, 429, -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, -1, -1, -1, + 362, -1, -1, -1, -1, 367, 368, 369, 370, 371, + 372, -1, 374, 375, 376, -1, 378, 379, -1, -1, + 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, + -1, -1, 394, 395, 396, 397, 398, 399, 400, 401, + -1, 256, -1, -1, -1, -1, 261, 262, -1, -1, + -1, 413, -1, -1, 416, -1, 418, -1, 420, -1, + -1, 423, -1, -1, -1, -1, -1, 429, -1, 284, + -1, -1, -1, -1, -1, 0, -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, -1, -1, -1, 362, -1, -1, + -1, -1, 367, 368, -1, 370, 371, 372, -1, 374, + 375, 376, -1, 378, 379, -1, 256, 382, 383, 384, + 385, -1, 262, -1, 389, 390, -1, -1, -1, 394, + 395, 396, 397, 398, 399, 400, 401, -1, 0, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 413, -1, + -1, 416, -1, 418, 294, -1, -1, -1, 298, -1, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, 284, -1, -1, -1, 417, - 418, 419, 420, -1, 422, 294, -1, -1, 297, 298, - -1, 429, -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, - -1, -1, -1, 362, -1, -1, -1, -1, 367, 368, - 369, 370, 371, 372, 373, 374, 375, 376, -1, 378, - 379, -1, -1, 382, 383, 384, 385, 386, -1, -1, - 389, 390, -1, -1, -1, 394, 395, 396, 397, 398, - 399, 400, 401, -1, -1, -1, -1, -1, -1, -1, - 256, -1, -1, -1, 413, 261, 262, 416, -1, 418, - -1, 420, -1, -1, 423, -1, -1, -1, -1, -1, - 429, 0, -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, -1, -1, -1, 362, -1, -1, -1, - -1, 367, 368, 369, 370, 371, 372, -1, 374, 375, - 376, -1, 378, 379, -1, -1, 382, 383, 384, 385, - 256, -1, -1, 389, 390, 261, 262, -1, 394, 395, - 396, 397, 398, 399, 400, 401, 0, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 413, 284, -1, - 416, -1, 418, -1, 420, -1, -1, 423, 294, -1, - -1, 297, 298, 429, -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, -1, -1, -1, 362, -1, -1, -1, - -1, 367, 368, 369, 370, 371, 372, -1, 374, 375, - 376, -1, 378, 379, -1, -1, 382, 383, 384, 385, - -1, -1, -1, 389, 390, -1, -1, -1, 394, 395, - 396, 397, 398, 399, 400, 401, -1, 256, -1, -1, - -1, -1, 261, 262, -1, -1, -1, 413, -1, -1, - 416, -1, 418, 0, 420, -1, -1, 423, -1, -1, - -1, -1, -1, 429, -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, 256, 344, -1, 346, 347, 348, - 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, - -1, -1, -1, 362, -1, -1, -1, -1, 367, 368, - -1, 370, 371, 372, -1, 374, 375, 376, -1, 378, - 379, -1, 256, 382, 383, 384, 385, -1, 262, -1, - 389, 390, -1, -1, -1, 394, 395, 396, 397, 398, - 399, 400, 401, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 413, -1, -1, 416, -1, 418, - 294, -1, -1, -1, 298, -1, -1, 339, -1, -1, - 429, 0, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 262, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, 339, -1, -1, -1, -1, - 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, -1, -1, -1, -1, -1, 298, - -1, -1, -1, 367, 368, 369, 370, 371, 372, 373, - 374, 375, 376, -1, 378, 379, -1, -1, 382, 383, - 384, 385, 386, -1, -1, 389, 390, 429, -1, -1, - 394, 395, 396, 397, 398, 399, 400, 401, -1, 256, - -1, -1, -1, -1, -1, 262, -1, -1, -1, 413, - -1, -1, 416, -1, 418, -1, 420, -1, -1, 423, - 0, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 371, 372, 373, 374, -1, 294, -1, 378, - 379, 298, -1, 382, 383, 384, 385, 386, 387, 388, - 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, - 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, - 409, 410, 411, 412, 413, -1, -1, -1, -1, -1, - -1, 420, 339, 0, 423, -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, 368, -1, 370, 371, 372, -1, 374, 375, 376, - -1, 378, 379, -1, -1, 382, 383, 384, 385, -1, - 0, -1, 389, 390, -1, -1, -1, 394, 395, 396, - 397, 398, 399, 400, 401, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 413, -1, 257, 416, - -1, 418, 261, -1, 263, -1, 265, -1, 267, -1, - -1, 270, 429, 272, 273, -1, 275, -1, 277, -1, - 279, -1, 281, 282, 283, 284, -1, -1, 287, 288, - -1, -1, -1, 0, 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, 0, 336, 337, 338, - -1, -1, -1, 342, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 339, + -1, 0, -1, -1, 344, -1, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 367, 368, 369, + 370, 371, 372, 373, 374, 375, 376, -1, 378, 379, + -1, -1, 382, 383, 384, 385, 386, -1, -1, 389, + 390, -1, -1, -1, 394, 395, 396, 397, 398, 399, + 400, 401, -1, -1, -1, -1, -1, -1, -1, -1, + 0, -1, -1, 413, -1, -1, 416, -1, 418, -1, + 420, -1, 257, 423, -1, -1, 261, -1, 263, 429, + 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, 0, 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, 362, -1, 364, 365, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 256, 257, 377, 0, - -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, 418, - 300, 301, 302, -1, 304, -1, -1, 307, -1, 309, - 310, 311, 312, -1, -1, -1, 316, 317, 318, -1, - 257, 321, 322, 323, 261, -1, 0, -1, -1, -1, - 330, 331, -1, 333, 334, 272, 336, 337, 338, -1, - 277, -1, 342, -1, 281, -1, -1, 284, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 296, - 297, -1, 362, -1, 301, 302, -1, 257, 368, 369, - 307, 261, 309, 310, 311, 312, -1, 377, -1, -1, - 317, -1, 272, -1, 321, -1, 323, 277, -1, 0, - -1, 281, -1, -1, 284, -1, 333, -1, 335, 336, - -1, 338, -1, -1, -1, 342, 296, 297, -1, -1, - -1, 301, 302, -1, -1, -1, -1, 307, 418, 309, - 310, 311, 312, -1, -1, 362, -1, 317, -1, -1, - 257, 321, 369, 323, 261, -1, 0, -1, -1, -1, - -1, -1, -1, 333, -1, 272, 336, -1, 338, -1, - 277, -1, 342, -1, 281, -1, -1, 284, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 296, - 297, -1, 362, 257, 301, 302, -1, 261, 368, 369, + 0, -1, -1, -1, -1, -1, -1, 362, -1, 364, + 365, -1, -1, -1, 256, 257, -1, -1, -1, 261, + -1, -1, 377, 265, -1, 267, -1, -1, 270, -1, + 272, 273, -1, 275, -1, 277, -1, 279, -1, 281, + 282, 283, 284, 0, -1, 287, 288, -1, -1, -1, + -1, 293, -1, 295, 296, 297, -1, -1, 300, 301, + 302, -1, 304, 418, -1, 307, -1, 309, 310, 311, + 312, -1, -1, -1, 316, 317, 318, -1, 257, 321, + 322, 323, 261, -1, -1, -1, 0, -1, 330, 331, + -1, 333, 334, 272, 336, 337, 338, -1, 277, -1, + 342, -1, 281, -1, -1, 284, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 296, 297, -1, + 362, -1, 301, 302, -1, -1, 368, 369, 307, 0, + 309, 310, 311, 312, -1, 377, -1, -1, 317, -1, + -1, -1, 321, -1, 323, -1, -1, 257, -1, -1, + -1, 261, -1, -1, 333, -1, 335, 336, -1, 338, + -1, -1, 272, 342, -1, -1, -1, 277, -1, -1, + -1, 281, 0, -1, 284, -1, 418, -1, -1, -1, + -1, -1, -1, 362, -1, -1, 296, 297, -1, 368, + 369, 301, 302, -1, 257, -1, -1, 307, 261, 309, + 310, 311, 312, -1, -1, -1, -1, 317, -1, 272, + -1, 321, -1, 323, 277, 0, -1, -1, 281, -1, + -1, 284, -1, 333, -1, 335, 336, -1, 338, -1, + -1, -1, 342, 296, 297, -1, -1, -1, 301, 302, + -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, + -1, -1, 362, -1, 317, -1, -1, 257, 321, 369, + 323, 261, -1, -1, -1, -1, -1, -1, -1, -1, + 333, -1, 272, 336, -1, 338, -1, 277, 0, 342, + -1, 281, -1, -1, 284, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 296, 297, -1, 362, + 257, 301, 302, -1, 261, 368, 369, 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, 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, -1, 0, + 317, -1, 362, 277, 321, -1, 323, 281, 368, 369, 284, -1, -1, -1, -1, -1, 333, -1, -1, 336, -1, 338, 296, 297, -1, 342, 257, 301, 302, -1, 261, -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, 272, -1, 317, -1, 362, 277, 321, -1, 323, - 281, 368, 369, 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, -1, 317, -1, 362, -1, - 321, -1, 323, 257, -1, 369, -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, -1, -1, - -1, 362, 296, 297, -1, -1, -1, 301, 302, -1, - -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, - -1, -1, -1, 317, -1, -1, 257, 321, -1, 323, - 261, -1, -1, -1, -1, -1, -1, -1, -1, 333, - -1, 272, 336, -1, 338, -1, 277, -1, 342, -1, - 281, -1, -1, 284, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 296, 297, -1, 362, -1, - 301, 302, -1, 257, -1, -1, 307, 261, 309, 310, - 311, 312, -1, -1, -1, -1, 317, -1, 272, -1, - 321, -1, 323, 277, -1, -1, -1, 281, -1, -1, - 284, -1, 333, -1, -1, 336, -1, 338, -1, -1, - -1, 342, 296, 297, -1, -1, -1, 301, 302, -1, - -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, - -1, 362, -1, 317, -1, -1, 257, 321, -1, 323, - 261, -1, -1, -1, -1, -1, -1, -1, -1, 333, - -1, 272, 336, -1, 338, -1, 277, -1, 342, -1, - 281, -1, -1, 284, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 296, 297, -1, 362, -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, -1, 333, -1, 256, 336, -1, 338, -1, -1, - -1, 342, 264, 265, 266, 267, -1, -1, 270, 271, - -1, 273, 274, 275, 276, 277, 278, 279, -1, -1, - -1, 362, -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, 256, 344, 345, -1, -1, -1, 262, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 359, 360, 361, - -1, 363, -1, -1, -1, 367, -1, -1, -1, 371, - -1, -1, -1, -1, 376, 377, 378, 379, 380, -1, - -1, -1, 384, 298, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, - -1, -1, -1, 262, -1, 417, 418, 419, 420, -1, - -1, -1, -1, -1, 339, -1, -1, 429, -1, 344, - -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, -1, -1, -1, -1, -1, -1, 298, - -1, -1, -1, 368, 369, 370, 371, 372, 373, 374, - 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 408, 409, 410, 411, 412, 413, -1, - 256, -1, -1, 418, -1, 420, 262, -1, 423, -1, - -1, -1, -1, -1, 429, -1, -1, -1, -1, 368, - -1, -1, 371, -1, 373, 374, -1, -1, -1, 378, - 379, -1, -1, 382, 383, 384, 385, 386, 387, 388, - 389, 390, 298, 392, 393, 394, 395, 396, 397, 398, - 399, 400, 401, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 412, 413, -1, -1, -1, -1, -1, - -1, 420, 262, -1, 423, -1, -1, -1, -1, -1, - 429, -1, -1, 339, -1, -1, -1, -1, 344, -1, + 281, -1, 369, 284, -1, -1, -1, -1, -1, 333, + -1, -1, 336, -1, 338, 296, 297, -1, 342, 257, + 301, 302, -1, 261, -1, -1, 307, -1, 309, 310, + 311, 312, -1, -1, 272, -1, 317, -1, 362, 277, + 321, -1, 323, 281, -1, -1, 284, -1, -1, -1, + -1, -1, 333, -1, -1, 336, -1, 338, 296, 297, + -1, 342, 257, 301, 302, -1, 261, -1, -1, 307, + -1, 309, 310, 311, 312, -1, -1, 272, -1, 317, + -1, 362, 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, -1, + -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, + -1, -1, 317, -1, 362, 257, 321, -1, 323, 261, + -1, -1, -1, -1, -1, -1, -1, -1, 333, -1, + 272, 336, -1, 338, -1, 277, -1, 342, -1, 281, + -1, -1, 284, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 296, 297, -1, 362, -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, + -1, 333, -1, 256, 336, -1, 338, -1, -1, -1, + 342, 264, 265, 266, 267, -1, -1, 270, 271, -1, + 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, + 362, -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, + 256, 344, 345, -1, -1, -1, 262, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 359, 360, 361, 362, + 363, -1, -1, -1, 367, -1, -1, -1, 371, -1, + -1, -1, -1, 376, 377, 378, 379, 380, -1, -1, + -1, 384, 298, 386, -1, -1, -1, -1, -1, 392, + 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, + -1, -1, 262, -1, 417, 418, 419, 420, -1, -1, + -1, -1, -1, 339, -1, -1, 429, -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, 368, 369, 370, 371, 372, 373, 374, 375, + 356, 357, -1, -1, -1, -1, -1, -1, 298, -1, + -1, -1, 368, 369, 370, 371, 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, -1, 256, - -1, -1, -1, -1, 420, 262, -1, 357, -1, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, 369, - -1, 371, -1, 373, -1, -1, 376, -1, 378, 379, - -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, + -1, -1, 418, -1, 420, 262, -1, 423, -1, -1, + -1, -1, -1, 429, -1, -1, -1, -1, 368, -1, + -1, 371, -1, 373, 374, -1, -1, -1, 378, 379, + -1, -1, 382, 383, 384, 385, 386, 387, 388, 389, 390, 298, 392, 393, 394, 395, 396, 397, 398, 399, - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, - 410, 411, 412, 413, -1, -1, -1, -1, 418, -1, + 400, 401, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 412, 413, -1, -1, -1, -1, -1, -1, 420, 262, -1, 423, -1, -1, -1, -1, -1, 429, -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, 368, -1, 370, 371, 372, 373, 374, 375, 376, + 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, -1, 256, -1, - -1, -1, -1, 420, 262, -1, 423, -1, -1, -1, + -1, -1, -1, 420, 262, -1, 357, -1, -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, 369, -1, - 371, 372, 373, 374, -1, 376, -1, 378, 379, -1, - 381, 382, 383, 384, 385, -1, 387, 388, 389, 390, + 371, -1, 373, -1, -1, 376, -1, 378, 379, -1, + 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 298, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, -1, -1, -1, -1, 418, -1, 420, 262, -1, 423, -1, -1, -1, -1, -1, 429, -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, -1, + -1, -1, -1, -1, -1, -1, 298, -1, -1, 367, 368, -1, 370, 371, 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, -1, 256, -1, -1, -1, -1, 420, 262, -1, 423, -1, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 370, 371, - 372, 373, 374, -1, -1, -1, 378, 379, -1, 381, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 298, + -1, 429, -1, -1, -1, -1, -1, 369, -1, 371, + 372, 373, 374, -1, 376, -1, 378, 379, -1, 381, + 382, 383, 384, 385, -1, 387, 388, 389, 390, 298, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, - 412, 413, -1, -1, -1, -1, -1, -1, 420, -1, + 412, 413, -1, -1, -1, -1, 418, -1, 420, 262, -1, 423, -1, -1, -1, -1, -1, 429, -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, -1, 368, + -1, -1, -1, -1, -1, 298, -1, -1, -1, 368, -1, 370, 371, 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, - 409, 410, 411, 412, 413, -1, 256, 256, -1, -1, - -1, 420, 262, -1, 423, -1, 265, -1, 267, -1, - 429, 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, + 409, 410, 411, 412, 413, -1, 256, -1, -1, -1, + -1, 420, 262, -1, 423, -1, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 370, 371, 372, + 373, 374, -1, -1, -1, 378, 379, -1, 381, 382, + 383, 384, 385, 386, 387, 388, 389, 390, 298, 392, + 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, + 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, + 413, -1, -1, -1, -1, -1, -1, 420, -1, -1, + 423, -1, -1, -1, -1, -1, 429, -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, -1, 368, -1, @@ -11018,7 +11125,7 @@ void case_948() -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, - 410, 411, 412, 413, -1, 256, 256, -1, -1, 418, + 410, 411, 412, 413, -1, 256, 256, -1, -1, -1, 420, 262, -1, 423, -1, 265, -1, 267, -1, 429, 270, -1, -1, -1, -1, 275, -1, -1, -1, 279, -1, -1, -1, -1, -1, -1, -1, -1, 288, -1, @@ -11030,228 +11137,235 @@ void case_948() -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, -1, 368, -1, 370, - 371, 372, 373, 374, 375, 376, -1, 378, -1, -1, + 371, 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, - 411, 412, 413, -1, 256, -1, 256, -1, 418, 420, - 262, -1, 423, -1, 264, 265, -1, 267, 429, -1, - 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, - -1, -1, -1, -1, -1, 285, -1, -1, 288, -1, - -1, -1, -1, -1, -1, 295, 298, -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, 339, -1, -1, - -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 359, - 360, 361, -1, -1, -1, -1, 368, -1, 370, -1, - 372, 371, 374, 375, 376, -1, 378, 379, -1, 381, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 261, - -1, -1, 394, 395, 396, 397, 398, 399, 400, 401, - 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, - 256, 413, 284, -1, -1, -1, 262, 417, 418, -1, - -1, -1, -1, -1, -1, 297, -1, 429, -1, -1, - 302, -1, -1, 305, -1, 307, -1, 309, 310, 311, - 312, -1, -1, -1, -1, 317, -1, -1, -1, 321, - -1, -1, 298, 325, -1, -1, -1, -1, -1, -1, - -1, 333, -1, -1, 336, -1, 338, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, - -1, -1, -1, -1, 262, -1, -1, -1, -1, -1, - 362, -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, - 298, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, 378, 379, -1, -1, 382, 383, 384, 385, - 386, 387, 388, 389, 390, -1, 418, -1, 394, 395, - 396, 397, 398, 399, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 256, 429, -1, -1, -1, -1, 262, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - 378, 379, -1, -1, 382, 383, 384, 385, -1, -1, - -1, 389, 390, -1, -1, -1, 394, 395, 396, 397, - 398, 399, 400, 401, 298, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 413, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 256, 429, -1, -1, -1, -1, 262, -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, -1, - -1, -1, 298, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, 378, 379, -1, -1, 382, 383, - 384, 385, -1, -1, -1, 389, 390, 285, -1, -1, - 394, 395, 396, 397, 398, 399, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, 256, 429, -1, -1, -1, 327, - 262, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, 378, 379, -1, -1, 382, 383, 384, 385, - -1, -1, -1, 389, 390, -1, -1, -1, 394, 395, - 396, 397, 398, 399, 400, 401, 298, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 413, -1, 377, - 378, 379, 380, -1, 382, 383, 384, 385, 386, 387, - 388, 389, 256, 429, 392, 393, 394, 395, 396, 397, - 398, 399, -1, -1, -1, -1, -1, 339, -1, -1, + 411, 412, 413, -1, 256, 256, -1, -1, 418, 420, + 262, -1, 423, -1, 265, -1, 267, -1, 429, 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, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, 378, 379, -1, -1, - 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, - 256, -1, 394, 395, 396, 397, 398, 399, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, 382, 383, - 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, - 394, 395, 396, 397, 398, 399, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, -1, -1, 382, 383, 384, 385, - -1, -1, -1, 389, 390, -1, 256, -1, 394, 395, - 396, 397, 398, 399, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - -1, -1, -1, -1, 382, 383, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, 394, 395, 396, 397, - 398, 399, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, 382, 383, 384, 385, -1, -1, -1, 389, - 390, -1, 256, -1, -1, -1, 396, 397, 398, 399, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, - 256, -1, -1, -1, 396, 397, 398, 399, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, 382, 383, - 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, - -1, -1, 396, 397, 398, 399, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, -1, -1, 382, 383, 384, 385, - -1, -1, -1, 389, 390, -1, 256, -1, -1, -1, - 396, 397, 398, 399, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - -1, -1, -1, -1, 382, 383, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, -1, -1, 396, 397, - 398, 399, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, -1, -1, 384, 385, -1, -1, -1, 389, - 390, -1, 256, -1, -1, -1, -1, -1, 398, 399, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - -1, -1, 384, 385, -1, -1, -1, 389, 390, -1, - 256, -1, -1, -1, -1, -1, 398, 399, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, -1, -1, - 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, - -1, -1, -1, -1, 398, 399, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, -1, -1, -1, -1, 384, 385, - -1, -1, -1, 389, 390, -1, 256, -1, -1, -1, - -1, -1, -1, -1, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - -1, -1, -1, -1, -1, -1, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, -1, -1, -1, -1, - -1, -1, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, -1, -1, -1, 385, -1, -1, -1, 389, - 390, -1, 256, -1, -1, -1, -1, -1, -1, -1, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - -1, -1, -1, 385, -1, -1, -1, 389, 390, -1, - 256, -1, -1, -1, -1, -1, -1, -1, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, -1, -1, - -1, 385, -1, -1, -1, -1, 390, -1, 256, -1, - -1, -1, -1, -1, -1, -1, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, 256, -1, -1, -1, -1, 385, - -1, -1, -1, -1, 390, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, + -1, -1, -1, -1, -1, -1, 368, -1, 370, 371, + 372, 373, 374, 375, 376, -1, 378, -1, -1, 381, + 382, 383, 384, 385, 386, 387, 388, 389, 390, -1, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, + 412, 413, -1, 256, -1, 256, -1, 418, 420, 262, + -1, 423, -1, 264, 265, -1, 267, 429, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + -1, -1, -1, -1, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, 298, -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, 339, -1, -1, -1, + -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 359, 360, + 361, 362, -1, -1, -1, 368, -1, 370, -1, 372, + 371, 374, 375, 376, -1, 378, 379, -1, 381, 382, + 383, 384, 385, 386, 387, 388, 389, 390, 261, -1, + -1, 394, 395, 396, 397, 398, 399, 400, 401, 402, + 403, 404, 405, 406, 407, 408, 409, 410, 411, 256, + 413, 284, -1, -1, -1, 262, 417, 418, -1, -1, + -1, -1, -1, -1, 297, -1, 429, -1, -1, 302, + -1, -1, 305, -1, 307, -1, 309, 310, 311, 312, + -1, -1, -1, -1, 317, -1, -1, -1, 321, -1, + -1, 298, 325, -1, -1, -1, -1, -1, -1, -1, + 333, -1, -1, 336, -1, 338, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, + -1, -1, -1, 262, -1, -1, -1, -1, -1, 362, + -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, 298, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, 378, 379, -1, -1, 382, 383, 384, 385, 386, + 387, 388, 389, 390, -1, 418, -1, 394, 395, 396, + 397, 398, 399, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, 256, 429, -1, -1, -1, -1, 262, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, 378, + 379, -1, -1, 382, 383, 384, 385, -1, -1, -1, + 389, 390, -1, -1, -1, 394, 395, 396, 397, 398, + 399, 400, 401, 298, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 413, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, + 429, -1, -1, -1, -1, 262, -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, -1, -1, + -1, 298, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, 378, 379, -1, -1, 382, 383, 384, + 385, -1, -1, -1, 389, 390, -1, -1, -1, 394, + 395, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, 256, 429, -1, -1, -1, -1, 262, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, 378, 379, -1, -1, 382, 383, 384, 385, -1, + -1, -1, 389, 390, -1, -1, -1, 394, 395, 396, + 397, 398, 399, 400, 401, 298, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 413, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 390, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 401, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 413, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, 429, 374, 375, 376, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 256, -1, 390, -1, - -1, -1, -1, -1, 264, 265, 266, 267, -1, 401, - 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, - -1, 413, -1, -1, -1, 285, -1, 287, 288, 289, - 290, 291, 292, -1, -1, 295, -1, 429, -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, 359, - 360, 361, -1, 363, -1, -1, -1, 367, -1, -1, - -1, 371, -1, -1, -1, -1, 376, 377, 378, 379, - 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, - -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, + -1, 256, 429, -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, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, 378, 379, -1, -1, 382, + 383, 384, 385, -1, -1, -1, 389, 390, -1, 256, + -1, 394, 395, 396, 397, 398, 399, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, 382, 383, 384, + 385, -1, -1, -1, 389, 390, -1, 256, -1, 394, + 395, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, 382, 383, 384, 385, -1, + -1, -1, 389, 390, -1, 256, -1, 394, 395, 396, + 397, 398, 399, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, 382, 383, 384, 385, -1, -1, -1, + 389, 390, -1, 256, -1, 394, 395, 396, 397, 398, + 399, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, 382, 383, 384, 385, -1, -1, -1, 389, 390, + -1, 256, -1, -1, -1, 396, 397, 398, 399, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, -1, -1, 382, + 383, 384, 385, -1, -1, -1, 389, 390, -1, 256, + -1, -1, -1, 396, 397, 398, 399, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, 382, 383, 384, + 385, -1, -1, -1, 389, 390, -1, 256, -1, -1, + -1, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, 382, 383, 384, 385, -1, + -1, -1, 389, 390, -1, 256, -1, -1, -1, 396, + 397, 398, 399, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, 382, 383, 384, 385, -1, -1, -1, + 389, 390, -1, 256, -1, -1, -1, 396, 397, 398, + 399, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, -1, -1, 384, 385, -1, -1, -1, 389, 390, + -1, 256, -1, -1, -1, -1, -1, 398, 399, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, -1, -1, -1, + -1, 384, 385, -1, -1, -1, 389, 390, -1, 256, + -1, -1, -1, -1, -1, 398, 399, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, -1, -1, 384, + 385, -1, -1, -1, 389, 390, -1, 256, -1, -1, + -1, -1, -1, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, -1, -1, 384, 385, -1, + -1, -1, 389, 390, -1, 256, -1, -1, -1, -1, + -1, -1, -1, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, -1, -1, -1, 385, -1, -1, -1, + 389, 390, -1, 256, -1, -1, -1, -1, -1, -1, + -1, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, -1, -1, -1, 385, -1, -1, -1, 389, 390, + -1, 256, -1, -1, -1, -1, -1, -1, -1, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, -1, -1, -1, + -1, -1, 385, -1, -1, -1, -1, 390, -1, 256, + -1, -1, -1, -1, -1, -1, -1, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, -1, -1, -1, + 385, -1, -1, -1, -1, 390, -1, 256, -1, -1, + -1, -1, -1, -1, -1, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 256, -1, -1, -1, 417, 418, 419, - 420, 264, 265, 266, 267, -1, -1, 270, 271, -1, - 273, 274, 275, 276, 277, 278, 279, -1, -1, -1, + -1, -1, -1, 390, -1, 256, -1, -1, -1, -1, + -1, -1, -1, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, 256, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 390, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 390, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 401, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 413, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, 429, 374, + 375, 376, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 256, -1, 390, -1, -1, -1, -1, + -1, 264, 265, 266, 267, -1, 401, 270, 271, -1, + 273, 274, 275, 276, 277, 278, 279, -1, 413, -1, -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, - -1, -1, 295, -1, -1, -1, 299, 300, -1, 302, + -1, -1, 295, -1, 429, -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, 359, 360, 361, -1, + -1, -1, -1, -1, -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, -1, 376, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, @@ -11267,7 +11381,7 @@ void case_948() 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, 359, 360, 361, -1, 363, -1, -1, + -1, -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, -1, 376, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, @@ -11283,7 +11397,7 @@ void case_948() 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, - 359, 360, 361, -1, 363, -1, -1, -1, 367, -1, + 359, 360, 361, 362, 363, -1, -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, -1, 376, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, @@ -11299,88 +11413,29 @@ void case_948() 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, 359, 360, 361, - -1, 363, -1, -1, -1, 367, -1, -1, -1, 371, + 362, 363, -1, -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, -1, 376, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, 417, 418, 419, 420, 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, -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, 359, 360, 361, -1, 363, -1, - -1, -1, 367, 368, -1, -1, 371, -1, -1, -1, - -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + 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, 359, 360, 361, 362, 363, -1, + -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, + -1, 376, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, 417, 418, 419, 420, 264, 265, -1, 267, -1, -1, 270, 271, -1, 256, -1, 275, 276, 277, - 418, 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, 359, 360, 361, -1, 363, -1, -1, -1, 367, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, - -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, - -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, 417, - 418, 419, 420, 285, -1, -1, 288, -1, -1, -1, - -1, -1, -1, 295, -1, -1, -1, 418, 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, 359, 360, 361, - -1, 363, -1, -1, -1, 367, 368, -1, -1, 371, - -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, - -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 256, -1, 417, 418, 419, 420, -1, - -1, 264, 265, -1, 267, -1, 428, 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, 337, -1, 322, -1, 341, -1, - -1, 344, 345, -1, 330, 331, -1, -1, 334, -1, - -1, 337, -1, -1, -1, -1, 359, 360, 361, -1, - 363, -1, -1, -1, -1, -1, -1, -1, 371, -1, - -1, -1, -1, -1, 377, 378, 379, 380, -1, -1, - -1, 384, -1, 386, -1, -1, 372, -1, -1, 392, - 393, -1, -1, -1, -1, -1, -1, 264, 265, -1, - 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, - 277, -1, 279, -1, 417, 418, 419, 420, 285, -1, - -1, 288, -1, -1, -1, -1, -1, -1, 295, -1, - -1, -1, 418, 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, 359, 360, 361, -1, 363, -1, -1, -1, - 367, -1, -1, -1, 371, -1, -1, -1, -1, -1, - 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, - -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, - 417, 418, 419, 420, -1, -1, 264, 265, -1, 267, - -1, 428, 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, @@ -11389,50 +11444,139 @@ void case_948() -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, 359, 360, 361, -1, 363, -1, -1, -1, 367, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, 370, + -1, 359, 360, 361, 362, 363, -1, -1, -1, 367, + 368, -1, -1, 371, -1, -1, -1, -1, -1, 377, + 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, 417, 418, 419, 420, 264, 265, -1, 267, -1, -1, 270, - 271, -1, -1, -1, 275, 276, 277, 418, 279, -1, + 271, -1, 256, -1, 275, 276, 277, 418, 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, + -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, 359, 360, - 361, -1, 363, -1, -1, -1, -1, -1, -1, -1, + 361, 362, 363, -1, -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, -1, 279, -1, 417, 418, 419, 420, + 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, + 295, -1, -1, -1, 418, 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, 359, 360, 361, 362, 363, -1, + -1, -1, 367, 368, -1, -1, 371, -1, -1, -1, + -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 256, -1, 417, 418, 419, 420, -1, -1, 264, 265, + -1, 267, -1, 428, 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, 337, -1, 322, -1, 341, -1, -1, 344, 345, + -1, 330, 331, -1, -1, 334, -1, -1, 337, -1, + -1, -1, -1, 359, 360, 361, 362, 363, -1, -1, + -1, -1, -1, -1, -1, 371, -1, -1, -1, -1, + -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, + 386, -1, -1, 372, -1, -1, 392, 393, -1, -1, + -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, + 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, + -1, 417, 418, 419, 420, 285, -1, -1, 288, -1, + -1, -1, -1, -1, -1, 295, -1, -1, -1, 418, + 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, 359, + 360, 361, 362, 363, -1, -1, -1, 367, -1, -1, + -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, + 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, + -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, -1, 417, 418, 419, + 420, -1, -1, 264, 265, -1, 267, -1, 428, 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, 359, 360, + 361, 362, 363, -1, -1, -1, 367, -1, -1, -1, + 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, + -1, -1, -1, 384, -1, 386, 370, -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, 417, 418, 419, 420, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, - -1, 275, 276, 277, 418, 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, -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, 359, 360, 361, -1, 363, + -1, 275, 276, 277, 418, 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, 359, 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, + -1, -1, -1, 417, 418, 419, 420, 264, 265, -1, + 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, + 277, 418, 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, -1, + -1, -1, -1, -1, -1, 262, -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, 298, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, + -1, -1, -1, -1, 371, -1, -1, -1, -1, -1, + 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, + -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 417, 418, 419, 420, 371, 372, 373, 374, -1, -1, + -1, 378, 379, -1, -1, 382, 383, 384, 385, 386, + 387, 388, 389, 390, -1, 392, 393, 394, 395, 396, + 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, + 407, 408, 409, 410, 411, 412, 413, -1, 261, -1, + -1, -1, 265, 420, 267, -1, 423, 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, -1, - -1, -1, -1, 417, 418, 419, 420, 261, -1, -1, - -1, 265, -1, 267, -1, -1, 270, -1, 272, 273, - -1, 275, -1, 277, -1, 279, -1, 281, 282, 283, + -1, -1, -1, -1, -1, -1, -1, 261, -1, 362, + -1, 265, -1, 267, -1, 368, 270, -1, 272, 273, + -1, 275, -1, 277, 377, 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, 316, 317, 318, 418, -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, -1, -1, @@ -11465,390 +11609,368 @@ void case_948() 317, 318, 418, -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, -1, -1, -1, 261, -1, + -1, -1, 265, -1, 267, 362, -1, 270, -1, 272, + 273, 368, 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, + 261, 304, -1, -1, 307, -1, 309, 310, 311, 312, + -1, -1, -1, 316, 317, 318, -1, -1, 321, 322, + 323, 418, -1, 284, -1, -1, -1, 330, 331, -1, + 333, 334, 261, 336, 337, 338, 297, -1, -1, 342, + -1, 302, -1, -1, 305, -1, 307, -1, 309, 310, + 311, 312, -1, -1, -1, 284, 317, -1, -1, 362, + 321, -1, -1, -1, 325, 368, -1, -1, 297, -1, + 261, -1, 333, 302, -1, 336, -1, 338, 307, -1, + 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, + -1, -1, 321, 284, -1, -1, 357, -1, -1, -1, + -1, 362, -1, -1, 333, -1, 297, 336, 369, 338, + 371, 302, 373, -1, 305, 418, 307, -1, 309, 310, + 311, 312, -1, -1, -1, 386, 317, -1, -1, -1, + 321, -1, -1, 362, 325, -1, -1, -1, -1, -1, + -1, -1, 333, 264, 265, 336, 267, 338, -1, 270, + 271, -1, -1, -1, 275, 276, 277, 418, 279, -1, + -1, -1, -1, -1, 285, -1, -1, 288, -1, -1, + -1, 362, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, 306, -1, -1, -1, 418, + -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, 418, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 359, 360, + 361, 362, 363, -1, -1, -1, -1, -1, -1, -1, + 371, 372, -1, 374, -1, -1, 377, 378, 379, 380, + -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, -1, 279, -1, 417, 418, 419, 420, + 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, 359, 360, 361, 362, 363, -1, + -1, -1, -1, -1, -1, -1, 371, -1, -1, 374, + -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, + -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, + 279, -1, 417, 418, 419, 420, 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, -1, -1, 261, -1, 362, -1, 265, -1, 267, - -1, 368, 270, -1, 272, 273, -1, 275, -1, 277, - 377, 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, 418, -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, -1, -1, -1, 261, -1, -1, - -1, 265, -1, 267, 362, -1, 270, -1, 272, 273, - 368, 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, 261, - 304, -1, -1, 307, -1, 309, 310, 311, 312, -1, - -1, -1, 316, 317, 318, -1, -1, 321, 322, 323, - 418, -1, 284, -1, -1, -1, 330, 331, -1, 333, - 334, 261, 336, 337, 338, 297, -1, -1, 342, -1, - 302, -1, -1, 305, -1, 307, -1, 309, 310, 311, - 312, -1, -1, -1, 284, 317, -1, -1, 362, 321, - -1, -1, -1, 325, 368, -1, -1, 297, -1, 261, - -1, 333, 302, -1, 336, -1, 338, 307, -1, 309, - 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, - -1, 321, 284, -1, -1, 357, -1, -1, -1, 261, - 362, -1, -1, 333, -1, 297, 336, 369, 338, 371, - 302, 373, -1, 305, 418, 307, -1, 309, 310, 311, - 312, -1, 284, -1, 386, 317, -1, -1, -1, 321, - -1, -1, 362, 325, -1, 297, -1, -1, -1, -1, - 302, 333, -1, -1, 336, 307, 338, 309, 310, 311, - 312, -1, -1, -1, -1, 317, 418, -1, -1, 321, - -1, -1, -1, 325, -1, -1, 264, 265, -1, 267, - 362, 333, 270, 271, 336, -1, 338, 275, 276, 277, - -1, 279, -1, -1, -1, -1, -1, 285, 418, -1, - 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, - 362, -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, 418, 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, 418, -1, -1, -1, - -1, 359, 360, 361, -1, 363, -1, -1, -1, -1, - -1, -1, -1, 371, 372, -1, 374, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, - -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, - -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, 417, - 418, 419, 420, 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, 359, 360, 361, - -1, 363, -1, -1, -1, -1, -1, -1, -1, 371, - -1, -1, 374, -1, -1, 377, 378, 379, 380, -1, - -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, 264, 265, - -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, - 276, 277, -1, 279, -1, 417, 418, 419, 420, 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, 359, 360, 361, -1, 363, -1, -1, - -1, -1, -1, -1, -1, 371, -1, -1, -1, -1, - -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, - 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, - -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, - 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, - -1, 417, 418, 419, 420, 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, 337, -1, -1, - -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 359, - 360, 361, -1, 363, -1, -1, -1, -1, -1, -1, - -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, - 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, - -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, - 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, - -1, 275, 276, 277, -1, 279, -1, 417, 418, 419, - 420, 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, 359, 360, 361, -1, 363, - -1, -1, -1, -1, 368, -1, -1, 371, -1, -1, - -1, -1, -1, 377, 378, 379, 380, -1, -1, -1, - 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, - -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, - -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, - -1, 279, -1, 417, 418, 419, 420, 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, 359, 360, 361, -1, 363, -1, -1, -1, 367, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, - -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, - -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, 417, - 418, 419, 420, 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, 359, 360, 361, - -1, 363, -1, -1, -1, 367, -1, -1, -1, 371, - -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, - -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, 264, 265, - -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, - 276, 277, -1, 279, -1, 417, 418, 419, 420, 285, - -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, - -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, + 359, 360, 361, 362, 363, -1, -1, -1, -1, -1, + -1, -1, 371, -1, -1, -1, -1, -1, 377, 378, + 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, + -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, + -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, + -1, -1, 275, 276, 277, -1, 279, -1, 417, 418, + 419, 420, 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, 337, -1, -1, -1, 341, -1, + -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 359, 360, 361, 362, + 363, -1, -1, -1, -1, -1, -1, -1, 371, -1, + -1, -1, -1, -1, 377, 378, 379, 380, -1, -1, + -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, + 393, -1, -1, -1, -1, -1, -1, 264, 265, -1, + 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, + 277, -1, 279, -1, 417, 418, 419, 420, 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, - 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, 359, 360, 361, 362, 363, -1, -1, -1, + -1, 368, -1, -1, 371, -1, -1, -1, -1, -1, + 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, + -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 417, 418, 419, 420, 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, 359, 360, + 361, 362, 363, -1, -1, -1, 367, -1, -1, -1, + 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, + -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, -1, 279, -1, 417, 418, 419, 420, + 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, 359, 360, 361, -1, 363, -1, -1, - -1, -1, -1, -1, -1, 371, -1, -1, -1, -1, - -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, - 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, - -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, - 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, - -1, 417, 418, 419, 420, 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, 359, - 360, 361, -1, 363, -1, -1, -1, -1, -1, -1, - -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, - 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, - -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, - 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, - -1, 275, 276, 277, -1, 279, -1, 417, 418, 419, - 420, 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, 359, 360, 361, -1, 363, - -1, -1, -1, -1, -1, -1, -1, 371, -1, -1, - -1, -1, -1, 377, 378, 379, 380, -1, -1, -1, - 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, - -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, - -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, - -1, 279, -1, 417, 418, 419, 420, 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, 359, 360, 361, 362, 363, -1, + -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, + -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, + -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, + 279, -1, 417, 418, 419, 420, 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, 359, 360, 361, -1, 363, -1, -1, -1, -1, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, - -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, - -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, 417, - 418, 419, 420, 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, 359, 360, 361, - -1, 363, -1, -1, -1, -1, -1, -1, -1, 371, - -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, - -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, 264, 265, - -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, - 276, 277, -1, 279, -1, 417, 418, 419, 420, 285, - -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, - -1, 261, -1, -1, 300, -1, 302, 303, 304, -1, + 359, 360, 361, 362, 363, -1, -1, -1, -1, -1, + -1, -1, 371, -1, -1, -1, -1, -1, 377, 378, + 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, + -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, + -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, + -1, -1, 275, 276, 277, -1, 279, -1, 417, 418, + 419, 420, 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, 359, 360, 361, 362, + 363, -1, -1, -1, -1, -1, -1, -1, 371, -1, + -1, -1, -1, -1, 377, 378, 379, 380, -1, -1, + -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, + 393, -1, -1, -1, -1, -1, -1, 264, 265, -1, + 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, + 277, -1, 279, -1, 417, 418, 419, 420, 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, - 316, -1, 318, 319, 284, -1, 322, -1, -1, 325, - -1, 327, -1, 329, 330, 331, 332, 297, 334, -1, - -1, -1, 302, -1, -1, -1, -1, 307, -1, 309, - 310, 311, 312, -1, -1, 315, -1, 317, -1, -1, - -1, 321, -1, 359, 360, 361, -1, 363, -1, -1, - -1, -1, -1, 333, -1, 371, 336, -1, 338, -1, - -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, - 386, -1, 264, 265, -1, 267, 392, 393, 270, 271, - -1, -1, 362, 275, 276, 277, -1, 279, 368, 369, - -1, -1, -1, 285, -1, -1, 288, -1, -1, -1, - 261, 417, 418, 295, 420, -1, -1, -1, 300, -1, - 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 284, 316, -1, 318, 319, -1, -1, - 322, -1, -1, 325, -1, 327, 297, 329, 330, 331, - 332, 302, 334, -1, -1, -1, 307, -1, 309, 310, - 311, 312, -1, -1, 315, -1, 317, -1, -1, -1, - 321, -1, -1, -1, -1, -1, -1, 359, 360, 361, - -1, 363, 333, -1, -1, 336, -1, 338, -1, 371, - 263, -1, 265, -1, 267, 377, -1, 270, 380, 272, - 273, -1, 275, -1, 277, -1, 279, -1, 281, 282, - 283, 362, -1, -1, 287, 288, -1, 368, -1, -1, - 293, -1, 295, 296, -1, -1, -1, 300, -1, -1, - -1, 304, -1, -1, -1, 417, 418, -1, 420, -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, + -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, + -1, -1, -1, -1, 371, -1, -1, -1, -1, -1, + 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, + -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 417, 418, 419, 420, 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, 359, 360, + 361, 362, 363, -1, -1, -1, -1, -1, -1, -1, + 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, + -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, -1, 279, -1, 417, 418, 419, 420, 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, - 295, 364, 365, -1, -1, 300, -1, 302, 303, 304, - -1, -1, -1, -1, 377, -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, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 418, -1, -1, -1, -1, - -1, -1, -1, -1, 359, 360, 361, 265, -1, 267, - -1, -1, 270, -1, 272, 273, 371, 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, -1, 316, -1, - 318, -1, 417, 418, 322, 323, -1, -1, -1, -1, - -1, -1, 330, 331, -1, 265, 334, 267, -1, 337, - 270, -1, 272, 273, 342, 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, 377, - -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, 265, - -1, 267, 342, -1, 270, -1, -1, 273, -1, 275, - 418, 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, 265, 342, 267, 418, -1, - 270, -1, 316, -1, 318, 275, -1, -1, 322, 279, - -1, -1, -1, -1, -1, -1, 330, 331, 288, -1, - 334, -1, -1, 337, -1, 295, -1, 265, 342, 267, - 300, 377, 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, - 308, 265, 418, 267, -1, 313, 270, -1, 316, -1, - 318, 275, -1, -1, 322, 279, -1, 325, -1, -1, - -1, -1, 330, 331, 288, -1, 334, -1, -1, 337, - -1, 295, 372, 265, 418, 267, 300, -1, 270, -1, - 304, -1, 306, 275, 308, -1, -1, 279, -1, 313, - -1, -1, 316, -1, 318, -1, 288, -1, 322, -1, - -1, 325, 370, 295, -1, -1, 330, 331, 300, -1, - 334, -1, 304, 337, 306, -1, -1, -1, 418, -1, - -1, 313, -1, -1, 316, -1, 318, -1, -1, -1, - 322, -1, -1, 325, -1, -1, -1, -1, 330, 331, - -1, -1, 334, -1, 265, 337, 267, -1, -1, 270, - 418, 272, -1, -1, 275, -1, -1, -1, 279, -1, - -1, -1, -1, -1, -1, -1, -1, 288, 265, -1, - 267, -1, -1, 270, 295, -1, -1, -1, 275, 300, - -1, 302, 279, 304, -1, -1, 283, -1, -1, -1, - -1, 288, -1, -1, 418, 316, 293, 318, 295, -1, - -1, 322, 323, 300, -1, -1, -1, 304, 305, 330, - 331, -1, -1, 334, -1, -1, 337, -1, 265, 316, - 267, 318, -1, 270, -1, 322, 418, -1, 275, -1, - -1, -1, 279, 330, 331, -1, -1, 334, -1, -1, - -1, 288, 265, -1, 267, -1, -1, 270, 295, -1, - -1, -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, -1, 334, -1, -1, - 337, -1, -1, 316, -1, 318, 265, 418, 267, 322, - -1, 270, -1, -1, -1, -1, 275, 330, 331, -1, - 279, 334, -1, 265, 337, 267, -1, -1, 270, 288, - -1, 418, -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, 418, 270, -1, -1, -1, -1, 275, 330, 331, - -1, 279, 334, -1, -1, 337, -1, -1, -1, -1, - 288, 265, -1, 267, -1, 418, 270, 295, -1, -1, - -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, -1, 334, -1, -1, 337, - -1, 265, 316, 267, 318, -1, 270, -1, 322, 418, - -1, 275, -1, -1, -1, 279, 330, 331, -1, -1, - 334, -1, -1, 337, 288, 265, 418, 267, -1, -1, + -1, -1, -1, -1, -1, -1, 341, -1, -1, 344, + 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 359, 360, 361, 362, 363, -1, + -1, -1, -1, -1, -1, -1, 371, -1, -1, -1, + -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, + -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, + 279, -1, 417, 418, 419, 420, 285, -1, -1, 288, + -1, -1, -1, -1, -1, -1, 295, -1, 261, -1, + -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, + 319, 284, -1, 322, -1, -1, 325, -1, 327, -1, + 329, 330, 331, 332, 297, 334, -1, -1, -1, 302, + -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, + -1, -1, 315, -1, 317, -1, -1, -1, 321, -1, + 359, 360, 361, 362, 363, -1, -1, -1, -1, -1, + 333, -1, 371, 336, -1, 338, -1, -1, 377, 378, + 379, 380, -1, -1, -1, 384, -1, 386, -1, 264, + 265, -1, 267, 392, 393, 270, 271, -1, -1, 362, + 275, 276, 277, -1, 279, 368, 369, -1, -1, -1, + 285, -1, -1, 288, -1, -1, -1, 261, 417, 418, + 295, 420, -1, -1, -1, 300, -1, 302, 303, 304, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 284, 316, -1, 318, 319, -1, -1, 322, -1, -1, + 325, -1, 327, 297, 329, 330, 331, 332, 302, 334, + -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, 315, -1, 317, -1, -1, -1, 321, -1, -1, + -1, -1, -1, -1, 359, 360, 361, 362, 363, 333, + -1, -1, 336, -1, 338, -1, 371, 263, -1, 265, + -1, 267, 377, -1, 270, 380, 272, 273, -1, 275, + -1, 277, -1, 279, -1, 281, 282, 283, 362, -1, + -1, 287, 288, -1, 368, -1, -1, 293, -1, 295, + 296, -1, -1, -1, 300, -1, -1, -1, 304, -1, + -1, -1, 417, 418, -1, 420, -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, -1, -1, -1, 295, 364, 365, + -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, + -1, 377, -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, -1, -1, -1, 265, -1, 267, -1, + -1, 270, 418, 272, -1, -1, 275, -1, -1, -1, + 279, 359, 360, 361, 362, -1, -1, -1, -1, 288, + 265, -1, 267, 371, -1, 270, 295, 272, 273, -1, + 275, 300, 277, 302, 279, 304, 281, 282, 283, -1, + -1, -1, 287, 288, -1, -1, -1, 316, 293, 318, + 295, 296, -1, 322, 323, 300, -1, -1, -1, 304, + -1, 330, 331, -1, -1, 334, -1, -1, 337, 417, + 418, 316, -1, 318, -1, -1, -1, 322, 323, -1, + -1, -1, -1, -1, -1, 330, 331, -1, 265, 334, + 267, -1, 337, 270, -1, 272, 273, 342, 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, 377, -1, -1, -1, -1, -1, -1, 316, + -1, 318, -1, -1, -1, 322, 323, -1, -1, 418, + -1, -1, -1, 330, 331, -1, -1, 334, -1, -1, + 337, -1, 265, -1, 267, 342, -1, 270, -1, -1, + 273, -1, 275, 418, 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, 265, 342, + 267, 418, -1, 270, -1, 316, -1, 318, 275, -1, + -1, 322, 279, -1, -1, -1, -1, -1, -1, 330, + 331, 288, -1, 334, -1, -1, 337, -1, 295, -1, + 265, 342, 267, 300, 377, 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, 308, 265, 418, 267, -1, 313, 270, + -1, 316, -1, 318, 275, -1, -1, 322, 279, -1, + 325, -1, -1, -1, -1, 330, 331, 288, -1, 334, + -1, -1, 337, -1, 295, 372, 265, 418, 267, 300, + -1, 270, -1, 304, -1, 306, 275, 308, -1, -1, + 279, -1, 313, -1, -1, 316, -1, 318, -1, 288, + -1, 322, -1, -1, 325, 370, 295, -1, -1, 330, + 331, 300, -1, 334, -1, 304, 337, 306, -1, -1, + -1, 418, -1, -1, 313, -1, -1, 316, -1, 318, + -1, -1, -1, 322, -1, -1, 325, -1, -1, -1, + -1, 330, 331, -1, -1, 334, -1, 265, 337, 267, + -1, -1, 270, 418, -1, -1, -1, 275, -1, -1, + -1, 279, -1, -1, -1, 283, 265, -1, 267, -1, + 288, 270, -1, -1, -1, 293, 275, 295, -1, -1, + 279, -1, 300, -1, -1, -1, 304, 305, -1, 288, + -1, -1, -1, -1, -1, -1, 295, 418, 316, -1, + 318, 300, -1, -1, 322, 304, -1, -1, -1, -1, + -1, -1, 330, 331, -1, -1, 334, 316, -1, 318, + 265, -1, 267, 322, -1, 270, -1, -1, -1, 418, + 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, -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, -1, -1, + 418, 275, 330, 331, -1, 279, 334, -1, -1, 337, + -1, -1, -1, -1, 288, 265, -1, 267, -1, 418, 270, 295, -1, -1, -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, -1, - 334, -1, -1, 337, -1, -1, 316, -1, 318, 265, - 418, 267, 322, -1, 270, -1, -1, -1, -1, 275, - 330, 331, -1, 279, 334, -1, 265, 337, 267, -1, - -1, 270, 288, -1, 418, -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, 418, 270, -1, -1, -1, -1, - 275, 330, 331, -1, 279, 334, -1, -1, 337, -1, - -1, -1, -1, 288, -1, -1, -1, -1, 418, -1, - 295, -1, -1, -1, -1, 300, -1, -1, 261, 304, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, - -1, 316, -1, 318, 277, -1, -1, 322, 281, -1, - -1, 284, -1, -1, -1, 330, 331, -1, -1, 334, - -1, -1, 337, 296, 297, -1, -1, -1, 301, 302, - -1, -1, 418, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, -1, 317, -1, -1, -1, 321, 418, - 323, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 333, -1, 335, 336, 261, 338, -1, -1, -1, 342, - -1, -1, -1, -1, -1, 272, -1, -1, -1, -1, - 277, -1, -1, -1, 281, -1, -1, 284, -1, 362, - -1, -1, -1, -1, -1, 368, 369, -1, -1, 296, - 297, -1, -1, 418, 301, 302, 261, -1, 263, -1, - 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, - 317, -1, -1, -1, 321, -1, 323, -1, -1, 284, - -1, -1, -1, -1, -1, -1, 333, -1, -1, 336, - -1, 338, 297, -1, -1, 342, -1, 302, -1, -1, + 334, -1, -1, 337, -1, 265, 316, 267, 318, -1, + 270, -1, 322, 418, -1, 275, -1, -1, -1, 279, + 330, 331, -1, -1, 334, -1, -1, 337, 288, 265, + 418, 267, -1, -1, 270, 295, -1, -1, -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, -1, 334, -1, -1, 337, -1, -1, + 316, -1, 318, 265, 418, 267, 322, -1, 270, -1, + -1, -1, -1, 275, 330, 331, -1, 279, 334, -1, + 265, 337, 267, -1, -1, 270, 288, -1, 418, -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, 418, 270, + -1, -1, -1, -1, 275, 330, 331, -1, 279, 334, + -1, -1, 337, -1, -1, -1, -1, 288, 265, -1, + 267, -1, 418, 270, 295, -1, -1, -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, 261, 334, -1, -1, 337, -1, -1, 316, + -1, 318, -1, 272, -1, 322, 418, -1, 277, -1, + -1, -1, 281, 330, 331, 284, -1, 334, -1, -1, + 337, -1, -1, 418, -1, -1, -1, 296, 297, -1, + -1, -1, 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, 335, 336, -1, 338, + 296, 297, -1, 342, -1, 301, 302, 418, -1, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + -1, 317, -1, 362, -1, 321, -1, 323, -1, 368, + 369, 418, -1, 261, -1, 263, -1, 333, -1, -1, + 336, -1, 338, -1, -1, -1, 342, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 284, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 362, -1, -1, 297, + -1, -1, 368, 369, 302, -1, 261, -1, -1, 307, + -1, 309, 310, 311, 312, -1, -1, 272, -1, 317, + -1, -1, 277, 321, -1, -1, 281, -1, -1, 284, + -1, -1, -1, -1, -1, 333, -1, -1, 336, -1, + 338, 296, 297, -1, -1, -1, 301, 302, -1, 261, -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, - -1, -1, 317, -1, -1, 362, 321, -1, -1, 261, - -1, 368, 369, -1, -1, -1, -1, -1, 333, -1, - 272, 336, -1, 338, -1, 277, -1, -1, -1, 281, - -1, -1, 284, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 296, 297, -1, 362, -1, 301, - 302, -1, 261, 368, 369, 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, 261, -1, -1, -1, 307, -1, - 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, - 362, -1, 321, -1, 323, -1, 368, 284, -1, -1, - -1, -1, -1, -1, 333, -1, -1, 336, -1, 338, - 297, -1, 261, 342, -1, 302, -1, -1, -1, -1, - 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, - 317, -1, -1, 362, 321, 284, -1, -1, -1, 368, - -1, -1, -1, -1, -1, -1, 333, -1, 297, 336, - 261, 338, 263, 302, -1, -1, -1, -1, 307, -1, - 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, - -1, -1, 321, 284, -1, 362, -1, 364, 365, -1, - -1, 368, -1, -1, 333, -1, 297, 336, 261, 338, - -1, 302, -1, -1, -1, -1, 307, -1, 309, 310, - 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, - 321, 284, -1, 362, -1, 364, 365, -1, 261, 368, - 263, -1, 333, -1, 297, 336, -1, 338, -1, 302, - -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, - -1, 284, -1, -1, 317, -1, -1, -1, 321, -1, - -1, 362, -1, -1, 297, -1, -1, 368, 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, -1, -1, 261, 362, - 333, 364, 365, 336, 297, 338, -1, -1, 301, 302, + 272, -1, 317, -1, 362, 277, 321, -1, 323, 281, + 368, 369, 284, -1, -1, -1, -1, -1, 333, -1, + -1, 336, -1, 338, 296, 297, -1, 342, -1, 301, + 302, 261, -1, -1, -1, 307, -1, 309, 310, 311, + 312, -1, -1, -1, -1, 317, -1, 362, -1, 321, + -1, 323, -1, 368, 284, -1, -1, -1, -1, -1, + -1, 333, -1, -1, 336, -1, 338, 297, -1, 261, + 342, -1, 302, -1, -1, -1, -1, 307, -1, 309, + 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, + 362, 321, 284, -1, -1, -1, 368, -1, -1, -1, + -1, -1, -1, 333, -1, 297, 336, 261, 338, 263, + 302, -1, -1, -1, -1, 307, -1, 309, 310, 311, + 312, -1, -1, -1, -1, 317, -1, -1, -1, 321, + 284, -1, 362, -1, 364, 365, -1, -1, 368, -1, + -1, 333, -1, 297, 336, 261, 338, -1, 302, -1, + -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, -1, 317, -1, -1, -1, 321, 284, -1, + 362, -1, 364, 365, -1, 261, 368, -1, -1, 333, + -1, 297, 336, -1, 338, -1, 302, -1, -1, -1, + -1, 307, -1, 309, 310, 311, 312, -1, 284, -1, + -1, 317, -1, -1, -1, 321, -1, -1, 362, -1, + -1, 297, -1, -1, 368, 301, 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, -1, -1, -1, 362, 333, 364, 365, + 336, -1, 338, -1, 297, -1, -1, -1, -1, 302, -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, - -1, 284, -1, -1, 317, -1, -1, -1, 321, 362, - -1, -1, -1, -1, 297, -1, -1, -1, -1, 302, - 333, -1, -1, 336, 307, 338, 309, 310, 311, 312, - -1, -1, -1, -1, 317, -1, -1, -1, 321, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 362, + -1, -1, -1, -1, 317, -1, 362, -1, 321, -1, + -1, -1, -1, -1, -1, -1, -1, -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, -1, -1, -1, 362, }; -#line 6185 "cs-parser.jay" +#line 6263 "cs-parser.jay" // // A class used to hold info about an operator declarator @@ -12157,21 +12279,24 @@ end_block (Location loc) return retval; } -void start_anonymous (bool lambda, ParametersCompiled parameters, Location loc) +void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync, Location loc) { - if (lang_version == LanguageVersion.ISO_1){ - FeatureIsNotAvailable (loc, "anonymous methods"); - } - oob_stack.Push (current_anonymous_method); oob_stack.Push (current_local_parameters); oob_stack.Push (current_variable); current_local_parameters = parameters; + if (isLambda) { + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (loc, "lambda expressions"); - current_anonymous_method = lambda - ? new LambdaExpression (loc) - : new AnonymousMethodExpression (loc); + current_anonymous_method = new LambdaExpression (isAsync, loc); + } else { + if (lang_version == LanguageVersion.ISO_1) + FeatureIsNotAvailable (loc, "anonymous methods"); + + current_anonymous_method = new AnonymousMethodExpression (isAsync, loc); + } // Force the next block to be created as a ToplevelBlock parsing_anonymous_method = true; @@ -12202,6 +12327,8 @@ void Error_SyntaxError (int token) void Error_SyntaxError (int error_code, int token, string msg) { + Lexer.CompleteOnEOF = false; + // An error message has been reported by tokenizer if (token == Token.ERROR) return; diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay b/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay index 320e1e60e..5e6f9e909 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay @@ -143,6 +143,21 @@ namespace Mono.CSharp UsingsBag ubag; List> mod_locations; Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; + Location savedAttrParenOpenLocation, savedAttrParenCloseLocation; + Stack> locationListStack = new Stack> (); // used for type parameters + + object lastYYVal; + + // Can be used for code completion to get the last valid expression before an error. + // needs a hack in yyparse to make it work add + // lastYYVal = yyVal; + // after the big switch/case (somewhere around line 3915) + public object LastYYVal { + get { + return lastYYVal; + } + } + %} %token EOF @@ -654,7 +669,7 @@ attribute_sections { var sect = (List) $1; $$ = new Attributes (sect); - lbag.AddLocation ($$, savedOpenLocation, savedCloseLocation); + lbag.AddLocation (sect, savedOpenLocation, savedCloseLocation); } | attribute_sections attribute_section { @@ -664,6 +679,7 @@ attribute_sections attrs = new Attributes (sect); else attrs.AddAttributes (sect); + lbag.AddLocation (sect, savedOpenLocation, savedCloseLocation); $$ = attrs; } ; @@ -759,6 +775,9 @@ attribute Arguments [] arguments = (Arguments []) $3; ATypeNameExpression expr = mname.GetTypeExpression (); $$ = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname)); + if (arguments != null) { + lbag.AddLocation ($$, savedAttrParenOpenLocation, savedAttrParenCloseLocation); + } } ; @@ -770,6 +789,8 @@ opt_attribute_arguments : /* empty */ { $$ = null; } | OPEN_PARENS attribute_arguments CLOSE_PARENS { + savedAttrParenOpenLocation = GetLocation ($1); + savedAttrParenCloseLocation = GetLocation ($3); $$ = $2; } ; @@ -1239,8 +1260,18 @@ method_declaration Method method = (Method) $1; method.Block = (ToplevelBlock) $3; - if (current_container.Kind == MemberKind.Interface && method.Block != null) { - report.Error (531, method.Location, "`{0}': interface members cannot have a definition", method.GetSignatureForError ()); + if (method.Block == null) { + method.ParameterInfo.CheckParameters (method); + + if ((method.ModFlags & Modifiers.ASYNC) != 0) { + report.Error (1994, method.Location, "`{0}': The async modifier can only be used with methods that have a body", + method.GetSignatureForError ()); + } + } else { + if (current_container.Kind == MemberKind.Interface) { + report.Error (531, method.Location, "`{0}': interface members cannot have a definition", + method.GetSignatureForError ()); + } } current_local_parameters = null; @@ -1298,9 +1329,14 @@ method_header | opt_attributes opt_modifiers PARTIAL - VOID method_declaration_name + VOID + { + lexer.parsing_generic_declaration = true; + } + method_declaration_name OPEN_PARENS { + lexer.parsing_generic_declaration = false; valid_param_mod = ParameterModifierType.All; } opt_formal_parameter_list CLOSE_PARENS @@ -1312,10 +1348,10 @@ method_header lexer.ConstraintsParsing = false; valid_param_mod = 0; - MemberName name = (MemberName) $5; - current_local_parameters = (ParametersCompiled) $8; + MemberName name = (MemberName) $6; + current_local_parameters = (ParametersCompiled) $9; - if ($10 != null && name.TypeArguments == null) + if ($11 != null && name.TypeArguments == null) report.Error (80, lexer.Location, "Constraints are not allowed on non-generic declarations"); @@ -1331,7 +1367,6 @@ method_header var modifiers = (Modifiers) $2; - const Modifiers invalid_partial_mod = Modifiers.AccessibilityMask | Modifiers.ABSTRACT | Modifiers.EXTERN | Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.SEALED | Modifiers.VIRTUAL; @@ -1354,9 +1389,8 @@ method_header if (doc_support) method.DocComment = Lexer.consume_doc_comment (); - // TODO: lbag, push void StoreModifierLocation (Modifiers.PARTIAL, GetLocation ($3)); - lbag.AddMember (method, GetModifierLocations (), GetLocation ($6), GetLocation ($9)); + lbag.AddMember (method, mod_locations, GetLocation ($7), GetLocation ($10)); $$ = method; } | opt_attributes @@ -1722,8 +1756,7 @@ indexer_declaration { valid_param_mod = 0; var type = (FullNamedExpression) $3; - Indexer indexer = new Indexer (current_class, type, - (MemberName)$4, (Modifiers) $2, (ParametersCompiled) $7, (Attributes) $1); + Indexer indexer = new Indexer (current_class, type, (MemberName) $4, (Modifiers) $2, (ParametersCompiled) $7, (Attributes) $1); current_property = indexer; @@ -1746,10 +1779,13 @@ indexer_declaration } accessor_declarations { - lexer.PropertyParsing = false; + lexer.PropertyParsing = false; } CLOSE_BRACE - { + { + if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) + ((Indexer) current_property).ParameterInfo.CheckParameters (current_property); + if (doc_support) current_property.DocComment = ConsumeStoredComment (); @@ -1974,6 +2010,9 @@ operator_declaration current_class, decl.optype, decl.ret_type, (Modifiers) $2, current_local_parameters, (ToplevelBlock) $5, (Attributes) $1, decl.location); + + if (op.Block == null) + op.ParameterInfo.CheckParameters (op); if (doc_support) { op.DocComment = tmpComment; @@ -2619,9 +2658,11 @@ delegate_declaration Delegate del = new Delegate (current_namespace, current_class, (FullNamedExpression) $4, (Modifiers) $2, name, p, (Attributes) $1); + p.CheckParameters (del); ubag.PushTypeDeclaration (del); ubag.PopTypeDeclaration (); + current_container.AddDelegate (del); current_delegate = del; lexer.ConstraintsParsing = true; @@ -2694,9 +2735,13 @@ opt_type_argument_list | OP_GENERICS_LT type_arguments OP_GENERICS_GT { if (lang_version < LanguageVersion.ISO_2) - FeatureIsNotAvailable (GetLocation ($1), "generics"); - - $$ = $2; + FeatureIsNotAvailable (GetLocation ($1), "generics"); + var list = locationListStack.Pop (); + list.Add (GetLocation ($1)); + list.Add (GetLocation ($2)); + lbag.AddLocation ($2, list); + + $$ = $2;; } | OP_GENERICS_LT error { @@ -2711,13 +2756,15 @@ type_arguments TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) $1); $$ = type_args; + locationListStack.Push (new List ()); } | type_arguments COMMA type { TypeArguments type_args = (TypeArguments) $1; type_args.Add ((FullNamedExpression) $3); $$ = type_args; - } + locationListStack.Peek ().Add (GetLocation ($2)); + } ; // @@ -3722,7 +3769,7 @@ pointer_member_access anonymous_method_expression : DELEGATE opt_anonymous_method_signature { - start_anonymous (false, (ParametersCompiled) $2, GetLocation ($1)); + start_anonymous (false, (ParametersCompiled) $2, false, GetLocation ($1)); } block { @@ -3733,6 +3780,14 @@ anonymous_method_expression lbag.AddLocation ($$, GetLocation ($1)); } } + | ASYNC DELEGATE opt_anonymous_method_signature + { + start_anonymous (false, (ParametersCompiled) $3, true, GetLocation ($1)); + } + block + { + $$ = end_anonymous ((ParametersBlock) $5); + } ; opt_anonymous_method_signature @@ -3793,6 +3848,7 @@ cast_expression await_expression : AWAIT unary_expression { + current_block.ParametersBlock.IsAsync = true; $$ = new Await ((Expression) $2, GetLocation ($1)); } ; @@ -4127,32 +4183,54 @@ expression_or_error lambda_expression : IDENTIFIER ARROW { - var lt = (Tokenizer.LocatedToken) $1; + var lt = (Tokenizer.LocatedToken) $1; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); - start_anonymous (true, new ParametersCompiled (p), GetLocation ($1)); + start_anonymous (true, new ParametersCompiled (p), false, lt.Location); } lambda_expression_body { $$ = end_anonymous ((ParametersBlock) $4); lbag.AddLocation ($$, GetLocation ($2)); } + | ASYNC IDENTIFIER ARROW + { + var lt = (Tokenizer.LocatedToken) $2; + Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); + start_anonymous (true, new ParametersCompiled (p), true, lt.Location); + } + lambda_expression_body + { + $$ = end_anonymous ((ParametersBlock) $5); + lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3)); + } | OPEN_PARENS_LAMBDA { - if (lang_version <= LanguageVersion.ISO_2) - FeatureIsNotAvailable (GetLocation ($1), "lambda expressions"); - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } opt_lambda_parameter_list CLOSE_PARENS ARROW { valid_param_mod = 0; - start_anonymous (true, (ParametersCompiled) $3, GetLocation ($1)); + start_anonymous (true, (ParametersCompiled) $3, false, GetLocation ($1)); } - lambda_expression_body + lambda_expression_body { $$ = end_anonymous ((ParametersBlock) $7); lbag.AddLocation ($$, GetLocation ($4), GetLocation ($5)); } + | ASYNC OPEN_PARENS_LAMBDA + { + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + } + opt_lambda_parameter_list CLOSE_PARENS ARROW + { + valid_param_mod = 0; + start_anonymous (true, (ParametersCompiled) $4, true, GetLocation ($1)); + } + lambda_expression_body + { + $$ = end_anonymous ((ParametersBlock) $8); + lbag.AddLocation ($$, GetLocation ($1), GetLocation ($5), GetLocation ($6)); + } ; expression @@ -4364,7 +4442,7 @@ modifier StoreModifierLocation ($$, GetLocation ($1)); } ; - + opt_class_base : /* empty */ | COLON type_list @@ -4923,10 +5001,10 @@ statement_expression ExpressionStatement s = $1 as ExpressionStatement; if (s == null) { Expression.Error_InvalidExpressionStatement (report, GetLocation ($1)); - s = EmptyExpressionStatement.Instance; + $$ = new StatementExpression (EmptyExpressionStatement.Instance); + } else { + $$ = new StatementExpression (s); } - - $$ = new StatementExpression (s); } ; @@ -6490,21 +6568,24 @@ end_block (Location loc) return retval; } -void start_anonymous (bool lambda, ParametersCompiled parameters, Location loc) +void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync, Location loc) { - if (lang_version == LanguageVersion.ISO_1){ - FeatureIsNotAvailable (loc, "anonymous methods"); - } - oob_stack.Push (current_anonymous_method); oob_stack.Push (current_local_parameters); oob_stack.Push (current_variable); current_local_parameters = parameters; + if (isLambda) { + if (lang_version <= LanguageVersion.ISO_2) + FeatureIsNotAvailable (loc, "lambda expressions"); - current_anonymous_method = lambda - ? new LambdaExpression (loc) - : new AnonymousMethodExpression (loc); + current_anonymous_method = new LambdaExpression (isAsync, loc); + } else { + if (lang_version == LanguageVersion.ISO_1) + FeatureIsNotAvailable (loc, "anonymous methods"); + + current_anonymous_method = new AnonymousMethodExpression (isAsync, loc); + } // Force the next block to be created as a ToplevelBlock parsing_anonymous_method = true; @@ -6535,6 +6616,8 @@ void Error_SyntaxError (int token) void Error_SyntaxError (int error_code, int token, string msg) { + Lexer.CompleteOnEOF = false; + // An error message has been reported by tokenizer if (token == Token.ERROR) return; diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs index d3d1d485e..6054c4462 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-tokenizer.cs @@ -789,7 +789,7 @@ namespace Mono.CSharp // TODO: async, it's modifiers context only case Token.ASYNC: - if (parsing_block > 0 || context.Settings.Version != LanguageVersion.Future) { + if (context.Settings.Version != LanguageVersion.Future) { res = -1; } break; @@ -1080,6 +1080,8 @@ namespace Mono.CSharp case Token.VOID: break; case Token.OP_GENERICS_GT: + case Token.IN: + case Token.OUT: return true; default: @@ -1294,7 +1296,7 @@ namespace Mono.CSharp } } - int integer_type_suffix (ulong ul, int c) + ILiteralConstant integer_type_suffix (ulong ul, int c, Location loc) { bool is_unsigned = false; bool is_long = false; @@ -1337,40 +1339,38 @@ namespace Mono.CSharp } if (is_long && is_unsigned){ - val = new ULongLiteral (context.BuiltinTypes, ul, Location); - return Token.LITERAL; + return new ULongLiteral (context.BuiltinTypes, ul, loc); } if (is_unsigned){ // uint if possible, or ulong else. if ((ul & 0xffffffff00000000) == 0) - val = new UIntLiteral (context.BuiltinTypes, (uint) ul, Location); + return new UIntLiteral (context.BuiltinTypes, (uint) ul, loc); else - val = new ULongLiteral (context.BuiltinTypes, ul, Location); + return new ULongLiteral (context.BuiltinTypes, ul, loc); } else if (is_long){ // long if possible, ulong otherwise if ((ul & 0x8000000000000000) != 0) - val = new ULongLiteral (context.BuiltinTypes, ul, Location); + return new ULongLiteral (context.BuiltinTypes, ul, loc); else - val = new LongLiteral (context.BuiltinTypes, (long) ul, Location); + return new LongLiteral (context.BuiltinTypes, (long) ul, loc); } else { // int, uint, long or ulong in that order if ((ul & 0xffffffff00000000) == 0){ uint ui = (uint) ul; if ((ui & 0x80000000) != 0) - val = new UIntLiteral (context.BuiltinTypes, ui, Location); + return new UIntLiteral (context.BuiltinTypes, ui, loc); else - val = new IntLiteral (context.BuiltinTypes, (int) ui, Location); + return new IntLiteral (context.BuiltinTypes, (int) ui, loc); } else { if ((ul & 0x8000000000000000) != 0) - val = new ULongLiteral (context.BuiltinTypes, ul, Location); + return new ULongLiteral (context.BuiltinTypes, ul, loc); else - val = new LongLiteral (context.BuiltinTypes, (long) ul, Location); + return new LongLiteral (context.BuiltinTypes, (long) ul, loc); } } - return Token.LITERAL; } // @@ -1378,7 +1378,7 @@ namespace Mono.CSharp // we need to convert to a special type, and then choose // the best representation for the integer // - int adjust_int (int c) + ILiteralConstant adjust_int (int c, Location loc) { try { if (number_pos > 9){ @@ -1387,63 +1387,58 @@ namespace Mono.CSharp for (int i = 1; i < number_pos; i++){ ul = checked ((ul * 10) + ((uint)(number_builder [i] - '0'))); } - return integer_type_suffix (ul, c); + + return integer_type_suffix (ul, c, loc); } else { uint ui = (uint) (number_builder [0] - '0'); for (int i = 1; i < number_pos; i++){ ui = checked ((ui * 10) + ((uint)(number_builder [i] - '0'))); } - return integer_type_suffix (ui, c); + + return integer_type_suffix (ui, c, loc); } } catch (OverflowException) { Error_NumericConstantTooLong (); - val = new IntLiteral (context.BuiltinTypes, 0, Location); - return Token.LITERAL; + return new IntLiteral (context.BuiltinTypes, 0, loc); } catch (FormatException) { Report.Error (1013, Location, "Invalid number"); - val = new IntLiteral (context.BuiltinTypes, 0, Location); - return Token.LITERAL; + return new IntLiteral (context.BuiltinTypes, 0, loc); } } - int adjust_real (TypeCode t) + ILiteralConstant adjust_real (TypeCode t, Location loc) { - string s = new String (number_builder, 0, number_pos); + string s = new string (number_builder, 0, number_pos); const string error_details = "Floating-point constant is outside the range of type `{0}'"; switch (t){ case TypeCode.Decimal: try { - val = new DecimalLiteral (context.BuiltinTypes, decimal.Parse (s, styles, csharp_format_info), Location); + return new DecimalLiteral (context.BuiltinTypes, decimal.Parse (s, styles, csharp_format_info), loc); } catch (OverflowException) { - val = new DecimalLiteral (context.BuiltinTypes, 0, Location); Report.Error (594, Location, error_details, "decimal"); + return new DecimalLiteral (context.BuiltinTypes, 0, loc); } - break; case TypeCode.Single: try { - val = new FloatLiteral (context.BuiltinTypes, float.Parse (s, styles, csharp_format_info), Location); + return new FloatLiteral (context.BuiltinTypes, float.Parse (s, styles, csharp_format_info), loc); } catch (OverflowException) { - val = new FloatLiteral (context.BuiltinTypes, 0, Location); Report.Error (594, Location, error_details, "float"); + return new FloatLiteral (context.BuiltinTypes, 0, loc); } - break; default: try { - val = new DoubleLiteral (context.BuiltinTypes, double.Parse (s, styles, csharp_format_info), Location); + return new DoubleLiteral (context.BuiltinTypes, double.Parse (s, styles, csharp_format_info), loc); } catch (OverflowException) { - val = new DoubleLiteral (context.BuiltinTypes, 0, Location); - Report.Error (594, Location, error_details, "double"); + Report.Error (594, loc, error_details, "double"); + return new DoubleLiteral (context.BuiltinTypes, 0, loc); } - break; } - - return Token.LITERAL; } - int handle_hex () + ILiteralConstant handle_hex (Location loc) { int d; ulong ul; @@ -1458,23 +1453,22 @@ namespace Mono.CSharp } string s = new String (number_builder, 0, number_pos); + try { if (number_pos <= 8) ul = System.UInt32.Parse (s, NumberStyles.HexNumber); else ul = System.UInt64.Parse (s, NumberStyles.HexNumber); + + return integer_type_suffix (ul, peek_char (), loc); } catch (OverflowException){ Error_NumericConstantTooLong (); - val = new IntLiteral (context.BuiltinTypes, 0, Location); - return Token.LITERAL; + return new IntLiteral (context.BuiltinTypes, 0, loc); } catch (FormatException) { Report.Error (1013, Location, "Invalid number"); - val = new IntLiteral (context.BuiltinTypes, 0, Location); - return Token.LITERAL; + return new IntLiteral (context.BuiltinTypes, 0, loc); } - - return integer_type_suffix (ul, peek_char ()); } // @@ -1482,16 +1476,26 @@ namespace Mono.CSharp // int is_number (int c) { - bool is_real = false; + ILiteralConstant res; +#if FULL_AST + int read_start = reader.Position - 1; +#endif number_pos = 0; + var loc = Location; if (c >= '0' && c <= '9'){ if (c == '0'){ int peek = peek_char (); - if (peek == 'x' || peek == 'X') - return handle_hex (); + if (peek == 'x' || peek == 'X') { + val = res = handle_hex (loc); +#if FULL_AST + res.ParsedValue = reader.ReadChars (read_start, reader.Position - 1); +#endif + + return Token.LITERAL; + } } decimal_digits (c); c = get_char (); @@ -1501,6 +1505,7 @@ namespace Mono.CSharp // We need to handle the case of // "1.1" vs "1.string" (LITERAL_FLOAT vs NUMBER DOT IDENTIFIER) // + bool is_real = false; if (c == '.'){ if (decimal_digits ('.')){ is_real = true; @@ -1508,7 +1513,12 @@ namespace Mono.CSharp } else { putback ('.'); number_pos--; - return adjust_int (-1); + val = res = adjust_int (-1, loc); + +#if FULL_AST + res.ParsedValue = reader.ReadChars (read_start, reader.Position - 1); +#endif + return Token.LITERAL; } } @@ -1516,7 +1526,7 @@ namespace Mono.CSharp is_real = true; if (number_pos == max_number_size) Error_NumericConstantTooLong (); - number_builder [number_pos++] = 'e'; + number_builder [number_pos++] = (char) c; c = get_char (); if (c == '+'){ @@ -1540,21 +1550,26 @@ namespace Mono.CSharp } var type = real_type_suffix (c); - if (type == TypeCode.Empty && !is_real){ + if (type == TypeCode.Empty && !is_real) { putback (c); - return adjust_int (c); - } + res = adjust_int (c, loc); + } else { + is_real = true; - is_real = true; + if (type == TypeCode.Empty) { + putback (c); + } - if (type == TypeCode.Empty){ - putback (c); + res = adjust_real (type, loc); } - - if (is_real) - return adjust_real (type); - throw new Exception ("Is Number should never reach this point"); + val = res; + +#if FULL_AST + res.ParsedValue = reader.ReadChars (read_start, reader.Position - (type == TypeCode.Empty ? 1 : 0)); +#endif + + return Token.LITERAL; } // @@ -2682,6 +2697,10 @@ namespace Mono.CSharp if (quoted) start_location = start_location - 1; +#if FULL_AST + int reader_pos = reader.Position; +#endif + while (true){ c = get_char (); if (c == '"') { @@ -2702,13 +2721,23 @@ namespace Mono.CSharp else s = new string (value_builder, 0, pos); - val = new StringLiteral (context.BuiltinTypes, s, start_location); + ILiteralConstant res = new StringLiteral (context.BuiltinTypes, s, start_location); + val = res; +#if FULL_AST + res.ParsedValue = quoted ? + reader.ReadChars (reader_pos - 2, reader.Position - 1) : + reader.ReadChars (reader_pos - 1, reader.Position); +#endif + return Token.LITERAL; } if (c == '\n') { - if (!quoted) + if (!quoted) { Report.Error (1010, Location, "Newline in constant"); + val = new StringLiteral (context.BuiltinTypes, new string (value_builder, 0, pos), start_location); + return Token.LITERAL; + } } else if (c == '\\' && !quoted) { int surrogate; c = escape (c, out surrogate); diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs index a00769c49..0329cf6a5 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/decl.cs @@ -918,11 +918,12 @@ namespace Mono.CSharp { PendingMemberCacheMembers = 1 << 14, PendingBaseTypeInflate = 1 << 15, InterfacesExpanded = 1 << 16, - IsNotRealProperty = 1 << 17, + IsNotCSharpCompatible = 1 << 17, SpecialRuntimeType = 1 << 18, InflatedExpressionType = 1 << 19, InflatedNullableType = 1 << 20, GenericIterateInterface = 1 << 21, + GenericTask = 1 << 22 } protected Modifiers modifiers; @@ -1010,6 +1011,18 @@ namespace Mono.CSharp { } } + // + // Returns true for imported members which are not compatible with C# language + // + public bool IsNotCSharpCompatible { + get { + return (state & StateFlags.IsNotCSharpCompatible) != 0; + } + set { + state = value ? state | StateFlags.IsNotCSharpCompatible : state & ~StateFlags.IsNotCSharpCompatible; + } + } + public bool IsPrivate { get { return (modifiers & Modifiers.PRIVATE) != 0; } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs index ea3b2510c..769154d69 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/doc.cs @@ -150,6 +150,10 @@ namespace Mono.CSharp HandleSeeAlso (mc, ds_target, seealso); foreach (XmlElement see in n.SelectNodes (".//exception")) HandleException (mc, ds_target, see); + foreach (XmlElement node in n.SelectNodes (".//typeparam")) + HandleTypeParam (mc, node); + foreach (XmlElement node in n.SelectNodes (".//typeparamref")) + HandleTypeParamRef (mc, node); } n.WriteTo (XmlCommentOutput); @@ -229,6 +233,55 @@ namespace Mono.CSharp HandleXrefCommon (mc, ds, seealso); } + // + // Handles node + // + void HandleTypeParam (MemberCore mc, XmlElement node) + { + if (!node.HasAttribute ("name")) + return; + + string tp_name = node.GetAttribute ("name"); + if (mc.CurrentTypeParameters != null) { + foreach (var tp in mc.CurrentTypeParameters) { + if (tp.Name == tp_name) + return; + } + } + + // TODO: CS1710, CS1712 + + mc.Compiler.Report.Warning (1711, 2, mc.Location, + "XML comment on `{0}' has a typeparam name `{1}' but there is no type parameter by that name", + mc.GetSignatureForError (), tp_name); + } + + // + // Handles node + // + void HandleTypeParamRef (MemberCore mc, XmlElement node) + { + if (!node.HasAttribute ("name")) + return; + + string tp_name = node.GetAttribute ("name"); + var member = mc; + do { + if (member.CurrentTypeParameters != null) { + foreach (var tp in member.CurrentTypeParameters) { + if (tp.Name == tp_name) + return; + } + } + + member = member.Parent; + } while (member != null); + + mc.Compiler.Report.Warning (1735, 2, mc.Location, + "XML comment on `{0}' has a typeparamref name `{1}' that could not be resolved", + mc.GetSignatureForError (), tp_name); + } + FullNamedExpression ResolveMemberName (IMemberContext context, MemberName mn) { if (mn.Left == null) diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs index d0b1cb971..de220c3e7 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/driver.cs @@ -357,6 +357,7 @@ namespace Mono.CSharp public LocationsBag LocationsBag { get; set; } public UsingsBag UsingsBag { get; set; } public SpecialsBag SpecialsBag { get; set; } + public object LastYYValue { get; set; } } // @@ -454,8 +455,14 @@ namespace Mono.CSharp 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 }; + + return new CompilerCompilationUnit () { + ModuleCompiled = RootContext.ToplevelTypes, + LocationsBag = parser.LocationsBag, + UsingsBag = parser.UsingsBag, + SpecialsBag = parser.Lexer.sbag, + LastYYValue = parser.LastYYVal + }; } finally { Reset (); } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs index 6e736c811..3be2ce0cd 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/ecore.cs @@ -588,9 +588,9 @@ namespace Mono.CSharp { continue; } - if (non_method == null || member is MethodSpec) { + if (non_method == null || member is MethodSpec || non_method.IsNotCSharpCompatible) { non_method = member; - } else if (!errorMode) { + } else if (!errorMode && !member.IsNotCSharpCompatible) { ambig_non_method = member; } } @@ -1873,18 +1873,18 @@ namespace Mono.CSharp { this.loc = expr.Location; } - public override Expression CreateExpressionTree (ResolveContext ec) + public override Expression CreateExpressionTree (ResolveContext rc) { - return expr.CreateExpressionTree (ec); + return expr.CreateExpressionTree (rc); } public Expression Child { get { return expr; } } - protected override Expression DoResolve (ResolveContext ec) + protected override Expression DoResolve (ResolveContext rc) { - expr = expr.Resolve (ec); + expr = expr.Resolve (rc); if (expr != null) { type = expr.Type; eclass = expr.eclass; @@ -1915,6 +1915,12 @@ namespace Mono.CSharp { this.expr = expr; } + public Expression Expr { + get { + return expr; + } + } + protected override void CloneTo (CloneContext clonectx, Expression t) { if (expr == null) @@ -1934,9 +1940,6 @@ namespace Mono.CSharp { throw new InternalErrorException ("Missing Resolve call"); } - public Expression Expr { - get { return expr; } - } } // @@ -2313,10 +2316,13 @@ namespace Mono.CSharp { e = rc.LookupNamespaceOrType (Name, -System.Math.Max (1, Arity), LookupMode.Probing, loc); if (e != null) { - Error_TypeArgumentsCannotBeUsed (rc, e.Type, Arity, loc); - } else { - rc.Report.Error (103, loc, "The name `{0}' does not exist in the current context", Name); + if (!(e is TypeExpr) || (restrictions & MemberLookupRestrictions.InvocableOnly) == 0 || !e.Type.IsDelegate) { + Error_TypeArgumentsCannotBeUsed (rc, e.Type, Arity, loc); + return e; + } } + + rc.Report.Error (103, loc, "The name `{0}' does not exist in the current context", Name); } return ErrorExpression.Instance; @@ -2329,7 +2335,6 @@ namespace Mono.CSharp { } lookup_arity = 0; - restrictions &= ~MemberLookupRestrictions.InvocableOnly; errorMode = true; } } @@ -2525,7 +2530,6 @@ namespace Mono.CSharp { get; } - // TODO: Not needed protected abstract TypeSpec DeclaringType { get; } @@ -3418,6 +3422,28 @@ namespace Mono.CSharp { if (q.Kind == MemberKind.Void) { return p.Kind != MemberKind.Void ? 1: 0; } + + // + // When anonymous method is an asynchronous, and P has a return type Task, and Q has a return type Task + // better conversion is performed between underlying types Y1 and Y2 + // + if (p.IsGenericTask || q.IsGenericTask) { + if (p.IsGenericTask != q.IsGenericTask) { + return 0; + } + + var async_am = a.Expr as AnonymousMethodExpression; + if (async_am == null || !async_am.IsAsync) + return 0; + + q = q.TypeArguments[0]; + p = p.TypeArguments[0]; + } + + // + // The parameters are identicial and return type is not void, use better type conversion + // on return type to determine better one + // } else { if (argument_type == p) return 1; @@ -5084,11 +5110,21 @@ namespace Mono.CSharp { public void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool prepare_for_load) { - prepared = prepare_for_load && !(source is DynamicExpressionStatement); - if (IsInstance) - EmitInstance (ec, prepared); + var await_expr = source as Await; + if (await_expr != null) { + // + // Await is not ordinary expression (it contains jump), hence the usual flow cannot be used + // to emit instance load before expression + // + await_expr.EmitAssign (ec, this); + } else { + prepared = prepare_for_load && !(source is DynamicExpressionStatement); + if (IsInstance) + EmitInstance (ec, prepared); + + source.Emit (ec); + } - source.Emit (ec); if (leave_copy) { ec.Emit (OpCodes.Dup); if (!IsStatic) { @@ -5370,7 +5406,7 @@ namespace Mono.CSharp { { eclass = ExprClass.PropertyAccess; - if (best_candidate.IsNotRealProperty) { + if (best_candidate.IsNotCSharpCompatible) { Error_PropertyNotValid (rc); } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs index 3bbae9555..03097dfd8 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/eval.cs @@ -962,17 +962,17 @@ namespace Mono.CSharp static public string help { get { return "Static methods:\n" + - " Describe (object) - Describes the object's type\n" + - " LoadPackage (package); - Loads the given Package (like -pkg:FILE)\n" + - " LoadAssembly (assembly) - Loads the given assembly (like -r:ASSEMBLY)\n" + - " ShowVars (); - Shows defined local variables.\n" + - " ShowUsing (); - Show active using declarations.\n" + - " Prompt - The prompt used by the C# shell\n" + - " ContinuationPrompt - The prompt for partial input\n" + - " Time(() -> { }) - Times the specified code\n" + - " print (obj) - Shorthand for Console.WriteLine\n" + - " quit; - You'll never believe it - this quits the repl!\n" + - " help; - This help text\n"; + " Describe (object); - Describes the object's type\n" + + " LoadPackage (package); - Loads the given Package (like -pkg:FILE)\n" + + " LoadAssembly (assembly); - Loads the given assembly (like -r:ASSEMBLY)\n" + + " ShowVars (); - Shows defined local variables.\n" + + " ShowUsing (); - Show active using declarations.\n" + + " Prompt - The prompt used by the C# shell\n" + + " ContinuationPrompt - The prompt for partial input\n" + + " Time (() => { }); - Times the specified code\n" + + " print (obj); - Shorthand for Console.WriteLine\n" + + " quit; - You'll never believe it - this quits the repl!\n" + + " help; - This help text\n"; } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs index adce86b0a..3349a7c00 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs @@ -7141,9 +7141,7 @@ namespace Mono.CSharp FullNamedExpression texpr; public FullNamedExpression FullNamedExpression { - get { - return texpr; - } + get { return texpr;} } public RefValueExpr (Expression expr, FullNamedExpression texpr, Location loc) @@ -7728,6 +7726,22 @@ namespace Mono.CSharp return e; } + protected virtual void Error_OperatorCannotBeApplied (ResolveContext rc, TypeSpec type) + { + if (type == InternalType.NullLiteral && rc.IsRuntimeBinder) + rc.Report.Error (Report.RuntimeErrorId, loc, "Cannot perform member binding on `null' value"); + else + Unary.Error_OperatorCannotBeApplied (rc, loc, ".", type); + } + + public static bool IsValidDotExpression (TypeSpec type) + { + const MemberKind dot_kinds = MemberKind.Class | MemberKind.Struct | MemberKind.Delegate | MemberKind.Enum | + MemberKind.Interface | MemberKind.TypeParameter | MemberKind.ArrayType; + + return (type.Kind & dot_kinds) != 0; + } + public override Expression LookupNameExpression (ResolveContext rc, MemberLookupRestrictions restrictions) { var sn = expr as SimpleName; @@ -7788,14 +7802,8 @@ namespace Mono.CSharp return new DynamicMemberBinder (Name, args, loc); } - 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) { - 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); + if (!IsValidDotExpression (expr_type)) { + Error_OperatorCannotBeApplied (rc, expr_type); return null; } @@ -8518,6 +8526,7 @@ namespace Mono.CSharp } #region Properties + protected override TypeSpec DeclaringType { get { return best_candidate.DeclaringType; @@ -9931,43 +9940,4 @@ namespace Mono.CSharp Name, initializer); } } - - class Await : ExpressionStatement - { - Expression expr; - - public Await (Expression expr, Location loc) - { - this.expr = expr; - this.loc = loc; - } - - public override Expression CreateExpressionTree (ResolveContext ec) - { - throw new NotImplementedException (); - } - - public override void Emit (EmitContext ec) - { - throw new NotImplementedException (); - } - - public override void EmitStatement (EmitContext ec) - { - throw new NotImplementedException (); - } - - protected override Expression DoResolve (ResolveContext rc) - { - expr = expr.Resolve (rc); - if (expr == null) - return null; - -// Iterator.CreateIterator - - type = expr.Type; - eclass = expr.eclass; - return this; - } - } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs index eb8e6570b..d864dc875 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/flowanalysis.cs @@ -636,8 +636,9 @@ namespace Mono.CSharp public class FlowBranchingIterator : FlowBranchingBlock { - Iterator iterator; - public FlowBranchingIterator (FlowBranching parent, Iterator iterator) + readonly StateMachineInitializer iterator; + + public FlowBranchingIterator (FlowBranching parent, StateMachineInitializer iterator) : base (parent, BranchingType.Iterator, SiblingType.Block, iterator.Block, iterator.Location) { this.iterator = iterator; diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs index c96f2d0e7..197570477 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/generic.cs @@ -1517,6 +1517,12 @@ namespace Mono.CSharp { } } + public override bool IsGenericTask { + get { + return (open_type.state & StateFlags.GenericTask) != 0; + } + } + public override bool IsNullableType { get { return (open_type.state & StateFlags.InflatedNullableType) != 0; @@ -2782,7 +2788,8 @@ namespace Mono.CSharp { // // Some types cannot be used as type arguments // - if (bound.Type.Kind == MemberKind.Void || bound.Type.IsPointer || bound.Type.IsSpecialRuntimeType) + if (bound.Type.Kind == MemberKind.Void || bound.Type.IsPointer || bound.Type.IsSpecialRuntimeType || + bound.Type == InternalType.MethodGroup) return; var a = bounds [index]; @@ -3063,6 +3070,11 @@ namespace Mono.CSharp { fixed_types[i] = best_candidate; return true; } + + public bool HasBounds (int pos) + { + return bounds[pos] != null; + } // // Uses inferred or partially infered types to inflate delegate type argument. Returns diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs index c8a49cfcd..137c5ccb3 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/import.cs @@ -615,7 +615,7 @@ namespace Mono.CSharp spec = new PropertySpec (MemberKind.Property, declaringType, new ImportedMemberDefinition (pi, type, this), type, pi, mod); if (!is_valid_property) { - spec.IsNotRealProperty = true; + spec.IsNotCSharpCompatible = true; return spec; } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs index f3bab35e2..9a256de68 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/iterators.cs @@ -23,70 +23,86 @@ using IKVM.Reflection.Emit; using System.Reflection.Emit; #endif -namespace Mono.CSharp { - - public class Yield : ResumableStatement { - Expression expr; +namespace Mono.CSharp +{ + public abstract class YieldStatement : ResumableStatement where T : StateMachineInitializer + { + protected Expression expr; bool unwind_protect; - Iterator iterator; + protected T machine_initializer; int resume_pc; public Expression Expr { get { return this.expr; } } - public Yield (Expression expr, Location l) + protected YieldStatement (Expression expr, Location l) { this.expr = expr; loc = l; } + protected override void CloneTo (CloneContext clonectx, Statement t) + { + var target = (YieldStatement) t; + target.expr = expr.Clone (clonectx); + } + + protected override void DoEmit (EmitContext ec) + { + machine_initializer.InjectYield (ec, expr, resume_pc, unwind_protect, resume_point); + } + + public override bool Resolve (BlockContext bc) + { + expr = expr.Resolve (bc); + if (expr == null) + return false; + + machine_initializer = bc.CurrentAnonymousMethod as T; + + if (!bc.CurrentBranching.CurrentUsageVector.IsUnreachable) + unwind_protect = bc.CurrentBranching.AddResumePoint (this, loc, out resume_pc); + + return true; + } + } + + public class Yield : YieldStatement + { + public Yield (Expression expr, Location loc) + : base (expr, loc) + { + } + public static bool CheckContext (ResolveContext ec, Location loc) { if (!ec.CurrentAnonymousMethod.IsIterator) { ec.Report.Error (1621, loc, - "The yield statement cannot be used inside " + - "anonymous method blocks"); + "The yield statement cannot be used inside anonymous method blocks"); return false; } return true; } - public override bool Resolve (BlockContext ec) + public override bool Resolve (BlockContext bc) { - expr = expr.Resolve (ec); - if (expr == null) + if (!CheckContext (bc, loc)) return false; - if (!CheckContext (ec, loc)) + if (!base.Resolve (bc)) return false; - iterator = ec.CurrentIterator; - if (expr.Type != iterator.OriginalIteratorType) { - expr = Convert.ImplicitConversionRequired ( - ec, expr, iterator.OriginalIteratorType, loc); + var otype = bc.CurrentIterator.OriginalIteratorType; + if (expr.Type != otype) { + expr = Convert.ImplicitConversionRequired (bc, expr, otype, loc); if (expr == null) return false; } - if (!ec.CurrentBranching.CurrentUsageVector.IsUnreachable) - unwind_protect = ec.CurrentBranching.AddResumePoint (this, loc, out resume_pc); - return true; } - - protected override void DoEmit (EmitContext ec) - { - iterator.MarkYield (ec, expr, resume_pc, unwind_protect, resume_point); - } - - protected override void CloneTo (CloneContext clonectx, Statement t) - { - Yield target = (Yield) t; - - target.expr = expr.Clone (clonectx); - } public override object Accept (StructuralVisitor visitor) { @@ -130,18 +146,83 @@ namespace Mono.CSharp { } } - public class IteratorStorey : AnonymousMethodStorey + public abstract class StateMachine : AnonymousMethodStorey { - class GetEnumeratorMethod : IteratorMethod + public enum State + { + Running = -3, // Used only in CurrentPC, never stored into $PC + Uninitialized = -2, + After = -1, + Start = 0 + } + + Field disposing_field; + Field pc_field; + int local_name_idx; + StateMachineMethod method; + + protected StateMachine (Block block, TypeContainer parent, MemberBase host, TypeParameter[] tparams, string name) + : base (block, parent, host, tparams, name) + { + } + + #region Properties + + public Field DisposingField { + get { + return disposing_field; + } + } + + public StateMachineMethod StateMachineMethod { + get { + return method; + } + } + + public Field PC { + get { + return pc_field; + } + } + + #endregion + + public void AddEntryMethod (StateMachineMethod method) + { + if (this.method != null) + throw new InternalErrorException (); + + this.method = method; + AddMethod (method); + } + + protected override bool DoDefineMembers () + { + pc_field = AddCompilerGeneratedField ("$PC", new TypeExpression (Compiler.BuiltinTypes.Int, Location)); + disposing_field = AddCompilerGeneratedField ("$disposing", new TypeExpression (Compiler.BuiltinTypes.Bool, Location)); + + return base.DoDefineMembers (); + } + + protected override string GetVariableMangledName (LocalVariable local_info) + { + return "<" + local_info.Name + ">__" + local_name_idx++.ToString (); + } + } + + class IteratorStorey : StateMachine + { + class GetEnumeratorMethod : StateMachineMethod { sealed class GetEnumeratorStatement : Statement { - IteratorStorey host; - IteratorMethod host_method; + readonly IteratorStorey host; + readonly StateMachineMethod host_method; Expression new_storey; - public GetEnumeratorStatement (IteratorStorey host, IteratorMethod host_method) + public GetEnumeratorStatement (IteratorStorey host, StateMachineMethod host_method) { this.host = host; this.host_method = host_method; @@ -170,8 +251,8 @@ namespace Mono.CSharp { init = new List (host.HoistedParameters.Count); for (int i = 0; i < host.hoisted_params.Count; ++i) { - HoistedParameter hp = (HoistedParameter) host.hoisted_params [i]; - HoistedParameter hp_cp = (HoistedParameter) host.hoisted_params_copy [i]; + HoistedParameter hp = host.hoisted_params [i]; + HoistedParameter hp_cp = host.hoisted_params_copy [i]; FieldExpr from = new FieldExpr (hp_cp.Field, loc); from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); @@ -201,14 +282,14 @@ namespace Mono.CSharp { ec.Emit (OpCodes.Ldarg_0); ec.Emit (OpCodes.Ldflda, host.PC.Spec); - ec.EmitInt ((int) Iterator.State.Start); - ec.EmitInt ((int) Iterator.State.Uninitialized); + ec.EmitInt ((int) State.Start); + ec.EmitInt ((int) State.Uninitialized); var m = ec.Module.PredefinedMembers.InterlockedCompareExchange.Resolve (loc); if (m != null) ec.Emit (OpCodes.Call, m); - ec.EmitInt ((int) Iterator.State.Uninitialized); + ec.EmitInt ((int) State.Uninitialized); ec.Emit (OpCodes.Bne_Un_S, label_init); ec.Emit (OpCodes.Ldarg_0); @@ -222,13 +303,13 @@ namespace Mono.CSharp { } public GetEnumeratorMethod (IteratorStorey host, FullNamedExpression returnType, MemberName name) - : base (host, returnType, Modifiers.DEBUGGER_HIDDEN, name) + : base (host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name) { Block.AddStatement (new GetEnumeratorStatement (host, this)); } } - class DisposeMethod : IteratorMethod + class DisposeMethod : StateMachineMethod { sealed class DisposeMethodStatement : Statement { @@ -252,12 +333,13 @@ namespace Mono.CSharp { protected override void DoEmit (EmitContext ec) { + ec.CurrentAnonymousMethod = iterator; iterator.EmitDispose (ec); } } public DisposeMethod (IteratorStorey host) - : base (host, new TypeExpression (host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, + : base (host, null, new TypeExpression (host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Dispose", host.Location)) { host.AddMethod (this); @@ -310,10 +392,10 @@ namespace Mono.CSharp { public readonly Iterator Iterator; + List hoisted_params_copy; + TypeExpr iterator_type_expr; - Field pc_field; Field current_field; - Field disposing_field; TypeExpr enumerator_type; TypeExpr enumerable_type; @@ -321,9 +403,6 @@ namespace Mono.CSharp { TypeExpr generic_enumerator_type; TypeExpr generic_enumerable_type; - List hoisted_params_copy; - int local_name_idx; - public IteratorStorey (Iterator iterator) : base (iterator.Container.ParametersBlock, iterator.Host, iterator.OriginalMethod as MemberBase, iterator.GenericMethod == null ? null : iterator.GenericMethod.CurrentTypeParameters, "Iterator") @@ -331,18 +410,6 @@ namespace Mono.CSharp { this.Iterator = iterator; } - public Field PC { - get { - return pc_field; - } - } - - public Field DisposingField { - get { - return disposing_field; - } - } - public Field CurrentField { get { return current_field; } } @@ -387,22 +454,9 @@ namespace Mono.CSharp { return base.ResolveBaseTypes (out base_class); } - protected override string GetVariableMangledName (LocalVariable local_info) - { - return "<" + local_info.Name + ">__" + local_name_idx++.ToString (); - } - protected override bool DoDefineMembers () { - DefineIteratorMembers (); - return base.DoDefineMembers (); - } - - void DefineIteratorMembers () - { - pc_field = AddCompilerGeneratedField ("$PC", new TypeExpression (Compiler.BuiltinTypes.Int, Location)); current_field = AddCompilerGeneratedField ("$current", iterator_type_expr); - disposing_field = AddCompilerGeneratedField ("$disposing", new TypeExpression (Compiler.BuiltinTypes.Bool, Location)); if (hoisted_params != null) { // @@ -432,7 +486,7 @@ namespace Mono.CSharp { name = new MemberName (name, "GetEnumerator", Location); if (generic_enumerator_type != null) { - Method get_enumerator = new IteratorMethod (this, enumerator_type, 0, name); + Method get_enumerator = new StateMachineMethod (this, null, enumerator_type, 0, name); name = new MemberName (name.Left.Left, "Generic", Location); name = new MemberName (name, "IEnumerable", generic_args, Location); @@ -451,12 +505,8 @@ namespace Mono.CSharp { AddMethod (new GetEnumeratorMethod (this, enumerator_type, name)); } } - } - protected override void EmitHoistedParameters (EmitContext ec, IList hoisted) - { - base.EmitHoistedParameters (ec, hoisted); - base.EmitHoistedParameters (ec, hoisted_params_copy); + return base.DoDefineMembers (); } void Define_Current (bool is_generic) @@ -504,43 +554,44 @@ namespace Mono.CSharp { reset.Block.AddStatement (new Throw (new New (new TypeExpression (ex_type, Location), null, Location), Location)); } + + protected override void EmitHoistedParameters (EmitContext ec, IList hoisted) + { + base.EmitHoistedParameters (ec, hoisted); + base.EmitHoistedParameters (ec, hoisted_params_copy); + } } - class IteratorMethod : Method + public class StateMachineMethod : Method { - readonly IteratorStorey host; + readonly StateMachineInitializer expr; - public IteratorMethod (IteratorStorey host, FullNamedExpression returnType, Modifiers mod, MemberName name) + public StateMachineMethod (StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name) : base (host, null, returnType, mod | Modifiers.COMPILER_GENERATED, name, ParametersCompiled.EmptyReadOnlyParameters, null) { - this.host = host; - + this.expr = expr; Block = new ToplevelBlock (host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location); } public override EmitContext CreateEmitContext (ILGenerator ig) { EmitContext ec = new EmitContext (this, ig, MemberType); - - ec.CurrentAnonymousMethod = host.Iterator; + ec.CurrentAnonymousMethod = expr; return ec; } } - // - // Iterators are implemented as hidden anonymous block - // - public class Iterator : AnonymousExpression + public abstract class StateMachineInitializer : AnonymousExpression { - sealed class MoveNextMethodStatement : Statement + sealed class MoveNextBodyStatement : Statement { - Iterator iterator; + readonly StateMachineInitializer state_machine; - public MoveNextMethodStatement (Iterator iterator) + public MoveNextBodyStatement (StateMachineInitializer stateMachine) { - this.iterator = iterator; - this.loc = iterator.Location; + this.state_machine = stateMachine; + this.loc = stateMachine.Location; } protected override void CloneTo (CloneContext clonectx, Statement target) @@ -555,61 +606,146 @@ namespace Mono.CSharp { protected override void DoEmit (EmitContext ec) { - iterator.EmitMoveNext (ec); + state_machine.EmitMoveNext (ec); } } - public readonly IMethodData OriginalMethod; public readonly TypeContainer Host; - public readonly bool IsEnumerable; - List resume_points; + protected StateMachine storey; // - // The state as we generate the iterator + // The state as we generate the machine // - Label move_next_ok, move_next_error; - LocalBuilder skip_finally, current_pc; + Label move_next_ok; + protected Label move_next_error; + protected LocalBuilder skip_finally, current_pc; + List resume_points; - public LocalBuilder SkipFinally { - get { return skip_finally; } + protected StateMachineInitializer (ParametersBlock block, TypeContainer host, TypeSpec returnType) + : base (block, returnType, block.StartLocation) + { + this.Host = host; } - public LocalBuilder CurrentPC { - get { return current_pc; } + public override AnonymousMethodStorey Storey { + get { + return storey; + } } - public Block Container { - get { return OriginalMethod.Block; } + public int AddResumePoint (ResumableStatement stmt) + { + if (resume_points == null) + resume_points = new List (); + + resume_points.Add (stmt); + return resume_points.Count; } - public GenericMethod GenericMethod { - get { return OriginalMethod.GenericMethod; } + public override Expression CreateExpressionTree (ResolveContext ec) + { + throw new NotSupportedException ("ET"); } - public readonly TypeSpec OriginalIteratorType; + protected virtual BlockContext CreateBlockContext (ResolveContext rc) + { + var ctx = new BlockContext (rc, block, ((BlockContext) rc).ReturnType); + ctx.CurrentAnonymousMethod = this; + return ctx; + } - IteratorStorey IteratorHost; + protected override Expression DoResolve (ResolveContext ec) + { + storey = (StateMachine) block.Parent.ParametersBlock.AnonymousMethodStorey; - public enum State { - Running = -3, // Used only in CurrentPC, never stored into $PC - Uninitialized = -2, - After = -1, - Start = 0 + var ctx = CreateBlockContext (ec); + + ctx.StartFlowBranching (this, ec.CurrentBranching); + Block.Resolve (ctx); + + // + // Explicit return is required for Task state machine + // + var task_storey = storey as AsyncTaskStorey; + if (task_storey == null || (task_storey.ReturnType != null && !task_storey.ReturnType.IsGenericTask)) + ctx.CurrentBranching.CurrentUsageVector.Goto (); + + ctx.EndFlowBranching (); + + if (!ec.IsInProbingMode) { + var move_next = new StateMachineMethod (storey, this, new TypeExpression (ReturnType, loc), Modifiers.PUBLIC, new MemberName ("MoveNext", loc)); + move_next.Block.AddStatement (new MoveNextBodyStatement (this)); + storey.AddEntryMethod (move_next); + } + + eclass = ExprClass.Value; + return this; } - public void EmitYieldBreak (EmitContext ec, bool unwind_protect) + public override void Emit (EmitContext ec) { - ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_error); + // + // Load Iterator storey instance + // + storey.Instance.Emit (ec); + } + + public void EmitDispose (EmitContext ec) + { + Label end = ec.DefineLabel (); + + Label[] labels = null; + int n_resume_points = resume_points == null ? 0 : resume_points.Count; + for (int i = 0; i < n_resume_points; ++i) { + ResumableStatement s = resume_points[i]; + Label ret = s.PrepareForDispose (ec, end); + if (ret.Equals (end) && labels == null) + continue; + if (labels == null) { + labels = new Label[resume_points.Count + 1]; + for (int j = 0; j <= i; ++j) + labels[j] = end; + } + + labels[i + 1] = ret; + } + + if (labels != null) { + current_pc = ec.GetTemporaryLocal (ec.BuiltinTypes.UInt); + ec.Emit (OpCodes.Ldarg_0); + ec.Emit (OpCodes.Ldfld, storey.PC.Spec); + ec.Emit (OpCodes.Stloc, current_pc); + } + + ec.Emit (OpCodes.Ldarg_0); + ec.EmitInt (1); + ec.Emit (OpCodes.Stfld, storey.DisposingField.Spec); + + ec.Emit (OpCodes.Ldarg_0); + ec.EmitInt ((int) IteratorStorey.State.After); + ec.Emit (OpCodes.Stfld, storey.PC.Spec); + + if (labels != null) { + //SymbolWriter.StartIteratorDispatcher (ec.ig); + ec.Emit (OpCodes.Ldloc, current_pc); + ec.Emit (OpCodes.Switch, labels); + //SymbolWriter.EndIteratorDispatcher (ec.ig); + + foreach (ResumableStatement s in resume_points) + s.EmitForDispose (ec, current_pc, end, true); + } + + ec.MarkLabel (end); } void EmitMoveNext_NoResumePoints (EmitContext ec, Block original_block) { ec.Emit (OpCodes.Ldarg_0); - ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec); + ec.Emit (OpCodes.Ldfld, storey.PC.Spec); ec.Emit (OpCodes.Ldarg_0); - ec.EmitInt ((int) State.After); - ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec); + ec.EmitInt ((int) IteratorStorey.State.After); + ec.Emit (OpCodes.Stfld, storey.PC.Spec); // We only care if the PC is zero (start executing) or non-zero (don't do anything) ec.Emit (OpCodes.Brtrue, move_next_error); @@ -618,9 +754,14 @@ namespace Mono.CSharp { original_block.Emit (ec); SymbolWriter.EndIteratorBody (ec); + EmitMoveNextEpilogue (ec); + ec.MarkLabel (move_next_error); - ec.Emit (OpCodes.Ldc_I4_0); - ec.Emit (OpCodes.Ret); + + if (ReturnType.Kind != MemberKind.Void) { + ec.EmitInt (0); + ec.Emit (OpCodes.Ret); + } } void EmitMoveNext (EmitContext ec) @@ -635,22 +776,22 @@ namespace Mono.CSharp { current_pc = ec.GetTemporaryLocal (ec.BuiltinTypes.UInt); ec.Emit (OpCodes.Ldarg_0); - ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec); + ec.Emit (OpCodes.Ldfld, storey.PC.Spec); ec.Emit (OpCodes.Stloc, current_pc); // We're actually in state 'running', but this is as good a PC value as any if there's an abnormal exit ec.Emit (OpCodes.Ldarg_0); - ec.EmitInt ((int) State.After); - ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec); + ec.EmitInt ((int) IteratorStorey.State.After); + ec.Emit (OpCodes.Stfld, storey.PC.Spec); - Label [] labels = new Label [1 + resume_points.Count]; - labels [0] = ec.DefineLabel (); + Label[] labels = new Label[1 + resume_points.Count]; + labels[0] = ec.DefineLabel (); bool need_skip_finally = false; for (int i = 0; i < resume_points.Count; ++i) { - ResumableStatement s = resume_points [i]; + ResumableStatement s = resume_points[i]; need_skip_finally |= s is ExceptionStatement; - labels [i+1] = s.PrepareForEmit (ec); + labels[i + 1] = s.PrepareForEmit (ec); } if (need_skip_finally) { @@ -666,7 +807,7 @@ namespace Mono.CSharp { ec.Emit (OpCodes.Br, move_next_error); SymbolWriter.EndIteratorDispatcher (ec); - ec.MarkLabel (labels [0]); + ec.MarkLabel (labels[0]); SymbolWriter.StartIteratorBody (ec); block.Emit (ec); @@ -675,93 +816,43 @@ namespace Mono.CSharp { SymbolWriter.StartIteratorDispatcher (ec); ec.Emit (OpCodes.Ldarg_0); - ec.EmitInt ((int) State.After); - ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec); - - ec.MarkLabel (move_next_error); - ec.EmitInt (0); - ec.Emit (OpCodes.Ret); - - ec.MarkLabel (move_next_ok); - ec.Emit (OpCodes.Ldc_I4_1); - ec.Emit (OpCodes.Ret); - - SymbolWriter.EndIteratorDispatcher (ec); - } - - public void EmitDispose (EmitContext ec) - { - Label end = ec.DefineLabel (); + ec.EmitInt ((int) IteratorStorey.State.After); + ec.Emit (OpCodes.Stfld, storey.PC.Spec); - Label [] labels = null; - int n_resume_points = resume_points == null ? 0 : resume_points.Count; - for (int i = 0; i < n_resume_points; ++i) { - ResumableStatement s = resume_points [i]; - Label ret = s.PrepareForDispose (ec, end); - if (ret.Equals (end) && labels == null) - continue; - if (labels == null) { - labels = new Label [resume_points.Count + 1]; - for (int j = 0; j <= i; ++j) - labels [j] = end; - } + EmitMoveNextEpilogue (ec); - labels [i+1] = ret; - } + ec.MarkLabel (move_next_error); - if (labels != null) { - 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); + if (ReturnType.Kind != MemberKind.Void) { + ec.EmitInt (0); + ec.Emit (OpCodes.Ret); } - ec.Emit (OpCodes.Ldarg_0); - ec.EmitInt (1); - ec.Emit (OpCodes.Stfld, IteratorHost.DisposingField.Spec); - - ec.Emit (OpCodes.Ldarg_0); - ec.EmitInt ((int) State.After); - ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec); - - if (labels != null) { - //SymbolWriter.StartIteratorDispatcher (ec.ig); - ec.Emit (OpCodes.Ldloc, current_pc); - ec.Emit (OpCodes.Switch, labels); - //SymbolWriter.EndIteratorDispatcher (ec.ig); + ec.MarkLabel (move_next_ok); - foreach (ResumableStatement s in resume_points) - s.EmitForDispose (ec, this, end, true); + if (ReturnType.Kind != MemberKind.Void) { + ec.EmitInt (1); + ec.Emit (OpCodes.Ret); } - ec.MarkLabel (end); + SymbolWriter.EndIteratorDispatcher (ec); } - public int AddResumePoint (ResumableStatement stmt) + protected virtual void EmitMoveNextEpilogue (EmitContext ec) { - if (resume_points == null) - resume_points = new List (); - - resume_points.Add (stmt); - return resume_points.Count; } // - // Called back from Yield + // Called back from YieldStatement // - public void MarkYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point) + public virtual void InjectYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point) { - // Store the new current - ec.Emit (OpCodes.Ldarg_0); - expr.Emit (ec); - ec.Emit (OpCodes.Stfld, IteratorHost.CurrentField.Spec); - // // Guard against being disposed meantime // Label disposed = ec.DefineLabel (); ec.Emit (OpCodes.Ldarg_0); - ec.Emit (OpCodes.Ldfld, IteratorHost.DisposingField.Spec); + ec.Emit (OpCodes.Ldfld, storey.DisposingField.Spec); ec.Emit (OpCodes.Brtrue_S, disposed); // @@ -769,7 +860,7 @@ namespace Mono.CSharp { // ec.Emit (OpCodes.Ldarg_0); ec.EmitInt (resume_pc); - ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec); + ec.Emit (OpCodes.Stfld, storey.PC.Spec); ec.MarkLabel (disposed); // mark finally blocks as disabled @@ -783,20 +874,42 @@ namespace Mono.CSharp { ec.MarkLabel (resume_point); } + } + + // + // Iterators are implemented as hidden anonymous block + // + public class Iterator : StateMachineInitializer + { + public readonly IMethodData OriginalMethod; + public readonly bool IsEnumerable; + public readonly TypeSpec OriginalIteratorType; - // - // Our constructor - // public Iterator (ParametersBlock block, IMethodData method, TypeContainer host, TypeSpec iterator_type, bool is_enumerable) - : base (block, host.Compiler.BuiltinTypes.Bool, block.StartLocation) + : base (block, host, host.Compiler.BuiltinTypes.Bool) { this.OriginalMethod = method; this.OriginalIteratorType = iterator_type; this.IsEnumerable = is_enumerable; - this.Host = host; this.type = method.ReturnType; } + public LocalBuilder SkipFinally { + get { return skip_finally; } + } + + public LocalBuilder CurrentPC { + get { return current_pc; } + } + + public Block Container { + get { return OriginalMethod.Block; } + } + + public GenericMethod GenericMethod { + get { return OriginalMethod.GenericMethod; } + } + public override string ContainerType { get { return "iterator"; } } @@ -805,8 +918,9 @@ namespace Mono.CSharp { get { return true; } } - public override AnonymousMethodStorey Storey { - get { return IteratorHost; } + public void EmitYieldBreak (EmitContext ec, bool unwind_protect) + { + ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_error); } public override string GetSignatureForError () @@ -814,42 +928,22 @@ namespace Mono.CSharp { return OriginalMethod.GetSignatureForError (); } - protected override Expression DoResolve (ResolveContext ec) - { - IteratorHost = (IteratorStorey) block.TopBlock.AnonymousMethodStorey; - - BlockContext ctx = new BlockContext (ec, block, ReturnType); - ctx.CurrentAnonymousMethod = this; - - ctx.StartFlowBranching (this, ec.CurrentBranching); - Block.Resolve (ctx); - ctx.EndFlowBranching (); - - 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); - - eclass = ExprClass.Value; - return this; - } - public override void Emit (EmitContext ec) { // // Load Iterator storey instance // - IteratorHost.Instance.Emit (ec); + storey.Instance.Emit (ec); // // Initialize iterator PC when it's unitialized // if (IsEnumerable) { ec.Emit (OpCodes.Dup); - ec.EmitInt ((int)State.Uninitialized); + ec.EmitInt ((int)IteratorStorey.State.Uninitialized); - var field = IteratorHost.PC.Spec; - if (Storey.MemberName.IsGeneric) { + var field = storey.PC.Spec; + if (storey.MemberName.IsGeneric) { field = MemberCache.GetMember (Storey.Instance.Type, field); } @@ -857,9 +951,19 @@ namespace Mono.CSharp { } } - public override Expression CreateExpressionTree (ResolveContext ec) + public override void EmitStatement (EmitContext ec) { - throw new NotSupportedException ("ET"); + throw new NotImplementedException (); + } + + public override void InjectYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point) + { + // Store the new value into current + var fe = new FieldExpr (((IteratorStorey) storey).CurrentField, loc); + fe.InstanceExpression = new CompilerGeneratedThis (storey.CurrentType, loc); + fe.EmitAssign (ec, expr, false, false); + + base.InjectYield (ec, expr, resume_pc, unwind_protect, resume_point); } public static void CreateIterator (IMethodData method, TypeContainer parent, Modifiers modifiers) @@ -898,8 +1002,7 @@ namespace Mono.CSharp { if (parameters.Types [i].IsPointer) { parent.Compiler.Report.Error (1637, p.Location, - "Iterators cannot have unsafe parameters or " + - "yield types"); + "Iterators cannot have unsafe parameters or yield types"); return; } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs index c98f46db6..3cad50ce4 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/lambda.cs @@ -23,8 +23,13 @@ namespace Mono.CSharp { // A list of Parameters (explicitly typed parameters) // An ImplicitLambdaParameter // + public LambdaExpression (bool isAsync, Location loc) + : base (isAsync, loc) + { + } + public LambdaExpression (Location loc) - : base (loc) + : this (false, loc) { } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs index aa6b1d4bb..b2efb35c1 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/literal.cs @@ -25,7 +25,14 @@ using IKVM.Reflection.Emit; using System.Reflection.Emit; #endif -namespace Mono.CSharp { +namespace Mono.CSharp +{ + public interface ILiteralConstant + { +#if FULL_AST + char[] ParsedValue { get; set; } +#endif + } // // The null literal @@ -75,7 +82,8 @@ namespace Mono.CSharp { } } - public class BoolLiteral : BoolConstant { + public class BoolLiteral : BoolConstant, ILiteralConstant + { public BoolLiteral (BuiltinTypes types, bool val, Location loc) : base (types, val, loc) { @@ -84,9 +92,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class CharLiteral : CharConstant { + public class CharLiteral : CharConstant, ILiteralConstant + { public CharLiteral (BuiltinTypes types, char c, Location loc) : base (types, c, loc) { @@ -95,9 +108,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class IntLiteral : IntConstant { + public class IntLiteral : IntConstant, ILiteralConstant + { public IntLiteral (BuiltinTypes types, int l, Location loc) : base (types, l, loc) { @@ -122,9 +140,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class UIntLiteral : UIntConstant { + public class UIntLiteral : UIntConstant, ILiteralConstant + { public UIntLiteral (BuiltinTypes types, uint l, Location loc) : base (types, l, loc) { @@ -133,9 +156,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - - public class LongLiteral : LongConstant { + + public class LongLiteral : LongConstant, ILiteralConstant + { public LongLiteral (BuiltinTypes types, long l, Location loc) : base (types, l, loc) { @@ -144,9 +172,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class ULongLiteral : ULongConstant { + public class ULongLiteral : ULongConstant, ILiteralConstant + { public ULongLiteral (BuiltinTypes types, ulong l, Location loc) : base (types, l, loc) { @@ -155,10 +188,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - - public class FloatLiteral : FloatConstant { + public class FloatLiteral : FloatConstant, ILiteralConstant + { public FloatLiteral (BuiltinTypes types, float f, Location loc) : base (types, f, loc) { @@ -168,9 +205,13 @@ namespace Mono.CSharp { get { return true; } } +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class DoubleLiteral : DoubleConstant { + public class DoubleLiteral : DoubleConstant, ILiteralConstant + { public DoubleLiteral (BuiltinTypes types, double d, Location loc) : base (types, d, loc) { @@ -202,9 +243,13 @@ namespace Mono.CSharp { get { return true; } } +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class DecimalLiteral : DecimalConstant { + public class DecimalLiteral : DecimalConstant, ILiteralConstant + { public DecimalLiteral (BuiltinTypes types, decimal d, Location loc) : base (types, d, loc) { @@ -213,9 +258,14 @@ namespace Mono.CSharp { public override bool IsLiteral { get { return true; } } + +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } - public class StringLiteral : StringConstant { + public class StringLiteral : StringConstant, ILiteralConstant + { public StringLiteral (BuiltinTypes types, string s, Location loc) : base (types, s, loc) { @@ -225,5 +275,8 @@ namespace Mono.CSharp { get { return true; } } +#if FULL_AST + char[] ILiteralConstant.ParsedValue { get; set; } +#endif } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs index 88f12d01f..fd3fe3aaa 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs @@ -732,7 +732,9 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" public List GetLocations (object element) { - List found; + if (element == null) + return null; + List found; simple_locs.TryGetValue (element, out found); return found; } @@ -758,6 +760,11 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" public List usings = new List (); public List members = new List (); + public Namespace () + { + // in case of missing close brace, set it to the highest value. + CloseBrace = new Location (int.MaxValue, int.MaxValue); + } public virtual void Accept (StructuralVisitor visitor) { diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs index 75c164b90..75998515a 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/method.cs @@ -597,6 +597,13 @@ namespace Mono.CSharp { // MethodBase mb = new PartialMethodDefinitionInfo (this); spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, null, parameters, ModFlags); + if (MemberName.Arity > 0) { + spec.IsGeneric = true; + + // TODO: Have to move DefineMethod after Define (ideally to Emit) + throw new NotImplementedException ("Generic partial methods"); + } + Parent.MemberCache.AddMember (spec); } @@ -853,8 +860,8 @@ namespace Mono.CSharp { MemberName name, ParametersCompiled parameters, Attributes attrs) : base (parent, generic, return_type, mod, parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface : - parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct : - AllowedModifiersClass, + parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct | Modifiers.ASYNC : + AllowedModifiersClass | Modifiers.ASYNC, name, attrs, parameters) { } @@ -1083,7 +1090,7 @@ namespace Mono.CSharp { continue; } - if (MethodData.implementing != null) { + if (MethodData != null && MethodData.implementing != null) { var base_tp = MethodData.implementing.Constraints[i]; if (!tp.Type.HasSameConstraintsImplementation (base_tp)) { Report.SymbolRelatedToPreviousError (MethodData.implementing); @@ -1133,13 +1140,19 @@ namespace Mono.CSharp { DefineTypeParameters (); } - if (block != null && block.IsIterator) { - // - // Current method is turned into automatically generated - // wrapper which creates an instance of iterator - // - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); - ModFlags |= Modifiers.DEBUGGER_HIDDEN; + if (block != null) { + if (block.IsIterator) { + // + // Current method is turned into automatically generated + // wrapper which creates an instance of iterator + // + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); + ModFlags |= Modifiers.DEBUGGER_HIDDEN; + } + + if ((ModFlags & Modifiers.ASYNC) != 0) { + AsyncInitializer.Create (block, parameters, Parent.PartialContainer, ReturnType, Location); + } } if ((ModFlags & Modifiers.STATIC) == 0) diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/modifiers.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/modifiers.cs index 3eb63d725..3edbed6ba 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/modifiers.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/modifiers.cs @@ -37,14 +37,14 @@ namespace Mono.CSharp EXTERN = 0x0800, VOLATILE = 0x1000, UNSAFE = 0x2000, - TOP = 0x4000, + ASYNC = 0x4000, + TOP = 0x8000, // // Compiler specific flags // - PROPERTY_CUSTOM = 0x4000, + PROPERTY_CUSTOM = 0x10000, - ASYNC = 0x10000, PARTIAL = 0x20000, DEFAULT_ACCESS_MODIFER = 0x40000, METHOD_EXTENSION = 0x80000, @@ -109,6 +109,8 @@ namespace Mono.CSharp s = "volatile"; break; case Modifiers.UNSAFE: s = "unsafe"; break; + case Modifiers.ASYNC: + s = "async"; break; } return s; diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs index 8a23be9ff..c36699f93 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/parameter.cs @@ -496,6 +496,11 @@ namespace Mono.CSharp { } } + public void Error_DuplicateName (Report r) + { + r.Error (100, Location, "The parameter name `{0}' is a duplicate", Name); + } + public virtual string GetSignatureForError () { string type_name; @@ -1109,6 +1114,20 @@ namespace Mono.CSharp { return parameters; } + // + // Parameters checks for members which don't have a block + // + public void CheckParameters (MemberCore member) + { + for (int i = 0; i < parameters.Length; ++i) { + var name = parameters[i].Name; + for (int ii = i + 1; ii < parameters.Length; ++ii) { + if (parameters[ii].Name == name) + this[ii].Error_DuplicateName (member.Compiler.Report); + } + } + } + public bool Resolve (IMemberContext ec) { if (types != null) diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs index f27cee787..d5adfccad 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/property.cs @@ -131,15 +131,6 @@ namespace Mono.CSharp } } - public bool IsNotRealProperty { - get { - return (state & StateFlags.IsNotRealProperty) != 0; - } - set { - state |= StateFlags.IsNotRealProperty; - } - } - public bool HasDifferentAccessibility { get { return HasGet && HasSet && diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs index a656afde8..e34e6951f 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/report.cs @@ -61,7 +61,7 @@ namespace Mono.CSharp { 1030, 1058, 1066, 1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 1587, 1589, 1590, 1591, 1592, 1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1699, - 1700, 1701, 1702, 1709, 1717, 1718, 1720, + 1700, 1701, 1702, 1709, 1711, 1717, 1718, 1720, 1735, 1901, 1956, 1981, 2002, 2023, 2029, 3000, 3001, 3002, 3003, 3005, 3006, 3007, 3008, 3009, @@ -831,6 +831,7 @@ namespace Mono.CSharp { break; case "xterm-color": + case "xterm-256color": xterm_colors = true; break; } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs index c84ed9fce..df7962043 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/roottypes.cs @@ -63,27 +63,14 @@ namespace Mono.CSharp // DefineInitializedData because it creates public type, // and its name is not unique among modules // - size_type = new Struct (null, this, new MemberName ("$ArrayType=" + data.Length, Location), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null); + size_type = new Struct (null, this, new MemberName ("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null); size_type.CreateType (); size_type.DefineType (); size_types.Add (data.Length, size_type); - var ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location); - if (ctor != null) { - var argsEncoded = new AttributeEncoder (); - argsEncoded.Encode ((short) LayoutKind.Explicit); - - 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 (Compiler.BuiltinTypes, (int) data.Length, Location), new IntConstant (Compiler.BuiltinTypes, 1, Location) } - ); - - size_type.TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), argsEncoded.ToArray ()); - } - } + + // It has to work even if StructLayoutAttribute does not exist + size_type.TypeBuilder.__SetLayout (1, data.Length); } var name = "$field-" + fields.ToString ("X"); diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs index 6fa3986e1..db028e02b 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/statement.cs @@ -28,7 +28,7 @@ namespace Mono.CSharp { /// Resolves the statement, true means that all sub-statements /// did resolve ok. // - public virtual bool Resolve (BlockContext ec) + public virtual bool Resolve (BlockContext bc) { return true; } @@ -624,7 +624,8 @@ namespace Mono.CSharp { } } - public class StatementExpression : Statement { + public class StatementExpression : Statement + { ExpressionStatement expr; public StatementExpression (ExpressionStatement expr) @@ -637,10 +638,10 @@ namespace Mono.CSharp { get { return this.expr; } } - public override bool Resolve (BlockContext ec) + protected override void CloneTo (CloneContext clonectx, Statement t) { - expr = expr.ResolveStatement (ec); - return expr != null; + StatementExpression target = (StatementExpression) t; + target.expr = (ExpressionStatement) expr.Clone (clonectx); } protected override void DoEmit (EmitContext ec) @@ -648,16 +649,10 @@ namespace Mono.CSharp { expr.EmitStatement (ec); } - public override string ToString () - { - return "StatementExpression (" + expr + ")"; - } - - protected override void CloneTo (CloneContext clonectx, Statement t) + public override bool Resolve (BlockContext ec) { - StatementExpression target = (StatementExpression) t; - - target.expr = (ExpressionStatement) expr.Clone (clonectx); + expr = expr.ResolveStatement (ec); + return expr != null; } public override object Accept (StructuralVisitor visitor) @@ -750,7 +745,7 @@ namespace Mono.CSharp { public class Return : ExitStatement { public Expression Expr { get; protected set; } - + public Return (Expression expr, Location l) { Expr = expr; @@ -771,6 +766,21 @@ namespace Mono.CSharp { if (ec.ReturnType.Kind == MemberKind.Void) return true; + // + // Return must not be followed by an expression when + // the method return type is Task + // + if (ec.CurrentAnonymousMethod is AsyncInitializer) { + var storey = (AsyncTaskStorey) ec.CurrentAnonymousMethod.Storey; + if (storey.ReturnType == ec.Module.PredefinedTypes.Task.TypeSpec) { + // + // Extra trick not to emit ret/leave inside awaiter body + // + Expr = EmptyExpression.Null; + return true; + } + } + if (ec.CurrentIterator != null) { Error_ReturnFromIterator (ec); } else { @@ -783,10 +793,11 @@ namespace Mono.CSharp { } Expr = Expr.Resolve (ec); + TypeSpec block_return_type = ec.ReturnType; AnonymousExpression am = ec.CurrentAnonymousMethod; if (am == null) { - if (ec.ReturnType.Kind == MemberKind.Void) { + if (block_return_type.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 ()); @@ -797,21 +808,49 @@ namespace Mono.CSharp { return false; } - var l = am as AnonymousMethodBody; - if (l != null && l.ReturnTypeInference != null && Expr != null) { - l.ReturnTypeInference.AddCommonTypeBound (Expr.Type); - return true; + var async_block = am as AsyncInitializer; + if (async_block != null) { + if (Expr != null) { + var storey = (AsyncTaskStorey) am.Storey; + var async_type = storey.ReturnType; + + if (async_type == null && async_block.ReturnTypeInference != null) { + async_block.ReturnTypeInference.AddCommonTypeBound (Expr.Type); + return true; + } + + if (!async_type.IsGenericTask) { + if (this is ContextualReturn) + return true; + + ec.Report.Error (1997, loc, + "`{0}': A return keyword must not be followed by an expression when async method returns Task. Consider using Task", + ec.GetSignatureForError ()); + return false; + } + + // + // The return type is actually Task type argument + // + block_return_type = async_type.TypeArguments[0]; + } + } else { + var l = am as AnonymousMethodBody; + if (l != null && l.ReturnTypeInference != null && Expr != null) { + l.ReturnTypeInference.AddCommonTypeBound (Expr.Type); + return true; + } } } if (Expr == null) return false; - if (Expr.Type != ec.ReturnType) { - Expr = Convert.ImplicitConversionRequired (ec, Expr, ec.ReturnType, loc); + if (Expr.Type != block_return_type) { + Expr = Convert.ImplicitConversionRequired (ec, Expr, block_return_type, loc); if (Expr == null) { - if (am != null) { + if (am != null && block_return_type == ec.ReturnType) { ec.Report.Error (1662, loc, "Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type", am.ContainerType, am.GetSignatureForError ()); @@ -828,6 +867,17 @@ namespace Mono.CSharp { if (Expr != null) { Expr.Emit (ec); + var async_body = ec.CurrentAnonymousMethod as AsyncInitializer; + if (async_body != null) { + var async_return = ((AsyncTaskStorey) async_body.Storey).HoistedReturn; + + // It's null for await without async + if (async_return != null) + async_return.EmitAssign (ec); + + return; + } + if (unwind_protect) ec.Emit (OpCodes.Stloc, ec.TemporaryReturn ()); } @@ -1843,7 +1893,8 @@ namespace Mono.CSharp { HasCapturedVariable = 64, HasCapturedThis = 1 << 7, IsExpressionTree = 1 << 8, - CompilerGenerated = 1 << 9 + CompilerGenerated = 1 << 9, + IsAsync = 1 << 10 } public Block Parent; @@ -1978,12 +2029,11 @@ namespace Mono.CSharp { { var pi = variable as ParametersBlock.ParameterInfo; if (pi != null) { - var p = pi.Parameter; - ParametersBlock.TopBlock.Report.Error (100, p.Location, "The parameter name `{0}' is a duplicate", p.Name); + pi.Parameter.Error_DuplicateName (ParametersBlock.TopBlock.Report); + } else { + ParametersBlock.TopBlock.Report.Error (128, variable.Location, + "A local variable named `{0}' is already defined in this scope", name); } - - ParametersBlock.TopBlock.Report.Error (128, variable.Location, - "A local variable named `{0}' is already defined in this scope", name); } public virtual void Error_AlreadyDeclaredTypeParameter (string name, Location loc) @@ -2424,7 +2474,7 @@ namespace Mono.CSharp { } // - // Block is converted to an expression + // Block is converted into an expression // sealed class BlockScopeExpression : Expression { @@ -2517,6 +2567,16 @@ namespace Mono.CSharp { #region Properties + public bool IsAsync + { + get { + return (flags & Flags.IsAsync) != 0; + } + set { + flags = value ? flags | Flags.IsAsync : flags & ~Flags.IsAsync; + } + } + // // Block has been converted to expression tree // @@ -2663,13 +2723,26 @@ namespace Mono.CSharp { if (rc.ReturnType.Kind != MemberKind.Void && !unreachable) { if (rc.CurrentAnonymousMethod == null) { // FIXME: Missing FlowAnalysis for generated iterator MoveNext method - if (md is IteratorMethod) { + if (md is StateMachineMethod) { unreachable = true; } else { rc.Report.Error (161, md.Location, "`{0}': not all code paths return a value", md.GetSignatureForError ()); return false; } } else { + // + // If an asynchronous body of F is either an expression classified as nothing, or a + // statement block where no return statements have expressions, the inferred return type is Task + // + if (IsAsync) { + var am = rc.CurrentAnonymousMethod as AnonymousMethodBody; + if (am != null && am.ReturnTypeInference != null && !am.ReturnTypeInference.HasBounds (0)) { + am.ReturnTypeInference = null; + am.ReturnType = rc.Module.PredefinedTypes.Task.TypeSpec; + return true; + } + } + rc.Report.Error (1643, rc.CurrentAnonymousMethod.Location, "Not all code paths return a value in anonymous method of type `{0}'", rc.CurrentAnonymousMethod.GetSignatureForError ()); return false; @@ -2707,6 +2780,22 @@ namespace Mono.CSharp { statements = new List (1); AddStatement (new Return (iterator, iterator.Location)); } + + public void WrapIntoAsyncTask (TypeContainer host, TypeSpec returnType) + { + ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation); + pb.EndLocation = EndLocation; + pb.statements = statements; + + var block_type = host.Module.Compiler.BuiltinTypes.Void; + var initializer = new AsyncInitializer (pb, host, block_type); + initializer.Type = block_type; + + am_storey = new AsyncTaskStorey (initializer, returnType); + + statements = new List (1); + AddStatement (new StatementExpression (initializer)); + } } // @@ -2752,6 +2841,16 @@ namespace Mono.CSharp { top_block = this; } + public bool IsIterator + { + get { + return (flags & Flags.IsIterator) != 0; + } + set { + flags = value ? flags | Flags.IsIterator : flags & ~Flags.IsIterator; + } + } + public override void AddLocalName (string name, INamedBlockVariable li) { if (names == null) @@ -3007,11 +3106,6 @@ namespace Mono.CSharp { return this_variable; } - public bool IsIterator { - get { return (flags & Flags.IsIterator) != 0; } - set { flags = value ? flags | Flags.IsIterator : flags & ~Flags.IsIterator; } - } - public bool IsThisAssigned (BlockContext ec) { return this_variable == null || this_variable.IsThisAssigned (ec, this); @@ -3963,7 +4057,8 @@ namespace Mono.CSharp { { return end; } - public virtual void EmitForDispose (EmitContext ec, Iterator iterator, Label end, bool have_dispatcher) + + public virtual void EmitForDispose (EmitContext ec, LocalBuilder pc, Label end, bool have_dispatcher) { } } @@ -4004,7 +4099,7 @@ namespace Mono.CSharp { EmitPreTryBody (ec); if (resume_points != null) { - ec.EmitInt ((int) Iterator.State.Running); + ec.EmitInt ((int) IteratorStorey.State.Running); ec.Emit (OpCodes.Stloc, iter.CurrentPC); } @@ -4080,7 +4175,7 @@ namespace Mono.CSharp { return dispose_try_block; } - public override void EmitForDispose (EmitContext ec, Iterator iterator, Label end, bool have_dispatcher) + public override void EmitForDispose (EmitContext ec, LocalBuilder pc, Label end, bool have_dispatcher) { if (emitted_dispose) return; @@ -4099,7 +4194,7 @@ namespace Mono.CSharp { Label [] labels = null; for (int i = 0; i < resume_points.Count; ++i) { - ResumableStatement s = (ResumableStatement) resume_points [i]; + ResumableStatement s = resume_points [i]; Label ret = s.PrepareForDispose (ec, end_of_try); if (ret.Equals (end_of_try) && labels == null) continue; @@ -4120,7 +4215,7 @@ namespace Mono.CSharp { if (emit_dispatcher) { //SymbolWriter.StartIteratorDispatcher (ec.ig); - ec.Emit (OpCodes.Ldloc, iterator.CurrentPC); + ec.Emit (OpCodes.Ldloc, pc); ec.EmitInt (first_resume_pc); ec.Emit (OpCodes.Sub); ec.Emit (OpCodes.Switch, labels); @@ -4128,7 +4223,7 @@ namespace Mono.CSharp { } foreach (ResumableStatement s in resume_points) - s.EmitForDispose (ec, iterator, end_of_try, emit_dispatcher); + s.EmitForDispose (ec, pc, end_of_try, emit_dispatcher); } ec.MarkLabel (end_of_try); @@ -4141,7 +4236,8 @@ namespace Mono.CSharp { } } - public class Lock : ExceptionStatement { + public class Lock : ExceptionStatement + { Expression expr; TemporaryVariableReference expr_copy; TemporaryVariableReference lock_taken; @@ -4182,9 +4278,11 @@ namespace Mono.CSharp { locked = false; } - ec.StartFlowBranching (this); - Statement.Resolve (ec); - ec.EndFlowBranching (); + using (ec.Set (ResolveContext.Options.LockScope)) { + ec.StartFlowBranching (this); + Statement.Resolve (ec); + ec.EndFlowBranching (); + } if (lv != null) { lv.IsLockedByStatement = locked; diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/support.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/support.cs index 2402db8c8..c10d13f89 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/support.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/support.cs @@ -237,6 +237,18 @@ namespace Mono.CSharp { return pos < char_count; } + public char[] ReadChars (int fromPosition, int toPosition) + { + char[] chars = new char[toPosition - fromPosition]; + if (buffer_start <= fromPosition && toPosition < buffer_start + buffer.Length) { + Array.Copy (buffer, fromPosition - buffer_start, chars, 0, chars.Length); + } else { + throw new NotImplementedException (); + } + + return chars; + } + public int Peek () { if ((pos >= char_count) && !ReadBuffer ()) diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs index 65725bafc..2e2d17064 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/typemanager.cs @@ -3,7 +3,7 @@ // // Author: Miguel de Icaza (miguel@gnu.org) // Ravi Pratap (ravi@ximian.com) -// Marek Safar (marek.safar@seznam.cz) +// Marek Safar (marek.safar@gmail.com) // // Dual licensed under the terms of the MIT X11 or GNU GPL // @@ -217,6 +217,16 @@ namespace Mono.CSharp public readonly PredefinedType CallSiteGeneric; public readonly PredefinedType BinderFlags; + // + // C# 5.0 + // + public readonly PredefinedType AsyncVoidMethodBuilder; + public readonly PredefinedType AsyncTaskMethodBuilder; + public readonly PredefinedType AsyncTaskMethodBuilderGeneric; + public readonly PredefinedType Action; + public readonly PredefinedType Task; + public readonly PredefinedType TaskGeneric; + public PredefinedTypes (ModuleContainer module) { TypedReference = new PredefinedType (module, MemberKind.Struct, "System", "TypedReference"); @@ -257,6 +267,13 @@ namespace Mono.CSharp Binder = new PredefinedType (module, MemberKind.Class, "Microsoft.CSharp.RuntimeBinder", "Binder"); BinderFlags = new PredefinedType (module, MemberKind.Enum, "Microsoft.CSharp.RuntimeBinder", "CSharpBinderFlags"); + Action = new PredefinedType (module, MemberKind.Delegate, "System", "Action"); + AsyncVoidMethodBuilder = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncVoidMethodBuilder"); + AsyncTaskMethodBuilder = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder"); + AsyncTaskMethodBuilderGeneric = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder", 1); + Task = new PredefinedType (module, MemberKind.Class, "System.Threading.Tasks", "Task"); + TaskGeneric = new PredefinedType (module, MemberKind.Class, "System.Threading.Tasks", "Task", 1); + // // Define types which are used for comparison. It does not matter // if they don't exist as no error report is needed @@ -281,12 +298,25 @@ namespace Mono.CSharp if (ExpressionGeneric.Define ()) ExpressionGeneric.TypeSpec.IsExpressionTreeType = true; + + Task.Define (); + if (TaskGeneric.Define ()) + TaskGeneric.TypeSpec.IsGenericTask = true; } } class PredefinedMembers { public readonly PredefinedMember ActivatorCreateInstance; + public readonly PredefinedMember AsyncTaskMethodBuilderCreate; + public readonly PredefinedMember AsyncTaskMethodBuilderSetResult; + public readonly PredefinedMember AsyncTaskMethodBuilderTask; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericCreate; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetResult; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericTask; + public readonly PredefinedMember AsyncVoidMethodBuilderCreate; + public readonly PredefinedMember AsyncVoidMethodBuilderSetException; + public readonly PredefinedMember AsyncVoidMethodBuilderSetResult; public readonly PredefinedMember DecimalCtor; public readonly PredefinedMember DecimalCtorInt; public readonly PredefinedMember DecimalCtorLong; @@ -318,7 +348,6 @@ namespace Mono.CSharp public readonly PredefinedMember StringInequal; public readonly PredefinedMember StructLayoutAttributeCtor; public readonly PredefinedMember StructLayoutCharSet; - public readonly PredefinedMember StructLayoutPack; public readonly PredefinedMember StructLayoutSize; public readonly PredefinedMember TypeGetTypeFromHandle; @@ -331,6 +360,40 @@ namespace Mono.CSharp ActivatorCreateInstance = new PredefinedMember (module, types.Activator, MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); + AsyncTaskMethodBuilderCreate = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncTaskMethodBuilder.TypeSpec)); + + AsyncTaskMethodBuilderSetResult = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + MemberFilter.Method ("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, btypes.Void)); + + AsyncTaskMethodBuilderTask = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + MemberFilter.Property ("Task", null)); + + AsyncTaskMethodBuilderGenericCreate = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec)); + + AsyncTaskMethodBuilderGenericSetResult = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + MemberFilter.Method ("SetResult", 0, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.NONE) + }, + new[] { + new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null) + }, false), btypes.Void)); + + AsyncTaskMethodBuilderGenericTask = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + MemberFilter.Property ("Task", null)); + + AsyncVoidMethodBuilderCreate = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec)); + + AsyncVoidMethodBuilderSetException = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + MemberFilter.Method ("SetException", 0, null, btypes.Void)); + + AsyncVoidMethodBuilderSetResult = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + MemberFilter.Method ("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, btypes.Void)); + DecimalCtor = new PredefinedMember (module, btypes.Decimal, MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( btypes.Int, btypes.Int, btypes.Int, btypes.Bool, btypes.Byte))); @@ -450,9 +513,6 @@ namespace Mono.CSharp 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)); diff --git a/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs b/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs index 03fa923fb..8c0a5ddc2 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/mcs/typespec.cs @@ -197,6 +197,18 @@ namespace Mono.CSharp } } + // + // Returns true for instances of System.Threading.Tasks.Task + // + public virtual bool IsGenericTask { + get { + return false; + } + set { + state = value ? state | StateFlags.GenericTask : state & ~StateFlags.GenericTask; + } + } + // TODO: Should probably do // IsGenericType -- recursive // HasTypeParameter -- non-recursive @@ -1638,29 +1650,27 @@ namespace Mono.CSharp public override string GetSignatureForDocumentation () { - var e = Element; - List ranks = new List (2); - ranks.Add (rank); + StringBuilder sb = new StringBuilder (); + GetElementSignatureForDocumentation (sb); + return sb.ToString (); + } - while (e is ArrayContainer) { - var ac = (ArrayContainer) e; - ranks.Add (ac.rank); - e = ac.Element; - } + void GetElementSignatureForDocumentation (StringBuilder sb) + { + var ac = Element as ArrayContainer; + if (ac == null) + sb.Append (Element.GetSignatureForDocumentation ()); + else + ac.GetElementSignatureForDocumentation (sb); - StringBuilder sb = new StringBuilder (e.GetSignatureForDocumentation ()); - for (int r = 0; r < ranks.Count; ++r) { - sb.Append ("["); - for (int i = 1; i < ranks[r]; i++) { - if (i == 1) - sb.Append ("0:"); + sb.Append ("["); + for (int i = 1; i < rank; i++) { + if (i == 1) + sb.Append ("0:"); - sb.Append (",0:"); - } - sb.Append ("]"); + sb.Append (",0:"); } - - return sb.ToString (); + sb.Append ("]"); } public static ArrayContainer MakeType (ModuleContainer module, TypeSpec element) diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/Action.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/Action.cs new file mode 100644 index 000000000..4a99ef162 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/Action.cs @@ -0,0 +1,55 @@ +// +// Change.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + /// + /// This is the base class for all refactoring operations that are performed. + /// + public abstract class Action + { + /// + /// Gets or sets the description. + /// + /// + /// A brief description of the refactoring change. + /// + public string Description { + get; + set; + } + + /// + /// Performs the change. + /// + /// + /// The context on which the change should perform on. + /// + public abstract void Perform (Script script); + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/AddAnotherAccessor.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/AddAnotherAccessor.cs new file mode 100644 index 000000000..f934917d9 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/AddAnotherAccessor.cs @@ -0,0 +1,89 @@ +// +// AddAnotherAccessor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + /// + /// Add another accessor to a property declaration that has only one. + /// + public class AddAnotherAccessor : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var pdecl = GetPropertyDeclaration (context); + if (pdecl == null) + return false; + var type = pdecl.Parent as TypeDeclaration; + if (type != null && type.ClassType == ICSharpCode.NRefactory.TypeSystem.ClassType.Interface) + return false; + + return pdecl.Setter.IsNull || pdecl.Getter.IsNull; + } + + public void Run (RefactoringContext context) + { + var pdecl = GetPropertyDeclaration (context); + var accessorStatement = BuildAccessorStatement (context, pdecl); + + Accessor accessor = new Accessor () { + Body = new BlockStatement { accessorStatement } + }; + + pdecl.AddChild (accessor, pdecl.Setter.IsNull ? PropertyDeclaration.SetterRole : PropertyDeclaration.GetterRole); + + using (var script = context.StartScript ()) { + script.InsertBefore (pdecl.RBraceToken, accessor); + script.Select (accessorStatement); + script.FormatText (ctx => GetPropertyDeclaration (context)); + } + } + + static Statement BuildAccessorStatement (RefactoringContext context, PropertyDeclaration pdecl) + { + if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull) { + var field = RemoveBackingStore.ScanGetter (context, pdecl); + if (field != null) + return new ExpressionStatement (new AssignmentExpression (new IdentifierExpression (field.Name), AssignmentOperatorType.Assign, new IdentifierExpression ("value"))); + } + + if (!pdecl.Setter.IsNull && pdecl.Getter.IsNull) { + var field = RemoveBackingStore.ScanSetter (context, pdecl); + if (field != null) + return new ReturnStatement (new IdentifierExpression (field.Name)); + } + + return new ThrowStatement (new ObjectCreateExpression (context.CreateShortType ("System", "NotImplementedException"))); + } + + static PropertyDeclaration GetPropertyDeclaration (RefactoringContext context) + { + var node = context.GetNode (); + if (node == null) + return null; + return node.Parent as PropertyDeclaration; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CheckIfParameterIsNull.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CheckIfParameterIsNull.cs new file mode 100644 index 000000000..3c52562aa --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CheckIfParameterIsNull.cs @@ -0,0 +1,112 @@ +// +// CheckIfParameterIsNull.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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 ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// Creates a 'if (param == null) throw new System.ArgumentNullException ();' contruct for a parameter. + /// + public class CheckIfParameterIsNull : IContextAction + { + //TODO: Create 'multiple' null checks when more than 1 parameter is selected. + public bool IsValid (RefactoringContext context) + { + var parameter = GetParameterDeclaration (context); + if (parameter == null) + return false; + + var bodyStatement = parameter.Parent.GetChildByRole (AstNode.Roles.Body); + + if (bodyStatement == null) + return false; + + if (parameter.Type is PrimitiveType) + return (((PrimitiveType)parameter.Type).Keyword == "object" || ((PrimitiveType)parameter.Type).Keyword == "string") && !HasNullCheck (parameter); + + // TODO: check for structs + return !HasNullCheck (parameter); + } + + public void Run (RefactoringContext context) + { + var parameter = GetParameterDeclaration (context); + + var bodyStatement = parameter.Parent.GetChildByRole (AstNode.Roles.Body); + + var statement = new IfElseStatement () { + Condition = new BinaryOperatorExpression (new IdentifierExpression (parameter.Name), BinaryOperatorType.Equality, new NullReferenceExpression ()), + TrueStatement = new ThrowStatement (new ObjectCreateExpression (context.CreateShortType ("System", "ArgumentNullException"), new PrimitiveExpression (parameter.Name))) + }; + + using (var script = context.StartScript ()) { + script.AddTo (bodyStatement, statement); + } + } + + static ParameterDeclaration GetParameterDeclaration (RefactoringContext context) + { + return context.GetNode (); + } + + static bool HasNullCheck (ParameterDeclaration parameter) + { + var visitor = new CheckNullVisitor (parameter); + parameter.Parent.AcceptVisitor (visitor, null); + return visitor.ContainsNullCheck; + } + + class CheckNullVisitor : DepthFirstAstVisitor + { + ParameterDeclaration parameter; + + public bool ContainsNullCheck { + get; + set; + } + + public CheckNullVisitor (ParameterDeclaration parameter) + { + this.parameter = parameter; + } + + public object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) + { + if (ifElseStatement.Condition is BinaryOperatorExpression) { + var binOp = ifElseStatement.Condition as BinaryOperatorExpression; + if ((binOp.Operator == BinaryOperatorType.Equality || binOp.Operator == BinaryOperatorType.InEquality) && + binOp.Left.IsMatch (new IdentifierExpression (parameter.Name)) && binOp.Right.IsMatch (new NullReferenceExpression ()) || + binOp.Right.IsMatch (new IdentifierExpression (parameter.Name)) && binOp.Left.IsMatch (new NullReferenceExpression ())) { + ContainsNullCheck = true; + } + } + + return base.VisitIfElseStatement (ifElseStatement, data); + } + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertDecToHex.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertDecToHex.cs new file mode 100644 index 000000000..c1ec0fa06 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertDecToHex.cs @@ -0,0 +1,52 @@ +// +// ConvertDecToHex.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + /// + /// Convert a dec numer to hex. For example: 16 -> 0x10 + /// + public class ConvertDecToHex : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var pexpr = context.GetNode (); + if (pexpr == null || pexpr.LiteralValue.StartsWith ("0X", System.StringComparison.OrdinalIgnoreCase)) + return false; + return (pexpr.Value is int) || (pexpr.Value is long) || (pexpr.Value is short) || (pexpr.Value is sbyte) || + (pexpr.Value is uint) || (pexpr.Value is ulong) || (pexpr.Value is ushort) || (pexpr.Value is byte); + } + + public void Run (RefactoringContext context) + { + var pexpr = context.GetNode (); + + using (var script = context.StartScript ()) { + script.Replace (pexpr, new PrimitiveExpression (pexpr.Value, string.Format ("0x{0:x}", pexpr.Value))); + } + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertForeachToFor.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertForeachToFor.cs new file mode 100644 index 000000000..b3f38e7cb --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertForeachToFor.cs @@ -0,0 +1,95 @@ +// +// ConvertForeachToFor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// Converts a foreach loop to for. + /// + public class ConvertForeachToFor : IContextAction + { + public bool IsValid (RefactoringContext context) + { + return GetForeachStatement (context) != null; + } + + static string GetCountProperty (IType type) + { +// if (!type.) +// return "Length"; + return "Count"; + } + + public void Run (RefactoringContext context) + { + var foreachStatement = GetForeachStatement (context); + + var result = context.Resolve (foreachStatement.InExpression); + var countProperty = GetCountProperty (result.Type); + + var initializer = new VariableDeclarationStatement (new PrimitiveType ("int"), "i", new PrimitiveExpression (0)); + var id1 = new IdentifierExpression ("i"); + var id2 = id1.Clone (); + var id3 = id1.Clone (); + + var forStatement = new ForStatement () { + Initializers = { initializer }, + Condition = new BinaryOperatorExpression (id1, BinaryOperatorType.LessThan, new MemberReferenceExpression (foreachStatement.InExpression.Clone (), countProperty)), + Iterators = { new ExpressionStatement (new UnaryOperatorExpression (UnaryOperatorType.PostIncrement, id2)) }, + EmbeddedStatement = new BlockStatement { + new VariableDeclarationStatement (foreachStatement.VariableType.Clone (), foreachStatement.VariableName, new IndexerExpression (foreachStatement.InExpression.Clone (), id3)) + } + }; + + if (foreachStatement.EmbeddedStatement is BlockStatement) { + foreach (var child in ((BlockStatement)foreachStatement.EmbeddedStatement).Statements) { + forStatement.EmbeddedStatement.AddChild (child.Clone (), BlockStatement.StatementRole); + } + } else { + forStatement.EmbeddedStatement.AddChild (foreachStatement.EmbeddedStatement.Clone (), BlockStatement.StatementRole); + } + + using (var script = context.StartScript ()) { + script.Replace (foreachStatement, forStatement); + script.Link (initializer.Variables.First ().NameToken, id1, id2, id3); + } + } + + static ForeachStatement GetForeachStatement (RefactoringContext context) + { + var astNode = context.GetNode (); + if (astNode == null) + return null; + var result = (astNode as ForeachStatement) ?? astNode.Parent as ForeachStatement; + if (result == null || context.Resolve (result.InExpression) == null) + return null; + return result; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertHexToDec.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertHexToDec.cs new file mode 100644 index 000000000..3c653c1c1 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ConvertHexToDec.cs @@ -0,0 +1,52 @@ +// +// ConvertHexToDec.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + /// + /// Convert a hex numer to dec. For example: 0x10 -> 16 + /// + public class ConvertHexToDec: IContextAction + { + public bool IsValid (RefactoringContext context) + { + var pexpr = context.GetNode (); + if (pexpr == null || !pexpr.LiteralValue.StartsWith ("0X", System.StringComparison.OrdinalIgnoreCase)) + return false; + return (pexpr.Value is int) || (pexpr.Value is long) || (pexpr.Value is short) || (pexpr.Value is sbyte) || + (pexpr.Value is uint) || (pexpr.Value is ulong) || (pexpr.Value is ushort) || (pexpr.Value is byte); + } + + public void Run (RefactoringContext context) + { + var pexpr = context.GetNode (); + + using (var script = context.StartScript ()) { + script.Replace (pexpr, new PrimitiveExpression (pexpr.Value)); + } + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateBackingStore.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateBackingStore.cs new file mode 100644 index 000000000..db6598a87 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateBackingStore.cs @@ -0,0 +1,73 @@ +// +// CreateBackingStore.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public class CreateBackingStore : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var propertyDeclaration = context.GetNode (); + return propertyDeclaration != null && + !propertyDeclaration.Getter.IsNull && !propertyDeclaration.Setter.IsNull && // automatic properties always need getter & setter + propertyDeclaration.Getter.Body.IsNull && + propertyDeclaration.Setter.Body.IsNull; + } + + public void Run (RefactoringContext context) + { + var property = context.GetNode (); + + string backingStoreName = context.GetNameProposal (property.Name); + + // create field + var backingStore = new FieldDeclaration (); + backingStore.ReturnType = property.ReturnType.Clone (); + + var initializer = new VariableInitializer (backingStoreName); + backingStore.Variables.Add (initializer); + + // create new property & implement the get/set bodies + var newProperty = (PropertyDeclaration)property.Clone (); + var id1 = new IdentifierExpression (backingStoreName); + var id2 = new IdentifierExpression (backingStoreName); + newProperty.Getter.Body = new BlockStatement () { + new ReturnStatement (id1) + }; + newProperty.Setter.Body = new BlockStatement () { + new ExpressionStatement (new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value"))) + }; + + using (var script = context.StartScript ()) { + script.Replace (property, newProperty); + script.InsertBefore (property, backingStore); + script.Link (initializer, id1, id2); + } + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateEventInvocator.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateEventInvocator.cs new file mode 100644 index 000000000..e8473bdd9 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateEventInvocator.cs @@ -0,0 +1,109 @@ +// +// CreateEventInvocator.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class CreateEventInvocator : IContextAction + { + public bool IsValid (RefactoringContext context) + { + VariableInitializer initializer; + var eventDeclaration = GetEventDeclaration (context, out initializer); + if (eventDeclaration == null) + return false; + var type = (TypeDeclaration)eventDeclaration.Parent; + return !type.Members.Any (m => m is MethodDeclaration && ((MethodDeclaration)m).Name == "On" + initializer.Name); + } + + public void Run (RefactoringContext context) + { + VariableInitializer initializer; + var eventDeclaration = GetEventDeclaration (context, out initializer); + var type = context.Resolve (eventDeclaration.ReturnType).Type; + if (type == null) + return; + var invokeMethod = type.GetDelegateInvokeMethod (); + if (invokeMethod == null) + return; + + bool hasSenderParam = false; + IEnumerable pars = invokeMethod.Parameters; + if (invokeMethod.Parameters.Any ()) { + var first = invokeMethod.Parameters [0]; + if (first.Name == "sender" /*&& first.Type == "System.Object"*/) { + hasSenderParam = true; + pars = invokeMethod.Parameters.Skip (1); + } + } + const string handlerName = "handler"; + + var arguments = new List (); + if (hasSenderParam) + arguments.Add (new ThisReferenceExpression ()); + foreach (var par in pars) + arguments.Add (new IdentifierExpression (par.Name)); + + var methodDeclaration = new MethodDeclaration () { + Name = "On" + initializer.Name, + ReturnType = new PrimitiveType ("void"), + Modifiers = ICSharpCode.NRefactory.CSharp.Modifiers.Protected | ICSharpCode.NRefactory.CSharp.Modifiers.Virtual, + Body = new BlockStatement () { + new VariableDeclarationStatement (context.CreateShortType (eventDeclaration.ReturnType), handlerName, new MemberReferenceExpression (new ThisReferenceExpression (), initializer.Name)), + new IfElseStatement () { + Condition = new BinaryOperatorExpression (new IdentifierExpression (handlerName), BinaryOperatorType.InEquality, new PrimitiveExpression (null)), + TrueStatement = new ExpressionStatement (new InvocationExpression (new IdentifierExpression (handlerName), arguments)) + } + } + }; + + foreach (var par in pars) { + var typeName = context.CreateShortType (par.Type.Resolve (context.TypeResolveContext)); + var decl = new ParameterDeclaration (typeName, par.Name); + methodDeclaration.Parameters.Add (decl); + } + + using (var script = context.StartScript ()) { + script.InsertWithCursor ("Create event invocator", methodDeclaration, Script.InsertPosition.After); + } + } + + static EventDeclaration GetEventDeclaration (RefactoringContext context, out VariableInitializer initializer) + { + var result = context.GetNode (); + if (result == null) { + initializer = null; + return null; + } + initializer = result.Variables.First (v => v.NameToken.Contains (context.Location)); + return initializer != null ? result : null; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateField.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateField.cs new file mode 100644 index 000000000..831dfe121 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateField.cs @@ -0,0 +1,77 @@ +// +// CreateField.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; +using ICSharpCode.NRefactory.PatternMatching; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class CreateField : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var identifier = GetIdentifier (context); + if (identifier == null) + return false; + return context.Resolve (identifier) == null && GuessType (context, identifier) != null; + } + + public void Run (RefactoringContext context) + { + var identifier = GetIdentifier (context); + + using (var script = context.StartScript ()) { + script.InsertWithCursor ("Create field", GenerateFieldDeclaration (context, identifier), Script.InsertPosition.Before); + } + } + + static AstNode GenerateFieldDeclaration (RefactoringContext context, IdentifierExpression identifier) + { + return new FieldDeclaration () { + ReturnType = GuessType (context, identifier), + Variables = { new VariableInitializer (identifier.Identifier) } + }; + } + + internal static AstType GuessType (RefactoringContext context, IdentifierExpression identifier) + { + if (identifier.Parent is AssignmentExpression) { + var assign = (AssignmentExpression)identifier.Parent; + var other = assign.Left == identifier ? assign.Right : assign.Left; + return context.Resolve (other).Type.ConvertToAstType (); + } + return null; + } + + public static IdentifierExpression GetIdentifier (RefactoringContext context) + { + return context.GetNode (); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateLocalVariable.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateLocalVariable.cs new file mode 100644 index 000000000..f5927a2d8 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateLocalVariable.cs @@ -0,0 +1,129 @@ +// +// CreateLocalVariable.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; +using ICSharpCode.NRefactory.PatternMatching; +using System.Linq; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class CreateLocalVariable : IContextAction + { + public List GetUnresolvedArguments (RefactoringContext context) + { + var expressions = new List (); + + var invocation = GetInvocation (context); + if (invocation != null) { + foreach (var arg in invocation.Arguments) { + IdentifierExpression identifier; + if (arg is DirectionExpression) { + identifier = ((DirectionExpression)arg).Expression as IdentifierExpression; + } else if (arg is NamedArgumentExpression) { + identifier = ((NamedArgumentExpression)arg).Expression as IdentifierExpression; + } else { + identifier = arg as IdentifierExpression; + } + if (identifier == null) + continue; + + if (context.Resolve (identifier) == null && GuessType (context, identifier) != null) + expressions.Insert (0, identifier); + } + } + return expressions; + } + + public bool IsValid (RefactoringContext context) + { + if (GetUnresolvedArguments (context).Count > 0) + return true; + var identifier = CreateField.GetIdentifier (context); + if (identifier == null) + return false; + if (context.GetNode () == null) + return false; + return context.Resolve (identifier) == null && GuessType (context, identifier) != null; + } + + public void Run (RefactoringContext context) + { + var stmt = context.GetNode (); + var unresolvedArguments = GetUnresolvedArguments (context); + if (unresolvedArguments.Count > 0) { + using (var script = context.StartScript ()) { + foreach (var id in unresolvedArguments) { + script.InsertBefore (stmt, GenerateLocalVariableDeclaration (context, id)); + } + } + return; + } + + using (var script = context.StartScript ()) { + script.InsertBefore (stmt, GenerateLocalVariableDeclaration (context, CreateField.GetIdentifier (context))); + } + } + + AstNode GenerateLocalVariableDeclaration (RefactoringContext context, IdentifierExpression identifier) + { + return new VariableDeclarationStatement () { + Type = GuessType (context, identifier), + Variables = { new VariableInitializer (identifier.Identifier) } + }; + } + + InvocationExpression GetInvocation (RefactoringContext context) + { + return context.GetNode (); + } + + AstType GuessType (RefactoringContext context, IdentifierExpression identifier) + { + var type = CreateField.GuessType (context, identifier); + if (type != null) + return type; + + if (identifier != null && (identifier.Parent is InvocationExpression || identifier.Parent.Parent is InvocationExpression)) { + var invocation = (identifier.Parent as InvocationExpression) ?? (identifier.Parent.Parent as InvocationExpression); + var result = context.Resolve (invocation).Type.GetDelegateInvokeMethod (); + if (result == null) + return null; + int i = 0; + foreach (var arg in invocation.Arguments) { + if (arg.Contains (identifier.StartLocation)) + break; + i++; + } + if (result.Parameters.Count < i) + return null; + return context.CreateShortType (result.Parameters[i].Type.Resolve (context.TypeResolveContext)); + } + return null; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateProperty.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateProperty.cs new file mode 100644 index 000000000..5dfd3d359 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/CreateProperty.cs @@ -0,0 +1,66 @@ +// +// CreateProperty.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; +using ICSharpCode.NRefactory.PatternMatching; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class CreateProperty : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var identifier = CreateField.GetIdentifier (context); + if (identifier == null) + return false; + return context.Resolve (identifier) == null && CreateField.GuessType (context, identifier) != null; + } + + public void Run (RefactoringContext context) + { + var identifier = GetIdentifier (context); + using (var script = context.StartScript ()) { + script.InsertWithCursor ("Create property", GeneratePropertyDeclaration (context, identifier), Script.InsertPosition.Before); + } + } + + AstNode GeneratePropertyDeclaration (RefactoringContext context, IdentifierExpression identifier) + { + return new PropertyDeclaration () { + ReturnType = CreateField.GuessType (context, identifier), + Name = identifier.Identifier, + Getter = new Accessor (), + Setter = new Accessor () + }; + } + + IdentifierExpression GetIdentifier (RefactoringContext context) + { + return context.GetNode (); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/FlipOperatorArguments.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/FlipOperatorArguments.cs new file mode 100644 index 000000000..9a11da7b0 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/FlipOperatorArguments.cs @@ -0,0 +1,59 @@ +// +// FlipOperatorArguments.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public class FlipOperatorArguments : IContextAction + { + public bool IsValid (RefactoringContext context) + { + return GetBinaryOperatorExpression (context) != null; + } + + public void Run (RefactoringContext context) + { + var binop = GetBinaryOperatorExpression (context); + + using (var script = context.StartScript ()) { + script.Replace (binop.Left, binop.Right); + script.Replace (binop.Right, binop.Left); + } + } + + public static BinaryOperatorExpression GetBinaryOperatorExpression (RefactoringContext context) + { + var node = context.GetNode (); + + if (node == null || !node.OperatorToken.Contains (context.Location)) + return null; + var result = node as BinaryOperatorExpression; + if (result == null || (result.Operator != BinaryOperatorType.Equality && result.Operator != BinaryOperatorType.InEquality)) + return null; + return result; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateGetter.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateGetter.cs new file mode 100644 index 000000000..5919da656 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateGetter.cs @@ -0,0 +1,95 @@ +// +// GenerateGetter.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; +using ICSharpCode.NRefactory.PatternMatching; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class GenerateGetter : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var initializer = GetVariableInitializer (context); + if (initializer == null || !initializer.NameToken.Contains (context.Location.Line, context.Location.Column)) + return false; + var type = initializer.Parent.Parent as TypeDeclaration; + if (type == null) + return false; + foreach (var member in type.Members) { + if (member is PropertyDeclaration && ContainsGetter ((PropertyDeclaration)member, initializer)) + return false; + } + return initializer.Parent is FieldDeclaration; + } + + public void Run (RefactoringContext context) + { + var initializer = GetVariableInitializer (context); + var field = initializer.Parent as FieldDeclaration; + + using (var script = context.StartScript ()) { + script.InsertWithCursor ("Create getter", GeneratePropertyDeclaration (context, field, initializer), Script.InsertPosition.After); + } + } + + static PropertyDeclaration GeneratePropertyDeclaration (RefactoringContext context, FieldDeclaration field, VariableInitializer initializer) + { + var mod = ICSharpCode.NRefactory.CSharp.Modifiers.Public; + if (field.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Static)) + mod |= ICSharpCode.NRefactory.CSharp.Modifiers.Static; + + return new PropertyDeclaration () { + Modifiers = mod, + Name = context.GetNameProposal (initializer.Name, false), + ReturnType = field.ReturnType.Clone (), + Getter = new Accessor () { + Body = new BlockStatement () { + new ReturnStatement (new IdentifierExpression (initializer.Name)) + } + } + }; + } + + bool ContainsGetter (PropertyDeclaration property, VariableInitializer initializer) + { + if (property.Getter.IsNull || property.Getter.Body.Statements.Count () != 1) + return false; + var ret = property.Getter.Body.Statements.Single () as ReturnStatement; + if (ret == null) + return false; + return ret.Expression.IsMatch (new IdentifierExpression (initializer.Name)) || + ret.Expression.IsMatch (new MemberReferenceExpression (new ThisReferenceExpression (), initializer.Name)); + } + + VariableInitializer GetVariableInitializer (RefactoringContext context) + { + return context.GetNode (); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateSwitchLabels.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateSwitchLabels.cs new file mode 100644 index 000000000..28ce57cf4 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/GenerateSwitchLabels.cs @@ -0,0 +1,88 @@ +// +// GenerateSwitchLabels.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class GenerateSwitchLabels : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var switchStatement = GetSwitchStatement (context); + if (switchStatement == null) + return false; + var result = context.Resolve (switchStatement.Expression); + if (result == null) + return false; + return result.Type.IsEnum (); + } + + public void Run (RefactoringContext context) + { + var switchStatement = GetSwitchStatement (context); + + var result = context.Resolve (switchStatement.Expression); + var type = result.Type; + var newSwitch = (SwitchStatement)switchStatement.Clone (); + + var target = new TypeReferenceExpression (context.CreateShortType (result.Type.Resolve (context.TypeResolveContext))); + foreach (var field in type.GetFields (context.TypeResolveContext)) { + if (field.IsSynthetic || !field.IsConst) + continue; + newSwitch.SwitchSections.Add (new SwitchSection () { + CaseLabels = { + new CaseLabel (new MemberReferenceExpression (target.Clone (), field.Name)) + }, + Statements = { + new BreakStatement () + } + }); + } + + newSwitch.SwitchSections.Add (new SwitchSection () { + CaseLabels = { + new CaseLabel () + }, + Statements = { + new ThrowStatement (new ObjectCreateExpression (context.CreateShortType ("System", "ArgumentOutOfRangeException"))) + } + }); + + using (var script = context.StartScript ()) { + script.Replace (switchStatement, newSwitch); + } + } + + static SwitchStatement GetSwitchStatement (RefactoringContext context) + { + var switchStatment = context.GetNode (); + if (switchStatment != null && switchStatment.SwitchSections.Count == 0) + return switchStatment; + return null; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InsertAnonymousMethodSignature.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InsertAnonymousMethodSignature.cs new file mode 100644 index 000000000..503899bd9 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InsertAnonymousMethodSignature.cs @@ -0,0 +1,94 @@ +// +// InsertAnonymousMethodSignature.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ICSharpCode.NRefactory.TypeSystem; +using System.Linq; +using System.Text; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class InsertAnonymousMethodSignature : IContextAction + { + public bool IsValid (RefactoringContext context) + { + IType type; + return GetAnonymousMethodExpression (context, out type) != null; + } + + public void Run (RefactoringContext context) + { + IType type; + var anonymousMethodExpression = GetAnonymousMethodExpression (context, out type); + + var delegateMethod = type.GetDelegateInvokeMethod (); + + var sb = new StringBuilder ("("); + for (int k = 0; k < delegateMethod.Parameters.Count; k++) { + if (k > 0) + sb.Append (", "); + + var paramType = delegateMethod.Parameters [k].Type; + + sb.Append (paramType.ToString ()); + sb.Append (" "); + sb.Append (delegateMethod.Parameters [k].Name); + } + sb.Append (")"); + + using (var script = context.StartScript ()) { + script.InsertText (context.GetOffset (anonymousMethodExpression.DelegateToken.EndLocation), sb.ToString ()); + } + } + + static AnonymousMethodExpression GetAnonymousMethodExpression (RefactoringContext context, out IType delegateType) + { + delegateType = null; + + var anonymousMethodExpression = context.GetNode (); + if (anonymousMethodExpression == null || !anonymousMethodExpression.DelegateToken.Contains (context.Location.Line, context.Location.Column) || anonymousMethodExpression.HasParameterList) + return null; + + IType resolvedType = null; + var parent = anonymousMethodExpression.Parent; + if (parent is AssignmentExpression) { + resolvedType = context.Resolve (((AssignmentExpression)parent).Left).Type; + } else if (parent is VariableDeclarationStatement) { + resolvedType = context.Resolve (((VariableDeclarationStatement)parent).Type).Type; + } else if (parent is InvocationExpression) { + // TODO: handle invocations + } + + if (resolvedType == null) + return null; + delegateType = resolvedType; + if (!delegateType.IsDelegate ()) + return null; + + return anonymousMethodExpression; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/IntroduceFormatItem.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/IntroduceFormatItem.cs new file mode 100644 index 000000000..d1530b90d --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/IntroduceFormatItem.cs @@ -0,0 +1,100 @@ +// +// IntroduceFormatItem.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; +using ICSharpCode.NRefactory.PatternMatching; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// Introduce format item. Works on strings that contain selections. + /// "this is string" => string.Format ("this is {0} string", ) + /// + public class IntroduceFormatItem : IContextAction + { + readonly static MemberReferenceExpression PrototypeFormatReference = new MemberReferenceExpression (new TypeReferenceExpression (new PrimitiveType ("string")), "Format"); + + public bool IsValid (RefactoringContext context) + { + if (!context.IsSomethingSelected) + return false; + var pexpr = context.GetNode (); + if (pexpr == null || !(pexpr.Value is string)) + return false; + if (pexpr.LiteralValue.StartsWith ("@")) + return pexpr.StartLocation < new AstLocation (context.Location.Line, context.Location.Column - 1) && + new AstLocation (context.Location.Line, context.Location.Column + 1) < pexpr.EndLocation; + return pexpr.StartLocation < context.Location && context.Location < pexpr.EndLocation; + } + + public void Run (RefactoringContext context) + { + var pexpr = context.GetNode (); + var invocation = context.GetNode (); + if (invocation != null && invocation.Target.IsMatch (PrototypeFormatReference)) { + AddFormatCallToInvocation (context, pexpr, invocation); + return; + } + + var arg = CreateFormatArgument (context); + var newInvocation = new InvocationExpression (PrototypeFormatReference.Clone ()) { + Arguments = { CreateFormatString (context, pexpr, 0), arg } + }; + + using (var script = context.StartScript ()) { + script.Replace (pexpr, newInvocation); + script.Select (arg); + } + } + + void AddFormatCallToInvocation (RefactoringContext context, PrimitiveExpression pExpr, InvocationExpression invocation) + { + var newInvocation = (InvocationExpression)invocation.Clone (); + + newInvocation.Arguments.First ().ReplaceWith (CreateFormatString (context, pExpr, newInvocation.Arguments.Count () - 1)); + newInvocation.Arguments.Add (CreateFormatArgument (context)); + + using (var script = context.StartScript ()) { + script.Replace (invocation, newInvocation); + } + } + + static PrimitiveExpression CreateFormatArgument (RefactoringContext context) + { + return new PrimitiveExpression (context.SelectedText); + } + + static PrimitiveExpression CreateFormatString (RefactoringContext context, PrimitiveExpression pExpr, int argumentNumber) + { + var start = context.GetOffset (pExpr.StartLocation); + var end = context.GetOffset (pExpr.EndLocation); + + return new PrimitiveExpression ("", context.GetText (start, context.SelectionStart - start) + "{" + argumentNumber + "}" + context.GetText (context.SelectionEnd, end - context.SelectionEnd)); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InvertIf.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InvertIf.cs new file mode 100644 index 000000000..79a59c32a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/InvertIf.cs @@ -0,0 +1,61 @@ +// +// InvertIf.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public class InvertIf : IContextAction + { + public bool IsValid (RefactoringContext context) + { + var ifStatement = GetIfElseStatement (context); + return ifStatement != null && !ifStatement.TrueStatement.IsNull && !ifStatement.FalseStatement.IsNull; + } + + // TODO: Invert if without else + // ex. if (cond) DoSomething () == if (!cond) return; DoSomething () + // beware of loop contexts return should be continue then. + public void Run (RefactoringContext context) + { + var ifStatement = GetIfElseStatement (context); + + using (var script = context.StartScript ()) { + script.Replace (ifStatement.Condition, CSharpUtil.InvertCondition (ifStatement.Condition)); + script.Replace (ifStatement.TrueStatement, ifStatement.FalseStatement); + script.Replace (ifStatement.FalseStatement, ifStatement.TrueStatement); + script.FormatText (ctx => GetIfElseStatement (ctx)); + } + } + + static IfElseStatement GetIfElseStatement (RefactoringContext context) + { + var result = context.GetNode (); + if (result != null && result.IfToken.Contains (context.Location)) + return result; + return null; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBackingStore.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBackingStore.cs new file mode 100644 index 000000000..6655656bc --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBackingStore.cs @@ -0,0 +1,123 @@ +// +// RemoveBackingStore.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ICSharpCode.NRefactory.TypeSystem; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Resolver; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class RemoveBackingStore : IContextAction + { + public bool IsValid (RefactoringContext context) + { + return GetBackingField (context) != null; + } + + public void Run (RefactoringContext context) + { + var property = context.GetNode (); + var field = GetBackingField (context); + + context.ReplaceReferences (field, property); + + // create new auto property + var newProperty = (PropertyDeclaration)property.Clone (); + newProperty.Getter.Body = BlockStatement.Null; + newProperty.Setter.Body = BlockStatement.Null; + + using (var script = context.StartScript ()) { + script.Remove (context.Unit.GetNodeAt (field.Region.BeginLine, field.Region.BeginColumn)); + script.Replace (property, newProperty); + } + + } + +// void ReplaceBackingFieldReferences (MDRefactoringContext context, IField backingStore, PropertyDeclaration property) +// { +// using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true, true)) { +// foreach (var memberRef in MonoDevelop.Ide.FindInFiles.ReferenceFinder.FindReferences (backingStore, monitor)) { +// if (property.Contains (memberRef.Line, memberRef.Column)) +// continue; +// if (backingStore.Location.Line == memberRef.Line && backingStore.Location.Column == memberRef.Column) +// continue; +// context.Do (new TextReplaceChange () { +// FileName = memberRef.FileName, +// Offset = memberRef.Position, +// RemovedChars = memberRef.Name.Length, +// InsertedText = property.Name +// }); +// } +// } +// } +// + static IField GetBackingField (RefactoringContext context) + { + var propertyDeclaration = context.GetNode (); + // automatic properties always need getter & setter + if (propertyDeclaration == null || propertyDeclaration.Getter.IsNull || propertyDeclaration.Setter.IsNull || propertyDeclaration.Getter.Body.IsNull || propertyDeclaration.Setter.Body.IsNull) + return null; + if (!context.HasCSharp3Support || propertyDeclaration.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Abstract) || ((TypeDeclaration)propertyDeclaration.Parent).ClassType == ICSharpCode.NRefactory.TypeSystem.ClassType.Interface) + return null; + var getterField = ScanGetter (context, propertyDeclaration); + if (getterField == null) + return null; + var setterField = ScanSetter (context, propertyDeclaration); + if (setterField == null) + return null; + if (getterField.Region != setterField.Region) + return null; + return getterField; + } + + internal static IField ScanGetter (RefactoringContext context, PropertyDeclaration propertyDeclaration) + { + if (propertyDeclaration.Getter.Body.Statements.Count != 1) + return null; + var returnStatement = propertyDeclaration.Getter.Body.Statements.First () as ReturnStatement; + + var result = context.Resolve (returnStatement.Expression); + if (result == null || !(result is MemberResolveResult)) + return null; + return ((MemberResolveResult)result).Member as IField; + } + + internal static IField ScanSetter (RefactoringContext context, PropertyDeclaration propertyDeclaration) + { + if (propertyDeclaration.Setter.Body.Statements.Count != 1) + return null; + var setAssignment = propertyDeclaration.Setter.Body.Statements.First () as ExpressionStatement; + var assignment = setAssignment != null ? setAssignment.Expression as AssignmentExpression : null; + if (assignment == null || assignment.Operator != AssignmentOperatorType.Assign) + return null; + var result = context.Resolve (assignment.Left); + if (result == null || !(result is MemberResolveResult)) + return null; + return ((MemberResolveResult)result).Member as IField; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBraces.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBraces.cs new file mode 100644 index 000000000..eed2e429f --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/RemoveBraces.cs @@ -0,0 +1,61 @@ +// +// RemoveBraces.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class RemoveBraces : IContextAction + { + public bool IsValid (RefactoringContext context) + { + return GetBlockStatement (context) != null; + } + + public void Run (RefactoringContext context) + { + var block = GetBlockStatement (context); + + using (var script = context.StartScript ()) { + script.Remove (block.LBraceToken); + script.Remove (block.RBraceToken); + script.FormatText (ctx => ctx.Unit.GetNodeAt (block.Parent.StartLocation)); + } + } + + static BlockStatement GetBlockStatement (RefactoringContext context) + { + var block = context.GetNode (); + if (block == null || block.LBraceToken.IsNull || block.RBraceToken.IsNull) + return null; + if (block.Parent.Role == TypeDeclaration.MemberRole) + return null; + if (block.Statements.Count () != 1) + return null; + return block; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ReplaceEmptyString.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ReplaceEmptyString.cs new file mode 100644 index 000000000..4e91b866b --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/ReplaceEmptyString.cs @@ -0,0 +1,53 @@ +// +// ReplaceEmptyString.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public class ReplaceEmptyString : IContextAction + { + public bool IsValid (RefactoringContext context) + { + return GetEmptyString (context) != null; + } + + public void Run (RefactoringContext context) + { + var expr = GetEmptyString (context); + using (var script = context.StartScript ()) { + script.Replace (expr, new MemberReferenceExpression (new TypeReferenceExpression (new PrimitiveType ("string")), "Empty")); + } + } + + static PrimitiveExpression GetEmptyString (RefactoringContext context) + { + var node = context.GetNode (); + if (node == null || !(node.Value is string) || node.Value.ToString () != "") + return null; + return node; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitDeclarationAndAssignment.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitDeclarationAndAssignment.cs new file mode 100644 index 000000000..414228053 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitDeclarationAndAssignment.cs @@ -0,0 +1,74 @@ +// +// SplitDeclarationAndAssignment.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class SplitDeclarationAndAssignment : IContextAction + { + public bool IsValid (RefactoringContext context) + { + AstType type; + return GetVariableDeclarationStatement (context, out type) != null; + } + + public void Run (RefactoringContext context) + { + AstType type; + var varDecl = GetVariableDeclarationStatement (context, out type); + + var assign = new AssignmentExpression (new IdentifierExpression (varDecl.Variables.First ().Name), AssignmentOperatorType.Assign, varDecl.Variables.First ().Initializer.Clone ()); + + var newVarDecl = (VariableDeclarationStatement)varDecl.Clone (); + + if (newVarDecl.Type.IsMatch (new SimpleType ("var"))) + newVarDecl.Type = type; + + newVarDecl.Variables.First ().Initializer = Expression.Null; + + using (var script = context.StartScript ()) { + script.InsertBefore (varDecl, newVarDecl); + script.Replace (varDecl, varDecl.Parent is ForStatement ? (AstNode)assign : new ExpressionStatement (assign)); + } + } + + static VariableDeclarationStatement GetVariableDeclarationStatement (RefactoringContext context, out AstType resolvedType) + { + var result = context.GetNode (); + if (result != null && result.Variables.Count == 1 && !result.Variables.First ().Initializer.IsNull && result.Variables.First ().NameToken.Contains (context.Location.Line, context.Location.Column)) { + resolvedType = context.Resolve (result.Variables.First ().Initializer).Type.ConvertToAstType (); + if (resolvedType == null) + return null; + return result; + } + resolvedType = null; + return null; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitString.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitString.cs new file mode 100644 index 000000000..425f54ca3 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/SplitString.cs @@ -0,0 +1,55 @@ +// +// SplitString.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public class SplitString: IContextAction + { + public bool IsValid (RefactoringContext context) + { + if (context.IsSomethingSelected) + return false; + var pexpr = context.GetNode (); + if (pexpr == null || !(pexpr.Value is string)) + return false; + if (pexpr.LiteralValue.StartsWith ("@")) + return pexpr.StartLocation < new AstLocation (context.Location.Line, context.Location.Column - 2) && + new AstLocation (context.Location.Line, context.Location.Column + 2) < pexpr.EndLocation; + return pexpr.StartLocation < new AstLocation (context.Location.Line, context.Location.Column - 1) && + new AstLocation (context.Location.Line, context.Location.Column + 1) < pexpr.EndLocation; + } + + public void Run (RefactoringContext context) + { + var pexpr = context.GetNode (); + int offset = context.GetOffset (context.Location); + using (var script = context.StartScript ()) { + script.InsertText (offset, pexpr.LiteralValue.StartsWith ("@") ? "\" + @\"" : "\" + \""); + } + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseExplicitType.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseExplicitType.cs new file mode 100644 index 000000000..b31bf78cb --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseExplicitType.cs @@ -0,0 +1,67 @@ +// +// UseExplicitType.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; +using ICSharpCode.NRefactory.PatternMatching; +using ICSharpCode.NRefactory.TypeSystem; + + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class UseExplicitType: IContextAction + { + public bool IsValid (RefactoringContext context) + { + var varDecl = GetVariableDeclarationStatement (context); + if (varDecl == null) + return false; + var type = context.Resolve (varDecl.Variables.First ().Initializer).Type; + return !type.Equals (SharedTypes.Null) && !type.Equals (SharedTypes.UnknownType); + } + + public void Run (RefactoringContext context) + { + var varDecl = GetVariableDeclarationStatement (context); + + using (var script = context.StartScript ()) { + var type = context.Resolve (varDecl.Variables.First ().Initializer).Type; + script.Replace (varDecl.Type, context.CreateShortType (type)); + } + } + + static VariableDeclarationStatement GetVariableDeclarationStatement (RefactoringContext context) + { + var result = context.GetNode (); + if (result != null && result.Variables.Count == 1 && !result.Variables.First ().Initializer.IsNull && result.Type.Contains (context.Location.Line, context.Location.Column) && result.Type.IsMatch (new SimpleType ("var"))) { + if (context.Resolve (result.Variables.First ().Initializer) == null) + return null; + return result; + } + return null; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseVarKeyword.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseVarKeyword.cs new file mode 100644 index 000000000..8aa9c8b66 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/ContextAction/UseVarKeyword.cs @@ -0,0 +1,56 @@ +// +// UseVarKeyword.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class UseVarKeyword: IContextAction + { + public bool IsValid (RefactoringContext context) + { + return GetVariableDeclarationStatement (context) != null; + } + + public void Run (RefactoringContext context) + { + var varDecl = GetVariableDeclarationStatement (context); + using (var script = context.StartScript ()) { + script.Replace (varDecl.Type, new SimpleType ("var")); + } + } + + static VariableDeclarationStatement GetVariableDeclarationStatement (RefactoringContext context) + { + var result = context.GetNode (); + if (result != null && result.Variables.Count == 1 && !result.Variables.First ().Initializer.IsNull && result.Type.Contains (context.Location.Line, context.Location.Column) && !result.Type.IsMatch (new SimpleType ("var"))) + return result; + return null; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/CreateLinkAction.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/CreateLinkAction.cs new file mode 100644 index 000000000..11212a1c9 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/CreateLinkAction.cs @@ -0,0 +1,44 @@ +// +// CreateLinkAction.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public abstract class CreateLinkAction : Action + { + public IEnumerable Linked { + get; + private set; + } + + public CreateLinkAction (IEnumerable linked) + { + this.Linked = linked; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/FormatTextAction.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/FormatTextAction.cs new file mode 100644 index 000000000..8b7fde661 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/FormatTextAction.cs @@ -0,0 +1,39 @@ +// +// FormatTextAction.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public abstract class FormatTextAction : Action + { + public Func Callback { get; private set; } + + public FormatTextAction (Func callback) + { + this.Callback = callback; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/IActionFactory.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/IActionFactory.cs new file mode 100644 index 000000000..f801a1c9b --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/IActionFactory.cs @@ -0,0 +1,75 @@ +// +// IChangeFactory.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// A factory that creates the changes. + /// + public interface IActionFactory + { + TextReplaceAction CreateTextReplaceAction (int offset, int removedChars, string insertedText); + NodeOutputAction CreateNodeOutputAction (int offset, int removedChars, NodeOutput output); + NodeSelectionAction CreateNodeSelectionAction (AstNode node); + FormatTextAction CreateFormatTextAction (Func callback); + CreateLinkAction CreateLinkAction (IEnumerable linkedNodes); + } + + public abstract class AbstractActionFactory : IActionFactory + { + #region IActionFactory implementation + public virtual TextReplaceAction CreateTextReplaceAction (int offset, int removedChars, string insertedText) + { + throw new NotImplementedException (); + } + + public virtual NodeOutputAction CreateNodeOutputAction (int offset, int removedChars, NodeOutput output) + { + throw new NotImplementedException (); + } + + public virtual NodeSelectionAction CreateNodeSelectionAction (AstNode node) + { + throw new NotImplementedException (); + } + + public virtual FormatTextAction CreateFormatTextAction (Func callback) + { + throw new NotImplementedException (); + } + + public virtual CreateLinkAction CreateLinkAction (IEnumerable linkedNodes) + { + throw new NotImplementedException (); + } + #endregion + + } + +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/IContextAction.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/IContextAction.cs new file mode 100644 index 000000000..8c2b64ce2 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/IContextAction.cs @@ -0,0 +1,36 @@ +// +// ContextAction.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public interface IContextAction + { + bool IsValid (RefactoringContext context); + void Run (RefactoringContext context); + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/NodeOutputAction.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/NodeOutputAction.cs new file mode 100644 index 000000000..47d5e7ba7 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/NodeOutputAction.cs @@ -0,0 +1,136 @@ +// +// NodeOutputChange.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// This is the node that should be outputted at a position. + /// + public class NodeOutput + { + public readonly Dictionary NodeSegments = new Dictionary (); + + public string Text { + get; + set; + } + + public void Trim () + { + for (int i = 0; i < Text.Length; i++) { + char ch = Text [i]; + if (ch != ' ' && ch != '\t') { + if (i > 0) { + Text = Text.Substring (i); + foreach (var seg in NodeSegments.Values) { + seg.Offset -= i; + } + } + break; + } + } + } + + public class Segment : ISegment + { + public int Offset { + get; + set; + } + + public int Length { + get { + return EndOffset - Offset; + } + } + + public int EndOffset { + get; + set; + } + + public Segment (int offset) + { + this.Offset = offset; + } + } + } + + + /// + /// Outputs an Ast node at a specific offset. + /// + public abstract class NodeOutputAction : TextReplaceAction + { + public NodeOutput NodeOutput { + get; + private set; + } + + public override string InsertedText { + get { + return NodeOutput.Text; + } + set { + throw new NotSupportedException ("Changing text with this propery is not supported on NodeOutputChange."); + } + } + + public NodeOutputAction (int offset, int removedChars, NodeOutput output) : base (offset, removedChars) + { + if (output == null) + throw new ArgumentNullException ("output"); + this.NodeOutput = output; + } + } + + + /// + /// An (Offset,Length)-pair. + /// + public interface ISegment + { + /// + /// Gets the start offset of the segment. + /// + int Offset { get; } + + /// + /// Gets the length of the segment. + /// + /// Must not be negative. + int Length { get; } + + /// + /// Gets the end offset of the segment. + /// + /// EndOffset = Offset + Length; + int EndOffset { get; } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/NodeSelectionAction.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/NodeSelectionAction.cs new file mode 100644 index 000000000..b7df34b95 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/NodeSelectionAction.cs @@ -0,0 +1,40 @@ +// +// SelectionAction.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + public abstract class NodeSelectionAction : Action + { + public AstNode AstNode { get; private set; } + + public NodeSelectionAction (AstNode astNode) + { + this.AstNode = astNode; + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/RefactoringContext.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/RefactoringContext.cs new file mode 100644 index 000000000..a73d97373 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/RefactoringContext.cs @@ -0,0 +1,141 @@ +// +// RefactoringContext.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; +using ICSharpCode.NRefactory.CSharp.Resolver; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public abstract class RefactoringContext : AbstractActionFactory + { + public CompilationUnit Unit { + get; + protected set; + } + + public virtual ITypeResolveContext TypeResolveContext { + get { + return null; + } + } + + public AstLocation Location { + get; + protected set; + } + + public abstract bool HasCSharp3Support { + get; + } + + public abstract CSharpFormattingOptions FormattingOptions { + get; + } + + public abstract AstType CreateShortType (IType fullType); + + public AstType CreateShortType (string ns, string typeName) + { + return CreateShortType (TypeResolveContext.GetTypeDefinition (ns, typeName, 0, StringComparer.Ordinal)); + } + + public virtual AstType CreateShortType (AstType fullType) + { + return CreateShortType (Resolve (fullType).Type.Resolve (TypeResolveContext)); + } + +// public abstract IType GetDefinition (AstType resolvedType); + + public abstract void ReplaceReferences (IMember member, MemberDeclaration replaceWidth); + + public AstNode GetNode () + { + return Unit.GetNodeAt (Location); + } + + public T GetNode () where T : AstNode + { + return Unit.GetNodeAt (Location); + } + + public abstract Script StartScript (); + + #region Text stuff + public abstract string EolMarker { get; } + public abstract bool IsSomethingSelected { get; } + public abstract string SelectedText { get; } + public abstract int SelectionStart { get; } + public abstract int SelectionEnd { get; } + public abstract int SelectionLength { get; } + public abstract int GetOffset (AstLocation location); + public int GetOffset (int line, int col) + { + return GetOffset (new AstLocation (line, col)); + } + public abstract AstLocation GetLocation (int offset); + public abstract string GetText (int offset, int length); + #endregion + + #region Resolving + public abstract ResolveResult Resolve (AstNode expression); + #endregion + + public string GetNameProposal (string name, bool camelCase = true) + { + string baseName = (camelCase ? char.ToLower (name [0]) : char.ToUpper (name [0])) + name.Substring (1); + + var type = GetNode (); + if (type == null) + return baseName; + + int number = -1; + string proposedName; + do { + proposedName = AppendNumberToName (baseName, number++); + } while (type.Members.Select (m => m.GetChildByRole (AstNode.Roles.Identifier)).Any (n => n.Name == proposedName)); + return proposedName; + } + + static string AppendNumberToName (string baseName, int number) + { + return baseName + (number > 0 ? (number + 1).ToString () : ""); + } + } + + public static class ExtensionMethods + { + #region ConvertTypes + public static ICSharpCode.NRefactory.CSharp.AstType ConvertToAstType (this IType type) + { + var builder = new TypeSystemAstBuilder (); + return builder.ConvertType (type); + } + #endregion + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/Script.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/Script.cs new file mode 100644 index 000000000..db6be3189 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/Script.cs @@ -0,0 +1,180 @@ +// +// Script.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public abstract class Script : IDisposable + { + public RefactoringContext Context { + get; + private set; + } + + protected readonly List changes = new List (); + + public IEnumerable Actions { + get { + return changes; + } + } + + public Script (RefactoringContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + this.Context = context; + } + + public void Queue (Action change) + { + changes.Add (change); + } + + public void InsertText (int offset, string text) + { + Queue (Context.CreateTextReplaceAction (offset, 0, text)); + } + + public void InsertBefore (AstNode node, AstNode insertNode) + { + var startOffset = Context.GetOffset (node.StartLocation.Line, 1); + var output = OutputNode (GetIndentLevelAt (startOffset), insertNode); + + if (!(insertNode is Expression || insertNode is AstType)) + output.Text += Context.EolMarker; + + Queue (Context.CreateNodeOutputAction (startOffset, 0, output)); + } + + public void AddTo (BlockStatement bodyStatement, AstNode insertNode) + { + var startOffset = Context.GetOffset (bodyStatement.LBraceToken.StartLocation) + 1; + var output = OutputNode (GetIndentLevelAt (startOffset), insertNode, true); + Queue (Context.CreateNodeOutputAction (startOffset, 0, output)); + } + + public void Link (params AstNode[] nodes) + { + Queue (Context.CreateLinkAction (nodes)); + } + + public void Link (IEnumerable nodes) + { + Queue (Context.CreateLinkAction (nodes)); + } + + public void Remove (AstNode node) + { + var startOffset = Context.GetOffset (node.StartLocation); + var endOffset = Context.GetOffset (node.EndLocation); + Remove (startOffset, endOffset - startOffset); + } + + void Remove (int offset, int length) + { + Queue (Context.CreateTextReplaceAction (offset, length, null)); + } + + void Replace (int offset, int length, string text) + { + Queue (Context.CreateTextReplaceAction (offset, length, text)); + } + + public void Replace (AstNode node, AstNode replaceWith) + { + var startOffset = Context.GetOffset (node.StartLocation); + var endOffset = Context.GetOffset (node.EndLocation); + int level = 0; + if (!(replaceWith is Expression) && !(replaceWith is AstType)) + level = GetIndentLevelAt (startOffset); + NodeOutput output = OutputNode (level, replaceWith); + output.Trim (); + Queue (Context.CreateNodeOutputAction (startOffset, endOffset - startOffset, output)); + } + + public void FormatText (Func callback) + { + Queue (Context.CreateFormatTextAction (callback)); + } + + public void Select (AstNode node) + { + Queue (Context.CreateNodeSelectionAction (node)); + } + + public enum InsertPosition { + Start, + Before, + After, + End + } + + public abstract void InsertWithCursor (string operation, AstNode node, InsertPosition defaultPosition); + + protected int GetIndentLevelAt (int offset) + { + var node = Context.Unit.GetNodeAt (Context.GetLocation (offset)); + int level = 0; + while (node != null) { + if (node is BlockStatement || node is TypeDeclaration || node is NamespaceDeclaration) + level++; + node = node.Parent; + } + return level; + } + + protected NodeOutput OutputNode (int indentLevel, AstNode node, bool startWithNewLine = false) + { + var result = new NodeOutput (); + var stringWriter = new System.IO.StringWriter (); + var formatter = new TextWriterOutputFormatter (stringWriter); + formatter.Indentation = indentLevel; + stringWriter.NewLine = Context.EolMarker; + if (startWithNewLine) + formatter.NewLine (); + var visitor = new OutputVisitor (formatter, Context.FormattingOptions); + visitor.OutputStarted += (sender, e) => { + result.NodeSegments [e.AstNode] = new NodeOutput.Segment (stringWriter.GetStringBuilder ().Length); + }; + visitor.OutputFinished += (sender, e) => { + result.NodeSegments [e.AstNode].EndOffset = stringWriter.GetStringBuilder ().Length; + }; + node.AcceptVisitor (visitor, null); + result.Text = stringWriter.ToString ().TrimEnd (); + if (node is FieldDeclaration) + result.Text += Context.EolMarker; + + return result; + } + + #region IDisposable implementation + public abstract void Dispose (); + #endregion + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/StringBuilderOutputFormatter.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/StringBuilderOutputFormatter.cs new file mode 100644 index 000000000..63830b47a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/StringBuilderOutputFormatter.cs @@ -0,0 +1,158 @@ +// +// StringBuilderOutputFormatter.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class StringBuilderOutputFormatter : IOutputFormatter + { + readonly StringBuilder sb = new StringBuilder (); + int indentation; + bool needsIndent = true; + + public int Length { + get { + WriteIndentation (); + return sb.Length; + } + } + + public int Indentation { + get { + return this.indentation; + } + set { + indentation = value; + } + } + + public string EolMarker { + get; + set; + } + + public override string ToString () + { + return sb.ToString (); + } + + public void WriteIdentifier (string ident) + { + WriteIndentation (); + sb.Append (ident); + } + + public void WriteKeyword (string keyword) + { + WriteIndentation (); + sb.Append (keyword); + } + + public void WriteToken (string token) + { + WriteIndentation (); + sb.Append (token); + } + + public void Space () + { + WriteIndentation (); + sb.Append (' '); + } + + public void OpenBrace (BraceStyle style) + { + WriteIndentation (); + sb.Append (' '); + sb.Append ('{'); + Indent (); + NewLine (); + } + + public void CloseBrace (BraceStyle style) + { + Unindent (); + WriteIndentation (); + sb.Append ('}'); + } + + void WriteIndentation () + { + if (needsIndent) { + needsIndent = false; + for (int i = 0; i < indentation; i++) { + sb.Append ('\t'); + } + } + } + + public void NewLine () + { + sb.Append (EolMarker); + needsIndent = true; + } + + public void Indent () + { + indentation++; + } + + public void Unindent () + { + indentation--; + } + + public void WriteComment (CommentType commentType, string content) + { + WriteIndentation (); + switch (commentType) { + case CommentType.SingleLine: + sb.Append ("//"); + sb.AppendLine (content); + break; + case CommentType.MultiLine: + sb.Append ("/*"); + sb.Append (content); + sb.Append ("*/"); + break; + case CommentType.Documentation: + sb.Append ("///"); + sb.AppendLine (content); + break; + } + } + + public virtual void StartNode (AstNode node) + { + } + + public virtual void EndNode (AstNode node) + { + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/TextReplaceAction.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/TextReplaceAction.cs new file mode 100644 index 000000000..d2bc29f58 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/TextReplaceAction.cs @@ -0,0 +1,134 @@ +// +// TextReplaceChange.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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.Refactoring +{ + /// + /// This is the base action for changes in a text document. + /// + public abstract class TextReplaceAction : Action + { + /// + /// Gets or sets the offset. + /// + /// + /// The offset of the replace. + /// + public int Offset { + get; + set; + } + + int removedChars; + /// + /// Gets or sets the numer of chars to removed. + /// + /// + /// The numer of chars to remove. + /// + /// + /// Is thrown when an argument passed to a method is invalid because it is outside the allowable range of values as + /// specified by the method. + /// + public int RemovedChars { + get { + return removedChars; + } + set { + if (value < 0) + throw new ArgumentOutOfRangeException ("RemovedChars", "needs to be >= 0"); + removedChars = value; + } + } + + /// + /// Gets or sets the inserted text. + /// + /// + /// The text to insert. + /// + public virtual string InsertedText { + get; + set; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The offset of the replace. + /// + /// + /// The numer of chars to remove. + /// + /// + /// Is thrown when an argument passed to a method is invalid because it is outside the allowable range of values as + /// specified by the method. + /// + protected TextReplaceAction (int offset, int removedChars) + { + 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; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The offset of the replace. + /// + /// + /// The numer of chars to remove. + /// + /// + /// The text to insert. + /// + /// + /// Is thrown when an argument passed to a method is invalid because it is outside the allowable range of values as + /// specified by the method. + public TextReplaceAction (int offset, int removedChars, string insertedText) : this (offset, removedChars) + { + this.InsertedText = insertedText; + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString () + { + return string.Format ("[TextReplaceAction: Offset={0}, RemovedChars={1}, InsertedText={2}]", Offset, RemovedChars, InsertedText == null ? "" : InsertedText.Replace ("\t", "\\t").Replace ("\n", "\\n")); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs b/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs new file mode 100644 index 000000000..6bd0c9830 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs @@ -0,0 +1,218 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// Converts from type system to the C# AST. + /// + public class TypeSystemAstBuilder + { + readonly CSharpResolver resolver; + + /// + /// Creates a new TypeSystemAstBuilder. + /// + /// + /// A resolver initialized for the position where the type will be inserted. + /// + public TypeSystemAstBuilder(CSharpResolver resolver = null) + { + this.resolver = resolver; + } + + public AstType ConvertType(IType type) + { + if (type == null) + throw new ArgumentNullException("type"); + TypeWithElementType typeWithElementType = type as TypeWithElementType; + if (typeWithElementType != null) { + if (typeWithElementType is PointerType) { + return ConvertType(typeWithElementType.ElementType).MakePointerType(); + } else if (typeWithElementType is ArrayType) { + return ConvertType(typeWithElementType.ElementType).MakeArrayType(((ArrayType)type).Dimensions); + } else { + // e.g. ByReferenceType; not supported as type in C# + return ConvertType(typeWithElementType.ElementType); + } + } + ParameterizedType pt = type as ParameterizedType; + if (pt != null) { + if (pt.Name == "Nullable" && pt.Namespace == "System" && pt.TypeParameterCount == 1) { + return ConvertType(pt.TypeArguments[0]).MakeNullableType(); + } + return ConvertTypeDefinition(pt.GetDefinition(), pt.TypeArguments); + } + ITypeDefinition typeDef = type as ITypeDefinition; + if (typeDef != null) { + if (typeDef.TypeParameterCount > 0) { + // Create an unbound type + IType[] typeArguments = new IType[typeDef.TypeParameterCount]; + for (int i = 0; i < typeArguments.Length; i++) { + typeArguments[i] = SharedTypes.UnknownType; + } + return ConvertTypeDefinition(typeDef, typeArguments); + } else { + return ConvertTypeDefinition(typeDef, EmptyList.Instance); + } + } + return new SimpleType(type.Name); + } + + AstType ConvertTypeDefinition(ITypeDefinition typeDef, IList typeArguments) + { + Debug.Assert(typeArguments.Count >= typeDef.TypeParameterCount); + switch (ReflectionHelper.GetTypeCode(typeDef)) { + case TypeCode.Object: + return new PrimitiveType("object"); + case TypeCode.Boolean: + return new PrimitiveType("bool"); + case TypeCode.Char: + return new PrimitiveType("char"); + case TypeCode.SByte: + return new PrimitiveType("sbyte"); + case TypeCode.Byte: + return new PrimitiveType("byte"); + case TypeCode.Int16: + return new PrimitiveType("short"); + case TypeCode.UInt16: + return new PrimitiveType("ushort"); + case TypeCode.Int32: + return new PrimitiveType("int"); + case TypeCode.UInt32: + return new PrimitiveType("uint"); + case TypeCode.Int64: + return new PrimitiveType("long"); + case TypeCode.UInt64: + return new PrimitiveType("ulong"); + case TypeCode.Single: + return new PrimitiveType("float"); + case TypeCode.Double: + return new PrimitiveType("double"); + case TypeCode.Decimal: + return new PrimitiveType("decimal"); + case TypeCode.String: + return new PrimitiveType("string"); + } + // There is no type code for System.Void + if (typeDef != null && typeDef.Namespace == "System" && typeDef.Name == "Void" && typeDef.TypeParameterCount == 0) + return new PrimitiveType("void"); + if (resolver != null && TypeArgumentsTrivial(typeArguments, OuterTypeParameterCount(typeDef))) { + TypeResolveResult trr = resolver.ResolveSimpleName(typeDef.Name, typeArguments) as TypeResolveResult; + if (trr != null && !trr.IsError && trr.Type.GetDefinition() == typeDef) { + // We can use the short type name + SimpleType shortResult = new SimpleType(typeDef.Name); + AddTypeArguments(shortResult, typeArguments, OuterTypeParameterCount(typeDef), typeDef.TypeParameterCount); + return shortResult; + } + } + + MemberType result = new MemberType(); + if (typeDef.DeclaringTypeDefinition != null) { + // Handle nested types + result.Target = ConvertTypeDefinition(typeDef.DeclaringTypeDefinition, typeArguments); + } else { + // Handle top-level types + if (string.IsNullOrEmpty(typeDef.Namespace)) { + result.Target = new SimpleType("global"); + result.IsDoubleColon = true; + } else { + result.Target = ConvertNamespace(typeDef.Namespace); + } + } + result.MemberName = typeDef.Name; + AddTypeArguments(result, typeArguments, OuterTypeParameterCount(typeDef), typeDef.TypeParameterCount); + return result; + } + + /// + /// Gets the number of type parameters belonging to outer classes. + /// + int OuterTypeParameterCount(ITypeDefinition typeDef) + { + if (typeDef.DeclaringType != null) + return typeDef.DeclaringType.TypeParameterCount; + else + return 0; + } + + /// + /// Gets whether the first type arguments are trivial, + /// that is, they point to a type parameter with the same index. + /// + bool TypeArgumentsTrivial(IList typeArguments, int num) + { + for (int i = 0; i < num; i++) { + ITypeParameter tp = typeArguments[i] as ITypeParameter; + if (!(tp != null && tp.OwnerType == EntityType.TypeDefinition && tp.Index == i)) + return false; + } + return true; + } + + /// + /// Adds type arguments to the result type. + /// + /// The result AST node (a SimpleType or MemberType) + /// The list of type arguments + /// Index of first type argument to add + /// Index after last type argument to add + void AddTypeArguments(AstType result, IList typeArguments, int startIndex, int endIndex) + { + for (int i = startIndex; i < endIndex; i++) { + result.AddChild(ConvertType(typeArguments[i]), AstType.Roles.TypeArgument); + } + } + + AstType ConvertNamespace(string ns) + { + if (resolver != null) { + // Look if there's an alias to the target namespace + for (UsingScope usingScope = resolver.UsingScope; usingScope != null; usingScope = usingScope.Parent) { + foreach (var pair in usingScope.UsingAliases) { + // maybe add some caching? we're resolving all aliases N times when converting a namespace name with N parts + NamespaceResolveResult nrr = pair.Value.ResolveNamespace(resolver.Context); + if (nrr != null && nrr.NamespaceName == ns) + return new SimpleType(pair.Key); + } + } + } + + int pos = ns.LastIndexOf('.'); + if (pos < 0) { + if (IsValidNamespace(ns)) { + return new SimpleType(ns); + } else { + return new MemberType { + Target = new SimpleType("global"), + IsDoubleColon = true, + MemberName = ns + }; + } + } else { + string parentNamespace = ns.Substring(0, pos); + string localNamespace = ns.Substring(pos + 1); + return new MemberType { + Target = ConvertNamespace(parentNamespace), + MemberName = localNamespace + }; + } + } + + bool IsValidNamespace(string firstNamespacePart) + { + if (resolver == null) + return true; // just assume namespaces are valid if we don't have a resolver + NamespaceResolveResult nrr = resolver.ResolveSimpleName(firstNamespacePart, EmptyList.Instance) as NamespaceResolveResult; + return nrr != null && !nrr.IsError && nrr.NamespaceName == firstNamespacePart; + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs b/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs index faec84fa0..f2f5dba1f 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/CSharpAttribute.cs @@ -107,10 +107,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { // If both types exist, C# considers that to be an ambiguity, but we are less strict. IType type = withoutSuffix.Resolve(context); - if (type == SharedTypes.UnknownType) - return withSuffix.Resolve(context); - else - return type; + var attrType = context.GetTypeDefinition (typeof(System.Attribute)); + if (attrType == null) + return SharedTypes.UnknownType; + + if (type == SharedTypes.UnknownType || !(type.GetDefinition () != null && type.GetDefinition ().IsDerivedFrom (attrType, context))) + type = withSuffix.Resolve(context); + + return type; } public override string ToString() diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs b/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs index 295c85a56..31dbf0f86 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/CSharpResolver.cs @@ -26,11 +26,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver internal readonly CancellationToken cancellationToken; #region Constructor - public CSharpResolver(ITypeResolveContext context) + public CSharpResolver(ITypeResolveContext context) : this (context, CancellationToken.None) { - if (context == null) - throw new ArgumentNullException("context"); - this.context = context; } public CSharpResolver(ITypeResolveContext context, CancellationToken cancellationToken) @@ -86,12 +83,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver internal readonly LocalVariable prev; internal readonly ITypeReference type; + internal readonly DomRegion region; internal readonly string name; internal readonly IConstantValue constantValue; - public LocalVariable(LocalVariable prev, ITypeReference type, string name, IConstantValue constantValue) + public LocalVariable(LocalVariable prev, ITypeReference type, DomRegion region, string name, IConstantValue constantValue) { this.prev = prev; + this.region = region; this.type = type; this.name = name; this.constantValue = constantValue; @@ -100,6 +99,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public string Name { get { return name; } } + + public DomRegion DeclarationRegion { + get { return region; } + } + public ITypeReference Type { get { return type; } } @@ -126,7 +130,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// public void PushBlock() { - localVariableStack = new LocalVariable(localVariableStack, null, null, null); + localVariableStack = new LocalVariable(localVariableStack, null, DomRegion.Empty, null, null); } /// @@ -146,13 +150,13 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// /// Adds a new variable to the current block. /// - public IVariable AddVariable(ITypeReference type, string name, IConstantValue constantValue = null) + public IVariable AddVariable(ITypeReference type, DomRegion declarationRegion, string name, IConstantValue constantValue = null) { if (type == null) throw new ArgumentNullException("type"); if (name == null) throw new ArgumentNullException("name"); - return localVariableStack = new LocalVariable(localVariableStack, type, name, constantValue); + return localVariableStack = new LocalVariable(localVariableStack, type, declarationRegion, name, constantValue); } /// @@ -306,6 +310,30 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver get { return true; } } + bool IEntity.IsPrivate { + get { return false; } + } + + bool IEntity.IsPublic { + get { return true; } + } + + bool IEntity.IsProtected { + get { return false; } + } + + bool IEntity.IsInternal { + get { return false; } + } + + bool IEntity.IsProtectedOrInternal { + get { return false; } + } + + bool IEntity.IsProtectedAndInternal { + get { return false; } + } + IProjectContent IEntity.ProjectContent { get { throw new NotSupportedException(); } } @@ -628,8 +656,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver // TODO: find user-defined operators - if (lhsType == SharedTypes.Null && rhsType.IsReferenceType == false - || lhsType.IsReferenceType == false && rhsType == SharedTypes.Null) + if (lhsType == SharedTypes.Null && rhsType.IsReferenceType(context) == false + || lhsType.IsReferenceType(context) == false && rhsType == SharedTypes.Null) { isNullable = true; } @@ -1559,9 +1587,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver for (ITypeDefinition t = this.CurrentTypeDefinition; t != null; t = t.DeclaringTypeDefinition) { if (k == 0) { // look for type parameter with that name - foreach (ITypeParameter tp in t.TypeParameters) { - if (tp.Name == identifier) - return new TypeResolveResult(tp); + var typeParameters = t.TypeParameters; + // only look at type parameters defined directly on this type, not at those copied from outer classes + for (int i = (t.DeclaringTypeDefinition != null ? t.DeclaringTypeDefinition.TypeParameterCount : 0); i < typeParameters.Count; i++) { + if (typeParameters[i].Name == identifier) + return new TypeResolveResult(typeParameters[i]); } } @@ -1587,7 +1617,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } } // then look for a type - ITypeDefinition def = context.GetClass(n.NamespaceName, identifier, k, StringComparer.Ordinal); + ITypeDefinition def = context.GetTypeDefinition(n.NamespaceName, identifier, k, StringComparer.Ordinal); if (def != null) { IType result = def; if (k != 0) { @@ -1621,14 +1651,16 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver foreach (var u in n.Usings) { NamespaceResolveResult ns = u.ResolveNamespace(context); if (ns != null) { - def = context.GetClass(ns.NamespaceName, identifier, k, StringComparer.Ordinal); - if (firstResult == null) { - if (k == 0) - firstResult = def; - else - firstResult = new ParameterizedType(def, typeArguments); - } else { - return new AmbiguousTypeResolveResult(firstResult); + def = context.GetTypeDefinition(ns.NamespaceName, identifier, k, StringComparer.Ordinal); + if (def != null) { + if (firstResult == null) { + if (k == 0) + firstResult = def; + else + firstResult = new ParameterizedType(def, typeArguments); + } else { + return new AmbiguousTypeResolveResult(firstResult); + } } } } @@ -1637,10 +1669,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } // if we didn't find anything: repeat lookup with parent namespace } - if (typeArguments.Count == 0) - return new UnknownIdentifierResolveResult(identifier); - else + if (typeArguments.Count == 0) { + if (identifier == "dynamic") + return new TypeResolveResult(SharedTypes.Dynamic); + else + return new UnknownIdentifierResolveResult(identifier); + } else { return ErrorResult; + } } /// @@ -1685,7 +1721,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (context.GetNamespace(fullName, StringComparer.Ordinal) != null) return new NamespaceResolveResult(fullName); } - ITypeDefinition def = context.GetClass(nrr.NamespaceName, identifier, typeArguments.Count, StringComparer.Ordinal); + ITypeDefinition def = context.GetTypeDefinition(nrr.NamespaceName, identifier, typeArguments.Count, StringComparer.Ordinal); if (def != null) return new TypeResolveResult(def); return ErrorResult; @@ -1760,10 +1796,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver IEnumerable GetExtensionMethods(string namespaceName) { return - from c in context.GetClasses(namespaceName, StringComparer.Ordinal) - where c.IsStatic + from c in context.GetTypes(namespaceName, StringComparer.Ordinal) + where c.IsStatic && c.HasExtensionMethods from m in c.Methods - where (m.IsExtensionMethod) + where m.IsExtensionMethod select m; } #endregion @@ -1869,7 +1905,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver do { newName = newArgumentName + num.ToString(); num++; - } while(argumentNames.Contains(newArgumentName)); + } while(argumentNames.Contains(newName)); newArgumentName = newName; } argumentNames[i] = newArgumentName; diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs b/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs index ff1edd29f..5c5990517 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/ConstantValues.cs @@ -107,6 +107,62 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver.ConstantValues } } + /// + /// Increments an integer by a fixed amount without changing the type. + /// + public sealed class IncrementConstantValue : Immutable, IConstantValue, ISupportsInterning + { + IConstantValue baseValue; + int incrementAmount; + + public IncrementConstantValue(IConstantValue baseValue, int incrementAmount = 1) + { + if (baseValue == null) + throw new ArgumentNullException("baseValue"); + IncrementConstantValue icv = baseValue as IncrementConstantValue; + if (icv != null) { + this.baseValue = icv.baseValue; + this.incrementAmount = icv.incrementAmount + incrementAmount; + } else { + this.baseValue = baseValue; + this.incrementAmount = incrementAmount; + } + } + + public IType GetValueType(ITypeResolveContext context) + { + return baseValue.GetValueType(context); + } + + public object GetValue(ITypeResolveContext context) + { + object val = baseValue.GetValue(context); + if (val == null) + return null; + TypeCode typeCode = Type.GetTypeCode(val.GetType()); + if (!(typeCode >= TypeCode.SByte && typeCode <= TypeCode.UInt64)) + return null; + long intVal = (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, val, false); + return CSharpPrimitiveCast.Cast(typeCode, unchecked(intVal + incrementAmount), false); + } + + void ISupportsInterning.PrepareForInterning(IInterningProvider provider) + { + baseValue = provider.Intern(baseValue); + } + + int ISupportsInterning.GetHashCodeForInterning() + { + return baseValue.GetHashCode() ^ incrementAmount; + } + + bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) + { + IncrementConstantValue o = other as IncrementConstantValue; + return o != null && baseValue == o.baseValue && incrementAmount == o.incrementAmount; + } + } + public abstract class ConstantExpression { public abstract ResolveResult Resolve(CSharpResolver resolver); diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/Conversions.cs b/ICSharpCode.NRefactory/CSharp/Resolver/Conversions.cs index e0be4512a..3109fb8f8 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/Conversions.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/Conversions.cs @@ -3,8 +3,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; +using System.Linq; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.Utils; namespace ICSharpCode.NRefactory.CSharp.Resolver { @@ -30,9 +31,17 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { if (resolveResult == null) throw new ArgumentNullException("resolveResult"); - if (resolveResult.IsCompileTimeConstant && (ImplicitEnumerationConversion(resolveResult, toType) || ImplicitConstantExpressionConversion(resolveResult, toType))) + if (resolveResult.IsCompileTimeConstant) { + if (ImplicitEnumerationConversion(resolveResult, toType)) + return true; + if (ImplicitConstantExpressionConversion(resolveResult, toType)) + return true; + } + if (ImplicitConversion(resolveResult.Type, toType)) return true; - return ImplicitConversion(resolveResult.Type, toType); + // TODO: Anonymous function conversions + // TODO: Method group conversions + return false; } public bool ImplicitConversion(IType fromType, IType toType) @@ -46,18 +55,44 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver return true; if (ImplicitNumericConversion(fromType, toType)) return true; - if (ImplicitReferenceConversion(fromType, toType)) - return true; if (ImplicitNullableConversion(fromType, toType)) return true; if (NullLiteralConversion(fromType, toType)) return true; + if (ImplicitReferenceConversion(fromType, toType)) + return true; if (BoxingConversion(fromType, toType)) return true; if (ImplicitDynamicConversion(fromType, toType)) return true; + if (ImplicitTypeParameterConversion(fromType, toType)) + return true; if (ImplicitPointerConversion(fromType, toType)) return true; + if (ImplicitUserDefinedConversion(fromType, toType)) + return true; + return false; + } + + public bool StandardImplicitConversion(IType fromType, IType toType) + { + if (fromType == null) + throw new ArgumentNullException("fromType"); + if (toType == null) + throw new ArgumentNullException("toType"); + // C# 4.0 spec: §6.3.1 + if (IdentityConversion(fromType, toType)) + return true; + if (ImplicitNumericConversion(fromType, toType)) + return true; + if (ImplicitNullableConversion(fromType, toType)) + return true; + if (ImplicitReferenceConversion(fromType, toType)) + return true; + if (ImplicitTypeParameterConversion(fromType, toType)) + return true; + if (BoxingConversion(fromType, toType)) + return true; return false; } #endregion @@ -168,7 +203,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver // C# 4.0 spec: §6.1.6 // reference conversions are possible only if both types are known to be reference types - if (fromType.IsReferenceType != true || toType.IsReferenceType != true) + if (!(fromType.IsReferenceType(context) == true && toType.IsReferenceType(context) == true)) return false; // conversion from null literal is always possible @@ -194,7 +229,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver || ImplicitReferenceConversion(fromArray.ElementType, toPT.TypeArguments[0]); } // conversion from any array to System.Array and the interfaces it implements: - ITypeDefinition systemArray = context.GetClass("System", "Array", 0, StringComparer.Ordinal); + ITypeDefinition systemArray = context.GetTypeDefinition("System", "Array", 0, StringComparer.Ordinal); return systemArray != null && (systemArray.Equals(toType) || ImplicitReferenceConversion(systemArray, toType)); } @@ -203,7 +238,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } // Determines whether s is a subtype of t. - // Helper method used for ImplicitReferenceConversion and BoxingConversion + // Helper method used for ImplicitReferenceConversion, BoxingConversion and ImplicitTypeParameterConversion bool IsSubtypeOf(IType s, IType t) { // conversion to dynamic + object are always possible @@ -262,7 +297,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { // C# 4.0 spec: §6.1.7 fromType = NullableType.GetUnderlyingType(fromType); - return fromType.IsReferenceType == false && toType.IsReferenceType == true && IsSubtypeOf(fromType, toType); + return fromType.IsReferenceType(context) == false && toType.IsReferenceType(context) == true && IsSubtypeOf(fromType, toType); } #endregion @@ -304,6 +339,21 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } #endregion + #region ImplicitTypeParameterConversion + /// + /// Implicit conversions involving type parameters. + /// + bool ImplicitTypeParameterConversion(IType fromType, IType toType) + { + ITypeParameter t = fromType as ITypeParameter; + if (t == null) + return false; // not a type parameter + if (t.IsReferenceType(context) == true) + return false; // already handled by ImplicitReferenceConversion + return IsSubtypeOf(t, toType); + } + #endregion + #region ImplicitPointerConversion bool ImplicitPointerConversion(IType fromType, IType toType) { @@ -316,7 +366,37 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } #endregion - // TODO: add support for user-defined conversions + #region ImplicitUserDefinedConversion + bool ImplicitUserDefinedConversion(IType fromType, IType toType) + { + // C# 4.0 spec §6.4.4 User-defined implicit conversions + // Currently we only test whether an applicable implicit conversion exists, + // we do not resolve which conversion is the most specific and gets used. + + // Find the candidate operators: + Predicate opImplicitFilter = m => m.IsStatic && m.IsOperator && m.Name == "op_Implicit" && m.Parameters.Count == 1; + var operators = NullableType.GetUnderlyingType(fromType).GetMethods(context, opImplicitFilter) + .Concat(NullableType.GetUnderlyingType(toType).GetMethods(context, opImplicitFilter)); + // Determine whether one of them is applicable: + foreach (IMethod op in operators) { + IType sourceType = op.Parameters[0].Type.Resolve(context); + IType targetType = op.ReturnType.Resolve(context); + // Try if the operator is applicable: + if (StandardImplicitConversion(fromType, sourceType) && StandardImplicitConversion(targetType, toType)) { + return true; + } + // Try if the operator is applicable in lifted form: + if (sourceType.IsReferenceType(context) == false && targetType.IsReferenceType(context) == false) { + IType liftedSourceType = NullableType.Create(sourceType, context); + IType liftedTargetType = NullableType.Create(targetType, context); + if (StandardImplicitConversion(fromType, liftedSourceType) && StandardImplicitConversion(liftedTargetType, toType)) { + return true; + } + } + } + return false; + } + #endregion #region BetterConversion /// diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/MapTypeIntoNewContext.cs b/ICSharpCode.NRefactory/CSharp/Resolver/MapTypeIntoNewContext.cs index 026ff6bf9..14cc7ccb1 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/MapTypeIntoNewContext.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/MapTypeIntoNewContext.cs @@ -27,14 +27,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (type.DeclaringTypeDefinition != null) { ITypeDefinition decl = type.DeclaringTypeDefinition.AcceptVisitor(this) as ITypeDefinition; if (decl != null) { - foreach (ITypeDefinition c in decl.InnerClasses) { + foreach (ITypeDefinition c in decl.NestedTypes) { if (c.Name == type.Name && c.TypeParameterCount == type.TypeParameterCount) return c; } } return type; } else { - return context.GetClass(type.Namespace, type.Name, type.TypeParameterCount, StringComparer.Ordinal) ?? type; + return context.GetTypeDefinition(type.Namespace, type.Name, type.TypeParameterCount, StringComparer.Ordinal) ?? type; } } diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/MemberLookup.cs b/ICSharpCode.NRefactory/CSharp/Resolver/MemberLookup.cs index f124141fa..06c1e67bc 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/MemberLookup.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/MemberLookup.cs @@ -25,9 +25,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver // C# 4.0 spec, §7.4 member lookup if (member is IEvent || member is IMethod) return true; - if (member.ReturnType == SharedTypes.Dynamic) + IType returnType = member.ReturnType.Resolve(context); + if (returnType == SharedTypes.Dynamic) return true; - return member.ReturnType.Resolve(context).IsDelegate(); + return returnType.IsDelegate(); } #endregion @@ -66,7 +67,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver case Accessibility.None: return false; case Accessibility.Private: - return entity.DeclaringTypeDefinition == currentTypeDefinition; + // check for members of outer classes (private members of outer classes can be accessed) + var lookupTypeDefinition = currentTypeDefinition; + while (lookupTypeDefinition != null) { + if (entity.DeclaringTypeDefinition.Equals (lookupTypeDefinition)) + return true; + lookupTypeDefinition = lookupTypeDefinition.DeclaringTypeDefinition; + } + return false; case Accessibility.Public: return true; case Accessibility.Protected: @@ -91,7 +99,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver bool IsProtectedAccessible(ITypeDefinition declaringType) { - if (declaringType == currentTypeDefinition) + if (declaringType.Equals (currentTypeDefinition)) return true; // PERF: this might hurt performance as this method is called several times (once for each member) // make sure resolving base types is cheap (caches?) or cache within the MemberLookup instance @@ -159,7 +167,9 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (!isInvocation) { // Consider nested types only if it's not an invocation. The type parameter count must match in this case. Predicate typeFilter = delegate (ITypeDefinition d) { - return d.TypeParameterCount == typeArgumentCount && d.Name == name && IsAccessible(d, true); + // inner types contain the type parameters of outer types. therefore this count has to been adjusted. + int correctedCount = d.TypeParameterCount - (d.DeclaringType != null ? d.DeclaringType.TypeParameterCount : 0); + return correctedCount == typeArgumentCount && d.Name == name && IsAccessible(d, true); }; types.AddRange(type.GetNestedTypes(context, typeFilter)); } @@ -170,10 +180,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver Predicate memberFilter = delegate(IMember member) { return !member.IsOverride && member.Name == name && IsAccessible(member, allowProtectedAccess); }; - members.AddRange(type.GetMethods(context, memberFilter.SafeCast()).SafeCast()); - members.AddRange(type.GetProperties(context, memberFilter.SafeCast()).SafeCast()); - members.AddRange(type.GetFields(context, memberFilter.SafeCast()).SafeCast()); - members.AddRange(type.GetEvents(context, memberFilter.SafeCast()).SafeCast()); + members.AddRange(type.GetMembers(context, memberFilter)); if (isInvocation) members.RemoveAll(m => !IsInvocable(m, context)); } else { diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/OverloadResolution.cs b/ICSharpCode.NRefactory/CSharp/Resolver/OverloadResolution.cs index d4d1fca43..e3942491a 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/OverloadResolution.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/OverloadResolution.cs @@ -259,11 +259,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ITypeParameter tp = typeParameters[i]; IType typeArg = newParameterizedType.TypeArguments[i]; if (tp.HasReferenceTypeConstraint) { - if (typeArg.IsReferenceType != true) + if (typeArg.IsReferenceType(overloadResolution.context) != true) ConstraintsValid = false; } if (tp.HasValueTypeConstraint) { - if (typeArg.IsReferenceType != false) + if (typeArg.IsReferenceType(overloadResolution.context) != false) ConstraintsValid = false; if (NullableType.IsNullable(typeArg)) ConstraintsValid = false; diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs b/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs index 3bcea943b..3e10c6016 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.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; @@ -39,7 +39,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver static readonly ResolveResult errorResult = new ErrorResolveResult(SharedTypes.UnknownType); CSharpResolver resolver; readonly ParsedFile parsedFile; - readonly Dictionary cache = new Dictionary(); + readonly Dictionary resolveResultCache = new Dictionary(); + readonly Dictionary resolverBeforeDict = new Dictionary(); readonly IResolveVisitorNavigator navigator; ResolveVisitorNavigationMode mode = ResolveVisitorNavigationMode.Scan; @@ -95,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public void Scan(AstNode node) { - if (node == null) + if (node == null || node.IsNull) return; if (mode == ResolveVisitorNavigationMode.ResolveAll) { Resolve(node); @@ -110,6 +111,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } break; case ResolveVisitorNavigationMode.Scan: + resolverBeforeDict[node] = resolver.Clone(); node.AcceptVisitor(this, null); break; case ResolveVisitorNavigationMode.Resolve: @@ -117,7 +119,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver Resolve(node); break; default: - throw new Exception("Invalid value for ResolveVisitorNavigationMode"); + throw new InvalidOperationException("Invalid value for ResolveVisitorNavigationMode"); } mode = oldMode; } @@ -125,21 +127,28 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public ResolveResult Resolve(AstNode node) { - if (node == null) + if (node == null || node.IsNull) return errorResult; bool wasScan = mode == ResolveVisitorNavigationMode.Scan; if (wasScan) mode = ResolveVisitorNavigationMode.Resolve; ResolveResult result; - if (!cache.TryGetValue(node, out result)) { + if (!resolveResultCache.TryGetValue(node, out result)) { resolver.cancellationToken.ThrowIfCancellationRequested(); - result = cache[node] = node.AcceptVisitor(this, null) ?? errorResult; + resolverBeforeDict[node] = resolver.Clone(); + result = resolveResultCache[node] = node.AcceptVisitor(this, null) ?? errorResult; } if (wasScan) mode = ResolveVisitorNavigationMode.Scan; return result; } + protected override ResolveResult VisitChildren(AstNode node, object data) + { + ScanChildren(node); + return null; + } + void ScanChildren(AstNode node) { for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) { @@ -156,11 +165,24 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public ResolveResult GetResolveResult(AstNode node) { ResolveResult result; - if (cache.TryGetValue(node, out result)) + if (resolveResultCache.TryGetValue(node, out result)) return result; else return null; } + + /// + /// Gets the resolver state in front of the specified node. + /// Returns null if no cached resolver was found (e.g. if the node was skipped by the navigator) + /// + public CSharpResolver GetResolverStateBefore(AstNode node) + { + CSharpResolver r; + if (resolverBeforeDict.TryGetValue(node, out r)) + return r; + else + return null; + } #endregion #region Track UsingScope @@ -199,9 +221,9 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver try { ITypeDefinition newTypeDefinition = null; if (resolver.CurrentTypeDefinition != null) { - foreach (ITypeDefinition innerClass in resolver.CurrentTypeDefinition.InnerClasses) { - if (innerClass.Region.IsInside(typeDeclaration.StartLocation)) { - newTypeDefinition = innerClass; + foreach (ITypeDefinition nestedType in resolver.CurrentTypeDefinition.NestedTypes) { + if (nestedType.Region.IsInside(typeDeclaration.StartLocation)) { + newTypeDefinition = nestedType; break; } } @@ -241,7 +263,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ResolveResult VisitFieldOrEventDeclaration(AttributedNode fieldOrEventDeclaration) { - int initializerCount = fieldOrEventDeclaration.GetChildrenByRole(FieldDeclaration.Roles.Variable).Count(); + int initializerCount = fieldOrEventDeclaration.GetChildrenByRole(FieldDeclaration.Roles.Variable).Count; ResolveResult result = null; for (AstNode node = fieldOrEventDeclaration.FirstChild; node != null; node = node.NextSibling) { if (node.Role == FieldDeclaration.Roles.Variable) { @@ -334,7 +356,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver for (AstNode node = propertyOrIndexerDeclaration.FirstChild; node != null; node = node.NextSibling) { if (node.Role == PropertyDeclaration.SetterRole && resolver.CurrentMember != null) { resolver.PushBlock(); - resolver.AddVariable(resolver.CurrentMember.ReturnType, "value"); + resolver.AddVariable(resolver.CurrentMember.ReturnType, DomRegion.Empty, "value"); Scan(node); resolver.PopBlock(); } else { @@ -369,7 +391,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver if (resolver.CurrentMember != null) { resolver.PushBlock(); - resolver.AddVariable(resolver.CurrentMember.ReturnType, "value"); + resolver.AddVariable(resolver.CurrentMember.ReturnType, DomRegion.Empty, "value"); ScanChildren(eventDeclaration); resolver.PopBlock(); } else { @@ -403,6 +425,32 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } } + public override ResolveResult VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, object data) + { + ScanChildren(typeParameterDeclaration); + if (resolverEnabled) { + string name = typeParameterDeclaration.Name; + IMethod m = resolver.CurrentMember as IMethod; + if (m != null) { + foreach (var tp in m.TypeParameters) { + if (tp.Name == name) + return new TypeResolveResult(tp); + } + } + if (resolver.CurrentTypeDefinition != null) { + var typeParameters = resolver.CurrentTypeDefinition.TypeParameters; + // look backwards so that TPs in the current type take precedence over those copied from outer types + for (int i = typeParameters.Count - 1; i >= 0; i--) { + if (typeParameters[i].Name == name) + return new TypeResolveResult(typeParameters[i]); + } + } + return errorResult; + } else { + return null; + } + } + public override ResolveResult VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data) { try { @@ -420,6 +468,11 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver resolver.CurrentMember = null; } } + + public override ResolveResult VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, object data) + { + throw new NotImplementedException(); + } #endregion #region Track CheckForOverflow @@ -497,11 +550,44 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver throw new NotImplementedException(); } - public override ResolveResult VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, object data) + static string GetAnonymousTypePropertyName(Expression expr, out Expression resolveExpr) { - // TODO: ? - ScanChildren(undocumentedExpression); - return new ResolveResult(resolver.Context.GetClass(typeof(RuntimeArgumentHandle)) ?? SharedTypes.UnknownType); + if (expr is NamedArgumentExpression) { + var namedArgExpr = (NamedArgumentExpression)expr; + resolveExpr = namedArgExpr.Expression; + return namedArgExpr.Identifier; + } + // no name given, so it's a projection initializer + if (expr is MemberReferenceExpression) { + resolveExpr = expr; + return ((MemberReferenceExpression)expr).MemberName; + } + if (expr is IdentifierExpression) { + resolveExpr = expr; + return ((IdentifierExpression)expr).Identifier; + } + resolveExpr = null; + return null; + } + + public override ResolveResult VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data) + { + // 7.6.10.6 Anonymous object creation expressions + var anonymousType = new DefaultTypeDefinition(resolver.CurrentTypeDefinition, "$Anonymous$"); + anonymousType.IsSynthetic = true; + foreach (var expr in anonymousTypeCreateExpression.Initializer) { + Expression resolveExpr; + var name = GetAnonymousTypePropertyName(expr, out resolveExpr); + if (string.IsNullOrEmpty(name)) + continue; + + var property = new DefaultProperty(anonymousType, name) { + Accessibility = Accessibility.Public, + ReturnType = new VarTypeReference(this, resolver.Clone(), resolveExpr, false) + }; + anonymousType.Properties.Add(property); + } + return new TypeResolveResult(anonymousType); } public override ResolveResult VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) @@ -598,11 +684,19 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } } + public override ResolveResult VisitEmptyExpression(EmptyExpression emptyExpression, object data) + { + return errorResult; + } + public override ResolveResult VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { if (resolverEnabled) { - // TODO: type arguments? - return resolver.ResolveSimpleName(identifierExpression.Identifier, EmptyList.Instance, + List typeArguments = new List(); + foreach (AstType typeArgument in identifierExpression.TypeArguments) { + typeArguments.Add(ResolveType(typeArgument)); + } + return resolver.ResolveSimpleName(identifierExpression.Identifier, typeArguments, IsTargetOfInvocation(identifierExpression)); } else { ScanChildren(identifierExpression); @@ -650,7 +744,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public override ResolveResult VisitIsExpression(IsExpression isExpression, object data) { ScanChildren(isExpression); - return new ResolveResult(KnownTypeReference.Boolean.Resolve(resolver.Context)); + if (resolverEnabled) + return new ResolveResult(KnownTypeReference.Boolean.Resolve(resolver.Context)); + else + return null; } public override ResolveResult VisitLambdaExpression(LambdaExpression lambdaExpression, object data) @@ -662,10 +759,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { if (resolverEnabled) { ResolveResult target = Resolve(memberReferenceExpression.Target); - List typeArgumentNodes = memberReferenceExpression.TypeArguments.ToList(); - // TODO: type arguments? + List typeArguments = new List(); + foreach (AstType typeArgument in memberReferenceExpression.TypeArguments) { + typeArguments.Add(ResolveType(typeArgument)); + } return resolver.ResolveMemberAccess(target, memberReferenceExpression.MemberName, - EmptyList.Instance, + typeArguments, IsTargetOfInvocation(memberReferenceExpression)); } else { ScanChildren(memberReferenceExpression); @@ -707,7 +806,20 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public override ResolveResult VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) { - throw new NotImplementedException(); + if (resolverEnabled) { + ResolveResult target = Resolve(pointerReferenceExpression.Target); + ResolveResult deferencedTarget = resolver.ResolveUnaryOperator(UnaryOperatorType.Dereference, target); + List typeArguments = new List(); + foreach (AstType typeArgument in pointerReferenceExpression.TypeArguments) { + typeArguments.Add(ResolveType(typeArgument)); + } + return resolver.ResolveMemberAccess(deferencedTarget, pointerReferenceExpression.MemberName, + typeArguments, + IsTargetOfInvocation(pointerReferenceExpression)); + } else { + ScanChildren(pointerReferenceExpression); + return null; + } } public override ResolveResult VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) @@ -756,6 +868,16 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver return null; } + public override ResolveResult VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) + { + if (resolverEnabled) { + return Resolve(typeReferenceExpression.Type); + } else { + Scan(typeReferenceExpression.Type); + return null; + } + } + public override ResolveResult VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) { if (resolverEnabled) { @@ -766,6 +888,38 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver return null; } } + + public override ResolveResult VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, object data) + { + ScanChildren(undocumentedExpression); + if (resolverEnabled) { + ITypeReference resultType; + switch (undocumentedExpression.UndocumentedExpressionType) { + case UndocumentedExpressionType.ArgListAccess: + case UndocumentedExpressionType.ArgList: + resultType = typeof(RuntimeArgumentHandle).ToTypeReference(); + break; + case UndocumentedExpressionType.RefValue: + var tre = undocumentedExpression.Arguments.ElementAtOrDefault(1) as TypeReferenceExpression; + if (tre != null) + resultType = ResolveType(tre.Type); + else + resultType = SharedTypes.UnknownType; + break; + case UndocumentedExpressionType.RefType: + resultType = systemType; + break; + case UndocumentedExpressionType.MakeRef: + resultType = typeof(TypedReference).ToTypeReference(); + break; + default: + throw new InvalidOperationException("Invalid value for UndocumentedExpressionType"); + } + return new ResolveResult(resultType.Resolve(resolver.Context)); + } else { + return null; + } + } #endregion #region Local Variable Scopes (Block Statements) @@ -788,7 +942,19 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver public override ResolveResult VisitFixedStatement(FixedStatement fixedStatement, object data) { resolver.PushBlock(); - ScanChildren(fixedStatement); + + VariableInitializer firstInitializer = fixedStatement.Variables.FirstOrDefault(); + ITypeReference type = MakeTypeReference(fixedStatement.Type, + firstInitializer != null ? firstInitializer.Initializer : null, + false); + + for (AstNode node = fixedStatement.FirstChild; node != null; node = node.NextSibling) { + if (node.Role == FixedStatement.Roles.Variable) { + VariableInitializer vi = (VariableInitializer)node; + resolver.AddVariable(type, new DomRegion (parsedFile.FileName, vi.StartLocation, vi.EndLocation) , vi.Name); + } + Scan(node); + } resolver.PopBlock(); return null; } @@ -806,123 +972,17 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { resolver.PushBlock(); ITypeReference type = MakeTypeReference(foreachStatement.VariableType, foreachStatement.InExpression, true); - resolver.AddVariable(type, foreachStatement.VariableName); + resolver.AddVariable(type, new DomRegion (parsedFile.FileName, foreachStatement.VariableNameToken.StartLocation, foreachStatement.VariableNameToken.EndLocation), foreachStatement.VariableName); ScanChildren(foreachStatement); resolver.PopBlock(); return null; } - #endregion - - #region Simple Statements (only ScanChildren) - public override ResolveResult VisitExpressionStatement(ExpressionStatement expressionStatement, object data) - { - ScanChildren(expressionStatement); - return null; - } - - public override ResolveResult VisitBreakStatement(BreakStatement breakStatement, object data) - { - ScanChildren(breakStatement); - return null; - } - - public override ResolveResult VisitContinueStatement(ContinueStatement continueStatement, object data) - { - ScanChildren(continueStatement); - return null; - } - - public override ResolveResult VisitEmptyStatement(EmptyStatement emptyStatement, object data) - { - ScanChildren(emptyStatement); - return null; - } - - public override ResolveResult VisitGotoStatement(GotoStatement gotoStatement, object data) - { - ScanChildren(gotoStatement); - return null; - } - - public override ResolveResult VisitIfElseStatement(IfElseStatement ifElseStatement, object data) - { - ScanChildren(ifElseStatement); - return null; - } - - public override ResolveResult VisitLabelStatement(LabelStatement labelStatement, object data) - { - ScanChildren(labelStatement); - return null; - } - - public override ResolveResult VisitLockStatement(LockStatement lockStatement, object data) - { - ScanChildren(lockStatement); - return null; - } - - public override ResolveResult VisitReturnStatement(ReturnStatement returnStatement, object data) - { - ScanChildren(returnStatement); - return null; - } - - public override ResolveResult VisitSwitchStatement(SwitchStatement switchStatement, object data) - { - ScanChildren(switchStatement); - return null; - } - - public override ResolveResult VisitSwitchSection(SwitchSection switchSection, object data) - { - ScanChildren(switchSection); - return null; - } - - public override ResolveResult VisitCaseLabel(CaseLabel caseLabel, object data) - { - ScanChildren(caseLabel); - return null; - } - - public override ResolveResult VisitThrowStatement(ThrowStatement throwStatement, object data) - { - ScanChildren(throwStatement); - return null; - } - - public override ResolveResult VisitUnsafeStatement(UnsafeStatement unsafeStatement, object data) - { - ScanChildren(unsafeStatement); - return null; - } - - public override ResolveResult VisitWhileStatement(WhileStatement whileStatement, object data) - { - ScanChildren(whileStatement); - return null; - } - - public override ResolveResult VisitYieldStatement(YieldStatement yieldStatement, object data) - { - ScanChildren(yieldStatement); - return null; - } - #endregion - - #region Try / Catch - public override ResolveResult VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) - { - ScanChildren(tryCatchStatement); - return null; - } public override ResolveResult VisitCatchClause(CatchClause catchClause, object data) { resolver.PushBlock(); if (catchClause.VariableName != null) { - resolver.AddVariable(MakeTypeReference(catchClause.Type, null, false), catchClause.VariableName); + resolver.AddVariable(MakeTypeReference(catchClause.Type, null, false), new DomRegion (parsedFile.FileName, catchClause.VariableNameToken.StartLocation, catchClause.VariableNameToken.EndLocation), catchClause.VariableName); } ScanChildren(catchClause); resolver.PopBlock(); @@ -938,17 +998,17 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ITypeReference type = MakeTypeReference(variableDeclarationStatement.Type, firstInitializer != null ? firstInitializer.Initializer : null, false); - - int initializerCount = variableDeclarationStatement.Variables.Count(); + + int initializerCount = variableDeclarationStatement.Variables.Count; ResolveResult result = null; for (AstNode node = variableDeclarationStatement.FirstChild; node != null; node = node.NextSibling) { - if (node.Role == FieldDeclaration.Roles.Variable) { + if (node.Role == VariableDeclarationStatement.Roles.Variable) { VariableInitializer vi = (VariableInitializer)node; IConstantValue cv = null; if (isConst) throw new NotImplementedException(); - resolver.AddVariable(type, vi.Name, cv); + resolver.AddVariable(type, new DomRegion (parsedFile.FileName, vi.StartLocation, vi.EndLocation), vi.Name, cv); if (resolverEnabled && initializerCount == 1) { result = Resolve(node); @@ -1063,14 +1123,41 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver #endregion #region Attributes - public override ResolveResult VisitAttribute(Attribute attribute, object data) - { - throw new NotImplementedException(); + ITypeReference GetAttributeType (Attribute attribute) + { + var withoutSuffix = MakeTypeReference(attribute.Type); + ITypeReference withSuffix; + if (attribute.Type is SimpleType) { + var st = (SimpleType)attribute.Type; + withSuffix = MakeTypeReference(new SimpleType (st.Identifier + "Attribute")); + } else if (attribute.Type is MemberType) { + var mt = (MemberType)attribute.Type; + withSuffix = MakeTypeReference(new MemberType (mt.Target.Clone (), mt.MemberName + "Attribute")); + } else { + // unsupported type. + return SharedTypes.UnknownType; + } + return new AttributeTypeReference(withoutSuffix, withSuffix); } - public override ResolveResult VisitAttributeSection(AttributeSection attributeSection, object data) + public override ResolveResult VisitAttribute(Attribute attribute, object data) { - ScanChildren(attributeSection); + ScanChildren(attribute); + if (resolverEnabled) { + var type = GetAttributeType (attribute).Resolve (resolver.Context); + if (!attribute.HasArgumentList) + return new TypeResolveResult (type); + // try if the attribute usage references a constructuor + string[] argumentNames; + ResolveResult[] arguments = GetArguments(attribute.Arguments, out argumentNames); + var result = resolver.ResolveObjectCreation(type, arguments, argumentNames); + Console.WriteLine (result); + // if this is an error give back type resolve result, an attribute arg list isn't a constructor reference + // in all cases. - is it better to always give back the type resolve result ? + if (result.IsError) + return new TypeResolveResult (type); + return result; + } return null; } #endregion @@ -1078,11 +1165,15 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver #region Using Declaration public override ResolveResult VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) { + // TODO: set isInUsingDeclaration + ScanChildren(usingDeclaration); return null; } public override ResolveResult VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration, object data) { + // TODO: set isInUsingDeclaration + ScanChildren(usingDeclaration); return null; } #endregion @@ -1125,70 +1216,50 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver #endregion #region Query Expressions - /* - public override ResolveResult VisitQueryExpressionFromClause(QueryExpressionFromClause queryExpressionFromClause, object data) - { - throw new NotImplementedException(); - } - - public override ResolveResult VisitQueryExpressionWhereClause(QueryExpressionWhereClause queryExpressionWhereClause, object data) - { - throw new NotImplementedException(); - } - - public override ResolveResult VisitQueryExpressionJoinClause(QueryExpressionJoinClause queryExpressionJoinClause, object data) - { - throw new NotImplementedException(); - } - - public override ResolveResult VisitQueryExpressionGroupClause(QueryExpressionGroupClause queryExpressionGroupClause, object data) + public override ResolveResult VisitQueryExpression(QueryExpression queryExpression, object data) { throw new NotImplementedException(); } + #endregion - public override ResolveResult VisitQueryExpressionLetClause(QueryExpressionLetClause queryExpressionLetClause, object data) + public override ResolveResult VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) { - throw new NotImplementedException(); + ScanChildren(constructorInitializer); + return null; } - public override ResolveResult VisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data) + public override ResolveResult VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, object data) { - throw new NotImplementedException(); + // TODO: array initializers are valid expressions if the parent node is a variable/field declaration + // that explicitly defines an array type + return errorResult; } - public override ResolveResult VisitQueryExpressionOrdering(QueryExpressionOrdering queryExpressionOrdering, object data) + public override ResolveResult VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data) { throw new NotImplementedException(); } - public override ResolveResult VisitQueryExpressionSelectClause(QueryExpressionSelectClause queryExpressionSelectClause, object data) + public override ResolveResult VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, object data) { throw new NotImplementedException(); } - */ - #endregion + #region Token Nodes public override ResolveResult VisitIdentifier(Identifier identifier, object data) { return null; } - public override ResolveResult VisitConstraint(Constraint constraint, object data) - { - ScanChildren(constraint); - return null; - } - - public override ResolveResult VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) + public override ResolveResult VisitComment(Comment comment, object data) { - ScanChildren(constructorInitializer); return null; } - public override ResolveResult VisitAccessor(Accessor accessor, object data) + public override ResolveResult VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, object data) { - ScanChildren(accessor); return null; } + #endregion } } diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/TypeInference.cs b/ICSharpCode.NRefactory/CSharp/Resolver/TypeInference.cs index ced1e1f02..e3c75632e 100644 --- a/ICSharpCode.NRefactory/CSharp/Resolver/TypeInference.cs +++ b/ICSharpCode.NRefactory/CSharp/Resolver/TypeInference.cs @@ -511,11 +511,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ArrayType arrU = U as ArrayType; ArrayType arrV = V as ArrayType; ParameterizedType pV = V as ParameterizedType; - if (arrU != null && (arrV != null && arrU.Dimensions == arrV.Dimensions - || IsIEnumerableCollectionOrList(pV) && arrU.Dimensions == 1)) - { + if (arrU != null && arrV != null && arrU.Dimensions == arrV.Dimensions) { MakeLowerBoundInference(arrU.ElementType, arrV.ElementType); return; + } else if (arrU != null && IsIEnumerableCollectionOrList(pV) && arrU.Dimensions == 1) { + MakeLowerBoundInference(arrU.ElementType, pV.TypeArguments[0]); + return; } // Handle parameterized types: if (pV != null) { @@ -534,7 +535,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver for (int i = 0; i < uniqueBaseType.TypeParameterCount; i++) { IType Ui = uniqueBaseType.TypeArguments[i]; IType Vi = pV.TypeArguments[i]; - if (Ui.IsReferenceType == true) { + if (Ui.IsReferenceType(context) == true) { // look for variance ITypeParameter Xi = pV.GetDefinition().TypeParameters[i]; switch (Xi.Variance) { @@ -594,11 +595,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ArrayType arrU = U as ArrayType; ArrayType arrV = V as ArrayType; ParameterizedType pU = U as ParameterizedType; - if (arrV != null && (arrU != null && arrU.Dimensions == arrV.Dimensions - || IsIEnumerableCollectionOrList(pU) && arrV.Dimensions == 1)) - { + if (arrV != null && arrU != null && arrU.Dimensions == arrV.Dimensions) { MakeUpperBoundInference(arrU.ElementType, arrV.ElementType); return; + } else if (arrV != null && IsIEnumerableCollectionOrList(pU) && arrV.Dimensions == 1) { + MakeUpperBoundInference(pU.TypeArguments[0], arrV.ElementType); + return; } // Handle parameterized types: if (pU != null) { @@ -617,7 +619,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver for (int i = 0; i < uniqueBaseType.TypeParameterCount; i++) { IType Ui = pU.TypeArguments[i]; IType Vi = uniqueBaseType.TypeArguments[i]; - if (Ui.IsReferenceType == true) { + if (Ui.IsReferenceType(context) == true) { // look for variance ITypeParameter Xi = pU.GetDefinition().TypeParameters[i]; switch (Xi.Variance) { @@ -690,8 +692,9 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver get { return "X"; } } - public override bool? IsReferenceType { - get { return null; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return null; } public override int GetHashCode() @@ -831,7 +834,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver candidateTypeDefinitions = hashSet.ToList(); } else { // Find candidates by looking at all classes in the project: - candidateTypeDefinitions = context.GetAllClasses().ToList(); + candidateTypeDefinitions = context.GetAllTypes().ToList(); } // Now filter out candidates that violate the upper bounds: diff --git a/ICSharpCode.NRefactory/Documentation/BinaryDocumentationProvider.cs b/ICSharpCode.NRefactory/Documentation/BinaryDocumentationProvider.cs deleted file mode 100644 index a824396c3..000000000 --- a/ICSharpCode.NRefactory/Documentation/BinaryDocumentationProvider.cs +++ /dev/null @@ -1,231 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using ICSharpCode.NRefactory.TypeSystem; - -namespace ICSharpCode.NRefactory.Documentation -{ - /// - /// Provides xml documentation from a binary cache file. - /// This allows providing XML documentation without having to read the whole documentation into memory. - /// - public class BinaryDocumentationProvider : IDisposable, IDocumentationProvider - { - struct IndexEntry - { - public readonly int HashCode; - public readonly int FileLocation; - - public IndexEntry(int HashCode, int FileLocation) - { - this.HashCode = HashCode; - this.FileLocation = FileLocation; - } - } - - #region Save binary files - // FILE FORMAT FOR BINARY DOCUMENTATION - // long magic = 0x4244636f446c6d58 (identifies file type = 'XmlDocDB') - const long magic = 0x4244636f446c6d58; - // short version = 3 (file version) - const short version = 3; - // long fileDate (last change date of xml file in DateTime ticks) - // int testHashCode = magicTestString.GetHashCode() // (check if hash-code implementation is compatible) - const string magicTestString = "HashMe-XmlDocDB"; - // int entryCount (count of entries) - // int indexPointer (points to location where index starts in the file) - // { - // string key (documentation key as length-prefixed string) - // string docu (xml documentation as length-prefixed string) - // } - // indexPointer points to the start of the following section: - // { - // int hashcode - // int index (index where the docu string starts in the file) - // } - - - /// - /// Saves the xml documentation into a on-disk database file. - /// - /// Filename of the database - /// Last-modified date of the .xml file - /// The xml documentation that should be written to disk. - public static void Save(string fileName, DateTime fileDate, IEnumerable> xmlDocumentation) - { - if (fileName == null) - throw new ArgumentNullException("fileName"); - if (xmlDocumentation == null) - throw new ArgumentNullException("xmlDocumentation"); - using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) { - using (BinaryWriter w = new BinaryWriter(fs)) { - w.Write(magic); - w.Write(version); - w.Write(fileDate.Ticks); - w.Write(magicTestString.GetHashCode()); - - List index = new List(); - int indexLengthPos = (int)fs.Position; - w.Write(0); // skip 4 bytes for index length - w.Write(0); // skip 4 bytes for index pointer - - int i = 0; - foreach (KeyValuePair p in xmlDocumentation) { - index.Add(new IndexEntry(p.Key.GetHashCode(), (int)fs.Position)); - w.Write(p.Key); - w.Write(p.Value.Trim()); - i += 1; - } - - index.Sort((a,b) => a.HashCode.CompareTo(b.HashCode)); - - int indexStart = (int)fs.Position; - foreach (IndexEntry entry in index) { - w.Write(entry.HashCode); - w.Write(entry.FileLocation); - } - w.Seek(indexLengthPos, SeekOrigin.Begin); - w.Write(index.Count); // write index length - w.Write(indexStart); // write index count - } - } - } - #endregion - - BinaryReader loader; - FileStream fs; - - Dictionary xmlDescription = new Dictionary(); - IndexEntry[] index; // SORTED array of index entries - - const int cacheLength = 50; // number of strings to cache when working in file-mode - Queue keyCacheQueue = new Queue(cacheLength); - - #region Load binary files - private BinaryDocumentationProvider() {} - - /// - /// Loads binary documentation. - /// - /// - /// Don't forget to dispose the BinaryDocumentationProvider. - /// - /// The name of the binary cache file. - /// The file date of the original XML file. Loading will fail if the cached data was generated - /// from a different file date than the original XML file. - /// - /// The BinaryDocumentationProvider representing the file's content; or null if loading failed. - /// - public static BinaryDocumentationProvider Load(string fileName, DateTime fileDate) - { - BinaryDocumentationProvider doc = new BinaryDocumentationProvider(); - try { - doc.fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); - int len = (int)doc.fs.Length; - BinaryReader loader = doc.loader = new BinaryReader(doc.fs); - if (loader.ReadInt64() != magic) { - Debug.WriteLine("Cannot load XmlDoc: wrong magic"); - return null; - } - if (loader.ReadInt16() != version) { - Debug.WriteLine("Cannot load XmlDoc: wrong version"); - return null; - } - if (loader.ReadInt64() != fileDate.Ticks) { - Debug.WriteLine("Not loading XmlDoc: file changed since cache was created"); - return null; - } - int count = loader.ReadInt32(); - int indexStartPosition = loader.ReadInt32(); // go to start of index - if (indexStartPosition <= 0 || indexStartPosition >= len) { - Debug.WriteLine("XmlDoc: Cannot find index, cache invalid!"); - return null; - } - doc.fs.Position = indexStartPosition; - IndexEntry[] index = new IndexEntry[count]; - for (int i = 0; i < index.Length; i++) { - index[i] = new IndexEntry(loader.ReadInt32(), loader.ReadInt32()); - } - doc.index = index; - return doc; - } catch (IOException ex) { - Debug.WriteLine("Cannot load from cache" + ex.ToString()); - return null; - } - } - - string LoadDocumentation(string key) - { - if (keyCacheQueue.Count > cacheLength - 1) { - xmlDescription.Remove(keyCacheQueue.Dequeue()); - } - - int hashcode = key.GetHashCode(); - - // use binary search to find the item - string resultDocu = null; - - int m = Array.BinarySearch(index, new IndexEntry(hashcode, 0)); - if (m >= 0) { - // correct hash code found. - // possibly there are multiple items with the same hash, so go to the first. - while (--m >= 0 && index[m].HashCode == hashcode); - // go through all items that have the correct hash - while (++m < index.Length && index[m].HashCode == hashcode) { - fs.Position = index[m].FileLocation; - string keyInFile = loader.ReadString(); - if (keyInFile == key) { - //LoggingService.Debug("Got XML documentation for " + key); - resultDocu = loader.ReadString(); - break; - } else { - // this is a harmless hash collision, just continue reading - Debug.WriteLine("Found " + keyInFile + " instead of " + key); - } - } - } - - keyCacheQueue.Enqueue(key); - xmlDescription.Add(key, resultDocu); - - return resultDocu; - } - #endregion - - public string GetDocumentation(string key) - { - lock (xmlDescription) { - if (index == null) - throw new ObjectDisposedException("BinaryDocumentationProvider"); - string result; - if (xmlDescription.TryGetValue(key, out result)) - return result; - return LoadDocumentation(key); - } - } - - public string GetDocumentation(IEntity entity) - { - return GetDocumentation(XmlDocumentationProvider.GetDocumentationKey(entity)); - } - - public void Dispose() - { - lock (xmlDescription) { - if (loader != null) { - loader.Close(); - fs.Close(); - } - xmlDescription.Clear(); - index = null; - keyCacheQueue = null; - loader = null; - fs = null; - } - } - } -} diff --git a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs index 8fc369d41..70d88aa16 100644 --- a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs +++ b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs @@ -14,37 +14,113 @@ namespace ICSharpCode.NRefactory.Documentation /// /// Provides documentation from an .xml file (as generated by the Microsoft C# compiler). /// + /// + /// This class first creates an in-memory index of the .xml file, and then uses that to read only the requested members. + /// This way, we avoid keeping all the documentation in memory. + /// public class XmlDocumentationProvider : IDocumentationProvider { - readonly IDictionary xmlDocumentation; + #region Cache + sealed class XmlDocumentationCache + { + readonly KeyValuePair[] entries; + int pos; + + public XmlDocumentationCache(int size = 50) + { + if (size <= 0) + throw new ArgumentOutOfRangeException("size", size, "Value must be positive"); + this.entries = new KeyValuePair[size]; + } + + internal string Get(string key) + { + foreach (var pair in entries) { + if (pair.Key == key) + return pair.Value; + } + return null; + } + + internal void Add(string key, string value) + { + entries[pos++] = new KeyValuePair(key, value); + if (pos == entries.Length) + pos = 0; + } + } + #endregion + + struct IndexEntry : IComparable + { + /// + /// Hash code of the documentation tag + /// + internal readonly int HashCode; + + /// + /// Position in the .xml file where the documentation starts + /// + internal readonly int PositionInFile; + + internal IndexEntry(int hashCode, int positionInFile) + { + this.HashCode = hashCode; + this.PositionInFile = positionInFile; + } + + public int CompareTo(IndexEntry other) + { + return this.HashCode.CompareTo(other.HashCode); + } + } + + readonly XmlDocumentationCache cache = new XmlDocumentationCache(); + readonly string fileName; + DateTime lastWriteDate; + IndexEntry[] index; // SORTED array of index entries - #region Load From File + #region Constructor / Redirection support + /// + /// Creates a new XmlDocumentationProvider. + /// + /// Name of the .xml file. public XmlDocumentationProvider(string fileName) { if (fileName == null) throw new ArgumentNullException("fileName"); - this.xmlDocumentation = new Dictionary(); + using (XmlTextReader xmlReader = new XmlTextReader(fileName)) { + xmlReader.XmlResolver = null; // no DTD resolving xmlReader.MoveToContent(); if (string.IsNullOrEmpty(xmlReader.GetAttribute("redirect"))) { + this.fileName = fileName; ReadXmlDoc(xmlReader); } else { string redirectionTarget = GetRedirectionTarget(xmlReader.GetAttribute("redirect")); if (redirectionTarget != null) { Debug.WriteLine("XmlDoc " + fileName + " is redirecting to " + redirectionTarget); using (XmlTextReader redirectedXmlReader = new XmlTextReader(redirectionTarget)) { + this.fileName = redirectionTarget; ReadXmlDoc(redirectedXmlReader); } } else { - Debug.WriteLine("XmlDoc " + fileName + " is redirecting to " + xmlReader.GetAttribute("redirect") + ", but that file was not found."); + throw new XmlException("XmlDoc " + fileName + " is redirecting to " + xmlReader.GetAttribute("redirect") + ", but that file was not found."); } } } } + private XmlDocumentationProvider(string fileName, DateTime lastWriteDate, IndexEntry[] index) + { + this.fileName = fileName; + this.lastWriteDate = lastWriteDate; + this.index = index; + } + static string GetRedirectionTarget(string target) { - string programFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); + string programFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); programFilesDir = AppendDirectorySeparator(programFilesDir); string corSysDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); @@ -95,36 +171,54 @@ namespace ICSharpCode.NRefactory.Documentation } #endregion - #region Load from XmlReader - public XmlDocumentationProvider(XmlReader reader) - { - if (reader == null) - throw new ArgumentNullException("reader"); - this.xmlDocumentation = new Dictionary(); - ReadXmlDoc(reader); - } - - public XmlDocumentationProvider(IDictionary dictionary) + #region Load / Create Index + void ReadXmlDoc(XmlTextReader reader) { - if (dictionary == null) - throw new ArgumentNullException("dictionary"); - this.xmlDocumentation = dictionary; + lastWriteDate = File.GetLastWriteTimeUtc(fileName); + // Open up a second file stream for the line<->position mapping + using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { + LinePositionMapper linePosMapper = new LinePositionMapper(fs); + List indexList = new List(); + while (reader.Read()) { + if (reader.IsStartElement()) { + switch (reader.LocalName) { + case "members": + ReadMembersSection(reader, linePosMapper, indexList); + break; + } + } + } + indexList.Sort(); + this.index = indexList.ToArray(); + } } - void ReadXmlDoc(XmlReader reader) + sealed class LinePositionMapper { - while (reader.Read()) { - if (reader.IsStartElement()) { - switch (reader.LocalName) { - case "members": - ReadMembersSection(reader); - break; + readonly FileStream fs; + int currentLine = 1; + + public LinePositionMapper(FileStream fs) + { + this.fs = fs; + } + + public int GetPositionForLine(int line) + { + Debug.Assert(line >= currentLine); + while (line > currentLine) { + int b = fs.ReadByte(); + if (b < 0) + throw new EndOfStreamException(); + if (b == '\n') { + currentLine++; } } + return checked((int)fs.Position); } } - void ReadMembersSection(XmlReader reader) + void ReadMembersSection(XmlTextReader reader, LinePositionMapper linePosMapper, List indexList) { while (reader.Read()) { switch (reader.NodeType) { @@ -135,9 +229,11 @@ namespace ICSharpCode.NRefactory.Documentation break; case XmlNodeType.Element: if (reader.LocalName == "member") { - string memberAttr = reader.GetAttribute(0); - string innerXml = reader.ReadInnerXml(); - xmlDocumentation[memberAttr] = innerXml; + int pos = linePosMapper.GetPositionForLine(reader.LineNumber) + Math.Max(reader.LinePosition - 2, 0); + string memberAttr = reader.GetAttribute("name"); + if (memberAttr != null) + indexList.Add(new IndexEntry(memberAttr.GetHashCode(), pos)); + reader.Skip(); } break; } @@ -145,35 +241,138 @@ namespace ICSharpCode.NRefactory.Documentation } #endregion + #region Save index / Restore from index + // FILE FORMAT FOR BINARY DOCUMENTATION + // long magic = 0x4244636f446c6d58 (identifies file type = 'XmlDocDB') + const long magic = 0x4244636f446c6d58; + // short version = 5 (file format version) + const short version = 5; + // string fileName (full name of .xml file) + // long fileDate (last change date of xml file in DateTime ticks) + // int testHashCode = magicTestString.GetHashCode() // (check if hash-code implementation is compatible) + // int entryCount (count of entries) + // int indexPointer (points to location where index starts in the file) + // { + // int hashcode + // int positionInFile (byte number where the docu string starts in the .xml file) + // } + + const string magicTestString = "XmlDoc-Test-String"; + + /// + /// Saves the index into a binary file. + /// Use to load the saved file. + /// + public void SaveIndex(BinaryWriter w) + { + if (w == null) + throw new ArgumentNullException("w"); + w.Write(magic); + w.Write(version); + w.Write(fileName); + w.Write(lastWriteDate.Ticks); + w.Write(magicTestString.GetHashCode()); + w.Write(index.Length); + foreach (var entry in index) { + w.Write(entry.HashCode); + w.Write(entry.PositionInFile); + } + } + /// - /// Gets all entries in the documentation file. + /// Restores XmlDocumentationProvider from the index file (created by ). /// - public IDictionary XmlDocumentation { - get { return xmlDocumentation; } + public static XmlDocumentationProvider LoadFromIndex(BinaryReader r) + { + if (r.ReadInt64() != magic) + throw new InvalidDataException("File is not a stored XmlDoc index"); + if (r.ReadInt16() != version) + throw new InvalidDataException("Index file was created by incompatible version"); + string fileName = r.ReadString(); + DateTime lastWriteDate = new DateTime(r.ReadInt64(), DateTimeKind.Utc); + if (r.ReadInt32() != magicTestString.GetHashCode()) + throw new InvalidDataException("Index file was created by another hash code algorithm"); + int indexLength = r.ReadInt32(); + IndexEntry[] index = new IndexEntry[indexLength]; + for (int i = 0; i < index.Length; i++) { + index[i] = new IndexEntry(r.ReadInt32(), r.ReadInt32()); + } + return new XmlDocumentationProvider(fileName, lastWriteDate, index); + } + #endregion + + #region GetDocumentation + /// + public string GetDocumentation(IEntity entity) + { + return GetDocumentation(GetDocumentationKey(entity)); } + /// + /// Get the documentation for the member with the specified documentation key. + /// public string GetDocumentation(string key) { if (key == null) throw new ArgumentNullException("key"); - string result; - if (xmlDocumentation.TryGetValue(key, out result)) - return result; - else + int hashcode = key.GetHashCode(); + // index is sorted, so we can use binary search + int m = Array.BinarySearch(index, new IndexEntry(hashcode, 0)); + if (m < 0) return null; + // correct hash code found. + // possibly there are multiple items with the same hash, so go to the first. + while (--m >= 0 && index[m].HashCode == hashcode); + // m is now 1 before the first item with the correct hash + + lock (cache) { + string val = cache.Get(key); + if (val == null) { + // go through all items that have the correct hash + while (++m < index.Length && index[m].HashCode == hashcode) { + val = LoadDocumentation(key, index[m].PositionInFile); + if (val != null) + break; + } + // cache the result (even if it is null) + cache.Add(key, val); + } + return val; + } } + #endregion - public string GetDocumentation(IEntity entity) + #region Load / Read XML + string LoadDocumentation(string key, int positionInFile) { - return GetDocumentation(GetDocumentationKey(entity)); + using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { + fs.Position = positionInFile; + using (XmlTextReader r = new XmlTextReader(fs, XmlNodeType.Element, null)) { + r.XmlResolver = null; // no DTD resolving + while (r.Read()) { + if (r.NodeType == XmlNodeType.Element) { + string memberAttr = r.GetAttribute("name"); + if (memberAttr == key) { + return r.ReadInnerXml(); + } else { + return null; + } + } + } + return null; + } + } } + #endregion + #region GetDocumentationKey public static string GetDocumentationKey(IEntity entity) { if (entity == null) throw new ArgumentNullException("entity"); throw new NotImplementedException(); } + #endregion } } diff --git a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj index 4ca65e7f7..1fad1819d 100644 --- a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj +++ b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj @@ -97,6 +97,7 @@ + @@ -199,7 +200,6 @@ - @@ -248,6 +248,7 @@ + @@ -255,6 +256,7 @@ + @@ -330,6 +332,7 @@ + @@ -348,13 +351,53 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -364,6 +407,10 @@ {D68133BD-1E63-496E-9EDE-4FBDBF77B486} Mono.Cecil + + {F054A788-B591-4561-A8BA-AE745BBEB817} + ICSharpCode.Editor + \ No newline at end of file diff --git a/ICSharpCode.NRefactory/TypeSystem/ArrayType.cs b/ICSharpCode.NRefactory/TypeSystem/ArrayType.cs index db590e2b9..9f42a2ec8 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ArrayType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ArrayType.cs @@ -31,8 +31,9 @@ namespace ICSharpCode.NRefactory.TypeSystem } } - public override Nullable IsReferenceType { - get { return true; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return true; } public override int GetHashCode() diff --git a/ICSharpCode.NRefactory/TypeSystem/ByReferenceType.cs b/ICSharpCode.NRefactory/TypeSystem/ByReferenceType.cs index 6d457dc2f..39288f25f 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ByReferenceType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ByReferenceType.cs @@ -16,8 +16,9 @@ namespace ICSharpCode.NRefactory.TypeSystem } } - public override Nullable IsReferenceType { - get { return null; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return null; } public override int GetHashCode() diff --git a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs index 80a522706..d7765d938 100644 --- a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs +++ b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs @@ -43,8 +43,28 @@ namespace ICSharpCode.NRefactory.TypeSystem /// Gets/Sets the interning provider. /// public IInterningProvider InterningProvider { get; set; } + + /// + /// Gets a value indicating whether this instance stores references to the cecil objects. + /// + /// + /// true if this instance has references to the cecil objects; otherwise, false. + /// + public bool HasCecilReferences { get { return typeSystemTranslationTable != null; } } #endregion + /// + /// Initializes a new instance of the class. + /// + /// + /// If true references to the cecil objects are hold. In this case the cecil loader can do a type system -> cecil mapping. + /// + public CecilLoader (bool createCecilReferences = false) + { + if (createCecilReferences) + typeSystemTranslationTable = new Dictionary (); + } + #region Load From AssemblyDefinition /// /// Loads the assembly definition into a project content. @@ -90,6 +110,8 @@ namespace ICSharpCode.NRefactory.TypeSystem foreach (CecilTypeDefinition c in types) { c.Init(this); } + if (HasCecilReferences) + typeSystemTranslationTable[pc] = assemblyDefinition; return pc; } finally { this.EarlyBindContext = oldEarlyBindContext; @@ -151,6 +173,17 @@ namespace ICSharpCode.NRefactory.TypeSystem // Disposing the synchronization context has no effect } + public IParsedFile GetFile(string fileName) + { + return null; + } + + public IEnumerable Files { + get { + return EmptyList.Instance; + } + } + string IDocumentationProvider.GetDocumentation(IEntity entity) { if (documentationProvider != null) @@ -168,7 +201,10 @@ namespace ICSharpCode.NRefactory.TypeSystem throw new ArgumentNullException("fileName"); var param = new ReaderParameters { AssemblyResolver = new DummyAssemblyResolver() }; AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(fileName, param); - return LoadAssembly(asm); + var result = LoadAssembly(asm); + if (HasCecilReferences) + typeSystemTranslationTable[result] = asm; + return result; } // used to prevent Cecil from loading referenced assemblies @@ -292,7 +328,7 @@ namespace ICSharpCode.NRefactory.TypeSystem name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount); var earlyBindContext = this.EarlyBindContext; if (earlyBindContext != null) { - IType c = earlyBindContext.GetClass(ns, name, typeParameterCount, StringComparer.Ordinal); + IType c = earlyBindContext.GetTypeDefinition(ns, name, typeParameterCount, StringComparer.Ordinal); if (c != null) return c; } @@ -653,7 +689,7 @@ namespace ICSharpCode.NRefactory.TypeSystem #region Read Type Definition sealed class CecilTypeDefinition : DefaultTypeDefinition { - TypeDefinition typeDefinition; + internal TypeDefinition typeDefinition; public CecilTypeDefinition(IProjectContent pc, TypeDefinition typeDefinition) : base(pc, typeDefinition.Namespace, ReflectionHelper.SplitTypeParameterCountFromReflectionName(typeDefinition.Name)) @@ -717,8 +753,8 @@ namespace ICSharpCode.NRefactory.TypeSystem } InitMembers(loader); - - this.typeDefinition = null; + if (!loader.HasCecilReferences) + this.typeDefinition = null; Freeze(); // freeze after initialization ApplyInterningProvider(loader.InterningProvider); } @@ -741,11 +777,11 @@ namespace ICSharpCode.NRefactory.TypeSystem if (name.Length == 0 || name[0] == '<') continue; name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(name); - InnerClasses.Add(new CecilTypeDefinition(this, name, nestedType)); + NestedTypes.Add(new CecilTypeDefinition(this, name, nestedType)); } } - foreach (CecilTypeDefinition innerClass in this.InnerClasses) { - innerClass.Init(loader); + foreach (CecilTypeDefinition nestedType in this.NestedTypes) { + nestedType.Init(loader); } } @@ -908,7 +944,7 @@ namespace ICSharpCode.NRefactory.TypeSystem m.IsExtensionMethod = true; } - FinishReadMember(m); + FinishReadMember(m, method); return m; } @@ -1042,7 +1078,7 @@ namespace ICSharpCode.NRefactory.TypeSystem f.IsVolatile = true; } - FinishReadMember(f); + FinishReadMember(f, field); return f; } @@ -1077,7 +1113,7 @@ namespace ICSharpCode.NRefactory.TypeSystem break; } - tp.HasDefaultConstructorConstraint = g.HasReferenceTypeConstraint; + tp.HasReferenceTypeConstraint = g.HasReferenceTypeConstraint; tp.HasValueTypeConstraint = g.HasNotNullableValueTypeConstraint; tp.HasDefaultConstructorConstraint = g.HasDefaultConstructorConstraint; @@ -1111,7 +1147,7 @@ namespace ICSharpCode.NRefactory.TypeSystem } AddAttributes(property, p); - FinishReadMember(p); + FinishReadMember(p, property); return p; } @@ -1151,15 +1187,69 @@ namespace ICSharpCode.NRefactory.TypeSystem AddAttributes(ev, e); - FinishReadMember(e); + FinishReadMember(e, ev); + return e; } #endregion - void FinishReadMember(AbstractMember member) + void FinishReadMember(AbstractMember member, object cecilDefinition) { member.Freeze(); member.ApplyInterningProvider(this.InterningProvider); + if (HasCecilReferences) + typeSystemTranslationTable[member] = cecilDefinition; + } + + #region Type system translation table + Dictionary typeSystemTranslationTable; + + T InternalGetCecilObject (object typeSystemObject) where T : class + { + if (typeSystemObject == null) + throw new ArgumentNullException ("typeSystemObject"); + if (!HasCecilReferences) + throw new NotSupportedException ("This instance contains no cecil references."); + object result; + if (!typeSystemTranslationTable.TryGetValue (typeSystemObject, out result)) + throw new InvalidOperationException ("No cecil reference stored for " + typeSystemObject); + return result as T; + } + + public AssemblyDefinition GetCecilObject (IProjectContent content) + { + return InternalGetCecilObject (content); + } + + public TypeDefinition GetCecilObject (ITypeDefinition type) + { + if (type == null) + throw new ArgumentNullException ("type"); + var cecilType = type as CecilTypeDefinition; + if (cecilType == null) + throw new ArgumentException ("type is no cecil type definition."); + return cecilType.typeDefinition; + } + + public MethodDefinition GetCecilObject (IMethod method) + { + return InternalGetCecilObject (method); } + + public FieldDefinition GetCecilObject (IField field) + { + return InternalGetCecilObject (field); + } + + public EventDefinition GetCecilObject (IEvent evt) + { + return InternalGetCecilObject (evt); + } + + public PropertyDefinition GetCecilObject (IProperty property) + { + return InternalGetCecilObject (property); + } + #endregion } } diff --git a/ICSharpCode.NRefactory/TypeSystem/DomRegion.cs b/ICSharpCode.NRefactory/TypeSystem/DomRegion.cs index b9d31cae6..851b97e90 100644 --- a/ICSharpCode.NRefactory/TypeSystem/DomRegion.cs +++ b/ICSharpCode.NRefactory/TypeSystem/DomRegion.cs @@ -60,6 +60,22 @@ namespace ICSharpCode.NRefactory.TypeSystem } } + public AstLocation Begin { + get { + return new AstLocation (beginLine, beginColumn); + } + } + + public AstLocation End { + get { + return new AstLocation (endLine, endColumn); + } + } + + public DomRegion (int beginLine, int beginColumn, int endLine, int endColumn) : this (null, beginLine, beginColumn, endLine, endColumn) + { + } + public DomRegion(string fileName, int beginLine, int beginColumn, int endLine, int endColumn) { this.fileName = fileName; @@ -69,15 +85,45 @@ namespace ICSharpCode.NRefactory.TypeSystem this.endColumn = endColumn; } - public DomRegion(string fileName, int beginLine, int beginColumn) + public DomRegion (int beginLine, int beginColumn) : this (null, beginLine, beginColumn) + { + } + + public DomRegion (string fileName, int beginLine, int beginColumn) { this.fileName = fileName; - this.beginLine = beginLine; + this.beginLine = beginLine; this.beginColumn = beginColumn; this.endLine = -1; this.endColumn = -1; } + public DomRegion (AstLocation begin, AstLocation end) : this (null, begin, end) + { + } + + public DomRegion (string fileName, AstLocation begin, AstLocation end) + { + this.fileName = fileName; + this.beginLine = begin.Line; + this.beginColumn = begin.Column; + this.endLine = end.Line; + this.endColumn = end.Column; + } + + public DomRegion (AstLocation begin) : this (null, begin) + { + } + + public DomRegion (string fileName, AstLocation begin) + { + this.fileName = fileName; + this.beginLine = begin.Line; + this.beginColumn = begin.Column; + this.endLine = -1; + this.endColumn = -1; + } + /// /// Returns true, if the given coordinates (line, column) are in the region. /// This method assumes that for an unknown end the end line is == -1 diff --git a/ICSharpCode.NRefactory/TypeSystem/Error.cs b/ICSharpCode.NRefactory/TypeSystem/Error.cs new file mode 100644 index 000000000..1684e8d81 --- /dev/null +++ b/ICSharpCode.NRefactory/TypeSystem/Error.cs @@ -0,0 +1,135 @@ +// +// Error.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Mike Krüger +// +// 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; + +namespace ICSharpCode.NRefactory.TypeSystem +{ + /// + /// Enum that describes the type of an error. + /// + public enum ErrorType + { + Unknown, + Error, + Warning + } + + /// + /// Descibes an error during parsing. + /// + public class Error + { + /// + /// The type of the error. + /// + public ErrorType ErrorType { get; private set; } + + /// + /// The error description. + /// + public string Message { get; private set; } + + /// + /// The region of the error. + /// + public DomRegion Region { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The error type. + /// + /// + /// The description of the error. + /// + /// + /// The region of the error. + /// + public Error (ErrorType errorType, string message, DomRegion region) + { + this.ErrorType = errorType; + this.Message = message; + this.Region = region; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The error type. + /// + /// + /// The description of the error. + /// + /// + /// The location of the error. + /// + public Error (ErrorType errorType, string message, AstLocation location) + { + this.ErrorType = errorType; + this.Message = message; + this.Region = new DomRegion (location, location); + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The error type. + /// + /// + /// The description of the error. + /// + /// + /// The line of the error. + /// + /// + /// The column of the error. + /// + public Error (ErrorType errorType, string message, int line, int col) : this (errorType, message, new AstLocation (line, col)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The error type. + /// + /// + /// The description of the error. + /// + public Error (ErrorType errorType, string message) + { + this.ErrorType = errorType; + this.Message = message; + this.Region = DomRegion.Empty; + } + } +} diff --git a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs index da2a6c06a..e2608b812 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs @@ -1,10 +1,13 @@ -// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) 2010 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; using System.Collections.Generic; using System.Linq; +using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.Utils; +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.CSharp; namespace ICSharpCode.NRefactory.TypeSystem { @@ -73,7 +76,7 @@ namespace ICSharpCode.NRefactory.TypeSystem Func> recursion = t => t.GetBaseTypes(context).Select(b => b.GetDefinition()).Where(d => d != null && typeDefinitions.Add(d)); - ITypeDefinition typeDef = type as ITypeDefinition; + ITypeDefinition typeDef = type.GetDefinition(); if (typeDef != null) { typeDefinitions.Add(typeDef); return TreeTraversal.PreOrder(typeDef, recursion); @@ -185,8 +188,17 @@ namespace ICSharpCode.NRefactory.TypeSystem ITypeDefinition def = type.GetDefinition(); if (def != null && def.ClassType == ClassType.Delegate) { foreach (IMethod method in def.Methods) { - if (method.Name == "Invoke") + if (method.Name == "Invoke") { + ParameterizedType pt = type as ParameterizedType; + if (pt != null) { + SpecializedMethod m = new SpecializedMethod(method); + m.SetDeclaringType(pt); + var substitution = pt.GetSubstitution(); + m.SubstituteTypes(t => new SubstitutionTypeReference(t, substitution)); + return m; + } return method; + } } } return null; @@ -208,13 +220,46 @@ namespace ICSharpCode.NRefactory.TypeSystem } #endregion - #region GetAllClasses + #region GetAllTypes /// - /// Gets all classes, including nested classes. + /// Gets all type definitions, including nested types. /// - public static IEnumerable GetAllClasses(this ITypeResolveContext context) + public static IEnumerable GetAllTypes(this ITypeResolveContext context) { - return TreeTraversal.PreOrder(context.GetClasses(), t => t.InnerClasses); + return TreeTraversal.PreOrder(context.GetTypes(), t => t.NestedTypes); + } + #endregion + + #region GetType/Member + /// + /// Gets the type (potentially a nested type) defined at the specified location. + /// Returns null if no type is defined at that location. + /// + public static ITypeDefinition GetTypeDefinition (this IParsedFile file, int line, int column) + { + return file.GetTypeDefinition (new AstLocation (line, column)); + } + + /// + /// Gets the member defined at the specified location. + /// Returns null if no member is defined at that location. + /// + public static IMember GetMember (this IParsedFile file, int line, int column) + { + return file.GetMember (new AstLocation (line, column)); + } + #endregion + + #region GetSubTypeDefinitions + /// + /// Gets all sub type definitions defined in a context. + /// + public static IEnumerable GetSubTypeDefinitions (this ITypeDefinition baseType, ITypeResolveContext context) + { + foreach (var contextType in context.GetAllTypes ()) { + if (contextType.IsDerivedFrom (baseType, context)) + yield return contextType; + } } #endregion } diff --git a/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs b/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs new file mode 100644 index 000000000..c7f8e7c23 --- /dev/null +++ b/ICSharpCode.NRefactory/TypeSystem/IAnnotatable.cs @@ -0,0 +1,216 @@ +// Copyright (c) 2010 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; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +namespace ICSharpCode.NRefactory +{ + /// + /// Provides an interface to handle annotations in an object. + /// + public interface IAnnotatable + { + /// + /// Gets all annotations stored on this IAnnotatable. + /// + IEnumerable Annotations { + get; + } + + /// + /// Gets the first annotation of the specified type. + /// Returns null if no matching annotation exists. + /// + /// + /// The type of the annotation. + /// + T Annotation () where T: class; + + /// + /// Gets the first annotation of the specified type. + /// Returns null if no matching annotation exists. + /// + /// + /// The type of the annotation. + /// + object Annotation (Type type); + + /// + /// Adds an annotation to this instance. + /// + /// + /// The annotation to add. + /// + void AddAnnotation (object annotation); + + /// + /// Removes all annotations of the specified type. + /// + /// + /// The type of the annotations to remove. + /// + void RemoveAnnotations () where T : class; + + /// + /// Removes all annotations of the specified type. + /// + /// + /// The type of the annotations to remove. + /// + void RemoveAnnotations(Type type); + } + + public abstract class AbstractAnnotatable : IAnnotatable + { + // Annotations: points either null (no annotations), to the single annotation, + // or to an AnnotationList. + // Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list) + protected object annotations; + + sealed class AnnotationList : List, ICloneable + { + // There are two uses for this custom list type: + // 1) it's private, and thus (unlike List) cannot be confused with real annotations + // 2) It allows us to simplify the cloning logic by making the list behave the same as a clonable annotation. + public AnnotationList (int initialCapacity) : base(initialCapacity) + { + } + + public object Clone () + { + lock (this) { + AnnotationList copy = new AnnotationList (this.Count); + for (int i = 0; i < this.Count; i++) { + object obj = this [i]; + ICloneable c = obj as ICloneable; + copy.Add (c != null ? c.Clone () : obj); + } + return copy; + } + } + } + + public virtual void AddAnnotation (object annotation) + { + if (annotation == null) + throw new ArgumentNullException ("annotation"); + retry: // Retry until successful + object oldAnnotation = Interlocked.CompareExchange (ref this.annotations, annotation, null); + if (oldAnnotation == null) { + return; // we successfully added a single annotation + } + AnnotationList list = oldAnnotation as AnnotationList; + if (list == null) { + // we need to transform the old annotation into a list + list = new AnnotationList (4); + list.Add (oldAnnotation); + list.Add (annotation); + if (Interlocked.CompareExchange (ref this.annotations, list, oldAnnotation) != oldAnnotation) { + // the transformation failed (some other thread wrote to this.annotations first) + goto retry; + } + } else { + // once there's a list, use simple locking + lock (list) { + list.Add (annotation); + } + } + } + + public virtual void RemoveAnnotations () where T : class + { + retry: // Retry until successful + object oldAnnotations = this.annotations; + AnnotationList list = oldAnnotations as AnnotationList; + if (list != null) { + lock (list) + list.RemoveAll (obj => obj is T); + } else if (oldAnnotations is T) { + if (Interlocked.CompareExchange (ref this.annotations, null, oldAnnotations) != oldAnnotations) { + // Operation failed (some other thread wrote to this.annotations first) + goto retry; + } + } + } + + public virtual void RemoveAnnotations (Type type) + { + if (type == null) + throw new ArgumentNullException ("type"); + retry: // Retry until successful + object oldAnnotations = this.annotations; + AnnotationList list = oldAnnotations as AnnotationList; + if (list != null) { + lock (list) + list.RemoveAll (obj => type.IsInstanceOfType (obj)); + } else if (type.IsInstanceOfType (oldAnnotations)) { + if (Interlocked.CompareExchange (ref this.annotations, null, oldAnnotations) != oldAnnotations) { + // Operation failed (some other thread wrote to this.annotations first) + goto retry; + } + } + } + + public T Annotation () where T: class + { + object annotations = this.annotations; + AnnotationList list = annotations as AnnotationList; + if (list != null) { + lock (list) { + foreach (object obj in list) { + T t = obj as T; + if (t != null) + return t; + } + return null; + } + } else { + return annotations as T; + } + } + + public object Annotation (Type type) + { + if (type == null) + throw new ArgumentNullException ("type"); + object annotations = this.annotations; + AnnotationList list = annotations as AnnotationList; + if (list != null) { + lock (list) { + foreach (object obj in list) { + if (type.IsInstanceOfType (obj)) + return obj; + } + } + } else { + if (type.IsInstanceOfType (annotations)) + return annotations; + } + return null; + } + + /// + /// Gets all annotations stored on this AstNode. + /// + public IEnumerable Annotations { + get { + object annotations = this.annotations; + AnnotationList list = annotations as AnnotationList; + if (list != null) { + lock (list) { + return list.ToArray (); + } + } else { + if (annotations != null) + return new object[] { annotations }; + else + return Enumerable.Empty (); + } + } + } + } +} + diff --git a/ICSharpCode.NRefactory/TypeSystem/IEntity.cs b/ICSharpCode.NRefactory/TypeSystem/IEntity.cs index d9f92d1ce..74bdec380 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IEntity.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IEntity.cs @@ -68,6 +68,54 @@ namespace ICSharpCode.NRefactory.TypeSystem /// bool IsSynthetic { get; } + /// + /// Gets a value indicating whether this instance is private. + /// + /// + /// true if this instance is private; otherwise, false. + /// + bool IsPrivate { get; } + + /// + /// Gets a value indicating whether this instance is public. + /// + /// + /// true if this instance is public; otherwise, false. + /// + bool IsPublic { get; } + + /// + /// Gets a value indicating whether this instance is protected. + /// + /// + /// true if this instance is protected; otherwise, false. + /// + bool IsProtected { get; } + + /// + /// Gets a value indicating whether this instance is internal. + /// + /// + /// true if this instance is internal; otherwise, false. + /// + bool IsInternal { get; } + + /// + /// Gets a value indicating whether this instance is protected or internal. + /// + /// + /// true if this instance is protected or internal; otherwise, false. + /// + bool IsProtectedOrInternal { get; } + + /// + /// Gets a value indicating whether this instance is protected and internal. + /// + /// + /// true if this instance is protected and internal; otherwise, false. + /// + bool IsProtectedAndInternal { get; } + /// /// The assembly in which this entity is defined. /// This property never returns null. diff --git a/ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs b/ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs new file mode 100644 index 000000000..0852028f2 --- /dev/null +++ b/ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.CSharp; + +namespace ICSharpCode.NRefactory.TypeSystem +{ + /// + /// Represents a single file that was parsed. + /// + public interface IParsedFile : IFreezable + { + /// + /// Gets the parent project content. + /// + IProjectContent ProjectContent { get; } + + /// + /// Returns the full path of the file. + /// + string FileName { get; } + + /// + /// Gets the time of object creation. + /// + DateTime ParseTime { get; } + + /// + /// Gets all top-level type definitions. + /// + IList TopLevelTypeDefinitions { get; } + + /// + /// Gets all assembly attributes that are defined in this file. + /// + IList AssemblyAttributes { get; } + + /// + /// Gets the top-level type defined at the specified location. + /// Returns null if no type is defined at that location. + /// + ITypeDefinition GetTopLevelTypeDefinition(AstLocation location); + + /// + /// Gets the type (potentially a nested type) defined at the specified location. + /// Returns null if no type is defined at that location. + /// + ITypeDefinition GetTypeDefinition(AstLocation location); + + /// + /// Gets the member defined at the specified location. + /// Returns null if no member is defined at that location. + /// + IMember GetMember(AstLocation location); + + /// + /// Gets the parser errors. + /// + IList Errors { get; } + } +} diff --git a/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs b/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs index be4d9651d..848553114 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs @@ -13,9 +13,22 @@ namespace ICSharpCode.NRefactory.TypeSystem #if WITH_CONTRACTS [ContractClass(typeof(IProjectContentContract))] #endif - public interface IProjectContent : ITypeResolveContext + public interface IProjectContent : ITypeResolveContext, IAnnotatable { + /// + /// Gets the list of all assembly attributes in the project. + /// IList AssemblyAttributes { get; } + + /// + /// Gets a parsed file by its file name. + /// + IParsedFile GetFile(string fileName); + + /// + /// Gets the list of all parsed files in the project content. + /// + IEnumerable Files { get; } } #if WITH_CONTRACTS @@ -28,6 +41,12 @@ namespace ICSharpCode.NRefactory.TypeSystem return null; } } + + IParsedFile IProjectContent.GetFile(string fileName) + { + Contract.Requires(fileName != null); + return; + } } #endif } diff --git a/ICSharpCode.NRefactory/TypeSystem/IType.cs b/ICSharpCode.NRefactory/TypeSystem/IType.cs index f6d3b3a32..6e64bf120 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IType.cs @@ -20,7 +20,11 @@ namespace ICSharpCode.NRefactory.TypeSystem /// false, if the type is a value type. /// null, if the type is not known (e.g. unconstrained generic type parameter or type not found) /// - bool? IsReferenceType { get; } + /// + /// The resolve context is required for type parameters with a constraint "T : SomeType": + /// the type parameter is a reference type iff SomeType is a class type. + /// + bool? IsReferenceType(ITypeResolveContext context); /// /// Gets the underlying type definition. @@ -90,14 +94,22 @@ namespace ICSharpCode.NRefactory.TypeSystem /// Gets all events that can be called on this return type. /// IEnumerable GetEvents(ITypeResolveContext context, Predicate filter = null); + + /// + /// Gets all members that can be called on this return type. + /// This is the union of GetFields(),GetProperties(),GetMethods() and GetEvents(). This does not include constructors. + /// + IEnumerable GetMembers(ITypeResolveContext context, Predicate filter = null); } #if WITH_CONTRACTS [ContractClassFor(typeof(IType))] abstract class ITypeContract : ITypeReferenceContract, IType { - Nullable IType.IsReferenceType { - get { return null; } + bool? IType.IsReferenceType(ITypeResolveContext context) + { + Contract.Requires(context != null); + return null; } int IType.TypeParameterCount { @@ -121,42 +133,49 @@ namespace ICSharpCode.NRefactory.TypeSystem IEnumerable IType.GetNestedTypes(ITypeResolveContext context, Predicate filter) { Contract.Requires(context != null); - Contract.Ensures(Contract.Result>() != null); + Contract.Ensures(Contract.Result>() != null); return null; } IEnumerable IType.GetMethods(ITypeResolveContext context, Predicate filter) { Contract.Requires(context != null); - Contract.Ensures(Contract.Result>() != null); + Contract.Ensures(Contract.Result>() != null); return null; } IEnumerable IType.GetConstructors(ITypeResolveContext context, Predicate filter) { Contract.Requires(context != null); - Contract.Ensures(Contract.Result>() != null); + Contract.Ensures(Contract.Result>() != null); return null; } IEnumerable IType.GetProperties(ITypeResolveContext context, Predicate filter) { Contract.Requires(context != null); - Contract.Ensures(Contract.Result>() != null); + Contract.Ensures(Contract.Result>() != null); return null; } IEnumerable IType.GetFields(ITypeResolveContext context, Predicate filter) { Contract.Requires(context != null); - Contract.Ensures(Contract.Result>() != null); + Contract.Ensures(Contract.Result>() != null); return null; } IEnumerable IType.GetEvents(ITypeResolveContext context, Predicate filter) { Contract.Requires(context != null); - Contract.Ensures(Contract.Result>() != null); + Contract.Ensures(Contract.Result>() != null); + return null; + } + + IEnumerable IType.GetEvents(ITypeResolveContext context, Predicate filter) + { + Contract.Requires(context != null); + Contract.Ensures(Contract.Result>() != null); return null; } diff --git a/ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs b/ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs index f2e1bc5a5..507d5420d 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs @@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.TypeSystem /// IList GetParts(); - IList InnerClasses { get; } + IList NestedTypes { get; } IList Fields { get; } IList Properties { get; } IList Methods { get; } diff --git a/ICSharpCode.NRefactory/TypeSystem/ITypeResolveContext.cs b/ICSharpCode.NRefactory/TypeSystem/ITypeResolveContext.cs index 9cdfb4133..b1490a653 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ITypeResolveContext.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ITypeResolveContext.cs @@ -18,36 +18,36 @@ namespace ICSharpCode.NRefactory.TypeSystem public interface ITypeResolveContext { /// - /// Retrieves a class. + /// Retrieves a type. /// - /// Namespace that contains the class - /// Name of the class + /// Namespace that contains the type + /// Name of the type /// Number of type parameters /// Language-specific rules for how class names are compared - /// The type definition for the class; or null if no such class exists. - /// This method never returns inner classes; it can be used only with top-level classes. - ITypeDefinition GetClass(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer); + /// The type definition for the class; or null if no such type exists. + /// This method never returns inner types; it can be used only with top-level types. + ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer); /// - /// Retrieves all top-level classes. + /// Retrieves all top-level types. /// /// /// If this method is called within using (pc.Synchronize()), then the returned enumerable is valid /// only until the end of the synchronize block. /// - IEnumerable GetClasses(); + IEnumerable GetTypes(); /// - /// Retrieves all classes in the specified namespace. + /// Retrieves all types in the specified namespace. /// - /// Namespace in which classes are being retrieved. Use string.Empty for the root namespace. + /// Namespace in which types are being retrieved. Use string.Empty for the root namespace. /// Language-specific rules for how namespace names are compared - /// List of classes within that namespace. + /// List of types within that namespace. /// /// If this method is called within using (var spc = pc.Synchronize()), then the returned enumerable is valid /// only until the end of the synchronize block. /// - IEnumerable GetClasses(string nameSpace, StringComparer nameComparer); + IEnumerable GetTypes(string nameSpace, StringComparer nameComparer); /// /// Retrieves all namespaces. @@ -112,13 +112,13 @@ namespace ICSharpCode.NRefactory.TypeSystem return null; } - IEnumerable ITypeResolveContext.GetClasses() + IEnumerable ITypeResolveContext.GetTypes() { Contract.Ensures(Contract.Result>() != null); return null; } - IEnumerable ITypeResolveContext.GetClasses(string nameSpace, StringComparer nameComparer) + IEnumerable ITypeResolveContext.GetTypes(string nameSpace, StringComparer nameComparer) { Contract.Requires(nameSpace != null); Contract.Requires(nameComparer != null); diff --git a/ICSharpCode.NRefactory/TypeSystem/IVariable.cs b/ICSharpCode.NRefactory/TypeSystem/IVariable.cs index 5c8f1d903..b5a0bad88 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IVariable.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IVariable.cs @@ -19,6 +19,11 @@ namespace ICSharpCode.NRefactory.TypeSystem /// string Name { get; } + /// + /// Gets the declaration region of the variable. + /// + DomRegion DeclarationRegion { get; } + /// /// Gets the type of the variable. /// diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractFreezable.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractFreezable.cs index 3f0e0d083..10ca6ee6e 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractFreezable.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractFreezable.cs @@ -63,18 +63,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return new List(inputList); } - protected static IList FreezeList(IList list) where T : IFreezable + protected static ReadOnlyCollection FreezeList(IList list) where T : IFreezable { if (list == null || list.Count == 0) return EmptyList.Instance; - list = new ReadOnlyCollection(list.ToArray()); - foreach (T item in list) { + var result = new ReadOnlyCollection(list.ToArray()); + foreach (T item in result) { item.Freeze(); } - return list; + return result; } - protected static IList FreezeList(IList list) + protected static ReadOnlyCollection FreezeList(IList list) { if (list == null || list.Count == 0) return EmptyList.Instance; @@ -82,7 +82,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return new ReadOnlyCollection(list.ToArray()); } - protected static IList FreezeList(IList list) + protected static ReadOnlyCollection FreezeList(IList list) { if (list == null || list.Count == 0) return EmptyList.Instance; diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractMember.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractMember.cs index a514e20a8..7d5961b9c 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractMember.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractMember.cs @@ -227,6 +227,30 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } + public bool IsPrivate { + get { return Accessibility == Accessibility.Private; } + } + + public bool IsPublic { + get { return Accessibility == Accessibility.Public; } + } + + public bool IsProtected { + get { return Accessibility == Accessibility.Protected; } + } + + public bool IsInternal { + get { return Accessibility == Accessibility.Internal; } + } + + public bool IsProtectedOrInternal { + get { return Accessibility == Accessibility.ProtectedOrInternal; } + } + + public bool IsProtectedAndInternal { + get { return Accessibility == Accessibility.ProtectedAndInternal; } + } + public IProjectContent ProjectContent { get { return declaringTypeDefinition.ProjectContent; } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs index 9fd926da9..76cc4db1d 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; +using System.Linq; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { @@ -34,7 +35,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return this.FullName; } } - public abstract bool? IsReferenceType { get; } + public abstract bool? IsReferenceType(ITypeResolveContext context); public virtual int TypeParameterCount { get { return 0; } @@ -89,6 +90,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return EmptyList.Instance; } + public virtual IEnumerable GetMembers(ITypeResolveContext context, Predicate filter = null) + { + return GetMethods(context, filter).SafeCast() + .Concat(GetProperties(context, filter).SafeCast()) + .Concat(GetFields(context, filter).SafeCast()) + .Concat(GetEvents(context, filter).SafeCast()); + } + public override bool Equals(object obj) { return Equals(obj as IType); diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/CompositeTypeResolveContext.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/CompositeTypeResolveContext.cs index 3d0ca71a1..d8d9d2319 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/CompositeTypeResolveContext.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/CompositeTypeResolveContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) 2010 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; @@ -52,10 +52,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } /// - public ITypeDefinition GetClass(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) + public ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) { foreach (ITypeResolveContext context in children) { - ITypeDefinition d = context.GetClass(nameSpace, name, typeParameterCount, nameComparer); + ITypeDefinition d = context.GetTypeDefinition(nameSpace, name, typeParameterCount, nameComparer); if (d != null) return d; } @@ -63,15 +63,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } /// - public IEnumerable GetClasses() + public IEnumerable GetTypes() { - return children.SelectMany(c => c.GetClasses()); + return children.SelectMany(c => c.GetTypes()); } /// - public IEnumerable GetClasses(string nameSpace, StringComparer nameComparer) + public IEnumerable GetTypes(string nameSpace, StringComparer nameComparer) { - return children.SelectMany(c => c.GetClasses(nameSpace, nameComparer)); + return children.SelectMany(c => c.GetTypes(nameSpace, nameComparer)); } /// @@ -93,11 +93,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation /// public virtual ISynchronizedTypeResolveContext Synchronize() - { - return Synchronize(new CacheManager(), true); - } - - ISynchronizedTypeResolveContext Synchronize(CacheManager cacheManager, bool isTopLevel) { ISynchronizedTypeResolveContext[] sync = new ISynchronizedTypeResolveContext[children.Length]; bool success = false; @@ -107,7 +102,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation if (sync[i] == null) throw new InvalidOperationException(children[i] + ".ToString() returned null"); } - ISynchronizedTypeResolveContext r = new CompositeSynchronizedTypeResolveContext(sync, cacheManager, isTopLevel); + ISynchronizedTypeResolveContext r = new CompositeSynchronizedTypeResolveContext(sync, new CacheManager(), true); success = true; return r; } finally { @@ -132,7 +127,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation readonly CacheManager cacheManager; readonly bool isTopLevel; - public CompositeSynchronizedTypeResolveContext(ISynchronizedTypeResolveContext[] children, CacheManager cacheManager, bool isTopLevel) + public CompositeSynchronizedTypeResolveContext(ITypeResolveContext[] children, CacheManager cacheManager, bool isTopLevel) : base(children) { Debug.Assert(cacheManager != null); @@ -142,10 +137,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public void Dispose() { - foreach (ISynchronizedTypeResolveContext element in children) { - element.Dispose(); - } if (isTopLevel) { + foreach (ISynchronizedTypeResolveContext element in children) { + element.Dispose(); + } // When the top-level synchronized block is closed, clear any cached data cacheManager.Dispose(); } @@ -160,7 +155,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public override ISynchronizedTypeResolveContext Synchronize() { // re-use the same cache manager for nested synchronized contexts - return base.Synchronize(cacheManager, false); + if (isTopLevel) + return new CompositeSynchronizedTypeResolveContext(children, cacheManager, false); + else + return this; } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs index 690dba3e5..c4fd96b3e 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs @@ -41,6 +41,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation constantValue = provider.Intern(constantValue); } + DomRegion IVariable.DeclarationRegion { + get { + return Region; + } + } + public bool IsConst { get { return constantValue != null; } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultMethod.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultMethod.cs index 7ed3cab39..a0c57feda 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultMethod.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultMethod.cs @@ -36,9 +36,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation /// protected DefaultMethod(IMethod method) : base(method) { - returnTypeAttributes = CopyList(returnTypeAttributes); - typeParameters = CopyList(typeParameters); - parameters = CopyList(parameters); + returnTypeAttributes = CopyList(method.ReturnTypeAttributes); + typeParameters = CopyList(method.TypeParameters); + parameters = CopyList(method.Parameters); this.IsExtensionMethod = method.IsExtensionMethod; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs index 0f412842d..08455723e 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs @@ -105,6 +105,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } + DomRegion IVariable.DeclarationRegion { + get { + return Region; + } + } + bool HasFlag(byte flag) { return (this.flags & flag) != 0; diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs index c707780c4..f9ee9a45e 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs @@ -21,7 +21,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation IList baseTypes; IList typeParameters; - IList innerClasses; + IList nestedTypes; IList fields; IList methods; IList properties; @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation { baseTypes = FreezeList(baseTypes); typeParameters = FreezeList(typeParameters); - innerClasses = FreezeList(innerClasses); + nestedTypes = FreezeList(nestedTypes); fields = FreezeList(fields); methods = FreezeList(methods); properties = FreezeList(properties); @@ -113,11 +113,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } - public IList InnerClasses { + public IList NestedTypes { get { - if (innerClasses == null) - innerClasses = new List(); - return innerClasses; + if (nestedTypes == null) + nestedTypes = new List(); + return nestedTypes; } } @@ -162,19 +162,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } - public bool? IsReferenceType { - get { - switch (this.ClassType) { - case ClassType.Class: - case ClassType.Interface: - case ClassType.Delegate: - return true; - case ClassType.Enum: - case ClassType.Struct: - return false; - default: - return null; - } + public bool? IsReferenceType(ITypeResolveContext context) + { + switch (this.ClassType) { + case ClassType.Class: + case ClassType.Interface: + case ClassType.Delegate: + return true; + case ClassType.Enum: + case ClassType.Struct: + return false; + default: + return null; } } @@ -313,6 +312,30 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } + public bool IsPrivate { + get { return Accessibility == Accessibility.Private; } + } + + public bool IsPublic { + get { return Accessibility == Accessibility.Public; } + } + + public bool IsProtected { + get { return Accessibility == Accessibility.Protected; } + } + + public bool IsInternal { + get { return Accessibility == Accessibility.Internal; } + } + + public bool IsProtectedOrInternal { + get { return Accessibility == Accessibility.ProtectedOrInternal; } + } + + public bool IsProtectedAndInternal { + get { return Accessibility == Accessibility.ProtectedAndInternal; } + } + public bool HasExtensionMethods { get { return flags[FlagHasExtensionMethods]; } set { @@ -353,7 +376,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation primitiveBaseType = typeof(object); break; } - IType t = context.GetClass(primitiveBaseType); + IType t = context.GetTypeDefinition(primitiveBaseType); if (t != null) yield return t; } @@ -369,11 +392,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return new ITypeDefinition[] { this }; } - public IType GetElementType() - { - throw new InvalidOperationException(); - } - public ITypeDefinition GetDefinition() { return this; @@ -404,9 +422,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation break; // there is at most 1 non-interface base } } - foreach (ITypeDefinition innerClass in this.InnerClasses) { - if (filter == null || filter(innerClass)) { - nestedTypes.Add(innerClass); + foreach (ITypeDefinition nestedType in this.NestedTypes) { + if (filter == null || filter(nestedType)) { + nestedTypes.Add(nestedType); } } } @@ -535,6 +553,34 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return events; } + public virtual IEnumerable GetMembers(ITypeResolveContext context, Predicate filter = null) + { + ITypeDefinition compound = GetCompoundClass(); + if (compound != this) + return compound.GetMembers(context, filter); + + List members = new List(); + using (var busyLock = BusyManager.Enter(this)) { + if (busyLock.Success) { + int baseCount = 0; + foreach (var baseType in GetBaseTypes(context)) { + ITypeDefinition baseTypeDef = baseType.GetDefinition(); + if (baseTypeDef != null && (baseTypeDef.ClassType != ClassType.Interface || this.ClassType == ClassType.Interface)) { + members.AddRange(baseType.GetMembers(context, filter)); + baseCount++; + } + } + if (baseCount > 1) + RemoveDuplicates(members); + AddFilteredRange(members, this.Methods.Where(m => !m.IsConstructor), filter); + AddFilteredRange(members, this.Properties, filter); + AddFilteredRange(members, this.Fields, filter); + AddFilteredRange(members, this.Events, filter); + } + } + return members; + } + static void AddFilteredRange(List targetList, IEnumerable sourceList, Predicate filter) where T : class { if (filter == null) { diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeParameter.cs index fded74f5f..ec8ce7007 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeParameter.cs @@ -71,17 +71,33 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } } - public bool? IsReferenceType { - get { - switch (flags.Data & (FlagReferenceTypeConstraint | FlagValueTypeConstraint)) { - case FlagReferenceTypeConstraint: - return true; - case FlagValueTypeConstraint: - return false; - default: - return null; + public bool? IsReferenceType(ITypeResolveContext context) + { + switch (flags.Data & (FlagReferenceTypeConstraint | FlagValueTypeConstraint)) { + case FlagReferenceTypeConstraint: + return true; + case FlagValueTypeConstraint: + return false; + } + // protect against cyclic dependencies between type parameters + using (var busyLock = BusyManager.Enter(this)) { + if (busyLock.Success) { + foreach (ITypeReference constraintRef in this.Constraints) { + IType constraint = constraintRef.Resolve(context); + ITypeDefinition constraintDef = constraint.GetDefinition(); + // While interfaces are reference types, an interface constraint does not + // force the type parameter to be a reference type; so we need to explicitly look for classes here. + if (constraintDef != null && constraintDef.ClassType == ClassType.Class) + return true; + if (constraint is ITypeParameter) { + bool? isReferenceType = constraint.IsReferenceType(context); + if (isReferenceType.HasValue) + return isReferenceType.Value; + } + } } } + return null; } int IType.TypeParameterCount { @@ -234,31 +250,86 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public IEnumerable GetMethods(ITypeResolveContext context, Predicate filter = null) { - // TODO: get methods from constraints - IType objectType = context.GetClass("System", "Object", 0, StringComparer.Ordinal); - IEnumerable objectMethods; - if (objectType != null) - objectMethods = objectType.GetMethods(context, filter); - else - objectMethods = EmptyList.Instance; - - // don't return static methods (those cannot be called from type parameter) - return objectMethods.Where(m => !m.IsStatic); + foreach (var baseType in GetNonCircularBaseTypes(context)) { + foreach (var m in baseType.GetMethods(context, filter)) { + if (!m.IsStatic) + yield return m; + } + } } public IEnumerable GetProperties(ITypeResolveContext context, Predicate filter = null) { - return EmptyList.Instance; + foreach (var baseType in GetNonCircularBaseTypes(context)) { + foreach (var m in baseType.GetProperties(context, filter)) { + if (!m.IsStatic) + yield return m; + } + } } public IEnumerable GetFields(ITypeResolveContext context, Predicate filter = null) { - return EmptyList.Instance; + foreach (var baseType in GetNonCircularBaseTypes(context)) { + foreach (var m in baseType.GetFields(context, filter)) { + if (!m.IsStatic) + yield return m; + } + } } public IEnumerable GetEvents(ITypeResolveContext context, Predicate filter = null) { - return EmptyList.Instance; + foreach (var baseType in GetNonCircularBaseTypes(context)) { + foreach (var m in baseType.GetEvents(context, filter)) { + if (!m.IsStatic) + yield return m; + } + } + } + + public IEnumerable GetMembers(ITypeResolveContext context, Predicate filter = null) + { + foreach (var baseType in GetNonCircularBaseTypes(context)) { + foreach (var m in baseType.GetMembers(context, filter)) { + if (!m.IsStatic) + yield return m; + } + } + } + + // Problem with type parameter resolving - circular declarations + // void Example (S s, T t) where S : T where T : S + IEnumerable GetNonCircularBaseTypes(ITypeResolveContext context) + { + var result = this.GetBaseTypes(context).Where(bt => !IsCircular (context, bt)); + if (result.Any ()) + return result; + + // result may be empty, GetBaseTypes doesn't return object/struct when there are only constraints (even circular) as base types are available, + // but even when there are only circular references the default base type should be included. + IType defaultBaseType = context.GetTypeDefinition("System", HasValueTypeConstraint ? "ValueType" : "Object", 0, StringComparer.Ordinal); + if (defaultBaseType != null) + return new [] { defaultBaseType }; + return Enumerable.Empty (); + } + + bool IsCircular(ITypeResolveContext context, IType baseType) + { + var parameter = baseType as DefaultTypeParameter; + if (parameter == null) + return false; + var stack = new Stack(); + while (true) { + if (parameter == this) + return true; + foreach (DefaultTypeParameter parameterBaseType in parameter.GetNonCircularBaseTypes(context).Where(t => t is DefaultTypeParameter)) { + stack.Push(parameterBaseType); + } + if (stack.Count == 0) + return false; + parameter = stack.Pop(); + } } IEnumerable IType.GetNestedTypes(ITypeResolveContext context, Predicate filter) @@ -268,12 +339,19 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public IEnumerable GetBaseTypes(ITypeResolveContext context) { - IType defaultBaseType = context.GetClass("System", HasValueTypeConstraint ? "ValueType" : "Object", 0, StringComparer.Ordinal); - if (defaultBaseType != null) - yield return defaultBaseType; - + bool hasNonInterfaceConstraint = false; foreach (ITypeReference constraint in this.Constraints) { - yield return constraint.Resolve(context); + IType c = constraint.Resolve(context); + yield return c; + ITypeDefinition cdef = c.GetDefinition(); + if (!(cdef != null && cdef.ClassType == ClassType.Interface)) + hasNonInterfaceConstraint = true; + } + // Do not add the 'System.Object' constraint if there is another constraint with a base class. + if (HasValueTypeConstraint || !hasNonInterfaceConstraint) { + IType defaultBaseType = context.GetTypeDefinition("System", HasValueTypeConstraint ? "ValueType" : "Object", 0, StringComparer.Ordinal); + if (defaultBaseType != null) + yield return defaultBaseType; } } @@ -301,7 +379,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) { DefaultTypeParameter o = other as DefaultTypeParameter; - return o != null + return o != null && this.attributes == o.attributes && this.constraints == o.constraints && this.flags == o.flags diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs index 8f2b70441..976b90ca5 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs @@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation IType DoResolve(ITypeResolveContext context) { */ - return context.GetClass(nameSpace, name, typeParameterCount, StringComparer.Ordinal) ?? SharedTypes.UnknownType; + return context.GetTypeDefinition(nameSpace, name, typeParameterCount, StringComparer.Ordinal) ?? SharedTypes.UnknownType; } public override string ToString() diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/NestedTypeReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/NestedTypeReference.cs index 5146309b1..856b7aa63 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/NestedTypeReference.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/NestedTypeReference.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation ITypeDefinition declaringType = declaringTypeRef.Resolve(context) as ITypeDefinition; if (declaringType != null) { int tpc = declaringType.TypeParameterCount; - foreach (IType type in declaringType.InnerClasses) { + foreach (IType type in declaringType.NestedTypes) { if (type.Name == name && type.TypeParameterCount == tpc + additionalTypeParameterCount) return type; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/ProxyTypeResolveContext.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/ProxyTypeResolveContext.cs index f8677c296..4876c1e5c 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/ProxyTypeResolveContext.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/ProxyTypeResolveContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) 2010 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; @@ -10,7 +10,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation /// Proxy that forwards calls to another TypeResolveContext. /// Useful as base class for decorators. /// - public class ProxyTypeResolveContext : ITypeResolveContext + public class ProxyTypeResolveContext : AbstractAnnotatable, ITypeResolveContext { protected readonly ITypeResolveContext target; @@ -25,21 +25,21 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } /// - public virtual ITypeDefinition GetClass(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) + public virtual ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) { - return target.GetClass(nameSpace, name, typeParameterCount, nameComparer); + return target.GetTypeDefinition(nameSpace, name, typeParameterCount, nameComparer); } /// - public virtual IEnumerable GetClasses() + public virtual IEnumerable GetTypes() { - return target.GetClasses(); + return target.GetTypes(); } /// - public virtual IEnumerable GetClasses(string nameSpace, StringComparer nameComparer) + public virtual IEnumerable GetTypes(string nameSpace, StringComparer nameComparer) { - return target.GetClasses(nameSpace, nameComparer); + return target.GetTypes(nameSpace, nameComparer); } /// diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs index 3a7f5caa9..6cb78cbfa 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) 2010 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; @@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation /// Compared with , this class adds support for the IProjectContent interface, /// for partial classes, and for multi-threading. /// - public sealed class SimpleProjectContent : IProjectContent + public sealed class SimpleProjectContent : AbstractAnnotatable, IProjectContent { // This class is sealed by design: // the synchronization story doesn't mix well with someone trying to extend this class. @@ -27,6 +27,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation readonly TypeStorage types = new TypeStorage(); readonly ReaderWriterLockSlim readerWriterLock = new ReaderWriterLockSlim(); + readonly Dictionary fileDict = new Dictionary(Platform.FileNameComparer); #region AssemblyAttributes readonly List assemblyAttributes = new List(); // mutable assembly attribute storage @@ -35,13 +36,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation /// public IList AssemblyAttributes { - get { return readOnlyAssemblyAttributes; } + get { return readOnlyAssemblyAttributes; } } - void AddRemoveAssemblyAttributes(ICollection addedAttributes, ICollection removedAttributes) + void AddRemoveAssemblyAttributes(ICollection removedAttributes, ICollection addedAttributes) { // API uses ICollection instead of IEnumerable to discourage users from evaluating // the list inside the lock (this method is called inside the write lock) + // [[not an issue anymore; the user now passes IParsedFile]] bool hasChanges = false; if (removedAttributes != null && removedAttributes.Count > 0) { if (assemblyAttributes.RemoveAll(removedAttributes.Contains) > 0) @@ -74,37 +76,41 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation #region RemoveType void RemoveType(ITypeDefinition typeDefinition) { - throw new NotImplementedException(); + types.RemoveType (typeDefinition); // <- Daniel: Correct ? } #endregion #region UpdateProjectContent /// - /// Removes oldTypes from the project, adds newTypes. - /// Removes oldAssemblyAttributes, adds newAssemblyAttributes. + /// Removes types and attributes from oldFile from the project, and adds those from newFile. /// /// /// The update is done inside a write lock; when other threads access this project content /// from within a using (Synchronize()) block, they will not see intermediate (inconsistent) state. /// - public void UpdateProjectContent(ICollection oldTypes = null, - ICollection newTypes = null, - ICollection oldAssemblyAttributes = null, - ICollection newAssemblyAttributes = null) + public void UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile) { + if (oldFile != null && newFile != null) { + if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName)) + throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name."); + } readerWriterLock.EnterWriteLock(); try { - if (oldTypes != null) { - foreach (var element in oldTypes) { + if (oldFile != null) { + foreach (var element in oldFile.TopLevelTypeDefinitions) { RemoveType(element); } + if (newFile == null) { + fileDict.Remove(oldFile.FileName); + } } - if (newTypes != null) { - foreach (var element in newTypes) { + if (newFile != null) { + foreach (var element in newFile.TopLevelTypeDefinitions) { AddType(element); } + fileDict[newFile.FileName] = newFile; } - AddRemoveAssemblyAttributes(oldAssemblyAttributes, newAssemblyAttributes); + AddRemoveAssemblyAttributes(oldFile != null ? oldFile.AssemblyAttributes : null, newFile != null ? newFile.AssemblyAttributes : null); } finally { readerWriterLock.ExitWriteLock(); } @@ -112,33 +118,33 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation #endregion #region IProjectContent implementation - public ITypeDefinition GetClass(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) + public ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) { readerWriterLock.EnterReadLock(); try { - return types.GetClass(nameSpace, name, typeParameterCount, nameComparer); + return types.GetTypeDefinition(nameSpace, name, typeParameterCount, nameComparer); } finally { readerWriterLock.ExitReadLock(); } } - public IEnumerable GetClasses() + public IEnumerable GetTypes() { readerWriterLock.EnterReadLock(); try { // make a copy with ToArray() for thread-safe access - return types.GetClasses().ToArray(); + return types.GetTypes().ToArray(); } finally { readerWriterLock.ExitReadLock(); } } - public IEnumerable GetClasses(string nameSpace, StringComparer nameComparer) + public IEnumerable GetTypes(string nameSpace, StringComparer nameComparer) { readerWriterLock.EnterReadLock(); try { // make a copy with ToArray() for thread-safe access - return types.GetClasses(nameSpace, nameComparer).ToArray(); + return types.GetTypes(nameSpace, nameComparer).ToArray(); } finally { readerWriterLock.ExitReadLock(); } @@ -164,6 +170,31 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation readerWriterLock.ExitReadLock(); } } + + public IParsedFile GetFile(string fileName) + { + readerWriterLock.EnterReadLock(); + try { + IParsedFile file; + if (fileDict.TryGetValue(fileName, out file)) + return file; + else + return null; + } finally { + readerWriterLock.ExitReadLock(); + } + } + + public IEnumerable Files { + get { + readerWriterLock.EnterReadLock(); + try { + return fileDict.Values.ToArray(); + } finally { + readerWriterLock.ExitReadLock(); + } + } + } #endregion #region Synchronization diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs index d55da252b..9d76f93e2 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMethod.cs @@ -52,20 +52,21 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return false; return object.Equals(this.memberDefinition, other.memberDefinition) && object.Equals(this.declaringType, other.declaringType); } - + /// /// Performs type substitution in parameter types and in the return type. /// - public void SubstituteTypes(ITypeResolveContext context, TypeVisitor substitution) + public void SubstituteTypes(Func substitution) { - this.ReturnType = this.ReturnType.Resolve(context).AcceptVisitor(substitution); + this.ReturnType = substitution(this.ReturnType); var p = this.Parameters; for (int i = 0; i < p.Count; i++) { - IType newType = p[i].Type.Resolve(context).AcceptVisitor(substitution); + ITypeReference newType = substitution(p[i].Type); if (newType != p[i].Type) { p[i] = new DefaultParameter(p[i]) { Type = newType }; } } + // TODO: we might also have to perform substitution within the method's constraints } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs index deb9b0c58..921ffc029 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedProperty.cs @@ -56,12 +56,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation /// /// Performs type substitution in parameter types and in the return type. /// - public void SubstituteTypes(ITypeResolveContext context, TypeVisitor substitution) + public void SubstituteTypes(Func substitution) { - this.ReturnType = this.ReturnType.Resolve(context).AcceptVisitor(substitution); + this.ReturnType = substitution(this.ReturnType); var p = this.Parameters; for (int i = 0; i < p.Count; i++) { - IType newType = p[i].Type.Resolve(context).AcceptVisitor(substitution); + ITypeReference newType = substitution(p[i].Type); if (newType != p[i].Type) { p[i] = new DefaultParameter(p[i]) { Type = newType }; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SubstitutionTypeReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SubstitutionTypeReference.cs new file mode 100644 index 000000000..aaf38718c --- /dev/null +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SubstitutionTypeReference.cs @@ -0,0 +1,31 @@ +// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.TypeSystem.Implementation +{ + /// + /// A type reference that wraps another type reference; but performs a substitution in the resolved type. + /// + public class SubstitutionTypeReference : ITypeReference + { + readonly ITypeReference baseTypeReference; + readonly TypeVisitor substitution; + + public SubstitutionTypeReference(ITypeReference baseTypeReference, TypeVisitor substitution) + { + if (baseTypeReference == null) + throw new ArgumentNullException("baseTypeReference"); + if (substitution == null) + throw new ArgumentNullException("substitution"); + this.baseTypeReference = baseTypeReference; + this.substitution = substitution; + } + + public IType Resolve(ITypeResolveContext context) + { + return baseTypeReference.Resolve(context).AcceptVisitor(substitution); + } + } +} diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeStorage.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeStorage.cs index aa05ee8d7..d5f284295 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeStorage.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeStorage.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) 2010 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; @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public bool Equals(FullNameAndTypeParameterCount x, FullNameAndTypeParameterCount y) { - return x.TypeParameterCount == y.TypeParameterCount + return x.TypeParameterCount == y.TypeParameterCount && NameComparer.Equals(x.Name, y.Name) && NameComparer.Equals(x.Namespace, y.Namespace); } @@ -110,11 +110,32 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation #region Namespace Storage class NamespaceEntry { + /// + /// Full namespace name + /// public readonly string Name; + + /// + /// Parent namespace + /// + public readonly NamespaceEntry Parent; + + /// + /// Number of classes in this namespace (not in sub-namespaces). + /// Note: this always refers to the number of classes from the ordinal typeDict that map + /// to this namespace when compared with the appropriate StringComparer. + /// The actual number of classes in the typeDict matching this StringComparer might be lower. + /// public int ClassCount; - public NamespaceEntry(string name) + /// + /// Number of sub-namespaces. + /// + public int SubNamespaceCount; + + public NamespaceEntry(NamespaceEntry parent, string name) { + this.Parent = parent; this.Name = name; } } @@ -145,9 +166,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } // now create new dict - var newDict = _typeDicts[0].Values.GroupBy(c => c.Namespace, nameComparer) - .Select(g => new NamespaceEntry(g.Key) { ClassCount = g.Count() }) - .ToDictionary(d => d.Name); + var newDict = new Dictionary(nameComparer); + foreach (ITypeDefinition type in _typeDicts[0].Values) { + NamespaceEntry ne = GetOrCreateNamespaceEntry(newDict, type.Namespace); + ne.ClassCount++; + } // add the new dict to the array of dicts var newNamespaceDicts = new Dictionary[namespaceDicts.Length + 1]; @@ -157,11 +180,30 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return newDict; } } + + NamespaceEntry GetOrCreateNamespaceEntry(Dictionary dict, string ns) + { + NamespaceEntry ne; + if (!dict.TryGetValue(ns, out ne)) { + NamespaceEntry parentEntry; + if (string.IsNullOrEmpty(ns)) { + parentEntry = null; + } else { + int pos = ns.LastIndexOf('.'); + string parentNS = pos < 0 ? string.Empty : ns.Substring(0, pos); + parentEntry = GetOrCreateNamespaceEntry(dict, parentNS); + parentEntry.SubNamespaceCount++; + } + ne = new NamespaceEntry(parentEntry, ns); + dict.Add(ns, ne); + } + return ne; + } #endregion #region ITypeResolveContext implementation /// - public ITypeDefinition GetClass(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) + public ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) { if (nameSpace == null) throw new ArgumentNullException("nameSpace"); @@ -179,19 +221,19 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation } /// - public IEnumerable GetClasses() + public IEnumerable GetTypes() { return _typeDicts[0].Values; } /// - public IEnumerable GetClasses(string nameSpace, StringComparer nameComparer) + public IEnumerable GetTypes(string nameSpace, StringComparer nameComparer) { if (nameSpace == null) throw new ArgumentNullException("nameSpace"); if (nameComparer == null) throw new ArgumentNullException("nameComparer"); - return GetClasses().Where(c => nameComparer.Equals(nameSpace, c.Namespace)); + return GetTypes().Where(c => nameComparer.Equals(nameSpace, c.Namespace)); } /// @@ -248,7 +290,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation ITypeDefinition defInDict; if (dict.TryGetValue(key, out defInDict)) { if (defInDict == typeDefinition) { - wasRemoved = true; + if (dict.Comparer == FullNameAndTypeParameterCountComparer.Ordinal) { + // Set wasRemoved flag only on removal in the ordinal comparison. + // This keeps the ClassCount consistent when there are name clashes. + wasRemoved = true; + } dict.Remove(key); } } @@ -257,12 +303,23 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation foreach (var dict in _namespaceDicts) { NamespaceEntry ns; if (dict.TryGetValue(typeDefinition.Namespace, out ns)) { - if (--ns.ClassCount == 0) - dict.Remove(typeDefinition.Namespace); + ns.ClassCount--; + RemoveNamespaceIfPossible(dict, ns); } } } } + + void RemoveNamespaceIfPossible(Dictionary dict, NamespaceEntry ns) + { + while (ns.ClassCount == 0 && ns.SubNamespaceCount == 0) { + dict.Remove(ns.Name); + ns = ns.Parent; + if (ns == null) + break; + ns.SubNamespaceCount--; + } + } #endregion #region UpdateType @@ -275,18 +332,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation if (typeDefinition == null) throw new ArgumentNullException("typeDefinition"); var key = new FullNameAndTypeParameterCount(typeDefinition.Namespace, typeDefinition.Name, typeDefinition.TypeParameterCount); + // Set isNew on addition in the ordinal comparison. + // This keeps the ClassCount consistent when there are name clashes. bool isNew = !_typeDicts[0].ContainsKey(key); foreach (var dict in _typeDicts) { dict[key] = typeDefinition; } if (isNew) { foreach (var dict in _namespaceDicts) { - NamespaceEntry ns; - if (dict.TryGetValue(typeDefinition.Namespace, out ns)) { - ++ns.ClassCount; - } else { - dict.Add(typeDefinition.Namespace, new NamespaceEntry(typeDefinition.Namespace) { ClassCount = 1 }); - } + NamespaceEntry ns = GetOrCreateNamespaceEntry(dict, typeDefinition.Namespace); + ++ns.ClassCount; } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/IntersectionType.cs b/ICSharpCode.NRefactory/TypeSystem/IntersectionType.cs index c23431a2b..688dc3893 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IntersectionType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IntersectionType.cs @@ -63,8 +63,14 @@ namespace ICSharpCode.NRefactory.TypeSystem } } - public override Nullable IsReferenceType { - get { return null; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + foreach (var t in types) { + bool? isReferenceType = t.IsReferenceType(context); + if (isReferenceType.HasValue) + return isReferenceType.Value; + } + return null; } public override int GetHashCode() diff --git a/ICSharpCode.NRefactory/TypeSystem/NullableType.cs b/ICSharpCode.NRefactory/TypeSystem/NullableType.cs index 6f2fd7165..11809396e 100644 --- a/ICSharpCode.NRefactory/TypeSystem/NullableType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/NullableType.cs @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.TypeSystem if (context == null) throw new ArgumentNullException("context"); - ITypeDefinition nullable = context.GetClass("System", "Nullable", 1, StringComparer.Ordinal); + ITypeDefinition nullable = context.GetTypeDefinition("System", "Nullable", 1, StringComparer.Ordinal); if (nullable != null) return new ParameterizedType(nullable, new [] { elementType }); else diff --git a/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs b/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs index f51fb1ea8..a75fb7c21 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs @@ -78,8 +78,9 @@ namespace ICSharpCode.NRefactory.TypeSystem this.typeArguments = typeArguments; } - public bool? IsReferenceType { - get { return genericType.IsReferenceType; } + public bool? IsReferenceType(ITypeResolveContext context) + { + return genericType.IsReferenceType(context); } public IType DeclaringType { @@ -156,6 +157,15 @@ namespace ICSharpCode.NRefactory.TypeSystem return type.AcceptVisitor(new Substitution(typeArguments)); } + /// + /// Gets a type visitor that performs the substitution of class type parameters with the type arguments + /// of this parameterized type. + /// + public TypeVisitor GetSubstitution() + { + return new Substitution(typeArguments); + } + public IEnumerable GetBaseTypes(ITypeResolveContext context) { Substitution substitution = new Substitution(typeArguments); @@ -183,7 +193,7 @@ namespace ICSharpCode.NRefactory.TypeSystem // (partially) parameterize the nested type definition IType[] newTypeArgs = new IType[def.TypeParameterCount]; for (int j = 0; j < newTypeArgs.Length; j++) { - if (j < typeArguments.Length) + if (i < typeArguments.Length) newTypeArgs[j] = typeArguments[i]; else newTypeArgs[j] = def.TypeParameters[j]; @@ -199,11 +209,12 @@ namespace ICSharpCode.NRefactory.TypeSystem public IEnumerable GetMethods(ITypeResolveContext context, Predicate filter = null) { Substitution substitution = new Substitution(typeArguments); + Func substitutionFunc = t => t.Resolve(context).AcceptVisitor(substitution); List methods = genericType.GetMethods(context, filter).ToList(); for (int i = 0; i < methods.Count; i++) { SpecializedMethod m = new SpecializedMethod(methods[i]); m.SetDeclaringType(this); - m.SubstituteTypes(context, substitution); + m.SubstituteTypes(substitutionFunc); methods[i] = m; } return methods; @@ -212,11 +223,12 @@ namespace ICSharpCode.NRefactory.TypeSystem public IEnumerable GetConstructors(ITypeResolveContext context, Predicate filter = null) { Substitution substitution = new Substitution(typeArguments); + Func substitutionFunc = t => t.Resolve(context).AcceptVisitor(substitution); List methods = genericType.GetConstructors(context, filter).ToList(); for (int i = 0; i < methods.Count; i++) { SpecializedMethod m = new SpecializedMethod(methods[i]); m.SetDeclaringType(this); - m.SubstituteTypes(context, substitution); + m.SubstituteTypes(substitutionFunc); methods[i] = m; } return methods; @@ -225,11 +237,12 @@ namespace ICSharpCode.NRefactory.TypeSystem public IEnumerable GetProperties(ITypeResolveContext context, Predicate filter = null) { Substitution substitution = new Substitution(typeArguments); + Func substitutionFunc = t => t.Resolve(context).AcceptVisitor(substitution); List properties = genericType.GetProperties(context, filter).ToList(); for (int i = 0; i < properties.Count; i++) { SpecializedProperty p = new SpecializedProperty(properties[i]); p.SetDeclaringType(this); - p.SubstituteTypes(context, substitution); + p.SubstituteTypes(substitutionFunc); properties[i] = p; } return properties; @@ -261,6 +274,50 @@ namespace ICSharpCode.NRefactory.TypeSystem return events; } + public IEnumerable GetMembers(ITypeResolveContext context, Predicate filter = null) + { + Substitution substitution = new Substitution(typeArguments); + Func substitutionFunc = t => t.Resolve(context).AcceptVisitor(substitution); + List members = genericType.GetMembers(context, filter).ToList(); + for (int i = 0; i < members.Count; i++) { + members[i] = Specialize(members[i], substitutionFunc); + } + return members; + } + + IMember Specialize(IMember member, Func substitution) + { + IMethod method = member as IMethod; + if (method != null) { + SpecializedMethod m = new SpecializedMethod(method); + m.SetDeclaringType(this); + m.SubstituteTypes(substitution); + return m; + } + IProperty property = member as IProperty; + if (property != null) { + SpecializedProperty p = new SpecializedProperty(property); + p.SetDeclaringType(this); + p.SubstituteTypes(substitution); + return p; + } + IField field = member as IField; + if (field != null) { + SpecializedField f = new SpecializedField(field); + f.SetDeclaringType(this); + f.ReturnType = substitution(f.ReturnType); + return f; + } + IEvent ev = member as IEvent; + if (ev != null) { + SpecializedEvent e = new SpecializedEvent(ev); + e.SetDeclaringType(this); + e.ReturnType = substitution(e.ReturnType); + return e; + } + throw new ArgumentException("Unknown member"); + } + public override bool Equals(object obj) { return Equals(obj as IType); diff --git a/ICSharpCode.NRefactory/TypeSystem/PointerType.cs b/ICSharpCode.NRefactory/TypeSystem/PointerType.cs index 12b473620..692e81479 100644 --- a/ICSharpCode.NRefactory/TypeSystem/PointerType.cs +++ b/ICSharpCode.NRefactory/TypeSystem/PointerType.cs @@ -18,8 +18,9 @@ namespace ICSharpCode.NRefactory.TypeSystem } } - public override Nullable IsReferenceType { - get { return null; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return null; } public override int GetHashCode() diff --git a/ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs b/ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs index 61b22bc7b..7decbb800 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs @@ -23,12 +23,16 @@ namespace ICSharpCode.NRefactory.TypeSystem /// public sealed class Dynamic {} - #region ITypeResolveContext.GetClass(Type) + #region ITypeResolveContext.GetTypeDefinition(Type) /// - /// Retrieves a class. + /// Retrieves a type definition. /// - /// Returns the class; or null if it is not found. - public static ITypeDefinition GetClass(this ITypeResolveContext context, Type type) + /// Returns the type definition; or null if it is not found. + /// + /// This method retrieves the type definition; consider using type.ToTypeReference().Resolve(context) instead + /// if you need an . + /// + public static ITypeDefinition GetTypeDefinition(this ITypeResolveContext context, Type type) { if (type == null) return null; @@ -39,14 +43,14 @@ namespace ICSharpCode.NRefactory.TypeSystem if (type.IsGenericParameter) return null; if (type.DeclaringType != null) { - ITypeDefinition declaringType = GetClass(context, type.DeclaringType); + ITypeDefinition declaringType = GetTypeDefinition(context, type.DeclaringType); if (declaringType != null) { int typeParameterCount; string name = SplitTypeParameterCountFromReflectionName(type.Name, out typeParameterCount); typeParameterCount += declaringType.TypeParameterCount; - foreach (ITypeDefinition innerClass in declaringType.InnerClasses) { - if (innerClass.Name == name && innerClass.TypeParameterCount == typeParameterCount) { - return innerClass; + foreach (ITypeDefinition nestedType in declaringType.NestedTypes) { + if (nestedType.Name == name && nestedType.TypeParameterCount == typeParameterCount) { + return nestedType; } } } @@ -54,7 +58,7 @@ namespace ICSharpCode.NRefactory.TypeSystem } else { int typeParameterCount; string name = SplitTypeParameterCountFromReflectionName(type.Name, out typeParameterCount); - return context.GetClass(type.Namespace, name, typeParameterCount, StringComparer.Ordinal); + return context.GetTypeDefinition(type.Namespace, name, typeParameterCount, StringComparer.Ordinal); } } #endregion diff --git a/ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs b/ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs index 6c8cf7eaf..f72e5fc15 100644 --- a/ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs +++ b/ICSharpCode.NRefactory/TypeSystem/SharedTypes.cs @@ -57,8 +57,9 @@ namespace ICSharpCode.NRefactory.TypeSystem get { return "?"; } } - public override bool? IsReferenceType { - get { return null; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return null; } public override bool Equals(IType other) @@ -81,8 +82,9 @@ namespace ICSharpCode.NRefactory.TypeSystem get { return "null"; } } - public override bool? IsReferenceType { - get { return true; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return true; } public override bool Equals(IType other) @@ -105,8 +107,9 @@ namespace ICSharpCode.NRefactory.TypeSystem get { return "dynamic"; } } - public override bool? IsReferenceType { - get { return true; } + public override bool? IsReferenceType(ITypeResolveContext context) + { + return true; } public override bool Equals(IType other) diff --git a/ICSharpCode.NRefactory/Utils/Platform.cs b/ICSharpCode.NRefactory/Utils/Platform.cs new file mode 100644 index 000000000..1e512330d --- /dev/null +++ b/ICSharpCode.NRefactory/Utils/Platform.cs @@ -0,0 +1,25 @@ +// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT license (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Utils +{ + /// + /// Platform-specific code. + /// + static class Platform + { + public static StringComparer FileNameComparer { + get { + switch (Environment.OSVersion.Platform) { + case PlatformID.Unix: + case PlatformID.MacOSX: + return StringComparer.Ordinal; + default: + return StringComparer.OrdinalIgnoreCase; + } + } + } + } +} diff --git a/NRefactory.sln b/NRefactory.sln index c96b7b6f7..baf2f03d5 100644 --- a/NRefactory.sln +++ b/NRefactory.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.1.0.7372-alpha +# SharpDevelop 4.1.0.7590-alpha Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DC98210E-1646-483B-819A-2BB8272461E4}" ProjectSection(SolutionItems) = postProject README = README @@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "..\Mono.Cecil 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}") = "ICSharpCode.Editor", "ICSharpCode.Editor\ICSharpCode.Editor.csproj", "{F054A788-B591-4561-A8BA-AE745BBEB817}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,6 +70,14 @@ Global {9C19E629-C93E-4ACB-9A4B-13072B5AEF9D}.Release|Any CPU.ActiveCfg = Release|x86 {9C19E629-C93E-4ACB-9A4B-13072B5AEF9D}.Release|x86.Build.0 = Release|x86 {9C19E629-C93E-4ACB-9A4B-13072B5AEF9D}.Release|x86.ActiveCfg = Release|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Debug|Any CPU.Build.0 = Debug|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Debug|Any CPU.ActiveCfg = Debug|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Debug|x86.Build.0 = Debug|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Debug|x86.ActiveCfg = Debug|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Release|Any CPU.Build.0 = Release|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Release|Any CPU.ActiveCfg = Release|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Release|x86.Build.0 = Release|x86 + {F054A788-B591-4561-A8BA-AE745BBEB817}.Release|x86.ActiveCfg = Release|x86 EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj diff --git a/README b/README index 551448567..4c6a493aa 100644 --- a/README +++ b/README @@ -1,5 +1,9 @@ Overview of the NRefactory library: +ICSharpCode.Editor: + Interfaces that abstract from the text editor control used. + Maybe future AvalonEdit versions will directly implement these interfaces, but you could also write adapters for other editors. + ICSharpCode.NRefactory.TypeSystem: Contains a language-independent representation of the .NET type system. @@ -10,8 +14,17 @@ ICSharpCode.NRefactory.CSharp.Ast: Abstract Syntax Tree for C# ICSharpCode.NRefactory.CSharp.Resolver: - Semantic analysis for C# - + Semantic analysis for C# (resolving the meaning of expressions) + +ICSharpCode.NRefactory.CSharp.Analysis: + Semantic analysis for C# (additional analysis functionality) + +ICSharpCode.NRefactory.Documentation: + Classes for working with .xml documentation files. + +ICSharpCode.NRefactory.PatternMatching: + Provides classes for pattern matching over the C# and VB ASTs. + ICSharpCode.NRefactory.Util: Various helper classes. From 3bddd8e2f00dee22b8a0a2d8c761959d075f9c30 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 6 Jul 2011 16:04:21 +0200 Subject: [PATCH 28/28] Fixed crash in DebugExecutableNodeCommand.IsVisible when right-clicking on an unmanaged assembly. --- Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs b/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs index f00c24542..3a122360b 100644 --- a/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs +++ b/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs @@ -10,7 +10,6 @@ using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Xml.Linq; - using ICSharpCode.AvalonEdit.Document; using ICSharpCode.ILSpy.Bookmarks; using ICSharpCode.ILSpy.Debugger; @@ -20,6 +19,7 @@ using ICSharpCode.ILSpy.Debugger.UI; using ICSharpCode.ILSpy.TreeNodes; using ICSharpCode.TreeView; using Microsoft.Win32; +using Mono.Cecil; namespace ICSharpCode.ILSpy.Debugger.Commands { @@ -182,7 +182,14 @@ namespace ICSharpCode.ILSpy.Debugger.Commands { public bool IsVisible(SharpTreeNode[] selectedNodes) { - return selectedNodes.All(n => n is AssemblyTreeNode && null != (n as AssemblyTreeNode).LoadedAssembly.AssemblyDefinition.EntryPoint); + return selectedNodes.All( + delegate (SharpTreeNode n) { + AssemblyTreeNode a = n as AssemblyTreeNode; + if (a == null) + return false; + AssemblyDefinition asm = a.LoadedAssembly.AssemblyDefinition; + return asm != null && asm.EntryPoint != null; + }); } public bool IsEnabled(SharpTreeNode[] selectedNodes)